Start to make use of the proper PEB structure for process

information.
This commit is contained in:
Alexandre Julliard 2003-05-22 03:44:01 +00:00
parent 2989895f70
commit 6bc5091160
8 changed files with 70 additions and 70 deletions

View File

@ -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;
}

View File

@ -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 */

View File

@ -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 */

View File

@ -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
*/

View File

@ -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 ) );

View File

@ -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;
}

View File

@ -26,7 +26,6 @@
#include "debugger.h"
#include "winternl.h"
#include "thread.h"
#include "wincon.h"
#include "winreg.h"
#include "wingdi.h"

View File

@ -211,7 +211,7 @@ void THREAD_Init(void)
{
THREAD_InitTEB( &initial_teb );
assert( initial_teb.teb_sel );
initial_teb.process = &current_process;
initial_teb.Peb = (PEB *)&current_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;