diff --git a/reactos/lib/kernel32/process/create.c b/reactos/lib/kernel32/process/create.c index 0bd166ad8c6..bf22324ee80 100644 --- a/reactos/lib/kernel32/process/create.c +++ b/reactos/lib/kernel32/process/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.32 2001/01/21 00:07:03 phreak Exp $ +/* $Id: create.c,v 1.33 2001/01/23 09:58:12 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -123,7 +123,6 @@ CreateProcessA ( return Result; } -#define STACK_TOP (0xb0000000) HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, LPSECURITY_ATTRIBUTES lpThreadAttributes, @@ -159,8 +158,8 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, else CreateSuspended = FALSE; - - BaseAddress = (PVOID)(STACK_TOP - dwStackSize); + /* Allocate thread stack */ + BaseAddress = NULL; Status = NtAllocateVirtualMemory(ProcessHandle, &BaseAddress, 0, @@ -180,7 +179,7 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, ThreadContext.SegDs = USER_DS; ThreadContext.SegCs = USER_CS; ThreadContext.SegSs = USER_DS; - ThreadContext.Esp = STACK_TOP - 20; + ThreadContext.Esp = (ULONG)(BaseAddress + dwStackSize - 20); ThreadContext.EFlags = (1<<1) + (1<<9); DPRINT("ThreadContext.Eip %x\n",ThreadContext.Eip); diff --git a/reactos/lib/ntdll/rtl/process.c b/reactos/lib/ntdll/rtl/process.c index 64bf1c2e452..654cb0e4fbe 100644 --- a/reactos/lib/ntdll/rtl/process.c +++ b/reactos/lib/ntdll/rtl/process.c @@ -1,4 +1,4 @@ -/* $Id: process.c,v 1.23 2000/12/28 20:38:27 ekohl Exp $ +/* $Id: process.c,v 1.24 2001/01/23 09:57:42 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -23,8 +23,6 @@ /* FUNCTIONS ****************************************************************/ -#define STACK_TOP (0xb0000000) - HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, ULONG StackSize, LPTHREAD_START_ROUTINE lpStartAddress, @@ -44,7 +42,7 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, ObjectAttributes.Attributes = 0; ObjectAttributes.SecurityQualityOfService = NULL; - BaseAddress = (PVOID)(STACK_TOP - StackSize); + BaseAddress = NULL; Status = NtAllocateVirtualMemory(ProcessHandle, &BaseAddress, 0, @@ -65,7 +63,7 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, ThreadContext.SegDs = USER_DS; ThreadContext.SegCs = USER_CS; ThreadContext.SegSs = USER_DS; - ThreadContext.Esp = STACK_TOP - 20; + ThreadContext.Esp = (ULONG)BaseAddress + StackSize - 20; ThreadContext.EFlags = (1<<1) + (1<<9); DPRINT("ThreadContext.Eip %x\n",ThreadContext.Eip); diff --git a/reactos/ntoskrnl/ldr/init.c b/reactos/ntoskrnl/ldr/init.c index 8d7960c1f78..6dc39b9ceb7 100644 --- a/reactos/ntoskrnl/ldr/init.c +++ b/reactos/ntoskrnl/ldr/init.c @@ -30,10 +30,6 @@ #define NDEBUG #include -/* GLOBALS *******************************************************************/ - -#define STACK_TOP (0xb0000000) - /* FUNCTIONS *****************************************************************/ /* @@ -157,16 +153,14 @@ NTSTATUS LdrLoadInitialProcess (VOID) Peb->ImageBaseAddress); NTHeaders = RtlImageNtHeader(Peb->ImageBaseAddress); DPRINT("NTHeaders %x\n", NTHeaders); - StackBase = (PVOID) - (STACK_TOP - NTHeaders->OptionalHeader.SizeOfStackReserve); - DPRINT("StackBase %x\n", StackBase); StackSize = NTHeaders->OptionalHeader.SizeOfStackReserve; DPRINT("StackSize %x\n", StackSize); KeDetachProcess(); DPRINT("Dereferencing process\n"); // ObDereferenceObject(Process); - DPRINT("Stack size %x\n", StackSize); + StackBase = (PVOID)NULL; + DPRINT("StackBase %x StackSize %x\n", StackBase, StackSize); DPRINT("Allocating virtual memory\n"); Status = ZwAllocateVirtualMemory(ProcessHandle, (PVOID*)&StackBase, @@ -194,7 +188,7 @@ NTSTATUS LdrLoadInitialProcess (VOID) */ memset(&Context,0,sizeof(CONTEXT)); Context.SegSs = USER_DS; - Context.Esp = STACK_TOP - 20; + Context.Esp = (ULONG)StackBase + StackSize - 20; Context.EFlags = 0x202; Context.SegCs = USER_CS; Context.Eip = (ULONG)LdrStartupAddr;