xref: /aoo4110/main/sal/inc/systools/win32/kernel9x.h (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #pragma once
25 
26 #ifndef _WINDOWS_
27 #include <windows.h>
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 //------------------------------------------------------------------------
35 // undefine the macros defined in the winbase.h file in order to avoid
36 // warnings because of multiple defines
37 //------------------------------------------------------------------------
38 
39 #ifdef LoadLibraryW
40 #undef LoadLibraryW
41 #endif
42 
43 #ifdef LoadLibraryExW
44 #undef LoadLibraryExW
45 #endif
46 
47 #ifdef GetModuleFileNameW
48 #undef GetModuleFileNameW
49 #endif
50 
51 #ifdef GetLogicalDriveStringsW
52 #undef GetLogicalDriveStringsW
53 #endif
54 
55 #ifdef DeleteFileW
56 #undef DeleteFileW
57 #endif
58 
59 #ifdef CopyFileW
60 #undef CopyFileW
61 #endif
62 
63 #ifdef MoveFileW
64 #undef MoveFileW
65 #endif
66 
67 #ifdef MoveFileExW
68 #undef MoveFileExW
69 #endif
70 
71 #ifdef CreateFileW
72 #undef CreateFileW
73 #endif
74 
75 #ifdef RemoveDirectoryW
76 #undef RemoveDirectoryW
77 #endif
78 
79 #ifdef CreateDirectoryW
80 #undef CreateDirectoryW
81 #endif
82 
83 #ifdef CreateDirectoryExW
84 #undef CreateDirectoryExW
85 #endif
86 
87 #ifdef CreateFileW
88 #undef CreateFileW
89 #endif
90 
91 #ifdef GetLongPathNameW
92 #undef GetLongPathNameW
93 #endif
94 
95 #ifdef GetLocaleInfoW
96 #undef GetLocaleInfoW
97 #endif
98 
99 #ifdef GetFullPathNameW
100 #undef GetFullPathNameW
101 #endif
102 
103 #ifdef CreateProcessW
104 #undef CreateProcessW
105 #endif
106 
107 #ifdef CreateProcessAsUserW
108 #undef CreateProcessAsUserW
109 #endif
110 
111 #ifdef GetEnvironmentVariableW
112 #undef GetEnvironmentVariableW
113 #endif
114 
115 #ifdef GetDriveTypeW
116 #undef GetDriveTypeW
117 #endif
118 
119 #ifdef GetCurrentDirectoryW
120 #undef GetCurrentDirectoryW
121 #endif
122 
123 #ifdef SetCurrentDirectoryW
124 #undef SetCurrentDirectoryW
125 #endif
126 
127 #ifdef GetVolumeInformationW
128 #undef GetVolumeInformationW
129 #endif
130 
131 
132 #ifdef GetDiskFreeSpaceExA
133 #undef GetDiskFreeSpaceExA
134 #endif
135 
136 #ifdef GetDiskFreeSpaceExW
137 #undef GetDiskFreeSpaceExW
138 #endif
139 
140 //------------------------------------------------------------------------
141 // set the compiler directives for the function pointer we declare below
142 // if we build sal or sal will be used as static library we define extern
143 // else sal exports the function pointers from a dll and we use __declspec
144 //------------------------------------------------------------------------
145 
146 #define KERNEL9X_API extern
147 
148 //------------------------------------------------------------------------
149 // declare function pointers to the appropriate kernel functions
150 //------------------------------------------------------------------------
151 
152 //BOOL WINAPI RegisterServiceProcess( DWORD dwProcessID, BOOL fRegister );
153 
154 KERNEL9X_API HMODULE (WINAPI *lpfnLoadLibraryExW ) (
155 	LPCWSTR lpLibFileName,  // file name of module
156 	HANDLE hFile,           // reserved, must be NULL
157 	DWORD dwFlags           // entry-point execution option
158 );
159 
160 KERNEL9X_API DWORD (WINAPI *lpfnGetModuleFileNameW ) (
161 	HMODULE hModule,    // handle to module
162 	LPWSTR lpFilename,  // file name of module
163 	DWORD nSize         // size of buffer
164 );
165 
166 KERNEL9X_API DWORD (WINAPI *lpfnGetLogicalDriveStringsW ) (
167 	DWORD nBufferLength,	// size of buffer
168 	LPWSTR lpBuffer			// drive strings buffer
169 );
170 
171 KERNEL9X_API HANDLE ( WINAPI *lpfnCreateFileW )(
172 	LPCWSTR	lpFileName,
173 	DWORD	dwDesiredAccess,
174 	DWORD	dwShareMode,
175 	LPSECURITY_ATTRIBUTES	lpSecurityAttributes,
176 	DWORD	dwCreationDisposition,
177 	DWORD	dwFlagsAndAttributes,
178 	HANDLE	hTemplateFile
179 );
180 
181 KERNEL9X_API DWORD WINAPI GetCanonicalPathNameA(
182 	LPCSTR lpszPath,			// file name
183 	LPSTR lpszCanonicalPath,	// path buffer
184 	DWORD cchBuffer				// size of path buffer
185 );
186 
187 KERNEL9X_API DWORD WINAPI GetCanonicalPathNameW(
188 	LPCWSTR lpszPath,			// file name
189 	LPWSTR lpszCanonicalPath,	// path buffer
190 	DWORD cchBuffer				// size of path buffer
191 );
192 
193 KERNEL9X_API HANDLE ( WINAPI * lpfnCreateFileW ) (
194 	LPCWSTR	lpFileName,
195 	DWORD	dwDesiredAccess,
196 	DWORD	dwShareMode,
197 	LPSECURITY_ATTRIBUTES	lpSecurityAttributes,
198 	DWORD	dwCreationDisposition,
199 	DWORD	dwFlagsAndAttributes,
200 	HANDLE	hTemplateFile );
201 
202 KERNEL9X_API BOOL (WINAPI *lpfnDeleteFileW ) (
203 	LPCWSTR	lpFileName			// file name
204 );
205 
206 KERNEL9X_API BOOL (WINAPI *lpfnCopyFileW ) (
207 	LPCWSTR lpExistingFileName,	// file name
208 	LPCWSTR lpNewFileName,		// new file name
209 	BOOL	bFailIfExist		// operation if file exists
210 );
211 
212 KERNEL9X_API BOOL (WINAPI *lpfnMoveFileW ) (
213 	LPCWSTR lpExistingFileName,	// file name
214 	LPCWSTR lpNewFileName		// new file name
215 );
216 
217 KERNEL9X_API BOOL (WINAPI *lpfnMoveFileExW ) (
218   LPCWSTR lpExistingFileName,	// file name
219   LPCWSTR lpNewFileName,		// new file name
220   DWORD dwFlags					// move options
221 );
222 
223 KERNEL9X_API BOOL (WINAPI *lpfnRemoveDirectoryW ) (
224 	LPCWSTR	lpPathName			// directory name
225 );
226 
227 KERNEL9X_API BOOL ( WINAPI * lpfnCreateDirectoryW ) (
228 	LPCWSTR	lpNewDirectory, LPSECURITY_ATTRIBUTES lpSecurityAttributes );
229 
230 KERNEL9X_API BOOL ( WINAPI * lpfnCreateDirectoryExW ) (
231 	LPCWSTR	lpTemplateDirectory,
232 	LPCWSTR	lpNewDirectory,
233 	LPSECURITY_ATTRIBUTES	lpSecurityAttributes );
234 
235 KERNEL9X_API DWORD ( WINAPI * lpfnGetLongPathNameW ) (
236   LPCWSTR lpszShortPath, // file name
237   LPWSTR lpszLongPath,   // path buffer
238   DWORD cchBuffer        // size of path buffer
239 );
240 
241 // GetCanonicalPath is a tool function with no exact counterpart
242 // in the win32 api; we use nevertheless a function pointer
243 // because every variable etc. must root in the Kernel9x.lib else
244 // we loose our AutoSystoolInit object during linking
245 KERNEL9X_API DWORD ( WINAPI * lpfnGetCanonicalPathW ) (
246 	LPCWSTR lpszPath,			// file name
247 	LPWSTR lpszCanonicalPath,	// path buffer
248 	DWORD cchBuffer				// size of path buffer
249 );
250 
251 KERNEL9X_API int ( WINAPI* lpfnGetLocaleInfoW ) (
252     LCID Locale,        // locale identifier
253     LCTYPE LCType,      // information type
254     LPWSTR lpLCData,    // information buffer
255     int cchData         // size of buffer
256 );
257 
258 KERNEL9X_API DWORD ( WINAPI * lpfnGetFullPathNameW )(
259 	LPCWSTR	lpFileName,		// file name
260 	DWORD	nBufferLength,	// size of path buffer
261 	LPWSTR	lpBuffer,		// path buffer
262 	LPWSTR	*lpFilePart		// address of file name in path
263 );
264 
265 KERNEL9X_API BOOL ( WINAPI * lpfnCreateProcessW )(
266     LPCWSTR lpApplicationName,                 // name of executable module
267     LPWSTR lpCommandLine,                      // command line string
268     LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
269     LPSECURITY_ATTRIBUTES lpThreadAttributes,  // SD
270     BOOL bInheritHandles,                      // handle inheritance option
271     DWORD dwCreationFlags,                     // creation flags
272     LPVOID lpEnvironment,                      // new environment block
273     LPCWSTR lpCurrentDirectory,                // current directory name
274     LPSTARTUPINFOW lpStartupInfo,              // startup information
275     LPPROCESS_INFORMATION lpProcessInformation // process information
276 );
277 
278 KERNEL9X_API BOOL ( WINAPI * lpfnCreateProcessAsUserW )(
279     HANDLE hToken,                             // handle to user token
280     LPCWSTR lpApplicationName,                 // name of executable module
281     LPWSTR lpCommandLine,                      // command-line string
282     LPSECURITY_ATTRIBUTES lpProcessAttributes, // SD
283     LPSECURITY_ATTRIBUTES lpThreadAttributes,  // SD
284     BOOL bInheritHandles,                      // inheritance option
285     DWORD dwCreationFlags,                     // creation flags
286     LPVOID lpEnvironment,                      // new environment block
287     LPCWSTR lpCurrentDirectory,                // current directory name
288     LPSTARTUPINFOW lpStartupInfo,              // startup information
289     LPPROCESS_INFORMATION lpProcessInformation // process information
290 );
291 
292 KERNEL9X_API DWORD ( WINAPI * lpfnGetEnvironmentVariableW )(
293     LPCWSTR lpName,  // environment variable name
294     LPWSTR lpBuffer, // buffer for variable value
295     DWORD nSize      // size of buffer
296 );
297 
298 
299 KERNEL9X_API UINT ( WINAPI * lpfnGetDriveTypeW )(
300 	LPCWSTR lpRootPathName	// root directory
301 );
302 
303 KERNEL9X_API DWORD ( WINAPI * lpfnGetCurrentDirectoryW )(
304     DWORD  nBufferLength,   // size of directory buffer
305     LPWSTR lpBuffer         // directory buffer
306 );
307 
308 KERNEL9X_API BOOL ( WINAPI * lpfnSetCurrentDirectoryW )(
309     LPCWSTR lpPathName  // new directory name
310 );
311 
312 // GetVolumeInformation
313 KERNEL9X_API BOOL ( WINAPI* lpfnGetVolumeInformationW )(
314 	LPCWSTR	lpRootPathName,				// root directory
315 	LPWSTR	lpVolumeNameBuffer,			// volume name buffer
316 	DWORD	nVolumeNameSize,			// length of name buffer
317 	LPDWORD	lpVolumeSerialNumber,		// volume serial number
318 	LPDWORD	lpMaximumComponentLength,	// maximum file name length
319 	LPDWORD	lpFileSystemFlags,			// file system options
320 	LPWSTR	lpFileSystemName,			// file system name buffer
321 	DWORD	nFileSystemNameSize			// length of file system name buffer
322 );
323 
324 // GetDiskFreeSpaceExA
325 KERNEL9X_API BOOL (WINAPI *lpfnGetDiskFreeSpaceExA)(
326   LPCSTR lpDirectoryName,                  // directory name
327   PULARGE_INTEGER lpFreeBytesAvailable,    // bytes available to caller
328   PULARGE_INTEGER lpTotalNumberOfBytes,    // bytes on disk
329   PULARGE_INTEGER lpTotalNumberOfFreeBytes // free bytes on disk
330 );
331 
332 // GetDiskFreeSpaceExW
333 KERNEL9X_API BOOL (WINAPI *lpfnGetDiskFreeSpaceExW)(
334   LPCWSTR lpDirectoryName,                 // directory name
335   PULARGE_INTEGER lpFreeBytesAvailable,    // bytes available to caller
336   PULARGE_INTEGER lpTotalNumberOfBytes,    // bytes on disk
337   PULARGE_INTEGER lpTotalNumberOfFreeBytes // free bytes on disk
338 );
339 
340 //------------------------------------------------------------------------
341 // redefine the above undefined macros so that the preprocessor replaces
342 // all occurrences of this macros with our function pointer
343 //------------------------------------------------------------------------
344 
345 #define LoadLibraryExW				lpfnLoadLibraryExW
346 #define LoadLibraryW(c)				LoadLibraryExW(c, NULL, 0)
347 #define GetModuleFileNameW			lpfnGetModuleFileNameW
348 #define GetLogicalDriveStringsW		lpfnGetLogicalDriveStringsW
349 #define CreateFileW					lpfnCreateFileW
350 #define DeleteFileW					lpfnDeleteFileW
351 #define CopyFileW					lpfnCopyFileW
352 #define MoveFileW					lpfnMoveFileW
353 #define MoveFileExW					lpfnMoveFileExW
354 #define RemoveDirectoryW			lpfnRemoveDirectoryW
355 #define CreateDirectoryW			lpfnCreateDirectoryW
356 #define CreateDirectoryExW			lpfnCreateDirectoryExW
357 #define GetLongPathNameW			lpfnGetLongPathNameW
358 #define GetFullPathNameW			lpfnGetFullPathNameW
359 
360 #define GetCanonicalPath			lpfnGetCanonicalPathW
361 #define GetLocaleInfoW              lpfnGetLocaleInfoW
362 
363 #define CreateProcessW              lpfnCreateProcessW
364 #define CreateProcessAsUserW        lpfnCreateProcessAsUserW
365 #define GetEnvironmentVariableW     lpfnGetEnvironmentVariableW
366 #define GetDriveTypeW				lpfnGetDriveTypeW
367 
368 #define GetCurrentDirectoryW        lpfnGetCurrentDirectoryW
369 #define SetCurrentDirectoryW        lpfnSetCurrentDirectoryW
370 
371 #define GetVolumeInformationW		lpfnGetVolumeInformationW
372 #define GetDiskFreeSpaceExA			lpfnGetDiskFreeSpaceExA
373 #define GetDiskFreeSpaceExW			lpfnGetDiskFreeSpaceExW
374 
375 #ifdef __cplusplus
376 }
377 #endif
378 
379 
380