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