mirror of
https://github.com/reactos/reactos.git
synced 2024-11-24 12:03:31 +08:00
[KERNEL32] Fix register initialization in BaseInitializeContext
Get rid of BaseThreadStartupThunk and BaseProcessStartThunk asm wrappers and go to the C functions directly (home space is allocated on the stack by the kernel)
This commit is contained in:
parent
2c2c570317
commit
8df1bd612a
@ -99,8 +99,7 @@ if(ARCH STREQUAL "i386")
|
||||
client/i386/thread.S)
|
||||
elseif(ARCH STREQUAL "amd64")
|
||||
list(APPEND ASM_SOURCE
|
||||
client/amd64/fiber.S
|
||||
client/amd64/thread.S)
|
||||
client/amd64/fiber.S)
|
||||
elseif(ARCH STREQUAL "arm")
|
||||
list(APPEND ASM_SOURCE
|
||||
client/arm/fiber.S
|
||||
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: dll/win32/kernel32/client/amd64/thread.S
|
||||
* PURPOSE: Thread Start Thunks
|
||||
* PROGRAMMER: Alex Ionescu (alex@relsoft.net)
|
||||
*/
|
||||
|
||||
#include <asm.inc>
|
||||
.code64
|
||||
|
||||
EXTERN BaseThreadStartup:PROC
|
||||
EXTERN BaseProcessStartup:PROC
|
||||
|
||||
PUBLIC BaseThreadStartupThunk
|
||||
PUBLIC BaseProcessStartThunk
|
||||
|
||||
BaseThreadStartupThunk:
|
||||
|
||||
/* Start out fresh */
|
||||
xor rbp, rbp
|
||||
|
||||
push rbx /* lpParameter */
|
||||
push rax /* lpStartAddress */
|
||||
push 0 /* Return RIP */
|
||||
jmp BaseThreadStartup
|
||||
|
||||
BaseProcessStartThunk:
|
||||
|
||||
/* Start out fresh */
|
||||
xor rbp, rbp
|
||||
|
||||
push rax /* lpStartAddress */
|
||||
push 0 /* Return RIP */
|
||||
jmp BaseProcessStartup
|
||||
|
||||
END
|
||||
/* EOF */
|
@ -580,12 +580,14 @@ BaseInitializeContext(IN PCONTEXT Context,
|
||||
|
||||
#elif defined(_M_AMD64)
|
||||
DPRINT("BaseInitializeContext: %p\n", Context);
|
||||
ASSERT(((ULONG_PTR)StackAddress & 15) == 0);
|
||||
|
||||
RtlZeroMemory(Context, sizeof(*Context));
|
||||
|
||||
/* Setup the Initial Win32 Thread Context */
|
||||
Context->Rax = (ULONG_PTR)StartAddress;
|
||||
Context->Rbx = (ULONG_PTR)Parameter;
|
||||
Context->Rsp = (ULONG_PTR)StackAddress;
|
||||
/* The other registers are undefined */
|
||||
Context->Rcx = (ULONG_PTR)StartAddress;
|
||||
Context->Rdx = (ULONG_PTR)Parameter;
|
||||
Context->Rsp = (ULONG_PTR)StackAddress - 5 * sizeof(PVOID);
|
||||
|
||||
/* Setup the Segments */
|
||||
Context->SegGs = KGDT64_R3_DATA | RPL_MASK;
|
||||
@ -596,11 +598,11 @@ BaseInitializeContext(IN PCONTEXT Context,
|
||||
Context->SegFs = KGDT64_R3_CMTEB | RPL_MASK;
|
||||
|
||||
/* Set the EFLAGS */
|
||||
Context->EFlags = 0x3000; /* IOPL 3 */
|
||||
Context->EFlags = 0x3000 | EFLAGS_INTERRUPT_MASK; /* IOPL 3 */
|
||||
|
||||
if (ContextType == 1) /* For Threads */
|
||||
{
|
||||
Context->Rip = (ULONG_PTR)BaseThreadStartupThunk;
|
||||
Context->Rip = (ULONG_PTR)BaseThreadStartup;
|
||||
}
|
||||
else if (ContextType == 2) /* For Fibers */
|
||||
{
|
||||
@ -608,14 +610,11 @@ BaseInitializeContext(IN PCONTEXT Context,
|
||||
}
|
||||
else /* For first thread in a Process */
|
||||
{
|
||||
Context->Rip = (ULONG_PTR)BaseProcessStartThunk;
|
||||
Context->Rip = (ULONG_PTR)BaseProcessStartup;
|
||||
}
|
||||
|
||||
/* Set the Context Flags */
|
||||
Context->ContextFlags = CONTEXT_FULL;
|
||||
|
||||
/* Give it some room for the Parameter */
|
||||
Context->Rsp -= sizeof(PVOID);
|
||||
#elif defined(_M_ARM)
|
||||
DPRINT("BaseInitializeContext: %p\n", Context);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user