Commit 6bc50911 authored by Alexandre Julliard's avatar Alexandre Julliard

Start to make use of the proper PEB structure for process

information.
parent 2989895f
...@@ -141,8 +141,7 @@ inline static void set_status( NTSTATUS status ) ...@@ -141,8 +141,7 @@ inline static void set_status( NTSTATUS status )
/* set the process main heap */ /* set the process main heap */
static void set_process_heap( HANDLE heap ) static void set_process_heap( HANDLE heap )
{ {
HANDLE *pdb = (HANDLE *)NtCurrentTeb()->process; NtCurrentTeb()->Peb->ProcessHeap = heap;
pdb[0x18 / sizeof(HANDLE)] = heap; /* heap is at offset 0x18 in pdb */
processHeap = heap; processHeap = heap;
} }
......
...@@ -40,51 +40,9 @@ extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, IMAGE_EXPORT_DIRECTORY *expor ...@@ -40,51 +40,9 @@ extern FARPROC SNOOP_GetProcAddress( HMODULE hmod, IMAGE_EXPORT_DIRECTORY *expor
FARPROC origfun, DWORD ordinal ); FARPROC origfun, DWORD ordinal );
extern void RELAY_SetupDLL( const char *module ); 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) static inline HANDLE ntdll_get_process_heap(void)
{ {
HANDLE *pdb = (HANDLE *)NtCurrentTeb()->process; return NtCurrentTeb()->Peb->ProcessHeap;
return pdb[0x18 / sizeof(HANDLE)]; /* get dword at offset 0x18 in pdb */
} }
/* FIXME: this should be part of PEB, once it's defined */ /* FIXME: this should be part of PEB, once it's defined */
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "winternl.h" #include "winternl.h"
#include "wine/windef16.h" #include "wine/windef16.h"
struct _PDB;
struct __EXCEPTION_FRAME; struct __EXCEPTION_FRAME;
struct _SECURITY_ATTRIBUTES; struct _SECURITY_ATTRIBUTES;
struct tagSYSLEVEL; struct tagSYSLEVEL;
...@@ -64,7 +63,7 @@ typedef struct _TEB ...@@ -64,7 +63,7 @@ typedef struct _TEB
HQUEUE16 queue; /* 1!- 28 Message queue (NT: DWORD ActiveRpcHandle)*/ HQUEUE16 queue; /* 1!- 28 Message queue (NT: DWORD ActiveRpcHandle)*/
WORD pad1; /* --n 2a */ WORD pad1; /* --n 2a */
LPVOID *tls_ptr; /* 1-- 2c Pointer to TLS array */ 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 flags; /* 1-n 34 */
DWORD exit_code; /* 1-- 38 Termination status */ DWORD exit_code; /* 1-- 38 Termination status */
WORD teb_sel; /* 1-- 3c Selector to TEB */ WORD teb_sel; /* 1-- 3c Selector to TEB */
......
...@@ -29,16 +29,6 @@ ...@@ -29,16 +29,6 @@
extern "C" { extern "C" {
#endif /* defined(__cplusplus) */ #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 * TEB data structure
...@@ -101,6 +91,67 @@ typedef struct _CURDIR ...@@ -101,6 +91,67 @@ typedef struct _CURDIR
PVOID Handle; PVOID Handle;
} CURDIR, *PCURDIR; } 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 * Enums
*/ */
......
...@@ -45,11 +45,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(module); ...@@ -45,11 +45,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(module);
WINE_DECLARE_DEBUG_CHANNEL(win32); WINE_DECLARE_DEBUG_CHANNEL(win32);
WINE_DECLARE_DEBUG_CHANNEL(loaddll); 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 * wait_input_idle
...@@ -481,7 +476,7 @@ HMODULE WINAPI GetModuleHandleA(LPCSTR module) ...@@ -481,7 +476,7 @@ HMODULE WINAPI GetModuleHandleA(LPCSTR module)
HMODULE ret; HMODULE ret;
UNICODE_STRING wstr; UNICODE_STRING wstr;
if (!module) return get_exe_module(); if (!module) return NtCurrentTeb()->Peb->ImageBaseAddress;
RtlCreateUnicodeStringFromAsciiz(&wstr, module); RtlCreateUnicodeStringFromAsciiz(&wstr, module);
nts = LdrGetDllHandle(0, 0, &wstr, &ret); nts = LdrGetDllHandle(0, 0, &wstr, &ret);
...@@ -503,7 +498,7 @@ HMODULE WINAPI GetModuleHandleW(LPCWSTR module) ...@@ -503,7 +498,7 @@ HMODULE WINAPI GetModuleHandleW(LPCWSTR module)
HMODULE ret; HMODULE ret;
UNICODE_STRING wstr; UNICODE_STRING wstr;
if (!module) return get_exe_module(); if (!module) return NtCurrentTeb()->Peb->ImageBaseAddress;
RtlInitUnicodeString( &wstr, module ); RtlInitUnicodeString( &wstr, module );
nts = LdrGetDllHandle( 0, 0, &wstr, &ret); nts = LdrGetDllHandle( 0, 0, &wstr, &ret);
...@@ -570,7 +565,7 @@ DWORD WINAPI GetModuleFileNameW( HMODULE hModule, LPWSTR lpFileName, DWORD size ...@@ -570,7 +565,7 @@ DWORD WINAPI GetModuleFileNameW( HMODULE hModule, LPWSTR lpFileName, DWORD size
LDR_MODULE* pldr; LDR_MODULE* pldr;
NTSTATUS nts; NTSTATUS nts;
if (!hModule) hModule = get_exe_module(); if (!hModule) hModule = NtCurrentTeb()->Peb->ImageBaseAddress;
nts = LdrFindEntryForAddress( hModule, &pldr ); nts = LdrFindEntryForAddress( hModule, &pldr );
if (nts == STATUS_SUCCESS) lstrcpynW(lpFileName, pldr->FullDllName.Buffer, size); if (nts == STATUS_SUCCESS) lstrcpynW(lpFileName, pldr->FullDllName.Buffer, size);
else SetLastError( RtlNtStatusToDosError( nts ) ); else SetLastError( RtlNtStatusToDosError( nts ) );
......
...@@ -225,8 +225,7 @@ BOOL WINAPI HeapWalk( ...@@ -225,8 +225,7 @@ BOOL WINAPI HeapWalk(
*/ */
HANDLE WINAPI GetProcessHeap(void) HANDLE WINAPI GetProcessHeap(void)
{ {
HANDLE *pdb = (HANDLE *)NtCurrentTeb()->process; return NtCurrentTeb()->Peb->ProcessHeap;
return pdb[0x18 / sizeof(HANDLE)]; /* get dword at offset 0x18 in pdb */
} }
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "debugger.h" #include "debugger.h"
#include "winternl.h" #include "winternl.h"
#include "thread.h"
#include "wincon.h" #include "wincon.h"
#include "winreg.h" #include "winreg.h"
#include "wingdi.h" #include "wingdi.h"
......
...@@ -211,7 +211,7 @@ void THREAD_Init(void) ...@@ -211,7 +211,7 @@ void THREAD_Init(void)
{ {
THREAD_InitTEB( &initial_teb ); THREAD_InitTEB( &initial_teb );
assert( initial_teb.teb_sel ); assert( initial_teb.teb_sel );
initial_teb.process = &current_process; initial_teb.Peb = (PEB *)&current_process; /* FIXME */
SYSDEPS_SetCurThread( &initial_teb ); SYSDEPS_SetCurThread( &initial_teb );
SYSDEPS_InitErrno(); SYSDEPS_InitErrno();
} }
...@@ -277,7 +277,7 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, SIZE_T stack, ...@@ -277,7 +277,7 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, SIZE_T stack,
return 0; return 0;
} }
teb->process = NtCurrentTeb()->process; teb->Peb = NtCurrentTeb()->Peb;
teb->tid = tid; teb->tid = tid;
teb->request_fd = request_pipe[1]; teb->request_fd = request_pipe[1];
teb->entry_point = start; teb->entry_point = start;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment