xref: /reactos/sdk/lib/crt/wine/winternl.h (revision 9efafd64)
1 /*
2  * Internal NT APIs and data structures
3  *
4  * Copyright (C) the Wine project
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #ifndef __WINE_WINTERNL_H
22 #define __WINE_WINTERNL_H
23 
24 #ifndef __REACTOS__
25 #include <ntdef.h>
26 #endif /* __REACTOS__ */
27 #include <windef.h>
28 
29 #include <windef.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* defined(__cplusplus) */
34 
35 #ifndef WINE_NTSTATUS_DECLARED
36 #define WINE_NTSTATUS_DECLARED
37     typedef LONG NTSTATUS;
38 #endif
39 
40 #ifndef __UNICODE_STRING_DEFINED__
41 #define __UNICODE_STRING_DEFINED__
42     typedef struct _UNICODE_STRING {
43         USHORT Length;        /* bytes */
44         USHORT MaximumLength; /* bytes */
45         PWSTR  Buffer;
46     } UNICODE_STRING, * PUNICODE_STRING;
47 #endif
48 
49     typedef struct _CLIENT_ID
50     {
51         HANDLE UniqueProcess;
52         HANDLE UniqueThread;
53     } CLIENT_ID, * PCLIENT_ID;
54 
55     typedef struct _CURDIR
56     {
57         UNICODE_STRING DosPath;
58         PVOID Handle;
59     } CURDIR, * PCURDIR;
60 
61     typedef struct RTL_DRIVE_LETTER_CURDIR
62     {
63         USHORT              Flags;
64         USHORT              Length;
65         ULONG               TimeStamp;
66         UNICODE_STRING      DosPath;
67     } RTL_DRIVE_LETTER_CURDIR, * PRTL_DRIVE_LETTER_CURDIR;
68 
69     typedef struct tagRTL_BITMAP {
70         ULONG  SizeOfBitMap; /* Number of bits in the bitmap */
71         PULONG Buffer; /* Bitmap data, assumed sized to a DWORD boundary */
72     } RTL_BITMAP, * PRTL_BITMAP;
73 
74     typedef const RTL_BITMAP* PCRTL_BITMAP;
75 
76     typedef struct _RTL_USER_PROCESS_PARAMETERS
77     {
78         ULONG               AllocationSize;
79         ULONG               Size;
80         ULONG               Flags;
81         ULONG               DebugFlags;
82         HANDLE              ConsoleHandle;
83         ULONG               ConsoleFlags;
84         HANDLE              hStdInput;
85         HANDLE              hStdOutput;
86         HANDLE              hStdError;
87         CURDIR              CurrentDirectory;
88         UNICODE_STRING      DllPath;
89         UNICODE_STRING      ImagePathName;
90         UNICODE_STRING      CommandLine;
91         PWSTR               Environment;
92         ULONG               dwX;
93         ULONG               dwY;
94         ULONG               dwXSize;
95         ULONG               dwYSize;
96         ULONG               dwXCountChars;
97         ULONG               dwYCountChars;
98         ULONG               dwFillAttribute;
99         ULONG               dwFlags;
100         ULONG               wShowWindow;
101         UNICODE_STRING      WindowTitle;
102         UNICODE_STRING      Desktop;
103         UNICODE_STRING      ShellInfo;
104         UNICODE_STRING      RuntimeInfo;
105         RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20];
106     } RTL_USER_PROCESS_PARAMETERS, * PRTL_USER_PROCESS_PARAMETERS;
107 
108     typedef struct _PEB_LDR_DATA
109     {
110         ULONG               Length;
111         BOOLEAN             Initialized;
112         PVOID               SsHandle;
113         LIST_ENTRY          InLoadOrderModuleList;
114         LIST_ENTRY          InMemoryOrderModuleList;
115         LIST_ENTRY          InInitializationOrderModuleList;
116         PVOID               EntryInProgress;
117     } PEB_LDR_DATA, * PPEB_LDR_DATA;
118 
119     typedef struct _GDI_TEB_BATCH
120     {
121         ULONG  Offset;
122         HANDLE HDC;
123         ULONG  Buffer[0x136];
124     } GDI_TEB_BATCH;
125 
126     typedef struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME
127     {
128         struct _RTL_ACTIVATION_CONTEXT_STACK_FRAME* Previous;
129         struct _ACTIVATION_CONTEXT* ActivationContext;
130         ULONG                                       Flags;
131     } RTL_ACTIVATION_CONTEXT_STACK_FRAME, * PRTL_ACTIVATION_CONTEXT_STACK_FRAME;
132 
133     typedef struct _ACTIVATION_CONTEXT_STACK
134     {
135         ULONG                               Flags;
136         ULONG                               NextCookieSequenceNumber;
137         RTL_ACTIVATION_CONTEXT_STACK_FRAME* ActiveFrame;
138         LIST_ENTRY                          FrameListCache;
139     } ACTIVATION_CONTEXT_STACK, * PACTIVATION_CONTEXT_STACK;
140 
141     typedef struct _TEB_ACTIVE_FRAME_CONTEXT
142     {
143         ULONG       Flags;
144         const char* FrameName;
145     } TEB_ACTIVE_FRAME_CONTEXT, * PTEB_ACTIVE_FRAME_CONTEXT;
146 
147     typedef struct _TEB_ACTIVE_FRAME
148     {
149         ULONG                     Flags;
150         struct _TEB_ACTIVE_FRAME* Previous;
151         TEB_ACTIVE_FRAME_CONTEXT* Context;
152     } TEB_ACTIVE_FRAME, * PTEB_ACTIVE_FRAME;
153 
154     typedef struct _PEB
155     {                                                                 /* win32/win64 */
156         BOOLEAN                      InheritedAddressSpace;             /* 000/000 */
157         BOOLEAN                      ReadImageFileExecOptions;          /* 001/001 */
158         BOOLEAN                      BeingDebugged;                     /* 002/002 */
159         BOOLEAN                      SpareBool;                         /* 003/003 */
160         HANDLE                       Mutant;                            /* 004/008 */
161         HMODULE                      ImageBaseAddress;                  /* 008/010 */
162         PPEB_LDR_DATA                LdrData;                           /* 00c/018 */
163         RTL_USER_PROCESS_PARAMETERS* ProcessParameters;                 /* 010/020 */
164         PVOID                        SubSystemData;                     /* 014/028 */
165         HANDLE                       ProcessHeap;                       /* 018/030 */
166         PRTL_CRITICAL_SECTION        FastPebLock;                       /* 01c/038 */
167         PVOID /*PPEBLOCKROUTINE*/    FastPebLockRoutine;                /* 020/040 */
168         PVOID /*PPEBLOCKROUTINE*/    FastPebUnlockRoutine;              /* 024/048 */
169         ULONG                        EnvironmentUpdateCount;            /* 028/050 */
170         PVOID                        KernelCallbackTable;               /* 02c/058 */
171         ULONG                        Reserved[2];                       /* 030/060 */
172         PVOID /*PPEB_FREE_BLOCK*/    FreeList;                          /* 038/068 */
173         ULONG                        TlsExpansionCounter;               /* 03c/070 */
174         PRTL_BITMAP                  TlsBitmap;                         /* 040/078 */
175         ULONG                        TlsBitmapBits[2];                  /* 044/080 */
176         PVOID                        ReadOnlySharedMemoryBase;          /* 04c/088 */
177         PVOID                        ReadOnlySharedMemoryHeap;          /* 050/090 */
178         PVOID* ReadOnlyStaticServerData;          /* 054/098 */
179         PVOID                        AnsiCodePageData;                  /* 058/0a0 */
180         PVOID                        OemCodePageData;                   /* 05c/0a8 */
181         PVOID                        UnicodeCaseTableData;              /* 060/0b0 */
182         ULONG                        NumberOfProcessors;                /* 064/0b8 */
183         ULONG                        NtGlobalFlag;                      /* 068/0bc */
184         LARGE_INTEGER                CriticalSectionTimeout;            /* 070/0c0 */
185         SIZE_T                       HeapSegmentReserve;                /* 078/0c8 */
186         SIZE_T                       HeapSegmentCommit;                 /* 07c/0d0 */
187         SIZE_T                       HeapDeCommitTotalFreeThreshold;    /* 080/0d8 */
188         SIZE_T                       HeapDeCommitFreeBlockThreshold;    /* 084/0e0 */
189         ULONG                        NumberOfHeaps;                     /* 088/0e8 */
190         ULONG                        MaximumNumberOfHeaps;              /* 08c/0ec */
191         PVOID* ProcessHeaps;                      /* 090/0f0 */
192         PVOID                        GdiSharedHandleTable;              /* 094/0f8 */
193         PVOID                        ProcessStarterHelper;              /* 098/100 */
194         PVOID                        GdiDCAttributeList;                /* 09c/108 */
195         PVOID                        LoaderLock;                        /* 0a0/110 */
196         ULONG                        OSMajorVersion;                    /* 0a4/118 */
197         ULONG                        OSMinorVersion;                    /* 0a8/11c */
198         ULONG                        OSBuildNumber;                     /* 0ac/120 */
199         ULONG                        OSPlatformId;                      /* 0b0/124 */
200         ULONG                        ImageSubSystem;                    /* 0b4/128 */
201         ULONG                        ImageSubSystemMajorVersion;        /* 0b8/12c */
202         ULONG                        ImageSubSystemMinorVersion;        /* 0bc/130 */
203         ULONG                        ImageProcessAffinityMask;          /* 0c0/134 */
204         HANDLE                       GdiHandleBuffer[28];               /* 0c4/138 */
205         ULONG                        unknown[6];                        /* 134/218 */
206         PVOID                        PostProcessInitRoutine;            /* 14c/230 */
207         PRTL_BITMAP                  TlsExpansionBitmap;                /* 150/238 */
208         ULONG                        TlsExpansionBitmapBits[32];        /* 154/240 */
209         ULONG                        SessionId;                         /* 1d4/2c0 */
210         ULARGE_INTEGER               AppCompatFlags;                    /* 1d8/2c8 */
211         ULARGE_INTEGER               AppCompatFlagsUser;                /* 1e0/2d0 */
212         PVOID                        ShimData;                          /* 1e8/2d8 */
213         PVOID                        AppCompatInfo;                     /* 1ec/2e0 */
214         UNICODE_STRING               CSDVersion;                        /* 1f0/2e8 */
215         PVOID                        ActivationContextData;             /* 1f8/2f8 */
216         PVOID                        ProcessAssemblyStorageMap;         /* 1fc/300 */
217         PVOID                        SystemDefaultActivationData;       /* 200/308 */
218         PVOID                        SystemAssemblyStorageMap;          /* 204/310 */
219         SIZE_T                       MinimumStackCommit;                /* 208/318 */
220         PVOID* FlsCallback;                       /* 20c/320 */
221         LIST_ENTRY                   FlsListHead;                       /* 210/328 */
222         PRTL_BITMAP                  FlsBitmap;                         /* 218/338 */
223         ULONG                        FlsBitmapBits[4];                  /* 21c/340 */
224     } PEB, * PPEB;
225 
226     typedef struct _TEB
227     {                                                                 /* win32/win64 */
228         NT_TIB                       Tib;                               /* 000/0000 */
229         PVOID                        EnvironmentPointer;                /* 01c/0038 */
230         CLIENT_ID                    ClientId;                          /* 020/0040 */
231         PVOID                        ActiveRpcHandle;                   /* 028/0050 */
232         PVOID                        ThreadLocalStoragePointer;         /* 02c/0058 */
233         PPEB                         Peb;                               /* 030/0060 */
234         ULONG                        LastErrorValue;                    /* 034/0068 */
235         ULONG                        CountOfOwnedCriticalSections;      /* 038/006c */
236         PVOID                        CsrClientThread;                   /* 03c/0070 */
237         PVOID                        Win32ThreadInfo;                   /* 040/0078 */
238         ULONG                        Win32ClientInfo[31];               /* 044/0080 used for user32 private data in Wine */
239         PVOID                        WOW32Reserved;                     /* 0c0/0100 */
240         ULONG                        CurrentLocale;                     /* 0c4/0108 */
241         ULONG                        FpSoftwareStatusRegister;          /* 0c8/010c */
242         PVOID                        SystemReserved1[54];               /* 0cc/0110 used for kernel32 private data in Wine */
243         LONG                         ExceptionCode;                     /* 1a4/02c0 */
244         ACTIVATION_CONTEXT_STACK     ActivationContextStack;            /* 1a8/02c8 */
245         BYTE                         SpareBytes1[24];                   /* 1bc/02e8 */
246         PVOID                        SystemReserved2[10];               /* 1d4/0300 used for ntdll platform-specific private data in Wine */
247         GDI_TEB_BATCH                GdiTebBatch;                       /* 1fc/0350 used for ntdll private data in Wine */
248         HANDLE                       gdiRgn;                            /* 6dc/0838 */
249         HANDLE                       gdiPen;                            /* 6e0/0840 */
250         HANDLE                       gdiBrush;                          /* 6e4/0848 */
251         CLIENT_ID                    RealClientId;                      /* 6e8/0850 */
252         HANDLE                       GdiCachedProcessHandle;            /* 6f0/0860 */
253         ULONG                        GdiClientPID;                      /* 6f4/0868 */
254         ULONG                        GdiClientTID;                      /* 6f8/086c */
255         PVOID                        GdiThreadLocaleInfo;               /* 6fc/0870 */
256         ULONG                        UserReserved[5];                   /* 700/0878 */
257         PVOID                        glDispatchTable[280];              /* 714/0890 */
258         PVOID                        glReserved1[26];                   /* b74/1150 */
259         PVOID                        glReserved2;                       /* bdc/1220 */
260         PVOID                        glSectionInfo;                     /* be0/1228 */
261         PVOID                        glSection;                         /* be4/1230 */
262         PVOID                        glTable;                           /* be8/1238 */
263         PVOID                        glCurrentRC;                       /* bec/1240 */
264         PVOID                        glContext;                         /* bf0/1248 */
265         ULONG                        LastStatusValue;                   /* bf4/1250 */
266         UNICODE_STRING               StaticUnicodeString;               /* bf8/1258 used by advapi32 */
267         WCHAR                        StaticUnicodeBuffer[261];          /* c00/1268 used by advapi32 */
268         PVOID                        DeallocationStack;                 /* e0c/1478 */
269         PVOID                        TlsSlots[64];                      /* e10/1480 */
270         LIST_ENTRY                   TlsLinks;                          /* f10/1680 */
271         PVOID                        Vdm;                               /* f18/1690 */
272         PVOID                        ReservedForNtRpc;                  /* f1c/1698 */
273         PVOID                        DbgSsReserved[2];                  /* f20/16a0 */
274         ULONG                        HardErrorDisabled;                 /* f28/16b0 */
275         PVOID                        Instrumentation[16];               /* f2c/16b8 */
276         PVOID                        WinSockData;                       /* f6c/1738 */
277         ULONG                        GdiBatchCount;                     /* f70/1740 */
278         ULONG                        Spare2;                            /* f74/1744 */
279         ULONG                        GuaranteedStackBytes;              /* f78/1748 */
280         PVOID                        ReservedForPerf;                   /* f7c/1750 */
281         PVOID                        ReservedForOle;                    /* f80/1758 */
282         ULONG                        WaitingOnLoaderLock;               /* f84/1760 */
283         PVOID                        Reserved5[3];                      /* f88/1768 */
284         PVOID* TlsExpansionSlots;                 /* f94/1780 */
285 #ifdef _WIN64
286         PVOID                        DeallocationBStore;                /*    /1788 */
287         PVOID                        BStoreLimit;                       /*    /1790 */
288 #endif
289         ULONG                        ImpersonationLocale;               /* f98/1798 */
290         ULONG                        IsImpersonating;                   /* f9c/179c */
291         PVOID                        NlsCache;                          /* fa0/17a0 */
292         PVOID                        ShimData;                          /* fa4/17a8 */
293         ULONG                        HeapVirtualAffinity;               /* fa8/17b0 */
294         PVOID                        CurrentTransactionHandle;          /* fac/17b8 */
295         TEB_ACTIVE_FRAME* ActiveFrame;                       /* fb0/17c0 */
296         PVOID* FlsSlots;                          /* fb4/17c8 */
297     } TEB, * PTEB;
298 
299     NTSYSAPI PVOID     WINAPI RtlAllocateHeap(HANDLE, ULONG, SIZE_T) __WINE_ALLOC_SIZE(3);
300     NTSYSAPI BOOLEAN   WINAPI RtlAreBitsSet(PCRTL_BITMAP, ULONG, ULONG);
301     NTSYSAPI BOOLEAN   WINAPI RtlAreBitsClear(PCRTL_BITMAP, ULONG, ULONG);
302     NTSYSAPI BOOLEAN   WINAPI RtlFreeHeap(HANDLE, ULONG, PVOID);
303     NTSYSAPI void      WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG);
304     NTSYSAPI void      WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG);
305 
306 #define ARRAY_SIZE ARRAYSIZE
307 #define MSVCRT_free free
308 #define MSVCRT_malloc malloc
309 //#define MSVCRT_terminate terminate
310 #define MSVCRT__exit exit
311 #define MSVCRT_abort abort
312 
313 #endif  /* __WINE_WINTERNL_H */
314