Removed fixed stack base address

svn path=/trunk/; revision=1559
This commit is contained in:
Eric Kohl 2001-01-23 09:58:12 +00:00
parent 6579aafa03
commit 42d7089e72
3 changed files with 10 additions and 19 deletions

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -123,7 +123,6 @@ CreateProcessA (
return Result; return Result;
} }
#define STACK_TOP (0xb0000000)
HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle,
LPSECURITY_ATTRIBUTES lpThreadAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes,
@ -159,8 +158,8 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle,
else else
CreateSuspended = FALSE; CreateSuspended = FALSE;
/* Allocate thread stack */
BaseAddress = (PVOID)(STACK_TOP - dwStackSize); BaseAddress = NULL;
Status = NtAllocateVirtualMemory(ProcessHandle, Status = NtAllocateVirtualMemory(ProcessHandle,
&BaseAddress, &BaseAddress,
0, 0,
@ -180,7 +179,7 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle,
ThreadContext.SegDs = USER_DS; ThreadContext.SegDs = USER_DS;
ThreadContext.SegCs = USER_CS; ThreadContext.SegCs = USER_CS;
ThreadContext.SegSs = USER_DS; ThreadContext.SegSs = USER_DS;
ThreadContext.Esp = STACK_TOP - 20; ThreadContext.Esp = (ULONG)(BaseAddress + dwStackSize - 20);
ThreadContext.EFlags = (1<<1) + (1<<9); ThreadContext.EFlags = (1<<1) + (1<<9);
DPRINT("ThreadContext.Eip %x\n",ThreadContext.Eip); DPRINT("ThreadContext.Eip %x\n",ThreadContext.Eip);

View file

@ -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 * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -23,8 +23,6 @@
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
#define STACK_TOP (0xb0000000)
HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle, HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle,
ULONG StackSize, ULONG StackSize,
LPTHREAD_START_ROUTINE lpStartAddress, LPTHREAD_START_ROUTINE lpStartAddress,
@ -44,7 +42,7 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle,
ObjectAttributes.Attributes = 0; ObjectAttributes.Attributes = 0;
ObjectAttributes.SecurityQualityOfService = NULL; ObjectAttributes.SecurityQualityOfService = NULL;
BaseAddress = (PVOID)(STACK_TOP - StackSize); BaseAddress = NULL;
Status = NtAllocateVirtualMemory(ProcessHandle, Status = NtAllocateVirtualMemory(ProcessHandle,
&BaseAddress, &BaseAddress,
0, 0,
@ -65,7 +63,7 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle,
ThreadContext.SegDs = USER_DS; ThreadContext.SegDs = USER_DS;
ThreadContext.SegCs = USER_CS; ThreadContext.SegCs = USER_CS;
ThreadContext.SegSs = USER_DS; ThreadContext.SegSs = USER_DS;
ThreadContext.Esp = STACK_TOP - 20; ThreadContext.Esp = (ULONG)BaseAddress + StackSize - 20;
ThreadContext.EFlags = (1<<1) + (1<<9); ThreadContext.EFlags = (1<<1) + (1<<9);
DPRINT("ThreadContext.Eip %x\n",ThreadContext.Eip); DPRINT("ThreadContext.Eip %x\n",ThreadContext.Eip);

View file

@ -30,10 +30,6 @@
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
/* GLOBALS *******************************************************************/
#define STACK_TOP (0xb0000000)
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
/* /*
@ -157,16 +153,14 @@ NTSTATUS LdrLoadInitialProcess (VOID)
Peb->ImageBaseAddress); Peb->ImageBaseAddress);
NTHeaders = RtlImageNtHeader(Peb->ImageBaseAddress); NTHeaders = RtlImageNtHeader(Peb->ImageBaseAddress);
DPRINT("NTHeaders %x\n", NTHeaders); DPRINT("NTHeaders %x\n", NTHeaders);
StackBase = (PVOID)
(STACK_TOP - NTHeaders->OptionalHeader.SizeOfStackReserve);
DPRINT("StackBase %x\n", StackBase);
StackSize = NTHeaders->OptionalHeader.SizeOfStackReserve; StackSize = NTHeaders->OptionalHeader.SizeOfStackReserve;
DPRINT("StackSize %x\n", StackSize); DPRINT("StackSize %x\n", StackSize);
KeDetachProcess(); KeDetachProcess();
DPRINT("Dereferencing process\n"); DPRINT("Dereferencing process\n");
// ObDereferenceObject(Process); // ObDereferenceObject(Process);
DPRINT("Stack size %x\n", StackSize); StackBase = (PVOID)NULL;
DPRINT("StackBase %x StackSize %x\n", StackBase, StackSize);
DPRINT("Allocating virtual memory\n"); DPRINT("Allocating virtual memory\n");
Status = ZwAllocateVirtualMemory(ProcessHandle, Status = ZwAllocateVirtualMemory(ProcessHandle,
(PVOID*)&StackBase, (PVOID*)&StackBase,
@ -194,7 +188,7 @@ NTSTATUS LdrLoadInitialProcess (VOID)
*/ */
memset(&Context,0,sizeof(CONTEXT)); memset(&Context,0,sizeof(CONTEXT));
Context.SegSs = USER_DS; Context.SegSs = USER_DS;
Context.Esp = STACK_TOP - 20; Context.Esp = (ULONG)StackBase + StackSize - 20;
Context.EFlags = 0x202; Context.EFlags = 0x202;
Context.SegCs = USER_CS; Context.SegCs = USER_CS;
Context.Eip = (ULONG)LdrStartupAddr; Context.Eip = (ULONG)LdrStartupAddr;