/* Some versions of compiler define MEMORYSTATUSEX, some don't, so we
use a different name to avoid compilation problems. */
typedef struct _MEMORY_STATUS_EX {
- DWORD dwLength;
- DWORD dwMemoryLoad;
- DWORDLONG ullTotalPhys;
- DWORDLONG ullAvailPhys;
- DWORDLONG ullTotalPageFile;
- DWORDLONG ullAvailPageFile;
- DWORDLONG ullTotalVirtual;
- DWORDLONG ullAvailVirtual;
- DWORDLONG ullAvailExtendedVirtual;
+ DWORD dwLength;
+ DWORD dwMemoryLoad;
+ DWORDLONG ullTotalPhys;
+ DWORDLONG ullAvailPhys;
+ DWORDLONG ullTotalPageFile;
+ DWORDLONG ullAvailPageFile;
+ DWORDLONG ullTotalVirtual;
+ DWORDLONG ullAvailVirtual;
+ DWORDLONG ullAvailExtendedVirtual;
} MEMORY_STATUS_EX,*LPMEMORY_STATUS_EX;
#include <lmcons.h>
_WIN32_WINNT than what we use. w32api suplied with MinGW 3.15
defines it in psapi.h */
typedef struct _PROCESS_MEMORY_COUNTERS_EX {
- DWORD cb;
- DWORD PageFaultCount;
- DWORD PeakWorkingSetSize;
- DWORD WorkingSetSize;
- DWORD QuotaPeakPagedPoolUsage;
- DWORD QuotaPagedPoolUsage;
- DWORD QuotaPeakNonPagedPoolUsage;
- DWORD QuotaNonPagedPoolUsage;
- DWORD PagefileUsage;
- DWORD PeakPagefileUsage;
- DWORD PrivateUsage;
+ DWORD cb;
+ DWORD PageFaultCount;
+ DWORD PeakWorkingSetSize;
+ DWORD WorkingSetSize;
+ DWORD QuotaPeakPagedPoolUsage;
+ DWORD QuotaPagedPoolUsage;
+ DWORD QuotaPeakNonPagedPoolUsage;
+ DWORD QuotaNonPagedPoolUsage;
+ DWORD PagefileUsage;
+ DWORD PeakPagefileUsage;
+ DWORD PrivateUsage;
} PROCESS_MEMORY_COUNTERS_EX,*PPROCESS_MEMORY_COUNTERS_EX;
#endif
static BOOL g_b_init_open_process_token;
static BOOL g_b_init_get_token_information;
static BOOL g_b_init_lookup_account_sid;
-static BOOL g_b_init_get_sid_identifier_authority;
static BOOL g_b_init_get_sid_sub_authority;
static BOOL g_b_init_get_sid_sub_authority_count;
static BOOL g_b_init_get_file_security;
LPTSTR DomainName,
LPDWORD cbDomainName,
PSID_NAME_USE peUse);
-typedef PSID_IDENTIFIER_AUTHORITY (WINAPI * GetSidIdentifierAuthority_Proc) (
- PSID pSid);
typedef PDWORD (WINAPI * GetSidSubAuthority_Proc) (
PSID pSid,
DWORD n);
LPFILETIME lpKernelTime,
LPFILETIME lpUserTime);
-
-
/* ** A utility function ** */
static BOOL
is_windows_9x (void)
{
- static BOOL s_b_ret=0;
+ static BOOL s_b_ret = 0;
OSVERSIONINFO os_ver;
if (g_b_init_is_windows_9x == 0)
{
/* ** The wrapper functions ** */
-BOOL WINAPI open_process_token (
- HANDLE ProcessHandle,
- DWORD DesiredAccess,
- PHANDLE TokenHandle)
+static BOOL WINAPI
+open_process_token (HANDLE ProcessHandle,
+ DWORD DesiredAccess,
+ PHANDLE TokenHandle)
{
static OpenProcessToken_Proc s_pfn_Open_Process_Token = NULL;
HMODULE hm_advapi32 = NULL;
);
}
-BOOL WINAPI get_token_information (
- HANDLE TokenHandle,
- TOKEN_INFORMATION_CLASS TokenInformationClass,
- LPVOID TokenInformation,
- DWORD TokenInformationLength,
- PDWORD ReturnLength)
+static BOOL WINAPI
+get_token_information (HANDLE TokenHandle,
+ TOKEN_INFORMATION_CLASS TokenInformationClass,
+ LPVOID TokenInformation,
+ DWORD TokenInformationLength,
+ PDWORD ReturnLength)
{
static GetTokenInformation_Proc s_pfn_Get_Token_Information = NULL;
HMODULE hm_advapi32 = NULL;
);
}
-BOOL WINAPI lookup_account_sid (
- LPCTSTR lpSystemName,
- PSID Sid,
- LPTSTR Name,
- LPDWORD cbName,
- LPTSTR DomainName,
- LPDWORD cbDomainName,
- PSID_NAME_USE peUse)
+static BOOL WINAPI
+lookup_account_sid (LPCTSTR lpSystemName,
+ PSID Sid,
+ LPTSTR Name,
+ LPDWORD cbName,
+ LPTSTR DomainName,
+ LPDWORD cbDomainName,
+ PSID_NAME_USE peUse)
{
static LookupAccountSid_Proc s_pfn_Lookup_Account_Sid = NULL;
HMODULE hm_advapi32 = NULL;
);
}
-PSID_IDENTIFIER_AUTHORITY WINAPI get_sid_identifier_authority (
- PSID pSid)
-{
- static GetSidIdentifierAuthority_Proc s_pfn_Get_Sid_Identifier_Authority = NULL;
- HMODULE hm_advapi32 = NULL;
- if (is_windows_9x () == TRUE)
- {
- return NULL;
- }
- if (g_b_init_get_sid_identifier_authority == 0)
- {
- g_b_init_get_sid_identifier_authority = 1;
- hm_advapi32 = LoadLibrary ("Advapi32.dll");
- s_pfn_Get_Sid_Identifier_Authority =
- (GetSidIdentifierAuthority_Proc) GetProcAddress (
- hm_advapi32, "GetSidIdentifierAuthority");
- }
- if (s_pfn_Get_Sid_Identifier_Authority == NULL)
- {
- return NULL;
- }
- return (s_pfn_Get_Sid_Identifier_Authority (pSid));
-}
-
-PDWORD WINAPI get_sid_sub_authority (
- PSID pSid,
- DWORD n)
+static PDWORD WINAPI
+get_sid_sub_authority (PSID pSid, DWORD n)
{
static GetSidSubAuthority_Proc s_pfn_Get_Sid_Sub_Authority = NULL;
static DWORD zero = 0U;
return (s_pfn_Get_Sid_Sub_Authority (pSid, n));
}
-PUCHAR WINAPI get_sid_sub_authority_count (
- PSID pSid)
+static PUCHAR WINAPI
+get_sid_sub_authority_count (PSID pSid)
{
static GetSidSubAuthorityCount_Proc s_pfn_Get_Sid_Sub_Authority_Count = NULL;
static UCHAR zero = 0U;
return (s_pfn_Get_Sid_Sub_Authority_Count (pSid));
}
-BOOL WINAPI get_file_security (
- LPCTSTR lpFileName,
- SECURITY_INFORMATION RequestedInformation,
- PSECURITY_DESCRIPTOR pSecurityDescriptor,
- DWORD nLength,
- LPDWORD lpnLengthNeeded)
+static BOOL WINAPI
+get_file_security (LPCTSTR lpFileName,
+ SECURITY_INFORMATION RequestedInformation,
+ PSECURITY_DESCRIPTOR pSecurityDescriptor,
+ DWORD nLength,
+ LPDWORD lpnLengthNeeded)
{
static GetFileSecurity_Proc s_pfn_Get_File_Security = NULL;
HMODULE hm_advapi32 = NULL;
lpnLengthNeeded));
}
-BOOL WINAPI get_security_descriptor_owner (
- PSECURITY_DESCRIPTOR pSecurityDescriptor,
- PSID *pOwner,
- LPBOOL lpbOwnerDefaulted)
+static BOOL WINAPI
+get_security_descriptor_owner (PSECURITY_DESCRIPTOR pSecurityDescriptor,
+ PSID *pOwner,
+ LPBOOL lpbOwnerDefaulted)
{
static GetSecurityDescriptorOwner_Proc s_pfn_Get_Security_Descriptor_Owner = NULL;
HMODULE hm_advapi32 = NULL;
lpbOwnerDefaulted));
}
-BOOL WINAPI get_security_descriptor_group (
- PSECURITY_DESCRIPTOR pSecurityDescriptor,
- PSID *pGroup,
- LPBOOL lpbGroupDefaulted)
+static BOOL WINAPI
+get_security_descriptor_group (PSECURITY_DESCRIPTOR pSecurityDescriptor,
+ PSID *pGroup,
+ LPBOOL lpbGroupDefaulted)
{
static GetSecurityDescriptorGroup_Proc s_pfn_Get_Security_Descriptor_Group = NULL;
HMODULE hm_advapi32 = NULL;
lpbGroupDefaulted));
}
-BOOL WINAPI is_valid_sid (
- PSID sid)
+static BOOL WINAPI
+is_valid_sid (PSID sid)
{
static IsValidSid_Proc s_pfn_Is_Valid_Sid = NULL;
HMODULE hm_advapi32 = NULL;
return (s_pfn_Is_Valid_Sid (sid));
}
-BOOL WINAPI equal_sid (
- PSID sid1,
- PSID sid2)
+static BOOL WINAPI
+equal_sid (PSID sid1, PSID sid2)
{
static EqualSid_Proc s_pfn_Equal_Sid = NULL;
HMODULE hm_advapi32 = NULL;
return (s_pfn_Equal_Sid (sid1, sid2));
}
-DWORD WINAPI get_length_sid (
- PSID sid)
+static DWORD WINAPI
+get_length_sid (PSID sid)
{
static GetLengthSid_Proc s_pfn_Get_Length_Sid = NULL;
HMODULE hm_advapi32 = NULL;
return (s_pfn_Get_Length_Sid (sid));
}
-BOOL WINAPI copy_sid (
- DWORD destlen,
- PSID dest,
- PSID src)
+static BOOL WINAPI
+copy_sid (DWORD destlen, PSID dest, PSID src)
{
static CopySid_Proc s_pfn_Copy_Sid = NULL;
HMODULE hm_advapi32 = NULL;
supported in Windows NT / 2k / XP
*/
-void WINAPI get_native_system_info (
- LPSYSTEM_INFO lpSystemInfo)
+static void WINAPI
+get_native_system_info (LPSYSTEM_INFO lpSystemInfo)
{
static GetNativeSystemInfo_Proc s_pfn_Get_Native_System_Info = NULL;
if (is_windows_9x () != TRUE)
lpSystemInfo->dwNumberOfProcessors = -1;
}
-BOOL WINAPI get_system_times (
- LPFILETIME lpIdleTime,
- LPFILETIME lpKernelTime,
- LPFILETIME lpUserTime)
+static BOOL WINAPI
+get_system_times (LPFILETIME lpIdleTime,
+ LPFILETIME lpKernelTime,
+ LPFILETIME lpUserTime)
{
static GetSystemTimes_Proc s_pfn_Get_System_times = NULL;
if (is_windows_9x () == TRUE)
return pw;
}
-void
+static void
init_user_info (void)
{
/* Find the user's real name by opening the process token and
/* Remove all CR's that are followed by a LF.
(From msdos.c...probably should figure out a way to share it,
although this code isn't going to ever change.) */
-int
+static int
crlf_to_lf (register int n, register unsigned char *buf)
{
unsigned char *np = buf;
return TRUE;
}
-int
+static int
is_unc_volume (const char *filename)
{
const char *ptr = filename;
/* Wrapper for GetVolumeInformation, which uses caching to avoid
performance penalty (~2ms on 486 for local drives, 7.5ms for local
cdrom drive, ~5-10ms or more for remote drives on LAN). */
-volume_info_data *
+static volume_info_data *
GetCachedVolumeInformation (char * root_dir)
{
volume_info_data * info;
/* Get information on the volume where name is held; set path pointer to
start of pathname in name (past UNC header\volume header if present). */
-int
+static int
get_volume_info (const char * name, const char ** pPath)
{
char temp[MAX_PATH];
/* Determine if volume is FAT format (ie. only supports short 8.3
names); also set path pointer to start of pathname in name. */
-int
+static int
is_fat_volume (const char * name, const char ** pPath)
{
if (get_volume_info (name, pPath))
/* Support shares on a network resource as subdirectories of a read-only
root directory. */
static HANDLE wnet_enum_handle = INVALID_HANDLE_VALUE;
-HANDLE open_unc_volume (const char *);
-char *read_unc_volume (HANDLE, char *, int);
-void close_unc_volume (HANDLE);
+static HANDLE open_unc_volume (const char *);
+static char *read_unc_volume (HANDLE, char *, int);
+static void close_unc_volume (HANDLE);
DIR *
opendir (char *filename)
return &dir_static;
}
-HANDLE
+static HANDLE
open_unc_volume (const char *path)
{
NETRESOURCE nr;
return INVALID_HANDLE_VALUE;
}
-char *
+static char *
read_unc_volume (HANDLE henum, char *readbuf, int size)
{
DWORD count;
return readbuf;
}
-void
+static void
close_unc_volume (HANDLE henum)
{
if (henum != INVALID_HANDLE_VALUE)
WNetCloseEnum (henum);
}
-DWORD
+static DWORD
unc_volume_file_attributes (const char *path)
{
HANDLE henum;
return (time_t) ((tmp - utc_base) / 10000000L);
}
-
-void
+static void
convert_from_time_t (time_t time, FILETIME * pft)
{
ULARGE_INTEGER tmp;
}
static void
-get_file_owner_and_group (
- PSECURITY_DESCRIPTOR psd,
- const char *fname,
- struct stat *st)
+get_file_owner_and_group (PSECURITY_DESCRIPTOR psd,
+ const char *fname,
+ struct stat *st)
{
int dflt_usr = 0, dflt_grp = 0;
buf->st_dev = volume_info.serialnum;
buf->st_rdev = volume_info.serialnum;
-
buf->st_size = wfd.nFileSizeHigh;
buf->st_size <<= 32;
buf->st_size += wfd.nFileSizeLow;
/* Helper wrapper functions. */
-HANDLE WINAPI create_toolhelp32_snapshot (
- DWORD Flags,
- DWORD Ignored)
+static HANDLE WINAPI
+create_toolhelp32_snapshot (DWORD Flags, DWORD Ignored)
{
static CreateToolhelp32Snapshot_Proc s_pfn_Create_Toolhelp32_Snapshot = NULL;
return (s_pfn_Create_Toolhelp32_Snapshot (Flags, Ignored));
}
-BOOL WINAPI process32_first (
- HANDLE hSnapshot,
- LPPROCESSENTRY32 lppe)
+static BOOL WINAPI
+process32_first (HANDLE hSnapshot, LPPROCESSENTRY32 lppe)
{
static Process32First_Proc s_pfn_Process32_First = NULL;
return (s_pfn_Process32_First (hSnapshot, lppe));
}
-BOOL WINAPI process32_next (
- HANDLE hSnapshot,
- LPPROCESSENTRY32 lppe)
+static BOOL WINAPI
+process32_next (HANDLE hSnapshot, LPPROCESSENTRY32 lppe)
{
static Process32Next_Proc s_pfn_Process32_Next = NULL;
return (s_pfn_Process32_Next (hSnapshot, lppe));
}
-BOOL WINAPI open_thread_token (
- HANDLE ThreadHandle,
- DWORD DesiredAccess,
- BOOL OpenAsSelf,
- PHANDLE TokenHandle)
+static BOOL WINAPI
+open_thread_token (HANDLE ThreadHandle,
+ DWORD DesiredAccess,
+ BOOL OpenAsSelf,
+ PHANDLE TokenHandle)
{
static OpenThreadToken_Proc s_pfn_Open_Thread_Token = NULL;
HMODULE hm_advapi32 = NULL;
);
}
-BOOL WINAPI impersonate_self (
- SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
+static BOOL WINAPI
+impersonate_self (SECURITY_IMPERSONATION_LEVEL ImpersonationLevel)
{
static ImpersonateSelf_Proc s_pfn_Impersonate_Self = NULL;
HMODULE hm_advapi32 = NULL;
return s_pfn_Impersonate_Self (ImpersonationLevel);
}
-BOOL WINAPI revert_to_self (void)
+static BOOL WINAPI
+revert_to_self (void)
{
static RevertToSelf_Proc s_pfn_Revert_To_Self = NULL;
HMODULE hm_advapi32 = NULL;
return s_pfn_Revert_To_Self ();
}
-BOOL WINAPI get_process_memory_info (
- HANDLE h_proc,
- PPROCESS_MEMORY_COUNTERS mem_counters,
- DWORD bufsize)
+static BOOL WINAPI
+get_process_memory_info (HANDLE h_proc,
+ PPROCESS_MEMORY_COUNTERS mem_counters,
+ DWORD bufsize)
{
static GetProcessMemoryInfo_Proc s_pfn_Get_Process_Memory_Info = NULL;
HMODULE hm_psapi = NULL;
return s_pfn_Get_Process_Memory_Info (h_proc, mem_counters, bufsize);
}
-BOOL WINAPI get_process_working_set_size (
- HANDLE h_proc,
- DWORD *minrss,
- DWORD *maxrss)
+static BOOL WINAPI
+get_process_working_set_size (HANDLE h_proc,
+ DWORD *minrss,
+ DWORD *maxrss)
{
static GetProcessWorkingSetSize_Proc
s_pfn_Get_Process_Working_Set_Size = NULL;
return s_pfn_Get_Process_Working_Set_Size (h_proc, minrss, maxrss);
}
-BOOL WINAPI global_memory_status (
- MEMORYSTATUS *buf)
+static BOOL WINAPI
+global_memory_status (MEMORYSTATUS *buf)
{
static GlobalMemoryStatus_Proc s_pfn_Global_Memory_Status = NULL;
return s_pfn_Global_Memory_Status (buf);
}
-BOOL WINAPI global_memory_status_ex (
- MEMORY_STATUS_EX *buf)
+static BOOL WINAPI
+global_memory_status_ex (MEMORY_STATUS_EX *buf)
{
static GlobalMemoryStatusEx_Proc s_pfn_Global_Memory_Status_Ex = NULL;
if (winsock_lib != NULL)
return TRUE;
- pfn_SetHandleInformation = NULL;
pfn_SetHandleInformation
= (void *) GetProcAddress (GetModuleHandle ("kernel32.dll"),
"SetHandleInformation");
#define SOCK_HANDLE(fd) ((SOCKET) fd_info[fd].hnd)
-int socket_to_fd (SOCKET s);
+static int socket_to_fd (SOCKET s);
int
sys_socket (int af, int type, int protocol)
}
/* Convert a SOCKET to a file descriptor. */
-int
+static int
socket_to_fd (SOCKET s)
{
int fd;
return -1;
}
-
int
sys_bind (int s, const struct sockaddr * addr, int namelen)
{
return SOCKET_ERROR;
}
-
int
sys_connect (int s, const struct sockaddr * name, int namelen)
{
return SOCKET_ERROR;
}
-
int
sys_shutdown (int s, int how)
{
return new_fd;
}
-
int
sys_dup2 (int src, int dst)
{
shutdown_handler ensures that buffers' autosave files are
up to date when the user logs off, or the system shuts down.
*/
-BOOL WINAPI
+static BOOL WINAPI
shutdown_handler (DWORD type)
{
/* Ctrl-C and Ctrl-Break are already suppressed, so don't handle them. */
g_b_init_open_process_token = 0;
g_b_init_get_token_information = 0;
g_b_init_lookup_account_sid = 0;
- g_b_init_get_sid_identifier_authority = 0;
g_b_init_get_sid_sub_authority = 0;
g_b_init_get_sid_sub_authority_count = 0;
g_b_init_get_file_security = 0;