- Revert 49767 on Pierre's request, which reverted this:
[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
12
13 #if DBG
14 #define DEBUG_CHANNEL(ch) static ULONG gDebugChannel = ch;
15 #else
16 #define DEBUG_CHANNEL(ch)
17 #endif
18
19 #define TRACE(fmt, ...) TRACE__(gDebugChannel, fmt, ##__VA_ARGS__)
20 #define WARN(fmt, ...) WARN__(gDebugChannel, fmt, ##__VA_ARGS__)
21 #define FIXME(fmt, ...) WARN__(gDebugChannel, fmt,## __VA_ARGS__)
22 #define ERR(fmt, ...) ERR__(gDebugChannel, fmt, ##__VA_ARGS__)
23
24 #define debugstr_a
25 #define debugstr_w
26 #define wine_dbgstr_w
27 #define debugstr_guid
28
29 #include "wine/unicode.h"
30 #include "baseheap.h"
31
32 #define BINARY_UNKNOWN (0)
33 #define BINARY_PE_EXE32 (1)
34 #define BINARY_PE_DLL32 (2)
35 #define BINARY_PE_EXE64 (3)
36 #define BINARY_PE_DLL64 (4)
37 #define BINARY_WIN16 (5)
38 #define BINARY_OS216 (6)
39 #define BINARY_DOS (7)
40 #define BINARY_UNIX_EXE (8)
41 #define BINARY_UNIX_LIB (9)
42
43 #define MAGIC(c1,c2,c3,c4) ((c1) + ((c2)<<8) + ((c3)<<16) + ((c4)<<24))
44
45 #define MAGIC_HEAP MAGIC( 'H','E','A','P' )
46
47 #define ROUNDUP(a,b) ((((a)+(b)-1)/(b))*(b))
48 #define ROUNDDOWN(a,b) (((a)/(b))*(b))
49
50 #define ROUND_DOWN(n, align) \
51 (((ULONG)n) & ~((align) - 1l))
52
53 #define ROUND_UP(n, align) \
54 ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
55
56 #ifndef FIELD_OFFSET
57 #define FIELD_OFFSET(type,fld) ((LONG)&(((type *)0)->fld))
58 #endif
59
60 #define IsConsoleHandle(h) \
61 (((((ULONG_PTR)h) & 0x10000003) == 0x3) ? TRUE : FALSE)
62
63 #define HANDLE_DETACHED_PROCESS (HANDLE)-2
64 #define HANDLE_CREATE_NEW_CONSOLE (HANDLE)-3
65 #define HANDLE_CREATE_NO_WINDOW (HANDLE)-4
66
67 /* Undocumented CreateProcess flag */
68 #define STARTF_SHELLPRIVATE 0x400
69
70 #define SetLastErrorByStatus(x) RtlSetLastWin32ErrorAndNtStatusFromNtStatus((x))
71 #define GetLastError() NtCurrentTeb()->LastErrorValue
72
73 typedef struct _CODEPAGE_ENTRY
74 {
75 LIST_ENTRY Entry;
76 UINT CodePage;
77 HANDLE SectionHandle;
78 PBYTE SectionMapping;
79 CPTABLEINFO CodePageTable;
80 } CODEPAGE_ENTRY, *PCODEPAGE_ENTRY;
81
82 typedef
83 DWORD
84 (*WaitForInputIdleType)(
85 HANDLE hProcess,
86 DWORD dwMilliseconds);
87
88 /* GLOBAL VARIABLES **********************************************************/
89
90 extern BOOL bIsFileApiAnsi;
91 extern HANDLE hProcessHeap;
92 extern HANDLE hBaseDir;
93 extern HMODULE hCurrentModule;
94
95 extern RTL_CRITICAL_SECTION DllLock;
96
97 extern UNICODE_STRING DllDirectory;
98
99 extern LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter;
100
101 /* FUNCTION PROTOTYPES *******************************************************/
102
103 BOOL WINAPI VerifyConsoleIoHandle(HANDLE Handle);
104
105 BOOL WINAPI CloseConsoleHandle(HANDLE Handle);
106
107 HANDLE WINAPI
108 GetConsoleInputWaitHandle (VOID);
109
110 HANDLE WINAPI OpenConsoleW (LPCWSTR wsName,
111 DWORD dwDesiredAccess,
112 BOOL bInheritHandle,
113 DWORD dwShareMode);
114
115 BOOL WINAPI SetConsoleInputExeNameW(LPCWSTR lpInputExeName);
116
117 PTEB GetTeb(VOID);
118
119 HANDLE FASTCALL TranslateStdHandle(HANDLE hHandle);
120
121 PWCHAR FilenameA2W(LPCSTR NameA, BOOL alloc);
122 DWORD FilenameW2A_N(LPSTR dest, INT destlen, LPCWSTR src, INT srclen);
123
124 DWORD FilenameW2A_FitOrFail(LPSTR DestA, INT destLen, LPCWSTR SourceW, INT sourceLen);
125 DWORD FilenameU2A_FitOrFail(LPSTR DestA, INT destLen, PUNICODE_STRING SourceU);
126
127 #define HeapAlloc RtlAllocateHeap
128 #define HeapReAlloc RtlReAllocateHeap
129 #define HeapFree RtlFreeHeap
130 #define _lread (_readfun)_hread
131
132 POBJECT_ATTRIBUTES
133 WINAPI
134 BasepConvertObjectAttributes(OUT POBJECT_ATTRIBUTES ObjectAttributes,
135 IN PSECURITY_ATTRIBUTES SecurityAttributes OPTIONAL,
136 IN PUNICODE_STRING ObjectName);
137
138 NTSTATUS
139 WINAPI
140 BasepCreateStack(HANDLE hProcess,
141 SIZE_T StackReserve,
142 SIZE_T StackCommit,
143 PINITIAL_TEB InitialTeb);
144
145 VOID
146 WINAPI
147 BasepInitializeContext(IN PCONTEXT Context,
148 IN PVOID Parameter,
149 IN PVOID StartAddress,
150 IN PVOID StackAddress,
151 IN ULONG ContextType);
152
153 VOID
154 WINAPI
155 BaseThreadStartupThunk(VOID);
156
157 VOID
158 WINAPI
159 BaseProcessStartThunk(VOID);
160
161 __declspec(noreturn)
162 VOID
163 WINAPI
164 BaseThreadStartup(LPTHREAD_START_ROUTINE lpStartAddress,
165 LPVOID lpParameter);
166
167 VOID
168 WINAPI
169 BasepFreeStack(HANDLE hProcess,
170 PINITIAL_TEB InitialTeb);
171
172 __declspec(noreturn)
173 VOID
174 WINAPI
175 BaseFiberStartup(VOID);
176
177 typedef UINT (WINAPI *PPROCESS_START_ROUTINE)(VOID);
178
179 VOID
180 WINAPI
181 BaseProcessStartup(PPROCESS_START_ROUTINE lpStartAddress);
182
183 BOOLEAN
184 WINAPI
185 BasepCheckRealTimePrivilege(VOID);
186
187 VOID
188 WINAPI
189 BasepAnsiStringToHeapUnicodeString(IN LPCSTR AnsiString,
190 OUT LPWSTR* UnicodeString);
191
192 PUNICODE_STRING
193 WINAPI
194 Basep8BitStringToStaticUnicodeString(IN LPCSTR AnsiString);
195
196 NTSTATUS
197 WINAPI
198 Basep8BitStringToLiveUnicodeString(OUT PUNICODE_STRING UnicodeString,
199 IN LPCSTR String);
200
201 NTSTATUS
202 WINAPI
203 Basep8BitStringToHeapUnicodeString(OUT PUNICODE_STRING UnicodeString,
204 IN LPCSTR String);
205
206 typedef NTSTATUS (NTAPI *PRTL_CONVERT_STRING)(IN PUNICODE_STRING UnicodeString,
207 IN PANSI_STRING AnsiString,
208 IN BOOLEAN AllocateMemory);
209
210 extern PRTL_CONVERT_STRING Basep8BitStringToUnicodeString;
211
212 NTSTATUS
213 WINAPI
214 BasepMapFile(IN LPCWSTR lpApplicationName,
215 OUT PHANDLE hSection,
216 IN PUNICODE_STRING ApplicationName);
217
218 PCODEPAGE_ENTRY FASTCALL
219 IntGetCodePageEntry(UINT CodePage);
220
221 LPWSTR
222 GetDllLoadPath(LPCWSTR lpModule);
223
224 VOID
225 WINAPI
226 InitCommandLines(VOID);
227
228 VOID
229 WINAPI
230 BaseSetLastNTError(IN NTSTATUS Status);