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