diff --git a/reactos/dll/ntdll/dbg/dbgui.c b/reactos/dll/ntdll/dbg/dbgui.c index 6bfeaceb818..6cbcd733ffd 100644 --- a/reactos/dll/ntdll/dbg/dbgui.c +++ b/reactos/dll/ntdll/dbg/dbgui.c @@ -259,7 +259,7 @@ DbgUiConvertStateChangeStructure(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange, /* Save the image name from the TIB */ DebugEvent->u.LoadDll.lpImageName = ((PTEB)ThreadBasicInfo.TebBaseAddress)-> - Tib.ArbitraryUserPointer; + NtTib.ArbitraryUserPointer; } else { diff --git a/reactos/dll/ntdll/ldr/utils.c b/reactos/dll/ntdll/ldr/utils.c index 2f22ba5436c..a3a416bebab 100644 --- a/reactos/dll/ntdll/ldr/utils.c +++ b/reactos/dll/ntdll/ldr/utils.c @@ -2210,8 +2210,8 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL, /* Map the dll into the process */ ViewSize = 0; ImageBase = 0; - ArbitraryUserPointer = NtCurrentTeb()->Tib.ArbitraryUserPointer; - NtCurrentTeb()->Tib.ArbitraryUserPointer = FullDosName.Buffer; + ArbitraryUserPointer = NtCurrentTeb()->NtTib.ArbitraryUserPointer; + NtCurrentTeb()->NtTib.ArbitraryUserPointer = FullDosName.Buffer; Status = NtMapViewOfSection(SectionHandle, NtCurrentProcess(), &ImageBase, @@ -2222,7 +2222,7 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL, ViewShare, 0, PAGE_READONLY); - NtCurrentTeb()->Tib.ArbitraryUserPointer = ArbitraryUserPointer; + NtCurrentTeb()->NtTib.ArbitraryUserPointer = ArbitraryUserPointer; if (!NT_SUCCESS(Status)) { DPRINT1("map view of section failed (Status 0x%08lx)\n", Status); diff --git a/reactos/dll/ntdll/rtl/libsupp.c b/reactos/dll/ntdll/rtl/libsupp.c index e9990ff9426..5fdcb68788e 100644 --- a/reactos/dll/ntdll/rtl/libsupp.c +++ b/reactos/dll/ntdll/rtl/libsupp.c @@ -206,8 +206,8 @@ RtlpCaptureStackLimits(IN ULONG_PTR Ebp, IN ULONG_PTR *StackEnd) { /* FIXME: Verify */ - *StackBegin = (ULONG_PTR)NtCurrentTeb()->Tib.StackLimit; - *StackEnd = (ULONG_PTR)NtCurrentTeb()->Tib.StackBase; + *StackBegin = (ULONG_PTR)NtCurrentTeb()->NtTib.StackLimit; + *StackEnd = (ULONG_PTR)NtCurrentTeb()->NtTib.StackBase; return TRUE; } @@ -218,8 +218,8 @@ RtlpGetStackLimits( OUT PULONG_PTR LowLimit, OUT PULONG_PTR HighLimit) { - *LowLimit = (ULONG_PTR)NtCurrentTeb()->Tib.StackLimit; - *HighLimit = (ULONG_PTR)NtCurrentTeb()->Tib.StackBase; + *LowLimit = (ULONG_PTR)NtCurrentTeb()->NtTib.StackLimit; + *HighLimit = (ULONG_PTR)NtCurrentTeb()->NtTib.StackBase; return; } #endif diff --git a/reactos/dll/win32/kernel32/thread/fiber.c b/reactos/dll/win32/kernel32/thread/fiber.c index 3010c8ea07b..1f62d99b22f 100644 --- a/reactos/dll/win32/kernel32/thread/fiber.c +++ b/reactos/dll/win32/kernel32/thread/fiber.c @@ -47,9 +47,9 @@ ConvertFiberToThread(VOID) pTeb->HasFiberData = FALSE; /* free the fiber */ - if(pTeb->Tib.FiberData != NULL) + if(pTeb->NtTib.FiberData != NULL) { - RtlFreeHeap(GetProcessHeap(), 0, pTeb->Tib.FiberData); + RtlFreeHeap(GetProcessHeap(), 0, pTeb->NtTib.FiberData); } /* success */ @@ -69,7 +69,7 @@ ConvertThreadToFiberEx(LPVOID lpParameter, DPRINT1("Converting Thread to Fiber\n"); /* the current thread is already a fiber */ - if(pTeb->HasFiberData && pTeb->Tib.FiberData) return pTeb->Tib.FiberData; + if(pTeb->HasFiberData && pTeb->NtTib.FiberData) return pTeb->NtTib.FiberData; /* allocate the fiber */ pfCurFiber = (PFIBER)RtlAllocateHeap(GetProcessHeap(), @@ -85,9 +85,9 @@ ConvertThreadToFiberEx(LPVOID lpParameter, /* copy some contextual data from the thread to the fiber */ pfCurFiber->Parameter = lpParameter; - pfCurFiber->ExceptionList = pTeb->Tib.ExceptionList; - pfCurFiber->StackBase = pTeb->Tib.StackBase; - pfCurFiber->StackLimit = pTeb->Tib.StackLimit; + pfCurFiber->ExceptionList = pTeb->NtTib.ExceptionList; + pfCurFiber->StackBase = pTeb->NtTib.StackBase; + pfCurFiber->StackLimit = pTeb->NtTib.StackLimit; pfCurFiber->DeallocationStack = pTeb->DeallocationStack; pfCurFiber->FlsData = pTeb->FlsData; pfCurFiber->GuaranteedStackBytes = pTeb->GuaranteedStackBytes; @@ -101,7 +101,7 @@ ConvertThreadToFiberEx(LPVOID lpParameter, } /* associate the fiber to the current thread */ - pTeb->Tib.FiberData = pfCurFiber; + pTeb->NtTib.FiberData = pfCurFiber; pTeb->HasFiberData = TRUE; /* success */ @@ -227,7 +227,7 @@ DeleteFiber(LPVOID lpFiber) RtlFreeHeap(GetProcessHeap(), 0, lpFiber); /* the fiber is deleting itself: let the system deallocate the stack */ - if(NtCurrentTeb()->Tib.FiberData == lpFiber) ExitThread(1); + if(NtCurrentTeb()->NtTib.FiberData == lpFiber) ExitThread(1); /* deallocate the stack */ NtFreeVirtualMemory(NtCurrentProcess(), diff --git a/reactos/include/ndk/peb_teb.h b/reactos/include/ndk/peb_teb.h new file mode 100644 index 00000000000..d6e9d71056e --- /dev/null +++ b/reactos/include/ndk/peb_teb.h @@ -0,0 +1,387 @@ + +#define PASTE2(x,y) x##y +#define PASTE(x,y) PASTE2(x,y) + +#ifdef EXPLICIT_32BIT + #define STRUCT(x) PASTE(x,32) + #define PTR(x) ULONG +#elif defined(EXPLICIT_64BIT) + #define STRUCT(x) PASTE(x,64) + #define PTR(x) ULONG64 +#else + #define STRUCT(x) x + #define PTR(x) x +#endif + +#if defined(_WIN64) && !defined(EXPLICIT_32BIT) + #define GDI_HANDLE_BUFFER_SIZE 60 +#else + #define GDI_HANDLE_BUFFER_SIZE 34 +#endif + +typedef struct STRUCT(_PEB) +{ + BOOLEAN InheritedAddressSpace; + BOOLEAN ReadImageFileExecOptions; + BOOLEAN BeingDebugged; +#if (NTDDI_VERSION >= NTDDI_WS03) + union + { + BOOLEAN BitField; + struct + { + BOOLEAN ImageUsesLargePages:1; +#if (NTDDI_VERSION >= NTDDI_LONGHORN) + BOOLEAN IsProtectedProcess:1; + BOOLEAN IsLegacyProcess:1; + BOOLEAN IsImageDynamicallyRelocated:1; + BOOLEAN SkipPatchingUser32Forwarders:1; + BOOLEAN SpareBits:3; +#else + BOOLEAN SpareBits:7; +#endif + }; + }; +#else + BOOLEAN SpareBool; +#endif + PTR(HANDLE) Mutant; + PTR(PVOID) ImageBaseAddress; + PTR(PPEB_LDR_DATA) Ldr; + PTR(struct _RTL_USER_PROCESS_PARAMETERS*) ProcessParameters; + PTR(PVOID) SubSystemData; + PTR(PVOID) ProcessHeap; + PTR(struct _RTL_CRITICAL_SECTION*) FastPebLock; +#if (NTDDI_VERSION >= NTDDI_LONGHORN) + PTR(PVOID) AltThunkSListPtr; + PTR(PVOID) IFEOKey; + union + { + ULONG CrossProcessFlags; + struct + { + ULONG ProcessInJob:1; + ULONG ProcessInitializing:1; + ULONG ProcessUsingVEH:1; + ULONG ProcessUsingVCH:1; + ULONG ReservedBits0:28; + }; + }; + union + { + PTR(PVOID) KernelCallbackTable; + PTR(PVOID) UserSharedInfoPtr; + }; +#elif (NTDDI_VERSION >= NTDDI_WS03) + PTR(PVOID) AltThunkSListPtr; + PTR(PVOID) SparePtr2; + ULONG EnvironmentUpdateCount; + PTR(PVOID) KernelCallbackTable; +#else + PTR(PPEBLOCKROUTINE) FastPebLockRoutine; + PTR(PPEBLOCKROUTINE) FastPebUnlockRoutine; + ULONG EnvironmentUpdateCount; + PTR(PVOID) KernelCallbackTable; +#endif + ULONG SystemReserved[1]; + ULONG SpareUlong; // AtlThunkSListPtr32 + PTR(PPEB_FREE_BLOCK) FreeList; + ULONG TlsExpansionCounter; + PTR(PVOID) TlsBitmap; + ULONG TlsBitmapBits[2]; + PTR(PVOID) ReadOnlySharedMemoryBase; +#if (NTDDI_VERSION >= NTDDI_LONGHORN) + PTR(PVOID) HotpatchInformation; +#else + PTR(PVOID) ReadOnlySharedMemoryHeap; +#endif + PTR(PVOID*) ReadOnlyStaticServerData; + PTR(PVOID) AnsiCodePageData; + PTR(PVOID) OemCodePageData; + PTR(PVOID) UnicodeCaseTableData; + ULONG NumberOfProcessors; + ULONG NtGlobalFlag; + LARGE_INTEGER CriticalSectionTimeout; + PTR(ULONG_PTR) HeapSegmentReserve; + PTR(ULONG_PTR) HeapSegmentCommit; + PTR(ULONG_PTR) HeapDeCommitTotalFreeThreshold; + PTR(ULONG_PTR) HeapDeCommitFreeBlockThreshold; + ULONG NumberOfHeaps; + ULONG MaximumNumberOfHeaps; + PTR(PVOID*) ProcessHeaps; + PTR(PVOID) GdiSharedHandleTable; + PTR(PVOID) ProcessStarterHelper; + ULONG GdiDCAttributeList; + PTR(struct _RTL_CRITICAL_SECTION*) LoaderLock; + ULONG OSMajorVersion; + ULONG OSMinorVersion; + USHORT OSBuildNumber; + USHORT OSCSDVersion; + ULONG OSPlatformId; + ULONG ImageSubsystem; + ULONG ImageSubsystemMajorVersion; + ULONG ImageSubsystemMinorVersion; + PTR(ULONG_PTR) ImageProcessAffinityMask; + ULONG GdiHandleBuffer[GDI_HANDLE_BUFFER_SIZE]; + PTR(PPOST_PROCESS_INIT_ROUTINE) PostProcessInitRoutine; + PTR(PVOID) TlsExpansionBitmap; + ULONG TlsExpansionBitmapBits[32]; + ULONG SessionId; +#if (NTDDI_VERSION >= NTDDI_WINXP) + ULARGE_INTEGER AppCompatFlags; + ULARGE_INTEGER AppCompatFlagsUser; + PTR(PVOID) pShimData; + PTR(PVOID) AppCompatInfo; + STRUCT(UNICODE_STRING) CSDVersion; + PTR(struct _ACTIVATION_CONTEXT_DATA*) ActivationContextData; + PTR(struct _ASSEMBLY_STORAGE_MAP*) ProcessAssemblyStorageMap; + PTR(struct _ACTIVATION_CONTEXT_DATA*) SystemDefaultActivationContextData; + PTR(struct _ASSEMBLY_STORAGE_MAP*) SystemAssemblyStorageMap; + PTR(ULONG_PTR) MinimumStackCommit; +#endif +#if (NTDDI_VERSION >= NTDDI_WS03) + PTR(PVOID*) FlsCallback; + STRUCT(LIST_ENTRY) FlsListHead; + PTR(PVOID) FlsBitmap; + ULONG FlsBitmapBits[4]; + ULONG FlsHighIndex; +#endif +#if (NTDDI_VERSION >= NTDDI_LONGHORN) + PTR(PVOID) WerRegistrationData; + PTR(PVOID) WerShipAssertPtr; +#endif +} STRUCT(PEB), *STRUCT(PPEB); + + +#if defined(_WIN64) && !defined(EXPLICIT_32BIT) +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), Mutant) == 0x08); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), Ldr) == 0x18); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), FastPebLock) == 0x038); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), TlsExpansionCounter) == 0x070); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), NtGlobalFlag) == 0x0BC); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), GdiSharedHandleTable) == 0x0F8); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), LoaderLock) == 0x110); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), ImageSubsystem) == 0x128); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), ImageProcessAffinityMask) == 0x138); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), PostProcessInitRoutine) == 0x230); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), SessionId) == 0x2C0); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), FlsHighIndex) == 0x350); +#else +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), Mutant) == 0x04); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), Ldr) == 0x0C); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), FastPebLock) == 0x01C); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), TlsExpansionCounter) == 0x03C); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), NtGlobalFlag) == 0x068); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), GdiSharedHandleTable) == 0x094); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), LoaderLock) == 0x0A0); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), ImageSubsystem) == 0x0B4); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), ImageProcessAffinityMask) == 0x0C0); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), PostProcessInitRoutine) == 0x14C); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), SessionId) == 0x1D4); +C_ASSERT(FIELD_OFFSET(STRUCT(PEB), FlsHighIndex) == 0x22C); +#endif + +// +// GDI Batch Descriptor +// +typedef struct STRUCT(_GDI_TEB_BATCH) +{ + ULONG Offset; + PTR(HANDLE) HDC; + ULONG Buffer[0x136]; +} STRUCT(GDI_TEB_BATCH), *STRUCT(PGDI_TEB_BATCH); + +// +// Thread Environment Block (TEB) +// +typedef struct STRUCT(_TEB) +{ + STRUCT(NT_TIB) NtTib; + PTR(PVOID) EnvironmentPointer; + STRUCT(CLIENT_ID) ClientId; + PTR(PVOID) ActiveRpcHandle; + PTR(PVOID) ThreadLocalStoragePointer; + PTR(STRUCT(PPEB)) ProcessEnvironmentBlock; + ULONG LastErrorValue; + ULONG CountOfOwnedCriticalSections; + PTR(PVOID) CsrClientThread; + PTR(PVOID) Win32ThreadInfo; + ULONG User32Reserved[26]; + ULONG UserReserved[5]; + PTR(PVOID) WOW32Reserved; + LCID CurrentLocale; + ULONG FpSoftwareStatusRegister; + PTR(PVOID) SystemReserved1[54]; + LONG ExceptionCode; +#if (NTDDI_VERSION >= NTDDI_LONGHORN) + PTR(struct _ACTIVATION_CONTEXT_STACK*) ActivationContextStackPointer; + UCHAR SpareBytes1[0x30 - 3 * sizeof(PTR(PVOID)]; + ULONG TxFsContext; +#elif (NTDDI_VERSION >= NTDDI_WS03) + PTR(struct _ACTIVATION_CONTEXT_STACK*) ActivationContextStackPointer; + UCHAR SpareBytes1[0x34 - 3 * sizeof(PTR(PVOID))]; +#else + ACTIVATION_CONTEXT_STACK ActivationContextStack; + UCHAR SpareBytes1[24]; +#endif + STRUCT(GDI_TEB_BATCH) GdiTebBatch; + STRUCT(CLIENT_ID) RealClientId; + PTR(PVOID) GdiCachedProcessHandle; + ULONG GdiClientPID; + ULONG GdiClientTID; + PTR(PVOID) GdiThreadLocalInfo; + PTR(SIZE_T) Win32ClientInfo[62]; + PTR(PVOID) glDispatchTable[233]; + PTR(SIZE_T) glReserved1[29]; + PTR(PVOID) glReserved2; + PTR(PVOID) glSectionInfo; + PTR(PVOID) glSection; + PTR(PVOID) glTable; + PTR(PVOID) glCurrentRC; + PTR(PVOID) glContext; + NTSTATUS LastStatusValue; + STRUCT(UNICODE_STRING) StaticUnicodeString; + WCHAR StaticUnicodeBuffer[261]; + PTR(PVOID) DeallocationStack; + PTR(PVOID) TlsSlots[64]; + STRUCT(LIST_ENTRY) TlsLinks; + PTR(PVOID) Vdm; + PTR(PVOID) ReservedForNtRpc; + PTR(PVOID) DbgSsReserved[2]; +#if (NTDDI_VERSION >= NTDDI_WS03) + ULONG HardErrorMode; +#else + ULONG HardErrorsAreDisabled; +#endif +#if (NTDDI_VERSION >= NTDDI_LONGHORN) + PTR(PVOID) Instrumentation[9]; + GUID ActivityId; + PTR(PVOID) SubProcessTag; + PTR(PVOID) EtwLocalData; +#elif (NTDDI_VERSION >= NTDDI_WS03) + PTR(PVOID) Instrumentation[14]; + PTR(PVOID) SubProcessTag; + PTR(PVOID) EtwLocalData; +#else + PTR(PVOID) Instrumentation[16]; +#endif + PTR(PVOID) WinSockData; + ULONG GdiBatchCount; +#if (NTDDI_VERSION >= NTDDI_LONGHORN) + BOOLEAN SpareBool0; + BOOLEAN SpareBool1; + BOOLEAN SpareBool2; +#else + BOOLEAN InDbgPrint; + BOOLEAN FreeStackOnTermination; + BOOLEAN HasFiberData; +#endif + UCHAR IdealProcessor; +#if (NTDDI_VERSION >= NTDDI_WS03) + ULONG GuaranteedStackBytes; +#else + ULONG Spare3; +#endif + PTR(PVOID) ReservedForPerf; + PTR(PVOID) ReservedForOle; + ULONG WaitingOnLoaderLock; +#if (NTDDI_VERSION >= NTDDI_LONGHORN) + PTR(PVOID) SavedPriorityState; + PTR(ULONG_PTR) SoftPatchPtr1; + PTR(ULONG_PTR) ThreadPoolData; +#elif (NTDDI_VERSION >= NTDDI_WS03) + PTR(ULONG_PTR) SparePointer1; + PTR(ULONG_PTR) SoftPatchPtr1; + PTR(ULONG_PTR) SoftPatchPtr2; +#else + Wx86ThreadState Wx86Thread; +#endif + PTR(PVOID*) TlsExpansionSlots; +#if defined(_WIN64) && !defined(EXPLICIT_32BIT) + PTR(PVOID) DeallocationBStore; + PTR(PVOID) BStoreLimit; +#endif + ULONG ImpersonationLocale; + ULONG IsImpersonating; + PTR(PVOID) NlsCache; + PTR(PVOID) pShimData; + ULONG HeapVirtualAffinity; + PTR(HANDLE) CurrentTransactionHandle; + PTR(PTEB_ACTIVE_FRAME) ActiveFrame; +#if (NTDDI_VERSION >= NTDDI_WS03) + PVOID FlsData; +#endif +#if (NTDDI_VERSION >= NTDDI_LONGHORN) + PVOID PreferredLangauges; + PVOID UserPrefLanguages; + PVOID MergedPrefLanguages; + ULONG MuiImpersonation; + union + { + struct + { + USHORT SpareCrossTebFlags:16; + }; + USHORT CrossTebFlags; + }; + union + { + struct + { + USHORT DbgSafeThunkCall:1; + USHORT DbgInDebugPrint:1; + USHORT DbgHasFiberData:1; + USHORT DbgSkipThreadAttach:1; + USHORT DbgWerInShipAssertCode:1; + USHORT DbgIssuedInitialBp:1; + USHORT DbgClonedThread:1; + USHORT SpareSameTebBits:9; + }; + USHORT SameTebFlags; + }; + PTR(PVOID) TxnScopeEntercallback; + PTR(PVOID) TxnScopeExitCAllback; + PTR(PVOID) TxnScopeContext; + ULONG LockCount; + ULONG ProcessRundown; + ULONG64 LastSwitchTime; + ULONG64 TotalSwitchOutTime; + LARGE_INTEGER WaitReasonBitMap; +#else + BOOLEAN SafeThunkCall; + BOOLEAN BooleanSpare[3]; +#endif +} STRUCT(TEB), *STRUCT(PTEB); + +#if defined(_WIN64) && !defined(EXPLICIT_32BIT) +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), EnvironmentPointer) == 0x038); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), ExceptionCode) == 0x2C0); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), GdiTebBatch) == 0x2F0); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), LastStatusValue) == 0x1250); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), Vdm) == 0x1690); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), HardErrorMode) == 0x16B0); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), SubProcessTag) == 0x1728); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), GdiBatchCount) == 0x1740); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), IdealProcessor) == 0x1747); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), WaitingOnLoaderLock) == 0x1760); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), TlsExpansionSlots) == 0x1780); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), WaitingOnLoaderLock) == 0x1760); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), ActiveFrame) == 0x17C0); +#else +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), EnvironmentPointer) == 0x01C); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), ExceptionCode) == 0x1A4); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), GdiTebBatch) == 0x1D4); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), LastStatusValue) == 0xBF4); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), Vdm) == 0xF18); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), HardErrorMode) == 0xF28); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), SubProcessTag) == 0xF64); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), GdiBatchCount) == 0xF70); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), TlsExpansionSlots) == 0xF94); +C_ASSERT(FIELD_OFFSET(STRUCT(TEB), ActiveFrame) == 0xFB0); +#endif + +#undef PTR +#undef STRUCT +#undef PASTE +#undef PASTE2 +#undef GDI_HANDLE_BUFFER_SIZE diff --git a/reactos/include/ndk/pstypes.h b/reactos/include/ndk/pstypes.h index 7f29d12a228..ca5477ca371 100644 --- a/reactos/include/ndk/pstypes.h +++ b/reactos/include/ndk/pstypes.h @@ -616,159 +616,6 @@ typedef struct _INITIAL_PEB HANDLE Mutant; } INITIAL_PEB, *PINITIAL_PEB; -// -// Process Environment Block (PEB) -// -typedef struct _PEB -{ - BOOLEAN InheritedAddressSpace; - BOOLEAN ReadImageFileExecOptions; - BOOLEAN BeingDebugged; -#if (NTDDI_VERSION >= NTDDI_WS03) - union - { - BOOLEAN BitField; - struct - { - UCHAR ImageUsesLargePages:1; -#if (NTDDI_VERSION >= NTDDI_LONGHORN) - BOOLEAN IsProtectedProcess:1; - BOOLEAN IsLegacyProcess:1; - BOOLEAN IsImageDynamicallyRelocated:1; - BOOLEAN SkipPatchingUser32Forwarders:1; - BOOLEAN SpareBits:3; -#else - BOOLEAN SpareBits:7; -#endif - }; - }; -#else - BOOLEAN SpareBool; -#endif - HANDLE Mutant; - PVOID ImageBaseAddress; - PPEB_LDR_DATA Ldr; - struct _RTL_USER_PROCESS_PARAMETERS *ProcessParameters; - PVOID SubSystemData; - PVOID ProcessHeap; -#if (NTDDI_VERSION >= NTDDI_LONGHORN) - struct _RTL_CRITICAL_SECTION *FastPebLock; - PVOID AltThunkSListPtr; - PVOID IFEOKey; - union - { - ULONG CrossProcessFlags; - struct - { - ULONG ProcessInJob:1; - ULONG ProcessInitializing:1; - ULONG ProcessUsingVEH:1; - ULONG ProcessUsingVCH:1; - ULONG ReservedBits0:28; - }; - }; - union - { - PVOID* KernelCallbackTable; - PVOID UserSharedInfoPtr; - }; - ULONG SystemReserved[1]; - ULONG SpareUlong; - ULONG_PTR SparePebPtr0; -#else - PVOID FastPebLock; - PPEBLOCKROUTINE FastPebLockRoutine; - PPEBLOCKROUTINE FastPebUnlockRoutine; - ULONG EnvironmentUpdateCount; - PVOID* KernelCallbackTable; - PVOID EventLogSection; - PVOID EventLog; - PPEB_FREE_BLOCK FreeList; -#endif - ULONG TlsExpansionCounter; - PVOID TlsBitmap; - ULONG TlsBitmapBits[0x2]; - PVOID ReadOnlySharedMemoryBase; -#if (NTDDI_VERSION >= NTDDI_LONGHORN) - PVOID HotpatchInformation; -#else - PVOID ReadOnlySharedMemoryHeap; -#endif - PVOID* ReadOnlyStaticServerData; - PVOID AnsiCodePageData; - PVOID OemCodePageData; - PVOID UnicodeCaseTableData; - ULONG NumberOfProcessors; - ULONG NtGlobalFlag; - LARGE_INTEGER CriticalSectionTimeout; - ULONG_PTR HeapSegmentReserve; - ULONG_PTR HeapSegmentCommit; - ULONG_PTR HeapDeCommitTotalFreeThreshold; - ULONG_PTR HeapDeCommitFreeBlockThreshold; - ULONG NumberOfHeaps; - ULONG MaximumNumberOfHeaps; - PVOID* ProcessHeaps; - PVOID GdiSharedHandleTable; - PVOID ProcessStarterHelper; - ULONG GdiDCAttributeList; -#if (NTDDI_VERSION >= NTDDI_LONGHORN) - struct _RTL_CRITICAL_SECTION *LoaderLock; -#else - PVOID LoaderLock; -#endif - ULONG OSMajorVersion; - ULONG OSMinorVersion; - USHORT OSBuildNumber; - USHORT OSCSDVersion; - ULONG OSPlatformId; - ULONG ImageSubSystem; - ULONG ImageSubSystemMajorVersion; - ULONG ImageSubSystemMinorVersion; - ULONG ImageProcessAffinityMask; -#ifdef _WIN64 - ULONG GdiHandleBuffer[0x3c]; -#else - ULONG GdiHandleBuffer[0x22]; -#endif - PPOST_PROCESS_INIT_ROUTINE PostProcessInitRoutine; - struct _RTL_BITMAP *TlsExpansionBitmap; - ULONG TlsExpansionBitmapBits[0x20]; - ULONG SessionId; -#if (NTDDI_VERSION >= NTDDI_WINXP) - ULARGE_INTEGER AppCompatFlags; - ULARGE_INTEGER AppCompatFlagsUser; - PVOID pShimData; - PVOID AppCompatInfo; - UNICODE_STRING CSDVersion; - struct _ACTIVATION_CONTEXT_DATA *ActivationContextData; - struct _ASSEMBLY_STORAGE_MAP *ProcessAssemblyStorageMap; - struct _ACTIVATION_CONTEXT_DATA *SystemDefaultActivationContextData; - struct _ASSEMBLY_STORAGE_MAP *SystemAssemblyStorageMap; - ULONG_PTR MinimumStackCommit; -#endif -#if (NTDDI_VERSION >= NTDDI_WS03) - PVOID *FlsCallback; - LIST_ENTRY FlsListHead; - struct _RTL_BITMAP *FlsBitmap; - ULONG FlsBitmapBits[4]; - ULONG FlsHighIndex; -#endif -#if (NTDDI_VERSION >= NTDDI_LONGHORN) - PVOID WerRegistrationData; - PVOID WerShipAssertPtr; -#endif -} PEB, *PPEB; - -// -// GDI Batch Descriptor -// -typedef struct _GDI_TEB_BATCH -{ - ULONG Offset; - HANDLE HDC; - ULONG Buffer[0x136]; -} GDI_TEB_BATCH, *PGDI_TEB_BATCH; - // // Initial TEB // @@ -797,146 +644,39 @@ typedef struct _TEB_ACTIVE_FRAME PTEB_ACTIVE_FRAME_CONTEXT Context; } TEB_ACTIVE_FRAME, *PTEB_ACTIVE_FRAME; +typedef struct _CLIENT_ID32 +{ + ULONG UniqueProcess; + ULONG UniqueThread; +} CLIENT_ID32, *PCLIENT_ID32; + +typedef struct _CLIENT_ID64 +{ + ULONG64 UniqueProcess; + ULONG64 UniqueThread; +} CLIENT_ID64, *PCLIENT_ID64; + // +// Process Environment Block (PEB) // Thread Environment Block (TEB) // -typedef struct _TEB -{ - NT_TIB Tib; - PVOID EnvironmentPointer; - CLIENT_ID ClientId; - PVOID ActiveRpcHandle; - PVOID ThreadLocalStoragePointer; - struct _PEB *ProcessEnvironmentBlock; - ULONG LastErrorValue; - ULONG CountOfOwnedCriticalSections; - PVOID CsrClientThread; - struct _W32THREAD* Win32ThreadInfo; - ULONG User32Reserved[0x1A]; - ULONG UserReserved[5]; - PVOID WOW32Reserved; - LCID CurrentLocale; - ULONG FpSoftwareStatusRegister; - PVOID SystemReserved1[0x36]; - LONG ExceptionCode; - struct _ACTIVATION_CONTEXT_STACK *ActivationContextStackPointer; +#include "peb_teb.h" + #ifdef _WIN64 - UCHAR SpareBytes1[24]; -#else - UCHAR SpareBytes1[0x24]; +// +// Explicit 32 bit PEB/TEB +// +#define EXPLICIT_32BIT +#include "peb_teb.h" +#undef EXPLICIT_32BIT + +// +// Explicit 64 bit PEB/TEB +// +#define EXPLICIT_64BIT +#include "peb_teb.h" +#undef EXPLICIT_64BIT #endif - ULONG TxFsContext; - GDI_TEB_BATCH GdiTebBatch; - CLIENT_ID RealClientId; - PVOID GdiCachedProcessHandle; - ULONG GdiClientPID; - ULONG GdiClientTID; - PVOID GdiThreadLocalInfo; - SIZE_T Win32ClientInfo[62]; - PVOID glDispatchTable[0xE9]; - SIZE_T glReserved1[0x1D]; - PVOID glReserved2; - PVOID glSectionInfo; - PVOID glSection; - PVOID glTable; - PVOID glCurrentRC; - PVOID glContext; - NTSTATUS LastStatusValue; - UNICODE_STRING StaticUnicodeString; - WCHAR StaticUnicodeBuffer[0x105]; - PVOID DeallocationStack; - PVOID TlsSlots[0x40]; - LIST_ENTRY TlsLinks; - PVOID Vdm; - PVOID ReservedForNtRpc; - PVOID DbgSsReserved[0x2]; - ULONG HardErrorDisabled; -#ifdef _WIN64 - PVOID Instrumentation[11]; -#else - PVOID Instrumentation[9]; -#endif - GUID ActivityId; - PVOID SubProcessTag; - PVOID EtwTraceData; -#if (NTDDI_VERSION >= NTDDI_LONGHORN) - PVOID EtwLocalData; -#endif - PVOID WinSockData; - ULONG GdiBatchCount; -#if (NTDDI_VERSION >= NTDDI_LONGHORN) - BOOLEAN SpareBool0; - BOOLEAN SpareBool1; - BOOLEAN SpareBool2; -#else - BOOLEAN InDbgPrint; - BOOLEAN FreeStackOnTermination; - BOOLEAN HasFiberData; -#endif - UCHAR IdealProcessor; - ULONG GuaranteedStackBytes; - PVOID ReservedForPerf; - PVOID ReservedForOle; - ULONG WaitingOnLoaderLock; -#if (NTDDI_VERSION >= NTDDI_LONGHORN) - PVOID SavedPriorityState; -#else - ULONG SparePointer1; -#endif - ULONG SoftPatchPtr1; - ULONG SoftPatchPtr2; - PVOID *TlsExpansionSlots; - ULONG ImpersonationLocale; - ULONG IsImpersonating; - PVOID NlsCache; - PVOID pShimData; - ULONG HeapVirualAffinity; - PVOID CurrentTransactionHandle; - PTEB_ACTIVE_FRAME ActiveFrame; -#if (NTDDI_VERSION >= NTDDI_WS03) - PVOID FlsData; -#endif -#if (NTDDI_VERSION >= NTDDI_LONGHORN) - PVOID PreferredLangauges; - PVOID UserPrefLanguages; - PVOID MergedPrefLanguages; - ULONG MuiImpersonation; - union - { - struct - { - USHORT SpareCrossTebFlags:16; - }; - USHORT CrossTebFlags; - }; - union - { - struct - { - USHORT DbgSafeThunkCall:1; - USHORT DbgInDebugPrint:1; - USHORT DbgHasFiberData:1; - USHORT DbgSkipThreadAttach:1; - USHORT DbgWerInShipAssertCode:1; - USHORT DbgIssuedInitialBp:1; - USHORT DbgClonedThread:1; - USHORT SpareSameTebBits:9; - }; - USHORT SameTebFlags; - }; - PVOID TxnScopeEntercallback; - PVOID TxnScopeExitCAllback; - PVOID TxnScopeContext; - ULONG LockCount; - ULONG ProcessRundown; - ULONGLONG LastSwitchTime; - ULONGLONG TotalSwitchOutTime; - LARGE_INTEGER WaitReasonBitMap; -#else - UCHAR SafeThunkCall; - UCHAR BooleanSpare[3]; -#endif -} TEB, *PTEB; #ifdef NTOS_MODE_USER diff --git a/reactos/ntoskrnl/dbgk/dbgkutil.c b/reactos/ntoskrnl/dbgk/dbgkutil.c index 2285c95a955..8e9cf123392 100644 --- a/reactos/ntoskrnl/dbgk/dbgkutil.c +++ b/reactos/ntoskrnl/dbgk/dbgkutil.c @@ -242,10 +242,10 @@ DbgkCreateThread(IN PETHREAD Thread, wcsncpy(Teb->StaticUnicodeBuffer, L"ntdll.dll", sizeof(Teb->StaticUnicodeBuffer) / sizeof(WCHAR)); - Teb->Tib.ArbitraryUserPointer = Teb->StaticUnicodeBuffer; + Teb->NtTib.ArbitraryUserPointer = Teb->StaticUnicodeBuffer; /* Return it in the debug event as well */ - LoadDll->NamePointer = &Teb->Tib.ArbitraryUserPointer; + LoadDll->NamePointer = &Teb->NtTib.ArbitraryUserPointer; } /* Get a handle */ diff --git a/reactos/ntoskrnl/mm/ARM3/procsup.c b/reactos/ntoskrnl/mm/ARM3/procsup.c index 6064686d2b4..9a5af8d0588 100644 --- a/reactos/ntoskrnl/mm/ARM3/procsup.c +++ b/reactos/ntoskrnl/mm/ARM3/procsup.c @@ -514,9 +514,9 @@ MmCreatePeb(IN PEPROCESS Process, // // Write subsystem data // - Peb->ImageSubSystem = NtHeaders->OptionalHeader.Subsystem; - Peb->ImageSubSystemMajorVersion = NtHeaders->OptionalHeader.MajorSubsystemVersion; - Peb->ImageSubSystemMinorVersion = NtHeaders->OptionalHeader.MinorSubsystemVersion; + Peb->ImageSubsystem = NtHeaders->OptionalHeader.Subsystem; + Peb->ImageSubsystemMajorVersion = NtHeaders->OptionalHeader.MajorSubsystemVersion; + Peb->ImageSubsystemMinorVersion = NtHeaders->OptionalHeader.MinorSubsystemVersion; // // Check for version data @@ -632,13 +632,13 @@ MmCreateTeb(IN PEPROCESS Process, // // Set TIB Data // - Teb->Tib.ExceptionList = EXCEPTION_CHAIN_END; - Teb->Tib.Self = (PNT_TIB)Teb; + Teb->NtTib.ExceptionList = EXCEPTION_CHAIN_END; + Teb->NtTib.Self = (PNT_TIB)Teb; // // Identify this as an OS/2 V3.0 ("Cruiser") TIB // - Teb->Tib.Version = 30 << 8; + Teb->NtTib.Version = 30 << 8; // // Set TEB Data @@ -657,8 +657,8 @@ MmCreateTeb(IN PEPROCESS Process, // // Use initial TEB values // - Teb->Tib.StackBase = InitialTeb->StackBase; - Teb->Tib.StackLimit = InitialTeb->StackLimit; + Teb->NtTib.StackBase = InitialTeb->StackBase; + Teb->NtTib.StackLimit = InitialTeb->StackLimit; Teb->DeallocationStack = InitialTeb->AllocatedStackBase; } else @@ -666,8 +666,8 @@ MmCreateTeb(IN PEPROCESS Process, // // Use grandparent TEB values // - Teb->Tib.StackBase = InitialTeb->PreviousStackBase; - Teb->Tib.StackLimit = InitialTeb->PreviousStackLimit; + Teb->NtTib.StackBase = InitialTeb->PreviousStackBase; + Teb->NtTib.StackLimit = InitialTeb->PreviousStackLimit; } // diff --git a/reactos/ntoskrnl/rtl/libsupp.c b/reactos/ntoskrnl/rtl/libsupp.c index 86c32c522fa..f7672f81f22 100644 --- a/reactos/ntoskrnl/rtl/libsupp.c +++ b/reactos/ntoskrnl/rtl/libsupp.c @@ -366,8 +366,8 @@ RtlWalkFrameChain(OUT PVOID *Callers, } /* Get the stack limits */ - StackBegin = (ULONG_PTR)Teb->Tib.StackLimit; - StackEnd = (ULONG_PTR)Teb->Tib.StackBase; + StackBegin = (ULONG_PTR)Teb->NtTib.StackLimit; + StackEnd = (ULONG_PTR)Teb->NtTib.StackBase; #ifdef _M_IX86 Stack = TrapFrame->Ebp; #elif defined(_M_PPC)