diff --git a/dlls/ntdll/heap.c b/dlls/ntdll/heap.c index 66d0ca800a3..75611d5d583 100644 --- a/dlls/ntdll/heap.c +++ b/dlls/ntdll/heap.c @@ -141,8 +141,7 @@ inline static void set_status( NTSTATUS status ) /* set the process main heap */ static void set_process_heap( HANDLE heap ) { - HANDLE *pdb = (HANDLE *)NtCurrentTeb()->process; - pdb[0x18 / sizeof(HANDLE)] = heap; /* heap is at offset 0x18 in pdb */ + NtCurrentTeb()->Peb->ProcessHeap = heap; processHeap = heap; } diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index bc8e6ce9994..184b1987721 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -40,51 +40,9 @@ extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, IMAGE_EXPORT_DIRECTORY *expor FARPROC origfun, DWORD ordinal ); extern void RELAY_SetupDLL( const char *module ); -typedef struct RTL_DRIVE_LETTER_CURDIR -{ - USHORT Flags; - USHORT Length; - ULONG TimeStamp; - UNICODE_STRING DosPath; -} RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR; - -typedef struct _RTL_USER_PROCESS_PARAMETERS -{ - ULONG AllocationSize; - ULONG Size; - ULONG Flags; - ULONG DebugFlags; - HANDLE hConsole; - ULONG ProcessGroup; - HANDLE hStdInput; - HANDLE hStdOutput; - HANDLE hStdError; - UNICODE_STRING CurrentDirectoryName; - HANDLE CurrentDirectoryHandle; - UNICODE_STRING DllPath; - UNICODE_STRING ImagePathName; - UNICODE_STRING CommandLine; - PWSTR Environment; - ULONG dwX; - ULONG dwY; - ULONG dwXSize; - ULONG dwYSize; - ULONG dwXCountChars; - ULONG dwYCountChars; - ULONG dwFillAttribute; - ULONG dwFlags; - ULONG wShowWindow; - UNICODE_STRING WindowTitle; - UNICODE_STRING DesktopInfo; - UNICODE_STRING ShellInfo; - UNICODE_STRING RuntimeInfo; - RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20]; -} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS; - static inline HANDLE ntdll_get_process_heap(void) { - HANDLE *pdb = (HANDLE *)NtCurrentTeb()->process; - return pdb[0x18 / sizeof(HANDLE)]; /* get dword at offset 0x18 in pdb */ + return NtCurrentTeb()->Peb->ProcessHeap; } /* FIXME: this should be part of PEB, once it's defined */ diff --git a/include/thread.h b/include/thread.h index 2e4798dbaf2..ff8e89d0822 100644 --- a/include/thread.h +++ b/include/thread.h @@ -24,7 +24,6 @@ #include "winternl.h" #include "wine/windef16.h" -struct _PDB; struct __EXCEPTION_FRAME; struct _SECURITY_ATTRIBUTES; struct tagSYSLEVEL; @@ -64,7 +63,7 @@ typedef struct _TEB HQUEUE16 queue; /* 1!- 28 Message queue (NT: DWORD ActiveRpcHandle)*/ WORD pad1; /* --n 2a */ LPVOID *tls_ptr; /* 1-- 2c Pointer to TLS array */ - struct _PDB *process; /* 12- 30 owning process (win95: PDB; nt: NTPEB !!) */ + PEB *Peb; /* 12- 30 owning process PEB */ DWORD flags; /* 1-n 34 */ DWORD exit_code; /* 1-- 38 Termination status */ WORD teb_sel; /* 1-- 3c Selector to TEB */ diff --git a/include/winternl.h b/include/winternl.h index 7efa558f465..2e6c04147f2 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -29,16 +29,6 @@ extern "C" { #endif /* defined(__cplusplus) */ -/*********************************************************************** - * PEB data structure - */ -typedef struct _PEB { - BYTE Reserved1[2]; - BYTE BeingDebugged; - BYTE Reserved2[229]; - PVOID Reserved3[59]; - ULONG SessionId; -} PEB, *PPEB; /*********************************************************************** * TEB data structure @@ -101,6 +91,67 @@ typedef struct _CURDIR PVOID Handle; } CURDIR, *PCURDIR; +typedef struct RTL_DRIVE_LETTER_CURDIR +{ + USHORT Flags; + USHORT Length; + ULONG TimeStamp; + UNICODE_STRING DosPath; +} RTL_DRIVE_LETTER_CURDIR, *PRTL_DRIVE_LETTER_CURDIR; + +typedef struct _RTL_USER_PROCESS_PARAMETERS +{ + ULONG AllocationSize; + ULONG Size; + ULONG Flags; + ULONG DebugFlags; + HANDLE hConsole; + ULONG ProcessGroup; + HANDLE hStdInput; + HANDLE hStdOutput; + HANDLE hStdError; + UNICODE_STRING CurrentDirectoryName; + HANDLE CurrentDirectoryHandle; + UNICODE_STRING DllPath; + UNICODE_STRING ImagePathName; + UNICODE_STRING CommandLine; + PWSTR Environment; + ULONG dwX; + ULONG dwY; + ULONG dwXSize; + ULONG dwYSize; + ULONG dwXCountChars; + ULONG dwYCountChars; + ULONG dwFillAttribute; + ULONG dwFlags; + ULONG wShowWindow; + UNICODE_STRING WindowTitle; + UNICODE_STRING DesktopInfo; + UNICODE_STRING ShellInfo; + UNICODE_STRING RuntimeInfo; + RTL_DRIVE_LETTER_CURDIR DLCurrentDirectory[0x20]; +} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS; + + +/*********************************************************************** + * PEB data structure + */ +typedef struct _PEB +{ + BYTE Reserved1[2]; /* 00 */ + BYTE BeingDebugged; /* 02 */ + BYTE Reserved2[5]; /* 03 */ + HMODULE ImageBaseAddress; /* 08 */ + PVOID __pad_0c; /* 0c */ + RTL_USER_PROCESS_PARAMETERS *ProcessParameters; /* 10 */ + PVOID __pad_14; /* 14 */ + HANDLE ProcessHeap; /* 18 */ + BYTE __pad_1c[204]; /* 1c */ + PVOID Reserved3[59]; /* e8 */ + ULONG SessionId; /* 1d4 */ +} PEB, *PPEB; + + /*********************************************************************** * Enums */ diff --git a/loader/module.c b/loader/module.c index 68e74faeb49..b9d30826cfd 100644 --- a/loader/module.c +++ b/loader/module.c @@ -45,11 +45,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(module); WINE_DECLARE_DEBUG_CHANNEL(win32); WINE_DECLARE_DEBUG_CHANNEL(loaddll); -inline static HMODULE get_exe_module(void) -{ - HANDLE *pdb = (HANDLE *)NtCurrentTeb()->process; - return pdb[0x08 / sizeof(HANDLE)]; /* get dword at offset 0x08 in pdb */ -} /*********************************************************************** * wait_input_idle @@ -481,7 +476,7 @@ HMODULE WINAPI GetModuleHandleA(LPCSTR module) HMODULE ret; UNICODE_STRING wstr; - if (!module) return get_exe_module(); + if (!module) return NtCurrentTeb()->Peb->ImageBaseAddress; RtlCreateUnicodeStringFromAsciiz(&wstr, module); nts = LdrGetDllHandle(0, 0, &wstr, &ret); @@ -503,7 +498,7 @@ HMODULE WINAPI GetModuleHandleW(LPCWSTR module) HMODULE ret; UNICODE_STRING wstr; - if (!module) return get_exe_module(); + if (!module) return NtCurrentTeb()->Peb->ImageBaseAddress; RtlInitUnicodeString( &wstr, module ); nts = LdrGetDllHandle( 0, 0, &wstr, &ret); @@ -570,7 +565,7 @@ DWORD WINAPI GetModuleFileNameW( HMODULE hModule, LPWSTR lpFileName, DWORD size LDR_MODULE* pldr; NTSTATUS nts; - if (!hModule) hModule = get_exe_module(); + if (!hModule) hModule = NtCurrentTeb()->Peb->ImageBaseAddress; nts = LdrFindEntryForAddress( hModule, &pldr ); if (nts == STATUS_SUCCESS) lstrcpynW(lpFileName, pldr->FullDllName.Buffer, size); else SetLastError( RtlNtStatusToDosError( nts ) ); diff --git a/memory/heap.c b/memory/heap.c index bceffb26841..046a41c0f13 100644 --- a/memory/heap.c +++ b/memory/heap.c @@ -225,8 +225,7 @@ BOOL WINAPI HeapWalk( */ HANDLE WINAPI GetProcessHeap(void) { - HANDLE *pdb = (HANDLE *)NtCurrentTeb()->process; - return pdb[0x18 / sizeof(HANDLE)]; /* get dword at offset 0x18 in pdb */ + return NtCurrentTeb()->Peb->ProcessHeap; } diff --git a/programs/winedbg/winedbg.c b/programs/winedbg/winedbg.c index ec575396dfd..502045c511a 100644 --- a/programs/winedbg/winedbg.c +++ b/programs/winedbg/winedbg.c @@ -26,7 +26,6 @@ #include "debugger.h" #include "winternl.h" -#include "thread.h" #include "wincon.h" #include "winreg.h" #include "wingdi.h" diff --git a/scheduler/thread.c b/scheduler/thread.c index f73830061e1..24792f94237 100644 --- a/scheduler/thread.c +++ b/scheduler/thread.c @@ -211,7 +211,7 @@ void THREAD_Init(void) { THREAD_InitTEB( &initial_teb ); assert( initial_teb.teb_sel ); - initial_teb.process = ¤t_process; + initial_teb.Peb = (PEB *)¤t_process; /* FIXME */ SYSDEPS_SetCurThread( &initial_teb ); SYSDEPS_InitErrno(); } @@ -277,7 +277,7 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, SIZE_T stack, return 0; } - teb->process = NtCurrentTeb()->process; + teb->Peb = NtCurrentTeb()->Peb; teb->tid = tid; teb->request_fd = request_pipe[1]; teb->entry_point = start;