2 * Windows APIs that are different for each system.
3 * We use pointers to the entry points so that a
4 * single binary will run on all Windows systems.
9 Copyright (C) 2000-2005 Kern Sibbald
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of
14 the License, or (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public
22 License along with this program; if not, write to the Free
23 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
30 #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
34 // init with win9x, but maybe set to NT in InitWinAPI
35 DWORD g_platform_id = VER_PLATFORM_WIN32_WINDOWS;
40 t_OpenProcessToken p_OpenProcessToken = NULL;
41 t_AdjustTokenPrivileges p_AdjustTokenPrivileges = NULL;
42 t_LookupPrivilegeValue p_LookupPrivilegeValue = NULL;
44 t_SetProcessShutdownParameters p_SetProcessShutdownParameters = NULL;
46 t_CreateFileA p_CreateFileA = NULL;
47 t_CreateFileW p_CreateFileW = NULL;
49 t_wunlink p_wunlink = NULL;
50 t_wmkdir p_wmkdir = NULL;
51 t_wopen p_wopen = NULL;
53 t_cgetws p_cgetws = NULL;
54 t_cwprintf p_cwprintf = NULL;
56 t_GetFileAttributesA p_GetFileAttributesA = NULL;
57 t_GetFileAttributesW p_GetFileAttributesW = NULL;
59 t_GetFileAttributesExA p_GetFileAttributesExA = NULL;
60 t_GetFileAttributesExW p_GetFileAttributesExW = NULL;
62 t_SetFileAttributesA p_SetFileAttributesA = NULL;
63 t_SetFileAttributesW p_SetFileAttributesW = NULL;
64 t_BackupRead p_BackupRead = NULL;
65 t_BackupWrite p_BackupWrite = NULL;
66 t_WideCharToMultiByte p_WideCharToMultiByte = NULL;
67 t_MultiByteToWideChar p_MultiByteToWideChar = NULL;
69 t_FindFirstFileA p_FindFirstFileA = NULL;
70 t_FindFirstFileW p_FindFirstFileW = NULL;
72 t_FindNextFileA p_FindNextFileA = NULL;
73 t_FindNextFileW p_FindNextFileW = NULL;
75 t_SetCurrentDirectoryA p_SetCurrentDirectoryA = NULL;
76 t_SetCurrentDirectoryW p_SetCurrentDirectoryW = NULL;
78 t_GetCurrentDirectoryA p_GetCurrentDirectoryA = NULL;
79 t_GetCurrentDirectoryW p_GetCurrentDirectoryW = NULL;
85 HMODULE hLib = LoadLibraryA("KERNEL32.DLL");
87 /* create file calls */
88 p_CreateFileA = (t_CreateFileA)
89 GetProcAddress(hLib, "CreateFileA");
90 p_CreateFileW = (t_CreateFileW)
91 GetProcAddress(hLib, "CreateFileW");
94 p_GetFileAttributesA = (t_GetFileAttributesA)
95 GetProcAddress(hLib, "GetFileAttributesA");
96 p_GetFileAttributesW = (t_GetFileAttributesW)
97 GetProcAddress(hLib, "GetFileAttributesW");
98 p_GetFileAttributesExA = (t_GetFileAttributesExA)
99 GetProcAddress(hLib, "GetFileAttributesExA");
100 p_GetFileAttributesExW = (t_GetFileAttributesExW)
101 GetProcAddress(hLib, "GetFileAttributesExW");
102 p_SetFileAttributesA = (t_SetFileAttributesA)
103 GetProcAddress(hLib, "SetFileAttributesA");
104 p_SetFileAttributesW = (t_SetFileAttributesW)
105 GetProcAddress(hLib, "SetFileAttributesW");
107 p_SetProcessShutdownParameters = (t_SetProcessShutdownParameters)
108 GetProcAddress(hLib, "SetProcessShutdownParameters");
110 p_BackupRead = (t_BackupRead)
111 GetProcAddress(hLib, "BackupRead");
112 p_BackupWrite = (t_BackupWrite)
113 GetProcAddress(hLib, "BackupWrite");
114 /* char conversion calls */
115 p_WideCharToMultiByte = (t_WideCharToMultiByte)
116 GetProcAddress(hLib, "WideCharToMultiByte");
117 p_MultiByteToWideChar = (t_MultiByteToWideChar)
118 GetProcAddress(hLib, "MultiByteToWideChar");
121 p_FindFirstFileA = (t_FindFirstFileA)
122 GetProcAddress(hLib, "FindFirstFileA");
123 p_FindFirstFileW = (t_FindFirstFileW)
124 GetProcAddress(hLib, "FindFirstFileW");
125 p_FindNextFileA = (t_FindNextFileA)
126 GetProcAddress(hLib, "FindNextFileA");
127 p_FindNextFileW = (t_FindNextFileW)
128 GetProcAddress(hLib, "FindNextFileW");
129 /* set and get directory */
130 p_SetCurrentDirectoryA = (t_SetCurrentDirectoryA)
131 GetProcAddress(hLib, "SetCurrentDirectoryA");
132 p_SetCurrentDirectoryW = (t_SetCurrentDirectoryW)
133 GetProcAddress(hLib, "SetCurrentDirectoryW");
134 p_GetCurrentDirectoryA = (t_GetCurrentDirectoryA)
135 GetProcAddress(hLib, "GetCurrentDirectoryA");
136 p_GetCurrentDirectoryW = (t_GetCurrentDirectoryW)
137 GetProcAddress(hLib, "GetCurrentDirectoryW");
141 hLib = LoadLibraryA("MSVCRT.DLL");
144 p_wunlink = (t_wunlink)
145 GetProcAddress(hLib, "_wunlink");
147 p_wmkdir = (t_wmkdir)
148 GetProcAddress(hLib, "_wmkdir");
151 GetProcAddress(hLib, "_wopen");
154 p_cgetws = (t_cgetws)
155 GetProcAddress (hLib, "_cgetws");
157 p_cwprintf = (t_cwprintf)
158 GetProcAddress (hLib, "_cwprintf");
163 hLib = LoadLibraryA("ADVAPI32.DLL");
165 p_OpenProcessToken = (t_OpenProcessToken)
166 GetProcAddress(hLib, "OpenProcessToken");
167 p_AdjustTokenPrivileges = (t_AdjustTokenPrivileges)
168 GetProcAddress(hLib, "AdjustTokenPrivileges");
169 p_LookupPrivilegeValue = (t_LookupPrivilegeValue)
170 GetProcAddress(hLib, "LookupPrivilegeValueA");
174 // do we run on win 9x ???
175 OSVERSIONINFO osversioninfo;
176 osversioninfo.dwOSVersionInfoSize = sizeof(osversioninfo);
178 // Get the current OS version
179 if (!GetVersionEx(&osversioninfo)) {
182 g_platform_id = osversioninfo.dwPlatformId;
185 if (g_platform_id == VER_PLATFORM_WIN32_WINDOWS) {
187 p_BackupWrite = NULL;
189 p_CreateFileW = NULL;
190 p_GetFileAttributesW = NULL;
191 p_GetFileAttributesExW = NULL;
193 p_SetFileAttributesW = NULL;
195 p_FindFirstFileW = NULL;
196 p_FindNextFileW = NULL;
197 p_SetCurrentDirectoryW = NULL;
198 p_GetCurrentDirectoryW = NULL;