d9d8dc69a644546d09d125025b5917771d6f4869
[reactos.git] / reactos / dll / win32 / kernel32 / include / kernel32.h
1 #pragma once
2
3 //
4 // Kernel32 Filter IDs
5 //
6 #define kernel32file 200
7 #define kernel32ver 201
8 #define actctx 202
9 #define resource 203
10 #define kernel32session 204
11 #define comm 205
12 #define profile 206
13 #define nls 207
14
15
16 #if DBG
17 #define DEBUG_CHANNEL(ch) static ULONG gDebugChannel = ch;
18 #else
19 #define DEBUG_CHANNEL(ch)
20 #endif
21
22 #define TRACE(fmt, ...) TRACE__(gDebugChannel, fmt, ##__VA_ARGS__)
23 #define WARN(fmt, ...) WARN__(gDebugChannel, fmt, ##__VA_ARGS__)
24 #define FIXME(fmt, ...) WARN__(gDebugChannel, fmt,## __VA_ARGS__)
25 #define ERR(fmt, ...) ERR__(gDebugChannel, fmt, ##__VA_ARGS__)
26
27 #define STUB \
28 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); \
29 DPRINT1("%s() is UNIMPLEMENTED!\n", __FUNCTION__)
30
31 #define debugstr_a
32 #define debugstr_w
33 #define debugstr_wn
34 #define wine_dbgstr_w
35 #define debugstr_guid
36
37 #include "wine/unicode.h"
38 #include "baseheap.h"
39
40 #define BINARY_UNKNOWN (0)
41 #define BINARY_PE_EXE32 (1)
42 #define BINARY_PE_DLL32 (2)
43 #define BINARY_PE_EXE64 (3)
44 #define BINARY_PE_DLL64 (4)
45 #define BINARY_WIN16 (5)
46 #define BINARY_OS216 (6)
47 #define BINARY_DOS (7)
48 #define BINARY_UNIX_EXE (8)
49 #define BINARY_UNIX_LIB (9)
50
51 #define MAGIC(c1,c2,c3,c4) ((c1) + ((c2)<<8) + ((c3)<<16) + ((c4)<<24))
52
53 #define MAGIC_HEAP MAGIC( 'H','E','A','P' )
54
55 #define ROUNDUP(a,b) ((((a)+(b)-1)/(b))*(b))
56 #define ROUNDDOWN(a,b) (((a)/(b))*(b))
57
58 #define ROUND_DOWN(n, align) \
59 (((ULONG)n) & ~((align) - 1l))
60
61 #define ROUND_UP(n, align) \
62 ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
63
64 #define __TRY _SEH2_TRY
65 #define __EXCEPT_PAGE_FAULT _SEH2_EXCEPT(_SEH2_GetExceptionCode() == STATUS_ACCESS_VIOLATION)
66 #define __ENDTRY _SEH2_END
67
68 /* Undocumented CreateProcess flag */
69 #define STARTF_SHELLPRIVATE 0x400
70
71 typedef struct _CODEPAGE_ENTRY
72 {
73 LIST_ENTRY Entry;
74 UINT CodePage;
75 HANDLE SectionHandle;
76 PBYTE SectionMapping;
77 CPTABLEINFO CodePageTable;
78 } CODEPAGE_ENTRY, *PCODEPAGE_ENTRY;
79
80 typedef struct tagLOADPARMS32
81 {
82 LPSTR lpEnvAddress;
83 LPSTR lpCmdLine;
84 WORD wMagicValue;
85 WORD wCmdShow;
86 DWORD dwReserved;
87 } LOADPARMS32;
88
89 typedef enum _BASE_SEARCH_PATH_TYPE
90 {
91 BaseSearchPathInvalid,
92 BaseSearchPathDll,
93 BaseSearchPathApp,
94 BaseSearchPathDefault,
95 BaseSearchPathEnv,
96 BaseSearchPathCurrent,
97 BaseSearchPathMax
98 } BASE_SEARCH_PATH_TYPE, *PBASE_SEARCH_PATH_TYPE;
99
100 typedef enum _BASE_CURRENT_DIR_PLACEMENT
101 {
102 BaseCurrentDirPlacementInvalid = -1,
103 BaseCurrentDirPlacementDefault,
104 BaseCurrentDirPlacementSafe,
105 BaseCurrentDirPlacementMax
106 } BASE_CURRENT_DIR_PLACEMENT;
107
108 typedef struct _BASEP_ACTCTX_BLOCK
109 {
110 ULONG Flags;
111 PVOID ActivationContext;
112 PVOID CompletionContext;
113 LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine;
114 } BASEP_ACTCTX_BLOCK, *PBASEP_ACTCTX_BLOCK;
115
116 #define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_ERROR 1
117 #define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_SUCCESS 2
118 #define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_CONTINUE 3
119
120 extern PBASE_STATIC_SERVER_DATA BaseStaticServerData;
121
122 typedef
123 DWORD
124 (*WaitForInputIdleType)(
125 HANDLE hProcess,
126 DWORD dwMilliseconds);
127
128 extern WaitForInputIdleType UserWaitForInputIdleRoutine;
129
130 /* Flags for PrivCopyFileExW && BasepCopyFileExW */
131 #define BASEP_COPY_METADATA 0x10
132 #define BASEP_COPY_SACL 0x20
133 #define BASEP_COPY_OWNER_AND_GROUP 0x40
134 #define BASEP_COPY_DIRECTORY 0x80
135 #define BASEP_COPY_BACKUP_SEMANTICS 0x100
136 #define BASEP_COPY_REPLACE 0x200
137 #define BASEP_COPY_SKIP_DACL 0x400
138 #define BASEP_COPY_PUBLIC_MASK 0xF
139 #define BASEP_COPY_BASEP_MASK 0xFFFFFFF0
140
141 /* Flags for PrivMoveFileIdentityW */
142 #define PRIV_DELETE_ON_SUCCESS 0x1
143 #define PRIV_ALLOW_NON_TRACKABLE 0x2
144
145 /* GLOBAL VARIABLES **********************************************************/
146
147 extern BOOL bIsFileApiAnsi;
148 extern HMODULE hCurrentModule;
149
150 extern RTL_CRITICAL_SECTION BaseDllDirectoryLock;
151
152 extern UNICODE_STRING BaseDllDirectory;
153 extern UNICODE_STRING BaseDefaultPath;
154 extern UNICODE_STRING BaseDefaultPathAppend;
155 extern PLDR_DATA_TABLE_ENTRY BasepExeLdrEntry;
156
157 extern LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter;
158
159 extern SYSTEM_BASIC_INFORMATION BaseCachedSysInfo;
160
161 extern BOOLEAN BaseRunningInServerProcess;
162
163 /* FUNCTION PROTOTYPES *******************************************************/
164
165 VOID
166 NTAPI
167 BaseDllInitializeMemoryManager(VOID);
168
169 PTEB GetTeb(VOID);
170
171 PWCHAR FilenameA2W(LPCSTR NameA, BOOL alloc);
172 DWORD FilenameW2A_N(LPSTR dest, INT destlen, LPCWSTR src, INT srclen);
173
174 DWORD FilenameW2A_FitOrFail(LPSTR DestA, INT destLen, LPCWSTR SourceW, INT sourceLen);
175 DWORD FilenameU2A_FitOrFail(LPSTR DestA, INT destLen, PUNICODE_STRING SourceU);
176
177 #define HeapAlloc RtlAllocateHeap
178 #define HeapReAlloc RtlReAllocateHeap
179 #define HeapFree RtlFreeHeap
180 #define _lread(a, b, c) (long)(_hread(a, b, (long)c))
181
182 PLARGE_INTEGER
183 WINAPI
184 BaseFormatTimeOut(OUT PLARGE_INTEGER Timeout,
185 IN DWORD dwMilliseconds);
186
187 POBJECT_ATTRIBUTES
188 WINAPI
189 BaseFormatObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes,
190 IN PSECURITY_ATTRIBUTES SecurityAttributes OPTIONAL,
191 IN PUNICODE_STRING ObjectName);
192
193 NTSTATUS
194 WINAPI
195 BaseCreateStack(HANDLE hProcess,
196 SIZE_T StackReserve,
197 SIZE_T StackCommit,
198 PINITIAL_TEB InitialTeb);
199
200 VOID
201 WINAPI
202 BaseInitializeContext(IN PCONTEXT Context,
203 IN PVOID Parameter,
204 IN PVOID StartAddress,
205 IN PVOID StackAddress,
206 IN ULONG ContextType);
207
208 VOID
209 WINAPI
210 BaseThreadStartupThunk(VOID);
211
212 VOID
213 WINAPI
214 BaseProcessStartThunk(VOID);
215
216 VOID
217 NTAPI
218 BasepFreeActivationContextActivationBlock(
219 IN PBASEP_ACTCTX_BLOCK ActivationBlock
220 );
221
222 NTSTATUS
223 NTAPI
224 BasepAllocateActivationContextActivationBlock(
225 IN DWORD Flags,
226 IN PVOID CompletionRoutine,
227 IN PVOID CompletionContext,
228 OUT PBASEP_ACTCTX_BLOCK *ActivationBlock
229 );
230
231 __declspec(noreturn)
232 VOID
233 WINAPI
234 BaseThreadStartup(LPTHREAD_START_ROUTINE lpStartAddress,
235 LPVOID lpParameter);
236
237 VOID
238 WINAPI
239 BaseFreeThreadStack(IN HANDLE hProcess,
240 IN PINITIAL_TEB InitialTeb);
241
242 __declspec(noreturn)
243 VOID
244 WINAPI
245 BaseFiberStartup(VOID);
246
247 typedef UINT (WINAPI *PPROCESS_START_ROUTINE)(VOID);
248
249 VOID
250 WINAPI
251 BaseProcessStartup(PPROCESS_START_ROUTINE lpStartAddress);
252
253 PVOID
254 WINAPI
255 BasepIsRealtimeAllowed(IN BOOLEAN Keep);
256
257 VOID
258 WINAPI
259 BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString,
260 OUT LPWSTR* UnicodeString);
261
262 PUNICODE_STRING
263 WINAPI
264 Basep8BitStringToStaticUnicodeString(IN LPCSTR AnsiString);
265
266 BOOLEAN
267 WINAPI
268 Basep8BitStringToDynamicUnicodeString(OUT PUNICODE_STRING UnicodeString,
269 IN LPCSTR String);
270
271 typedef NTSTATUS (NTAPI *PRTL_CONVERT_STRING)(IN PUNICODE_STRING UnicodeString,
272 IN PANSI_STRING AnsiString,
273 IN BOOLEAN AllocateMemory);
274
275 typedef ULONG (NTAPI *PRTL_COUNT_STRING)(IN PUNICODE_STRING UnicodeString);
276
277 typedef NTSTATUS (NTAPI *PRTL_CONVERT_STRINGA)(IN PANSI_STRING AnsiString,
278 IN PCUNICODE_STRING UnicodeString,
279 IN BOOLEAN AllocateMemory);
280
281 typedef ULONG (NTAPI *PRTL_COUNT_STRINGA)(IN PANSI_STRING UnicodeString);
282
283 ULONG
284 NTAPI
285 BasepUnicodeStringToAnsiSize(IN PUNICODE_STRING String);
286
287 ULONG
288 NTAPI
289 BasepAnsiStringToUnicodeSize(IN PANSI_STRING String);
290
291 extern PRTL_CONVERT_STRING Basep8BitStringToUnicodeString;
292 extern PRTL_CONVERT_STRINGA BasepUnicodeStringTo8BitString;
293 extern PRTL_COUNT_STRING BasepUnicodeStringTo8BitSize;
294 extern PRTL_COUNT_STRINGA Basep8BitStringToUnicodeSize;
295
296 extern UNICODE_STRING BaseWindowsDirectory, BaseWindowsSystemDirectory;
297 extern HANDLE BaseNamedObjectDirectory;
298
299 HANDLE
300 WINAPI
301 BaseGetNamedObjectDirectory(VOID);
302
303 NTSTATUS
304 WINAPI
305 BasepMapFile(IN LPCWSTR lpApplicationName,
306 OUT PHANDLE hSection,
307 IN PUNICODE_STRING ApplicationName);
308
309 PCODEPAGE_ENTRY FASTCALL
310 IntGetCodePageEntry(UINT CodePage);
311
312 LPWSTR
313 WINAPI
314 BaseComputeProcessDllPath(
315 IN LPWSTR FullPath,
316 IN PVOID Environment
317 );
318
319 LPWSTR
320 WINAPI
321 BaseComputeProcessExePath(
322 IN LPWSTR FullPath
323 );
324
325 ULONG
326 WINAPI
327 BaseIsDosApplication(
328 IN PUNICODE_STRING PathName,
329 IN NTSTATUS Status
330 );
331
332 NTSTATUS
333 WINAPI
334 BasepCheckBadapp(
335 IN HANDLE FileHandle,
336 IN PWCHAR ApplicationName,
337 IN PWCHAR Environment,
338 IN USHORT ExeType,
339 IN PVOID* SdbQueryAppCompatData,
340 IN PULONG SdbQueryAppCompatDataSize,
341 IN PVOID* SxsData,
342 IN PULONG SxsDataSize,
343 OUT PULONG FusionFlags
344 );
345
346 BOOLEAN
347 WINAPI
348 IsShimInfrastructureDisabled(
349 VOID
350 );
351
352 VOID
353 WINAPI
354 InitCommandLines(VOID);
355
356 DWORD
357 WINAPI
358 BaseSetLastNTError(IN NTSTATUS Status);
359
360 /* FIXME */
361 WCHAR WINAPI RtlAnsiCharToUnicodeChar(LPSTR *);
362
363 VOID
364 NTAPI
365 BasepLocateExeLdrEntry(IN PLDR_DATA_TABLE_ENTRY Entry,
366 IN PVOID Context,
367 OUT BOOLEAN *StopEnumeration);
368
369 typedef NTSTATUS
370 (NTAPI *PBASEP_APPCERT_PLUGIN_FUNC)(
371 IN LPWSTR ApplicationName,
372 IN ULONG CertFlag
373 );
374
375 typedef NTSTATUS
376 (NTAPI *PBASEP_APPCERT_EMBEDDED_FUNC)(
377 IN LPWSTR ApplicationName
378 );
379
380 typedef NTSTATUS
381 (NTAPI *PSAFER_REPLACE_PROCESS_THREAD_TOKENS)(
382 IN HANDLE Token,
383 IN HANDLE Process,
384 IN HANDLE Thread
385 );
386
387 typedef struct _BASEP_APPCERT_ENTRY
388 {
389 LIST_ENTRY Entry;
390 UNICODE_STRING Name;
391 PBASEP_APPCERT_PLUGIN_FUNC fPluginCertFunc;
392 } BASEP_APPCERT_ENTRY, *PBASEP_APPCERT_ENTRY;
393
394 typedef struct _BASE_MSG_SXS_HANDLES
395 {
396 HANDLE File;
397 HANDLE Process;
398 HANDLE Section;
399 LARGE_INTEGER ViewBase;
400 } BASE_MSG_SXS_HANDLES, *PBASE_MSG_SXS_HANDLES;
401
402 typedef struct _SXS_WIN32_NT_PATH_PAIR
403 {
404 PUNICODE_STRING Win32;
405 PUNICODE_STRING Nt;
406 } SXS_WIN32_NT_PATH_PAIR, *PSXS_WIN32_NT_PATH_PAIR;
407
408 typedef struct _SXS_OVERRIDE_MANIFEST
409 {
410 PCWCH Name;
411 PVOID Address;
412 ULONG Size;
413 } SXS_OVERRIDE_MANIFEST, *PSXS_OVERRIDE_MANIFEST;
414
415 NTSTATUS
416 NTAPI
417 BasepConfigureAppCertDlls(
418 IN PWSTR ValueName,
419 IN ULONG ValueType,
420 IN PVOID ValueData,
421 IN ULONG ValueLength,
422 IN PVOID Context,
423 IN PVOID EntryContext
424 );
425
426 extern LIST_ENTRY BasepAppCertDllsList;
427 extern RTL_CRITICAL_SECTION gcsAppCert;
428
429 VOID
430 WINAPI
431 BaseMarkFileForDelete(
432 IN HANDLE FileHandle,
433 IN ULONG FileAttributes
434 );
435
436 BOOL
437 BasepCopyFileExW(
438 IN LPCWSTR lpExistingFileName,
439 IN LPCWSTR lpNewFileName,
440 IN LPPROGRESS_ROUTINE lpProgressRoutine OPTIONAL,
441 IN LPVOID lpData OPTIONAL,
442 IN LPBOOL pbCancel OPTIONAL,
443 IN DWORD dwCopyFlags,
444 IN DWORD dwBasepFlags,
445 OUT LPHANDLE lpExistingHandle,
446 OUT LPHANDLE lpNewHandle
447 );
448
449 /* FIXME: This is EXPORTED! It should go in an external kernel32.h header */
450 VOID
451 WINAPI
452 BasepFreeAppCompatData(
453 IN PVOID AppCompatData,
454 IN PVOID AppCompatSxsData
455 );
456
457 NTSTATUS
458 WINAPI
459 BasepCheckWinSaferRestrictions(
460 IN HANDLE UserToken,
461 IN LPWSTR ApplicationName,
462 IN HANDLE FileHandle,
463 OUT PBOOLEAN InJob,
464 OUT PHANDLE NewToken,
465 OUT PHANDLE JobHandle
466 );