[KERNEL32]
[reactos.git] / 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 #ifndef FIELD_OFFSET
65 #define FIELD_OFFSET(type,fld) ((LONG)&(((type *)0)->fld))
66 #endif
67
68 #define __TRY _SEH2_TRY
69 #define __EXCEPT_PAGE_FAULT _SEH2_EXCEPT(_SEH2_GetExceptionCode() == STATUS_ACCESS_VIOLATION)
70 #define __ENDTRY _SEH2_END
71
72 /* Undocumented CreateProcess flag */
73 #define STARTF_SHELLPRIVATE 0x400
74
75 typedef struct _CODEPAGE_ENTRY
76 {
77 LIST_ENTRY Entry;
78 UINT CodePage;
79 HANDLE SectionHandle;
80 PBYTE SectionMapping;
81 CPTABLEINFO CodePageTable;
82 } CODEPAGE_ENTRY, *PCODEPAGE_ENTRY;
83
84 typedef struct tagLOADPARMS32
85 {
86 LPSTR lpEnvAddress;
87 LPSTR lpCmdLine;
88 WORD wMagicValue;
89 WORD wCmdShow;
90 DWORD dwReserved;
91 } LOADPARMS32;
92
93 typedef enum _BASE_SEARCH_PATH_TYPE
94 {
95 BaseSearchPathInvalid,
96 BaseSearchPathDll,
97 BaseSearchPathApp,
98 BaseSearchPathDefault,
99 BaseSearchPathEnv,
100 BaseSearchPathCurrent,
101 BaseSearchPathMax
102 } BASE_SEARCH_PATH_TYPE, *PBASE_SEARCH_PATH_TYPE;
103
104 typedef enum _BASE_CURRENT_DIR_PLACEMENT
105 {
106 BaseCurrentDirPlacementInvalid = -1,
107 BaseCurrentDirPlacementDefault,
108 BaseCurrentDirPlacementSafe,
109 BaseCurrentDirPlacementMax
110 } BASE_CURRENT_DIR_PLACEMENT;
111
112 typedef struct _BASEP_ACTCTX_BLOCK
113 {
114 ULONG Flags;
115 PVOID ActivationContext;
116 PVOID CompletionContext;
117 LPOVERLAPPED_COMPLETION_ROUTINE CompletionRoutine;
118 } BASEP_ACTCTX_BLOCK, *PBASEP_ACTCTX_BLOCK;
119
120 #define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_ERROR 1
121 #define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_SUCCESS 2
122 #define BASEP_GET_MODULE_HANDLE_EX_PARAMETER_VALIDATION_CONTINUE 3
123
124 extern PBASE_STATIC_SERVER_DATA BaseStaticServerData;
125
126 typedef
127 DWORD
128 (*WaitForInputIdleType)(
129 HANDLE hProcess,
130 DWORD dwMilliseconds);
131
132 extern WaitForInputIdleType UserWaitForInputIdleRoutine;
133
134 /* GLOBAL VARIABLES **********************************************************/
135
136 extern BOOL bIsFileApiAnsi;
137 extern HMODULE hCurrentModule;
138
139 extern RTL_CRITICAL_SECTION BaseDllDirectoryLock;
140
141 extern UNICODE_STRING BaseDllDirectory;
142 extern UNICODE_STRING BaseDefaultPath;
143 extern UNICODE_STRING BaseDefaultPathAppend;
144 extern PLDR_DATA_TABLE_ENTRY BasepExeLdrEntry;
145
146 extern LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter;
147
148 extern SYSTEM_BASIC_INFORMATION BaseCachedSysInfo;
149
150 extern BOOLEAN BaseRunningInServerProcess;
151
152 /* FUNCTION PROTOTYPES *******************************************************/
153
154 VOID
155 NTAPI
156 BaseDllInitializeMemoryManager(VOID);
157
158 PTEB GetTeb(VOID);
159
160 PWCHAR FilenameA2W(LPCSTR NameA, BOOL alloc);
161 DWORD FilenameW2A_N(LPSTR dest, INT destlen, LPCWSTR src, INT srclen);
162
163 DWORD FilenameW2A_FitOrFail(LPSTR DestA, INT destLen, LPCWSTR SourceW, INT sourceLen);
164 DWORD FilenameU2A_FitOrFail(LPSTR DestA, INT destLen, PUNICODE_STRING SourceU);
165
166 #define HeapAlloc RtlAllocateHeap
167 #define HeapReAlloc RtlReAllocateHeap
168 #define HeapFree RtlFreeHeap
169 #define _lread(a, b, c) (long)(_hread(a, b, (long)c))
170
171 PLARGE_INTEGER
172 WINAPI
173 BaseFormatTimeOut(OUT PLARGE_INTEGER Timeout,
174 IN DWORD dwMilliseconds);
175
176 POBJECT_ATTRIBUTES
177 WINAPI
178 BaseFormatObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes,
179 IN PSECURITY_ATTRIBUTES SecurityAttributes OPTIONAL,
180 IN PUNICODE_STRING ObjectName);
181
182 NTSTATUS
183 WINAPI
184 BaseCreateStack(HANDLE hProcess,
185 SIZE_T StackReserve,
186 SIZE_T StackCommit,
187 PINITIAL_TEB InitialTeb);
188
189 VOID
190 WINAPI
191 BaseInitializeContext(IN PCONTEXT Context,
192 IN PVOID Parameter,
193 IN PVOID StartAddress,
194 IN PVOID StackAddress,
195 IN ULONG ContextType);
196
197 VOID
198 WINAPI
199 BaseThreadStartupThunk(VOID);
200
201 VOID
202 WINAPI
203 BaseProcessStartThunk(VOID);
204
205 VOID
206 NTAPI
207 BasepFreeActivationContextActivationBlock(
208 IN PBASEP_ACTCTX_BLOCK ActivationBlock
209 );
210
211 NTSTATUS
212 NTAPI
213 BasepAllocateActivationContextActivationBlock(
214 IN DWORD Flags,
215 IN PVOID CompletionRoutine,
216 IN PVOID CompletionContext,
217 OUT PBASEP_ACTCTX_BLOCK *ActivationBlock
218 );
219
220 __declspec(noreturn)
221 VOID
222 WINAPI
223 BaseThreadStartup(LPTHREAD_START_ROUTINE lpStartAddress,
224 LPVOID lpParameter);
225
226 VOID
227 WINAPI
228 BaseFreeThreadStack(IN HANDLE hProcess,
229 IN PINITIAL_TEB InitialTeb);
230
231 __declspec(noreturn)
232 VOID
233 WINAPI
234 BaseFiberStartup(VOID);
235
236 typedef UINT (WINAPI *PPROCESS_START_ROUTINE)(VOID);
237
238 VOID
239 WINAPI
240 BaseProcessStartup(PPROCESS_START_ROUTINE lpStartAddress);
241
242 PVOID
243 WINAPI
244 BasepIsRealtimeAllowed(IN BOOLEAN Keep);
245
246 VOID
247 WINAPI
248 BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString,
249 OUT LPWSTR* UnicodeString);
250
251 PUNICODE_STRING
252 WINAPI
253 Basep8BitStringToStaticUnicodeString(IN LPCSTR AnsiString);
254
255 BOOLEAN
256 WINAPI
257 Basep8BitStringToDynamicUnicodeString(OUT PUNICODE_STRING UnicodeString,
258 IN LPCSTR String);
259
260 typedef NTSTATUS (NTAPI *PRTL_CONVERT_STRING)(IN PUNICODE_STRING UnicodeString,
261 IN PANSI_STRING AnsiString,
262 IN BOOLEAN AllocateMemory);
263
264 typedef ULONG (NTAPI *PRTL_COUNT_STRING)(IN PUNICODE_STRING UnicodeString);
265
266 typedef NTSTATUS (NTAPI *PRTL_CONVERT_STRINGA)(IN PANSI_STRING AnsiString,
267 IN PCUNICODE_STRING UnicodeString,
268 IN BOOLEAN AllocateMemory);
269
270 typedef ULONG (NTAPI *PRTL_COUNT_STRINGA)(IN PANSI_STRING UnicodeString);
271
272 ULONG
273 NTAPI
274 BasepUnicodeStringToAnsiSize(IN PUNICODE_STRING String);
275
276 ULONG
277 NTAPI
278 BasepAnsiStringToUnicodeSize(IN PANSI_STRING String);
279
280 extern PRTL_CONVERT_STRING Basep8BitStringToUnicodeString;
281 extern PRTL_CONVERT_STRINGA BasepUnicodeStringTo8BitString;
282 extern PRTL_COUNT_STRING BasepUnicodeStringTo8BitSize;
283 extern PRTL_COUNT_STRINGA Basep8BitStringToUnicodeSize;
284
285 extern UNICODE_STRING BaseWindowsDirectory, BaseWindowsSystemDirectory;
286 extern HANDLE BaseNamedObjectDirectory;
287
288 HANDLE
289 WINAPI
290 BaseGetNamedObjectDirectory(VOID);
291
292 NTSTATUS
293 WINAPI
294 BasepMapFile(IN LPCWSTR lpApplicationName,
295 OUT PHANDLE hSection,
296 IN PUNICODE_STRING ApplicationName);
297
298 PCODEPAGE_ENTRY FASTCALL
299 IntGetCodePageEntry(UINT CodePage);
300
301 LPWSTR
302 WINAPI
303 BaseComputeProcessDllPath(
304 IN LPWSTR FullPath,
305 IN PVOID Environment
306 );
307
308 LPWSTR
309 WINAPI
310 BaseComputeProcessExePath(
311 IN LPWSTR FullPath
312 );
313
314 ULONG
315 WINAPI
316 BaseIsDosApplication(
317 IN PUNICODE_STRING PathName,
318 IN NTSTATUS Status
319 );
320
321 NTSTATUS
322 WINAPI
323 BasepCheckBadapp(
324 IN HANDLE FileHandle,
325 IN PWCHAR ApplicationName,
326 IN PWCHAR Environment,
327 IN USHORT ExeType,
328 IN PVOID* SdbQueryAppCompatData,
329 IN PULONG SdbQueryAppCompatDataSize,
330 IN PVOID* SxsData,
331 IN PULONG SxsDataSize,
332 OUT PULONG FusionFlags
333 );
334
335 BOOLEAN
336 WINAPI
337 IsShimInfrastructureDisabled(
338 VOID
339 );
340
341 VOID
342 WINAPI
343 InitCommandLines(VOID);
344
345 VOID
346 WINAPI
347 BaseSetLastNTError(IN NTSTATUS Status);
348
349 /* FIXME */
350 WCHAR WINAPI RtlAnsiCharToUnicodeChar(LPSTR *);
351
352 VOID
353 NTAPI
354 BasepLocateExeLdrEntry(IN PLDR_DATA_TABLE_ENTRY Entry,
355 IN PVOID Context,
356 OUT BOOLEAN *StopEnumeration);
357
358 typedef NTSTATUS
359 (NTAPI *PBASEP_APPCERT_PLUGIN_FUNC)(
360 IN LPWSTR ApplicationName,
361 IN ULONG CertFlag
362 );
363
364 typedef NTSTATUS
365 (NTAPI *PBASEP_APPCERT_EMBEDDED_FUNC)(
366 IN LPWSTR ApplicationName
367 );
368
369 typedef NTSTATUS
370 (NTAPI *PSAFER_REPLACE_PROCESS_THREAD_TOKENS)(
371 IN HANDLE Token,
372 IN HANDLE Process,
373 IN HANDLE Thread
374 );
375
376 typedef struct _BASEP_APPCERT_ENTRY
377 {
378 LIST_ENTRY Entry;
379 UNICODE_STRING Name;
380 PBASEP_APPCERT_PLUGIN_FUNC fPluginCertFunc;
381 } BASEP_APPCERT_ENTRY, *PBASEP_APPCERT_ENTRY;
382
383 typedef struct _BASE_MSG_SXS_HANDLES
384 {
385 HANDLE File;
386 HANDLE Process;
387 HANDLE Section;
388 LARGE_INTEGER ViewBase;
389 } BASE_MSG_SXS_HANDLES, *PBASE_MSG_SXS_HANDLES;
390
391 typedef struct _SXS_WIN32_NT_PATH_PAIR
392 {
393 PUNICODE_STRING Win32;
394 PUNICODE_STRING Nt;
395 } SXS_WIN32_NT_PATH_PAIR, *PSXS_WIN32_NT_PATH_PAIR;
396
397 typedef struct _SXS_OVERRIDE_MANIFEST
398 {
399 PCWCH Name;
400 PVOID Address;
401 ULONG Size;
402 } SXS_OVERRIDE_MANIFEST, *PSXS_OVERRIDE_MANIFEST;
403
404 NTSTATUS
405 NTAPI
406 BasepConfigureAppCertDlls(
407 IN PWSTR ValueName,
408 IN ULONG ValueType,
409 IN PVOID ValueData,
410 IN ULONG ValueLength,
411 IN PVOID Context,
412 IN PVOID EntryContext
413 );
414
415 extern LIST_ENTRY BasepAppCertDllsList;
416 extern RTL_CRITICAL_SECTION gcsAppCert;
417
418 VOID
419 WINAPI
420 BaseMarkFileForDelete(
421 IN HANDLE FileHandle,
422 IN ULONG FileAttributes
423 );
424
425
426 /* FIXME: This is EXPORTED! It should go in an external kernel32.h header */
427 VOID
428 WINAPI
429 BasepFreeAppCompatData(
430 IN PVOID AppCompatData,
431 IN PVOID AppCompatSxsData
432 );
433
434 NTSTATUS
435 WINAPI
436 BasepCheckWinSaferRestrictions(
437 IN HANDLE UserToken,
438 IN LPWSTR ApplicationName,
439 IN HANDLE FileHandle,
440 OUT PBOOLEAN InJob,
441 OUT PHANDLE NewToken,
442 OUT PHANDLE JobHandle
443 );