ntdll: Call the process entry point through RtlUserThreadStart().
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1a9558cf9b
commit
c2c330532e
|
@ -3304,7 +3304,7 @@ static void test_SuspendProcessState(void)
|
|||
BOOL pipe_connected;
|
||||
ULONG pipe_magic, numb;
|
||||
BOOL ret;
|
||||
void *entry_ptr, *peb_ptr;
|
||||
void *user_thread_start, *start_ptr, *entry_ptr, *peb_ptr;
|
||||
PEB child_peb;
|
||||
|
||||
exit_process_ptr = GetProcAddress(hkernel32, "ExitProcess");
|
||||
|
@ -3365,6 +3365,7 @@ static void test_SuspendProcessState(void)
|
|||
ok( ctx.EFlags == 0x200, "wrong flags %08x\n", ctx.EFlags );
|
||||
ok( ctx.MxCsr == 0x1f80, "wrong mxcsr %08x\n", ctx.MxCsr );
|
||||
ok( ctx.FltSave.ControlWord == 0x27f, "wrong control %08x\n", ctx.FltSave.ControlWord );
|
||||
start_ptr = (void *)ctx.Rip;
|
||||
entry_ptr = (void *)ctx.Rcx;
|
||||
peb_ptr = (void *)ctx.Rdx;
|
||||
|
||||
|
@ -3395,6 +3396,7 @@ static void test_SuspendProcessState(void)
|
|||
ok( (ctx.EFlags & ~2) == 0x200, "wrong flags %08x\n", ctx.EFlags );
|
||||
ok( (WORD)ctx.FloatSave.ControlWord == 0x27f, "wrong control %08x\n", ctx.FloatSave.ControlWord );
|
||||
ok( *(WORD *)ctx.ExtendedRegisters == 0x27f, "wrong control %08x\n", *(WORD *)ctx.ExtendedRegisters );
|
||||
start_ptr = (void *)ctx.Eip;
|
||||
entry_ptr = (void *)ctx.Eax;
|
||||
peb_ptr = (void *)ctx.Ebx;
|
||||
|
||||
|
@ -3418,6 +3420,10 @@ static void test_SuspendProcessState(void)
|
|||
ok( ret, "Failed to read PEB (%u)\n", GetLastError() );
|
||||
ok( child_peb.ImageBaseAddress == exe_base, "wrong base %p/%p\n",
|
||||
child_peb.ImageBaseAddress, exe_base );
|
||||
user_thread_start = GetProcAddress( GetModuleHandleA("ntdll.dll"), "RtlUserThreadStart" );
|
||||
if (user_thread_start)
|
||||
ok( start_ptr == user_thread_start,
|
||||
"wrong start addr %p / %p\n", start_ptr, user_thread_start );
|
||||
ok( entry_ptr == (char *)exe_base + nt_header.OptionalHeader.AddressOfEntryPoint,
|
||||
"wrong entry point %p/%p\n", entry_ptr,
|
||||
(char *)exe_base + nt_header.OptionalHeader.AddressOfEntryPoint );
|
||||
|
|
|
@ -134,7 +134,7 @@ void DECLSPEC_HIDDEN call_thread_func( PRTL_THREAD_START_ROUTINE entry, void *ar
|
|||
}
|
||||
__EXCEPT(call_unhandled_exception_filter)
|
||||
{
|
||||
NtTerminateThread( GetCurrentThread(), GetExceptionCode() );
|
||||
NtTerminateProcess( GetCurrentThread(), GetExceptionCode() );
|
||||
}
|
||||
__ENDTRY
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ void WINAPI RtlUserThreadStart( PRTL_THREAD_START_ROUTINE entry, void *arg )
|
|||
}
|
||||
__EXCEPT(call_unhandled_exception_filter)
|
||||
{
|
||||
NtTerminateThread( GetCurrentThread(), GetExceptionCode() );
|
||||
NtTerminateProcess( GetCurrentThread(), GetExceptionCode() );
|
||||
}
|
||||
__ENDTRY
|
||||
}
|
||||
|
|
|
@ -1486,7 +1486,7 @@ void CDECL server_init_process_done( void *relay )
|
|||
SERVER_END_REQ;
|
||||
|
||||
assert( !status );
|
||||
signal_start_thread( entry, peb, suspend, relay, pLdrInitializeThunk, NtCurrentTeb() );
|
||||
signal_start_thread( entry, peb, suspend, pLdrInitializeThunk, NtCurrentTeb() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -983,12 +983,12 @@ void signal_init_process(void)
|
|||
/***********************************************************************
|
||||
* init_thread_context
|
||||
*/
|
||||
static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry, void *arg, void *relay )
|
||||
static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry, void *arg, TEB *teb )
|
||||
{
|
||||
context->R0 = (DWORD)entry;
|
||||
context->R1 = (DWORD)arg;
|
||||
context->Sp = (DWORD)NtCurrentTeb()->Tib.StackBase;
|
||||
context->Pc = (DWORD)relay;
|
||||
context->Sp = (DWORD)teb->Tib.StackBase;
|
||||
context->Pc = (DWORD)pRtlUserThreadStart;
|
||||
}
|
||||
|
||||
|
||||
|
@ -996,7 +996,7 @@ static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry,
|
|||
* get_initial_context
|
||||
*/
|
||||
PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void *arg,
|
||||
BOOL suspend, void *relay )
|
||||
BOOL suspend, TEB *teb )
|
||||
{
|
||||
CONTEXT *ctx;
|
||||
|
||||
|
@ -1004,15 +1004,15 @@ PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void
|
|||
{
|
||||
CONTEXT context = { CONTEXT_ALL };
|
||||
|
||||
init_thread_context( &context, entry, arg, relay );
|
||||
init_thread_context( &context, entry, arg, teb );
|
||||
wait_suspend( &context );
|
||||
ctx = (CONTEXT *)((ULONG_PTR)context.Sp & ~15) - 1;
|
||||
*ctx = context;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx = (CONTEXT *)NtCurrentTeb()->Tib.StackBase - 1;
|
||||
init_thread_context( ctx, entry, arg, relay );
|
||||
ctx = (CONTEXT *)teb->Tib.StackBase - 1;
|
||||
init_thread_context( ctx, entry, arg, teb );
|
||||
}
|
||||
pthread_sigmask( SIG_UNBLOCK, &server_block_set, NULL );
|
||||
ctx->ContextFlags = CONTEXT_FULL;
|
||||
|
@ -1026,12 +1026,12 @@ PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void
|
|||
__ASM_GLOBAL_FUNC( signal_start_thread,
|
||||
".arm\n\t"
|
||||
"push {r4-r12,lr}\n\t"
|
||||
"ldr r5, [sp, #40]\n\t" /* thunk */
|
||||
"mov r5, r3\n\t" /* thunk */
|
||||
/* store exit frame */
|
||||
"ldr r4, [sp, #44]\n\t" /* teb */
|
||||
"str sp, [r4, #0x1d4]\n\t" /* teb->GdiTebBatch */
|
||||
"ldr r3, [sp, #40]\n\t" /* teb */
|
||||
"str sp, [r3, #0x1d4]\n\t" /* arm_thread_data()->exit_frame */
|
||||
/* switch to thread stack */
|
||||
"ldr r4, [r4, #4]\n\t" /* teb->Tib.StackBase */
|
||||
"ldr r4, [r3, #4]\n\t" /* teb->Tib.StackBase */
|
||||
"sub sp, r4, #0x1000\n\t"
|
||||
/* attach dlls */
|
||||
"bl " __ASM_NAME("get_initial_context") "\n\t"
|
||||
|
@ -1042,7 +1042,7 @@ __ASM_GLOBAL_FUNC( signal_start_thread,
|
|||
extern void DECLSPEC_NORETURN call_thread_exit_func( int status, void (*func)(int), TEB *teb );
|
||||
__ASM_GLOBAL_FUNC( call_thread_exit_func,
|
||||
".arm\n\t"
|
||||
"ldr r3, [r2, #0x1d4]\n\t" /* teb->GdiTebBatch */
|
||||
"ldr r3, [r2, #0x1d4]\n\t" /* arm_thread_data()->exit_frame */
|
||||
"mov ip, #0\n\t"
|
||||
"str ip, [r2, #0x1d4]\n\t"
|
||||
"cmp r3, ip\n\t"
|
||||
|
|
|
@ -1077,13 +1077,13 @@ void signal_init_process(void)
|
|||
/***********************************************************************
|
||||
* init_thread_context
|
||||
*/
|
||||
static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry, void *arg, void *relay )
|
||||
static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry, void *arg, TEB *teb )
|
||||
{
|
||||
context->u.s.X0 = (DWORD64)entry;
|
||||
context->u.s.X1 = (DWORD64)arg;
|
||||
context->u.s.X18 = (DWORD64)NtCurrentTeb();
|
||||
context->Sp = (DWORD64)NtCurrentTeb()->Tib.StackBase;
|
||||
context->Pc = (DWORD64)relay;
|
||||
context->u.s.X18 = (DWORD64)teb;
|
||||
context->Sp = (DWORD64)teb->Tib.StackBase;
|
||||
context->Pc = (DWORD64)pRtlUserThreadStart;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1091,7 +1091,7 @@ static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry,
|
|||
* get_initial_context
|
||||
*/
|
||||
PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void *arg,
|
||||
BOOL suspend, void *relay )
|
||||
BOOL suspend, TEB *teb )
|
||||
{
|
||||
CONTEXT *ctx;
|
||||
|
||||
|
@ -1099,15 +1099,15 @@ PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void
|
|||
{
|
||||
CONTEXT context = { CONTEXT_ALL };
|
||||
|
||||
init_thread_context( &context, entry, arg, relay );
|
||||
init_thread_context( &context, entry, arg, teb );
|
||||
wait_suspend( &context );
|
||||
ctx = (CONTEXT *)((ULONG_PTR)context.Sp & ~15) - 1;
|
||||
*ctx = context;
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx = (CONTEXT *)NtCurrentTeb()->Tib.StackBase - 1;
|
||||
init_thread_context( ctx, entry, arg, relay );
|
||||
ctx = (CONTEXT *)teb->Tib.StackBase - 1;
|
||||
init_thread_context( ctx, entry, arg, teb );
|
||||
}
|
||||
pthread_sigmask( SIG_UNBLOCK, &server_block_set, NULL );
|
||||
ctx->ContextFlags = CONTEXT_FULL;
|
||||
|
@ -1120,15 +1120,16 @@ PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void
|
|||
*/
|
||||
__ASM_GLOBAL_FUNC( signal_start_thread,
|
||||
"stp x29, x30, [sp,#-16]!\n\t"
|
||||
"mov x19, x4\n\t" /* thunk */
|
||||
"mov x18, x5\n\t" /* teb */
|
||||
"mov x19, x3\n\t" /* thunk */
|
||||
"mov x18, x4\n\t" /* teb */
|
||||
/* store exit frame */
|
||||
"mov x29, sp\n\t"
|
||||
"str x29, [x5, #0x2f0]\n\t" /* arm64_thread_data()->exit_frame */
|
||||
"str x29, [x4, #0x2f0]\n\t" /* arm64_thread_data()->exit_frame */
|
||||
/* switch to thread stack */
|
||||
"ldr x5, [x5, #8]\n\t" /* teb->Tib.StackBase */
|
||||
"ldr x5, [x4, #8]\n\t" /* teb->Tib.StackBase */
|
||||
"sub sp, x5, #0x1000\n\t"
|
||||
/* attach dlls */
|
||||
"mov x3, x4\n\t"
|
||||
"bl " __ASM_NAME("get_initial_context") "\n\t"
|
||||
"mov lr, #0\n\t"
|
||||
"br x19" )
|
||||
|
|
|
@ -2372,7 +2372,7 @@ void signal_init_process(void)
|
|||
/***********************************************************************
|
||||
* init_thread_context
|
||||
*/
|
||||
static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry, void *arg, void *relay )
|
||||
static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry, void *arg )
|
||||
{
|
||||
context->SegCs = get_cs();
|
||||
context->SegDs = get_ds();
|
||||
|
@ -2384,7 +2384,7 @@ static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry,
|
|||
context->Eax = (DWORD)entry;
|
||||
context->Ebx = (DWORD)arg;
|
||||
context->Esp = (DWORD)NtCurrentTeb()->Tib.StackBase - 16;
|
||||
context->Eip = (DWORD)relay;
|
||||
context->Eip = (DWORD)pRtlUserThreadStart;
|
||||
context->FloatSave.ControlWord = 0x27f;
|
||||
((XSAVE_FORMAT *)context->ExtendedRegisters)->ControlWord = 0x27f;
|
||||
((XSAVE_FORMAT *)context->ExtendedRegisters)->MxCsr = 0x1f80;
|
||||
|
@ -2394,8 +2394,7 @@ static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry,
|
|||
/***********************************************************************
|
||||
* get_initial_context
|
||||
*/
|
||||
PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void *arg,
|
||||
BOOL suspend, void *relay )
|
||||
PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend )
|
||||
{
|
||||
CONTEXT *ctx;
|
||||
|
||||
|
@ -2403,7 +2402,7 @@ PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void
|
|||
{
|
||||
CONTEXT context = { CONTEXT_ALL };
|
||||
|
||||
init_thread_context( &context, entry, arg, relay );
|
||||
init_thread_context( &context, entry, arg );
|
||||
wait_suspend( &context );
|
||||
ctx = (CONTEXT *)((ULONG_PTR)context.Esp & ~15) - 1;
|
||||
*ctx = context;
|
||||
|
@ -2411,7 +2410,7 @@ PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void
|
|||
else
|
||||
{
|
||||
ctx = (CONTEXT *)((char *)NtCurrentTeb()->Tib.StackBase - 16) - 1;
|
||||
init_thread_context( ctx, entry, arg, relay );
|
||||
init_thread_context( ctx, entry, arg );
|
||||
}
|
||||
pthread_sigmask( SIG_UNBLOCK, &server_block_set, NULL );
|
||||
ctx->ContextFlags = CONTEXT_FULL | CONTEXT_FLOATING_POINT | CONTEXT_EXTENDED_REGISTERS;
|
||||
|
@ -2438,15 +2437,14 @@ __ASM_GLOBAL_FUNC( signal_start_thread,
|
|||
"movl %ebp,%fs:0x1f4\n\t" /* x86_thread_data()->exit_frame */
|
||||
/* switch to thread stack */
|
||||
"movl %fs:4,%eax\n\t" /* NtCurrentTeb()->StackBase */
|
||||
"leal -0x1000(%eax),%esp\n\t"
|
||||
"leal -0x1004(%eax),%esp\n\t"
|
||||
/* attach dlls */
|
||||
"pushl 20(%ebp)\n\t" /* relay */
|
||||
"pushl 16(%ebp)\n\t" /* suspend */
|
||||
"pushl 12(%ebp)\n\t" /* arg */
|
||||
"pushl 8(%ebp)\n\t" /* entry */
|
||||
"call " __ASM_NAME("get_initial_context") "\n\t"
|
||||
"movl %eax,(%esp)\n\t" /* context */
|
||||
"movl 24(%ebp),%edx\n\t" /* thunk */
|
||||
"movl 20(%ebp),%edx\n\t" /* thunk */
|
||||
"xorl %ebp,%ebp\n\t"
|
||||
"pushl $0\n\t"
|
||||
"jmp *%edx" )
|
||||
|
|
|
@ -2631,14 +2631,14 @@ void signal_init_process(void)
|
|||
/***********************************************************************
|
||||
* init_thread_context
|
||||
*/
|
||||
static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry, void *arg, void *relay )
|
||||
static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry, void *arg )
|
||||
{
|
||||
__asm__( "movw %%cs,%0" : "=m" (context->SegCs) );
|
||||
__asm__( "movw %%ss,%0" : "=m" (context->SegSs) );
|
||||
context->Rcx = (ULONG_PTR)entry;
|
||||
context->Rdx = (ULONG_PTR)arg;
|
||||
context->Rsp = (ULONG_PTR)NtCurrentTeb()->Tib.StackBase - 0x28;
|
||||
context->Rip = (ULONG_PTR)relay;
|
||||
context->Rip = (ULONG_PTR)pRtlUserThreadStart;
|
||||
context->EFlags = 0x200;
|
||||
context->u.FltSave.ControlWord = 0x27f;
|
||||
context->u.FltSave.MxCsr = context->MxCsr = 0x1f80;
|
||||
|
@ -2648,8 +2648,7 @@ static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry,
|
|||
/***********************************************************************
|
||||
* get_initial_context
|
||||
*/
|
||||
PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void *arg,
|
||||
BOOL suspend, void *relay )
|
||||
PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend )
|
||||
{
|
||||
CONTEXT *ctx;
|
||||
|
||||
|
@ -2658,7 +2657,7 @@ PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void
|
|||
CONTEXT context = { 0 };
|
||||
|
||||
context.ContextFlags = CONTEXT_ALL;
|
||||
init_thread_context( &context, entry, arg, relay );
|
||||
init_thread_context( &context, entry, arg );
|
||||
wait_suspend( &context );
|
||||
ctx = (CONTEXT *)((ULONG_PTR)context.Rsp & ~15) - 1;
|
||||
*ctx = context;
|
||||
|
@ -2666,7 +2665,7 @@ PCONTEXT DECLSPEC_HIDDEN get_initial_context( LPTHREAD_START_ROUTINE entry, void
|
|||
else
|
||||
{
|
||||
ctx = (CONTEXT *)((char *)NtCurrentTeb()->Tib.StackBase - 0x30) - 1;
|
||||
init_thread_context( ctx, entry, arg, relay );
|
||||
init_thread_context( ctx, entry, arg );
|
||||
}
|
||||
pthread_sigmask( SIG_UNBLOCK, &server_block_set, NULL );
|
||||
ctx->ContextFlags = CONTEXT_FULL;
|
||||
|
@ -2699,7 +2698,7 @@ __ASM_GLOBAL_FUNC( signal_start_thread,
|
|||
"movq %rsp,0x320(%rax)\n\t" /* amd64_thread_data()->exit_frame */
|
||||
/* switch to thread stack */
|
||||
"movq 8(%rax),%rax\n\t" /* NtCurrentTeb()->Tib.StackBase */
|
||||
"movq %r8,%rbx\n\t" /* thunk */
|
||||
"movq %rcx,%rbx\n\t" /* thunk */
|
||||
"leaq -0x1000(%rax),%rsp\n\t"
|
||||
/* attach dlls */
|
||||
"call " __ASM_NAME("get_initial_context") "\n\t"
|
||||
|
|
|
@ -99,8 +99,7 @@ static void start_thread( TEB *teb )
|
|||
thread_data->pthread_id = pthread_self();
|
||||
signal_init_thread( teb );
|
||||
server_init_thread( thread_data->start, &suspend );
|
||||
signal_start_thread( thread_data->start, thread_data->param, suspend,
|
||||
pRtlUserThreadStart, pLdrInitializeThunk, teb );
|
||||
signal_start_thread( thread_data->start, thread_data->param, suspend, pLdrInitializeThunk, teb );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ extern void signal_free_thread( TEB *teb ) DECLSPEC_HIDDEN;
|
|||
extern void signal_init_thread( TEB *teb ) DECLSPEC_HIDDEN;
|
||||
extern void signal_init_process(void) DECLSPEC_HIDDEN;
|
||||
extern void DECLSPEC_NORETURN signal_start_thread( PRTL_THREAD_START_ROUTINE entry, void *arg,
|
||||
BOOL suspend, void *relay, void *thunk, TEB *teb ) DECLSPEC_HIDDEN;
|
||||
BOOL suspend, void *thunk, TEB *teb ) DECLSPEC_HIDDEN;
|
||||
extern void DECLSPEC_NORETURN signal_exit_thread( int status, void (*func)(int) ) DECLSPEC_HIDDEN;
|
||||
extern void __wine_syscall_dispatcher(void) DECLSPEC_HIDDEN;
|
||||
extern void fill_vm_counters( VM_COUNTERS_EX *pvmi, int unix_pid ) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in New Issue