- Establish the pde for the thread structure within the process

before a switch to the process occurs.

svn path=/trunk/; revision=10704
This commit is contained in:
Hartmut Birr 2004-08-27 10:24:04 +00:00
parent aa00673d45
commit 16a24538c2
2 changed files with 17 additions and 8 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: kthread.c,v 1.51 2004/08/21 21:09:39 tamlin Exp $ /* $Id: kthread.c,v 1.52 2004/08/27 10:24:04 hbirr Exp $
* *
* FILE: ntoskrnl/ke/kthread.c * FILE: ntoskrnl/ke/kthread.c
* PURPOSE: Microkernel thread support * PURPOSE: Microkernel thread support
@ -188,8 +188,16 @@ KeInitializeThread(PKPROCESS Process, PKTHREAD Thread, BOOLEAN First)
Thread->StackLimit = (ULONG)&init_stack; Thread->StackLimit = (ULONG)&init_stack;
Thread->KernelStack = (PVOID)&init_stack_top; Thread->KernelStack = (PVOID)&init_stack_top;
} }
/*
* Establish the pde's for the new stack and the thread structure within the
* address space of the new process. They are accessed while taskswitching or
* while handling page faults. At this point it isn't possible to call the
* page fault handler for the missing pde's.
*/
MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread->StackLimit, MM_STACK_SIZE); MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread->StackLimit, MM_STACK_SIZE);
MmUpdatePageDir((PEPROCESS)Process, (PVOID)Thread, sizeof(ETHREAD));
/* /*
* The Native API function will initialize the TEB field later * The Native API function will initialize the TEB field later

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: process.c,v 1.25 2004/08/21 21:19:06 tamlin Exp $ /* $Id: process.c,v 1.26 2004/08/27 10:24:04 hbirr Exp $
* *
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/process.c * FILE: ntoskrnl/ke/process.c
@ -55,16 +55,17 @@ KeAttachProcess (PEPROCESS Process)
KEBUGCHECK(INVALID_PROCESS_ATTACH_ATTEMPT); KEBUGCHECK(INVALID_PROCESS_ATTACH_ATTEMPT);
} }
/* The stack of the current process may be located in a page which is /* The stack and the thread structure of the current process may be
not present in the page directory of the process we're attaching to. located in a page which is not present in the page directory of
That would lead to a page fault when this function returns. However, the process we're attaching to. That would lead to a page fault
since the processor can't call the page fault handler 'cause it can't when this function returns. However, since the processor can't
push EIP on the stack, this will show up as a stack fault which will call the page fault handler 'cause it can't push EIP on the stack,
crash the entire system. this will show up as a stack fault which will crash the entire system.
To prevent this, make sure the page directory of the process we're To prevent this, make sure the page directory of the process we're
attaching to is up-to-date. */ attaching to is up-to-date. */
MmUpdatePageDir(Process, (PVOID)CurrentThread->Tcb.StackLimit, MM_STACK_SIZE); MmUpdatePageDir(Process, (PVOID)CurrentThread->Tcb.StackLimit, MM_STACK_SIZE);
MmUpdatePageDir(Process, (PVOID)CurrentThread, sizeof(ETHREAD));
KeRaiseIrql(DISPATCH_LEVEL, &oldlvl); KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);