Commit 943e16de authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move RtlUserThreadStart implementation to the CPU backends.

parent bf2b38a8
......@@ -279,6 +279,27 @@ LONG WINAPI call_unhandled_exception_filter( PEXCEPTION_POINTERS eptr )
return unhandled_exception_filter( eptr );
}
/*******************************************************************
* call_unhandled_exception_handler
*/
EXCEPTION_DISPOSITION WINAPI call_unhandled_exception_handler( EXCEPTION_RECORD *rec, void *frame,
CONTEXT *context, void *dispatch )
{
EXCEPTION_POINTERS ep = { rec, context };
switch (call_unhandled_exception_filter( &ep ))
{
case EXCEPTION_CONTINUE_SEARCH:
return ExceptionContinueSearch;
case EXCEPTION_CONTINUE_EXECUTION:
return ExceptionContinueExecution;
case EXCEPTION_EXECUTE_HANDLER:
break;
}
NtTerminateProcess( GetCurrentProcess(), rec->ExceptionCode );
return ExceptionContinueExecution;
}
#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
......
......@@ -1488,6 +1488,22 @@ USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer,
return 0;
}
/***********************************************************************
* RtlUserThreadStart (NTDLL.@)
*/
void WINAPI RtlUserThreadStart( PRTL_THREAD_START_ROUTINE entry, void *arg )
{
__TRY
{
pBaseThreadInitThunk( 0, (LPTHREAD_START_ROUTINE)entry, arg );
}
__EXCEPT(call_unhandled_exception_filter)
{
NtTerminateProcess( GetCurrentProcess(), GetExceptionCode() );
}
__ENDTRY
}
/******************************************************************
* LdrInitializeThunk (NTDLL.@)
*/
......
......@@ -1525,6 +1525,22 @@ USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer,
return 0;
}
/***********************************************************************
* RtlUserThreadStart (NTDLL.@)
*/
void WINAPI RtlUserThreadStart( PRTL_THREAD_START_ROUTINE entry, void *arg )
{
__TRY
{
pBaseThreadInitThunk( 0, (LPTHREAD_START_ROUTINE)entry, arg );
}
__EXCEPT(call_unhandled_exception_filter)
{
NtTerminateProcess( GetCurrentProcess(), GetExceptionCode() );
}
__ENDTRY
}
/******************************************************************
* LdrInitializeThunk (NTDLL.@)
*/
......
......@@ -536,6 +536,43 @@ USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer,
/***********************************************************************
* RtlUserThreadStart (NTDLL.@)
*/
__ASM_STDCALL_FUNC( RtlUserThreadStart, 8,
"movl %ebx,8(%esp)\n\t" /* arg */
"movl %eax,4(%esp)\n\t" /* entry */
"jmp " __ASM_NAME("call_thread_func") )
/* wrapper to call BaseThreadInitThunk */
extern void DECLSPEC_NORETURN call_thread_func_wrapper( void *thunk, PRTL_THREAD_START_ROUTINE entry, void *arg );
__ASM_GLOBAL_FUNC( call_thread_func_wrapper,
"pushl %ebp\n\t"
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
"movl %esp,%ebp\n\t"
__ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
"subl $4,%esp\n\t"
"andl $~0xf,%esp\n\t"
"xorl %ecx,%ecx\n\t"
"movl 12(%ebp),%edx\n\t"
"movl 16(%ebp),%eax\n\t"
"movl %eax,(%esp)\n\t"
"call *8(%ebp)" )
void DECLSPEC_HIDDEN call_thread_func( PRTL_THREAD_START_ROUTINE entry, void *arg )
{
__TRY
{
call_thread_func_wrapper( pBaseThreadInitThunk, entry, arg );
}
__EXCEPT(call_unhandled_exception_filter)
{
NtTerminateProcess( GetCurrentProcess(), GetExceptionCode() );
}
__ENDTRY
}
/***********************************************************************
* signal_start_thread
*/
extern void CDECL DECLSPEC_NORETURN signal_start_thread( CONTEXT *ctx ) DECLSPEC_HIDDEN;
......
......@@ -1589,6 +1589,37 @@ USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer,
/***********************************************************************
* RtlUserThreadStart (NTDLL.@)
*/
#ifdef __ASM_SEH_SUPPORTED
__ASM_GLOBAL_FUNC( RtlUserThreadStart,
"subq $0x28,%rsp\n\t"
".seh_stackalloc 0x28\n\t"
".seh_endprologue\n\t"
"movq %rdx,%r8\n\t"
"movq %rcx,%rdx\n\t"
"xorq %rcx,%rcx\n\t"
"movq " __ASM_NAME( "pBaseThreadInitThunk" ) "(%rip),%r9\n\t"
"call *%r9\n\t"
"int3\n\t"
".seh_handler " __ASM_NAME("call_unhandled_exception_handler") ", @except" )
#else
void WINAPI RtlUserThreadStart( PRTL_THREAD_START_ROUTINE entry, void *arg )
{
__TRY
{
pBaseThreadInitThunk( 0, (LPTHREAD_START_ROUTINE)entry, arg );
}
__EXCEPT(call_unhandled_exception_filter)
{
NtTerminateProcess( GetCurrentProcess(), GetExceptionCode() );
}
__ENDTRY
}
#endif
/***********************************************************************
* signal_start_thread
*/
extern void CDECL DECLSPEC_NORETURN signal_start_thread( CONTEXT *ctx ) DECLSPEC_HIDDEN;
......
......@@ -247,96 +247,6 @@ void WINAPI RtlExitUserThread( ULONG status )
/***********************************************************************
* RtlUserThreadStart (NTDLL.@)
*/
#ifdef __i386__
__ASM_STDCALL_FUNC( RtlUserThreadStart, 8,
"movl %ebx,8(%esp)\n\t" /* arg */
"movl %eax,4(%esp)\n\t" /* entry */
"jmp " __ASM_NAME("call_thread_func") )
/* wrapper to call BaseThreadInitThunk */
extern void DECLSPEC_NORETURN call_thread_func_wrapper( void *thunk, PRTL_THREAD_START_ROUTINE entry, void *arg );
__ASM_GLOBAL_FUNC( call_thread_func_wrapper,
"pushl %ebp\n\t"
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
__ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
"movl %esp,%ebp\n\t"
__ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
"subl $4,%esp\n\t"
"andl $~0xf,%esp\n\t"
"xorl %ecx,%ecx\n\t"
"movl 12(%ebp),%edx\n\t"
"movl 16(%ebp),%eax\n\t"
"movl %eax,(%esp)\n\t"
"call *8(%ebp)" )
void DECLSPEC_HIDDEN call_thread_func( PRTL_THREAD_START_ROUTINE entry, void *arg )
{
__TRY
{
call_thread_func_wrapper( pBaseThreadInitThunk, entry, arg );
}
__EXCEPT(call_unhandled_exception_filter)
{
NtTerminateProcess( GetCurrentProcess(), GetExceptionCode() );
}
__ENDTRY
}
#elif /* __i386__ */ defined(__x86_64__) && defined(__ASM_SEH_SUPPORTED)
EXCEPTION_DISPOSITION WINAPI call_thread_func_handler( EXCEPTION_RECORD *rec, ULONG64 frame,
CONTEXT *context, DISPATCHER_CONTEXT *dispatch )
{
EXCEPTION_POINTERS ep = { rec, context };
WARN( "Unhandled exception, calling filter.\n" );
switch (call_unhandled_exception_filter( &ep ))
{
case EXCEPTION_CONTINUE_SEARCH:
return ExceptionContinueSearch;
case EXCEPTION_CONTINUE_EXECUTION:
return ExceptionContinueExecution;
case EXCEPTION_EXECUTE_HANDLER:
break;
}
NtTerminateProcess( GetCurrentProcess(), rec->ExceptionCode );
return ExceptionContinueExecution;
}
extern void WINAPI RtlUserThreadStart( PRTL_THREAD_START_ROUTINE entry, void *arg );
__ASM_GLOBAL_FUNC( RtlUserThreadStart,
"subq $0x28,%rsp\n\t"
".seh_stackalloc 0x28\n\t"
".seh_endprologue\n\t"
"movq %rdx,%r8\n\t"
"movq %rcx,%rdx\n\t"
"xorq %rcx,%rcx\n\t"
"movq " __ASM_NAME( "pBaseThreadInitThunk" ) "(%rip),%r9\n\t"
"call *%r9\n\t"
"int3\n\t"
".seh_handler call_thread_func_handler, @except\n\t" )
#else /* defined(__x86_64__) && defined(__ASM_SEH_SUPPORTED) */
void WINAPI RtlUserThreadStart( PRTL_THREAD_START_ROUTINE entry, void *arg )
{
__TRY
{
pBaseThreadInitThunk( 0, (LPTHREAD_START_ROUTINE)entry, arg );
}
__EXCEPT(call_unhandled_exception_filter)
{
NtTerminateProcess( GetCurrentProcess(), GetExceptionCode() );
}
__ENDTRY
}
#endif /* __i386__ */
/***********************************************************************
* RtlCreateUserThread (NTDLL.@)
*/
NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, SECURITY_DESCRIPTOR *descr,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment