1 /* TEB/PEB parameters */
2 #ifndef __INCLUDE_INTERNAL_TEB
3 #define __INCLUDE_INTERNAL_TEB
5 #include <napi/types.h>
9 #endif /* !__USE_W32API */
13 typedef struct _CLIENT_ID
17 } CLIENT_ID, *PCLIENT_ID;
19 typedef struct _RTL_USER_PROCESS_PARAMETERS {
29 UNICODE_STRING CurrentDirectoryName;
30 HANDLE CurrentDirectoryHandle;
31 UNICODE_STRING DllPath;
32 UNICODE_STRING ImagePathName;
33 UNICODE_STRING CommandLine;
41 ULONG dwFillAttribute;
44 UNICODE_STRING WindowTitle;
45 UNICODE_STRING DesktopInfo;
46 UNICODE_STRING ShellInfo;
47 UNICODE_STRING RuntimeInfo;
48 } RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;
50 typedef struct _NT_TIB {
51 struct _EXCEPTION_REGISTRATION_RECORD* ExceptionList; // 00h
52 PVOID StackBase; // 04h
53 PVOID StackLimit; // 08h
54 PVOID SubSystemTib; // 0Ch
56 PVOID FiberData; // 10h
59 PVOID ArbitraryUserPointer; // 14h
60 struct _NT_TIB *Self; // 18h
63 #endif /* !__USE_W32API */
65 typedef struct _CURDIR
67 UNICODE_STRING DosPath;
71 typedef struct RTL_DRIVE_LETTER_CURDIR
76 UNICODE_STRING DosPath;
77 } RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR;
79 typedef struct _PEB_FREE_BLOCK
81 struct _PEB_FREE_BLOCK* Next;
83 } PEB_FREE_BLOCK, *PPEB_FREE_BLOCK;
85 /* RTL_USER_PROCESS_PARAMETERS.Flags */
86 #define PPF_NORMALIZED (1)
88 #define PEB_BASE (0x7FFDF000)
90 typedef struct _PEB_LDR_DATA
95 LIST_ENTRY InLoadOrderModuleList;
96 LIST_ENTRY InMemoryOrderModuleList;
97 LIST_ENTRY InInitializationOrderModuleList;
98 } PEB_LDR_DATA, *PPEB_LDR_DATA;
100 typedef VOID STDCALL_FUNC (*PPEBLOCKROUTINE)(PVOID);
104 UCHAR InheritedAddressSpace; // 00h
105 UCHAR ReadImageFileExecOptions; // 01h
106 UCHAR BeingDebugged; // 02h
109 PVOID ImageBaseAddress; // 08h
110 PPEB_LDR_DATA Ldr; // 0Ch
111 PRTL_USER_PROCESS_PARAMETERS ProcessParameters; // 10h
112 PVOID SubSystemData; // 14h
113 PVOID ProcessHeap; // 18h
114 PVOID FastPebLock; // 1Ch
115 PPEBLOCKROUTINE FastPebLockRoutine; // 20h
116 PPEBLOCKROUTINE FastPebUnlockRoutine; // 24h
117 ULONG EnvironmentUpdateCount; // 28h
118 PVOID* KernelCallbackTable; // 2Ch
119 PVOID EventLogSection; // 30h
120 PVOID EventLog; // 34h
121 PPEB_FREE_BLOCK FreeList; // 38h
122 ULONG TlsExpansionCounter; // 3Ch
123 PVOID TlsBitmap; // 40h
124 ULONG TlsBitmapBits[0x2]; // 44h
125 PVOID ReadOnlySharedMemoryBase; // 4Ch
126 PVOID ReadOnlySharedMemoryHeap; // 50h
127 PVOID* ReadOnlyStaticServerData; // 54h
128 PVOID AnsiCodePageData; // 58h
129 PVOID OemCodePageData; // 5Ch
130 PVOID UnicodeCaseTableData; // 60h
131 ULONG NumberOfProcessors; // 64h
132 ULONG NtGlobalFlag; // 68h
133 UCHAR Spare2[0x4]; // 6Ch
134 LARGE_INTEGER CriticalSectionTimeout; // 70h
135 ULONG HeapSegmentReserve; // 78h
136 ULONG HeapSegmentCommit; // 7Ch
137 ULONG HeapDeCommitTotalFreeThreshold; // 80h
138 ULONG HeapDeCommitFreeBlockThreshold; // 84h
139 ULONG NumberOfHeaps; // 88h
140 ULONG MaximumNumberOfHeaps; // 8Ch
141 PVOID** ProcessHeaps; // 90h
142 PVOID GdiSharedHandleTable; // 94h
143 PVOID ProcessStarterHelper; // 98h
144 PVOID GdiDCAttributeList; // 9Ch
145 PVOID LoaderLock; // A0h
146 ULONG OSMajorVersion; // A4h
147 ULONG OSMinorVersion; // A8h
148 USHORT OSBuildNumber; // ACh
149 UCHAR SPMajorVersion; // AEh
150 UCHAR SPMinorVersion; // AFh
151 ULONG OSPlatformId; // B0h
152 ULONG ImageSubSystem; // B4h
153 ULONG ImageSubSystemMajorVersion; // B8h
154 ULONG ImageSubSystemMinorVersion; // C0h
155 ULONG GdiHandleBuffer[0x22]; // C4h
162 #endif /* !__USE_W32API */
164 typedef struct _GDI_TEB_BATCH
169 } GDI_TEB_BATCH, *PGDI_TEB_BATCH;
174 PVOID EnvironmentPointer; // 1Ch
175 CLIENT_ID Cid; // 20h
176 PVOID ActiveRpcInfo; // 28h
177 PVOID ThreadLocalStoragePointer; // 2Ch
179 ULONG LastErrorValue; // 34h
180 ULONG CountOfOwnedCriticalSections; // 38h
181 PVOID CsrClientThread; // 3Ch
182 struct _W32THREAD* Win32ThreadInfo; // 40h
183 ULONG Win32ClientInfo[0x1F]; // 44h
184 PVOID WOW32Reserved; // C0h
185 ULONG CurrentLocale; // C4h
186 ULONG FpSoftwareStatusRegister; // C8h
187 PVOID SystemReserved1[0x36]; // CCh
188 PVOID Spare1; // 1A4h
189 LONG ExceptionCode; // 1A8h
190 UCHAR SpareBytes1[0x28]; // 1ACh
191 PVOID SystemReserved2[0xA]; // 1D4h
192 GDI_TEB_BATCH GdiTebBatch; // 1FCh
193 ULONG gdiRgn; // 6DCh
194 ULONG gdiPen; // 6E0h
195 ULONG gdiBrush; // 6E4h
196 CLIENT_ID RealClientId; // 6E8h
197 PVOID GdiCachedProcessHandle; // 6F0h
198 ULONG GdiClientPID; // 6F4h
199 ULONG GdiClientTID; // 6F8h
200 PVOID GdiThreadLocaleInfo; // 6FCh
201 PVOID UserReserved[5]; // 700h
202 PVOID glDispatchTable[0x118]; // 714h
203 ULONG glReserved1[0x1A]; // B74h
204 PVOID glReserved2; // BDCh
205 PVOID glSectionInfo; // BE0h
206 PVOID glSection; // BE4h
207 PVOID glTable; // BE8h
208 PVOID glCurrentRC; // BECh
209 PVOID glContext; // BF0h
210 NTSTATUS LastStatusValue; // BF4h
211 UNICODE_STRING StaticUnicodeString; // BF8h
212 WCHAR StaticUnicodeBuffer[0x105]; // C00h
213 PVOID DeallocationStack; // E0Ch
214 PVOID TlsSlots[0x40]; // E10h
215 LIST_ENTRY TlsLinks; // F10h
217 PVOID ReservedForNtRpc; // F1Ch
218 PVOID DbgSsReserved[0x2]; // F20h
219 ULONG HardErrorDisabled; // F28h
220 PVOID Instrumentation[0x10]; // F2Ch
221 PVOID WinSockData; // F6Ch
222 ULONG GdiBatchCount; // F70h
223 ULONG Spare2; // F74h // NOTE: RtlExitUserThread writes something here
224 ULONG Spare3; // F78h
225 ULONG Spare4; // F7Ch
226 PVOID ReservedForOle; // F80h
227 ULONG WaitingOnLoaderLock; // F84h
228 PVOID WineDebugInfo; // Needed for WINE DLL's
231 /* FIXME: at least NtCurrentTeb should be defined in winnt.h */
236 /* on the x86, the TEB is contained in the FS segment */
238 FIXME: GCC should allow defining a variable that directly maps to a register.
239 It could make for even faster code
241 static inline struct _TEB * NtCurrentTeb(void)
245 /* FIXME: instead of hardcoded offsets, use offsetof() - if possible */
248 "movl %%fs:0x18, %0\n" /* fs:18h == Teb->Tib.Self */
249 : "=r" (pTeb) /* can't have two memory operands */
255 #define NtCurrentTeb NtCurrentTeb
257 #elif defined(_M_ALPHA)
259 void * __rdteb(void);
260 #pragma intrinsic(__rdteb)
262 /* on the Alpha AXP, we call the rdteb PAL to retrieve the address of the TEB */
263 #define NtCurrentTeb() ((struct _TEB *)__rdteb())
265 #elif defined(_M_MIPS)
267 /* on the MIPS R4000, the TEB is loaded at a fixed address */
268 #define NtCurrentTeb() ((struct _TEB *)0x7FFFF4A8)
270 #elif defined(_M_PPC)
272 unsigned __gregister_get(unsigned const regnum);
273 #pragma intrinsic(__gregister_get)
275 /* on the PowerPC, the TEB is pointed to by GPR 13 */
276 #define NtCurrentTeb() ((struct _TEB *)__gregister_get(13))
279 #error Unsupported architecture or no architecture specified.
286 static inline struct _PEB * NtCurrentPeb(void)
292 "movl %%fs:0x30, %0\n" /* fs:30h == Teb->Peb */
293 : "=r" (pPeb) /* can't have two memory operands */
301 /* generic NtCurrentPeb() */
302 #define NtCurrentPeb() (NtCurrentTeb()->Peb)
305 #endif /* __INCLUDE_INTERNAL_TEB */