Commit d89037a8 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Share KiUserCallbackDispatcher implementation across platforms.

parent 3031f157
......@@ -186,6 +186,30 @@ LONG call_vectored_handlers( EXCEPTION_RECORD *rec, CONTEXT *context )
/*******************************************************************
* dispatch_user_callback
*
* Implementation of KiUserCallbackDispatcher.
*/
NTSTATUS WINAPI dispatch_user_callback( void *args, ULONG len, ULONG id )
{
NTSTATUS status;
__TRY
{
KERNEL_CALLBACK_PROC func = NtCurrentTeb()->Peb->KernelCallbackTable[id];
status = func( args, len );
}
__EXCEPT_ALL
{
ERR( "ignoring exception\n" );
status = STATUS_SUCCESS;
}
__ENDTRY
return status;
}
/*******************************************************************
* raise_status
*
* Implementation of RtlRaiseStatus with a specific exception record.
......
......@@ -49,6 +49,7 @@ extern UINT_PTR page_size;
/* exceptions */
extern LONG call_vectored_handlers( EXCEPTION_RECORD *rec, CONTEXT *context );
extern NTSTATUS WINAPI dispatch_user_callback( void *args, ULONG len, ULONG id );
extern void DECLSPEC_NORETURN raise_status( NTSTATUS status, EXCEPTION_RECORD *rec );
extern LONG WINAPI call_unhandled_exception_filter( PEXCEPTION_POINTERS eptr );
......
......@@ -575,24 +575,6 @@ __ASM_GLOBAL_FUNC( KiUserApcDispatcher,
/*******************************************************************
* KiUserCallbackDispatcher (NTDLL.@)
*/
void WINAPI dispatch_callback( void *args, ULONG len, ULONG id )
{
NTSTATUS status;
__TRY
{
KERNEL_CALLBACK_PROC func = NtCurrentTeb()->Peb->KernelCallbackTable[id];
status = NtCallbackReturn( NULL, 0, func( args, len ));
}
__EXCEPT_ALL
{
ERR_(seh)( "ignoring exception\n" );
status = NtCallbackReturn( 0, 0, 0 );
}
__ENDTRY
RtlRaiseStatus( status );
}
__ASM_GLOBAL_FUNC( KiUserCallbackDispatcher,
__ASM_SEH(".seh_custom 0xee,0x01\n\t") /* MSFT_OP_MACHINE_FRAME */
"nop\n\t"
......@@ -606,7 +588,12 @@ __ASM_GLOBAL_FUNC( KiUserCallbackDispatcher,
"ldr r0, [sp]\n\t" /* args */
"ldr r1, [sp, #0x04]\n\t" /* len */
"ldr r2, [sp, #0x08]\n\t" /* id */
"bl " __ASM_NAME("dispatch_callback") "\n\t"
"bl " __ASM_NAME("dispatch_user_callback") "\n\t"
"mov r2, r0\n\t" /* status */
"mov r1, #0\n\t" /* ret_len */
"mov r0, r1\n\t" /* ret_ptr */
"bl " __ASM_NAME("NtCallbackReturn") "\n\t"
"bl " __ASM_NAME("RtlRaiseStatus") "\n\t"
"udf #1" )
......
......@@ -605,24 +605,6 @@ __ASM_GLOBAL_FUNC( KiUserApcDispatcher,
/*******************************************************************
* KiUserCallbackDispatcher (NTDLL.@)
*/
void WINAPI dispatch_callback( void *args, ULONG len, ULONG id )
{
NTSTATUS status;
__TRY
{
KERNEL_CALLBACK_PROC func = NtCurrentTeb()->Peb->KernelCallbackTable[id];
status = NtCallbackReturn( NULL, 0, func( args, len ));
}
__EXCEPT_ALL
{
ERR_(seh)( "ignoring exception\n" );
status = NtCallbackReturn( 0, 0, 0 );
}
__ENDTRY
RtlRaiseStatus( status );
}
__ASM_GLOBAL_FUNC( KiUserCallbackDispatcher,
__ASM_SEH(".seh_pushframe\n\t")
"nop\n\t"
......@@ -632,7 +614,12 @@ __ASM_GLOBAL_FUNC( KiUserCallbackDispatcher,
__ASM_SEH(".seh_endprologue\n\t")
"ldr x0, [sp]\n\t" /* args */
"ldp w1, w2, [sp, #0x08]\n\t" /* len, id */
"bl " __ASM_NAME("dispatch_callback") "\n\t"
"bl " __ASM_NAME("dispatch_user_callback") "\n\t"
"mov x2, x0\n\t" /* status */
"mov x1, #0\n\t" /* ret_len */
"mov x0, x1\n\t" /* ret_ptr */
"bl " __ASM_NAME("NtCallbackReturn") "\n\t"
"bl " __ASM_NAME("RtlRaiseStatus") "\n\t"
"brk #1" )
......
......@@ -1716,24 +1716,6 @@ __ASM_GLOBAL_FUNC( "#KiUserApcDispatcher",
/*******************************************************************
* KiUserCallbackDispatcher (NTDLL.@)
*/
void WINAPI dispatch_callback( void *args, ULONG len, ULONG id )
{
NTSTATUS status;
__TRY
{
KERNEL_CALLBACK_PROC func = NtCurrentTeb()->Peb->KernelCallbackTable[id];
status = NtCallbackReturn( NULL, 0, func( args, len ));
}
__EXCEPT_ALL
{
ERR_(seh)( "ignoring exception\n" );
status = NtCallbackReturn( 0, 0, 0 );
}
__ENDTRY
RtlRaiseStatus( status );
}
__ASM_GLOBAL_FUNC( "#KiUserCallbackDispatcher",
__ASM_SEH(".seh_pushframe\n\t")
"nop\n\t"
......@@ -1743,7 +1725,12 @@ __ASM_GLOBAL_FUNC( "#KiUserCallbackDispatcher",
__ASM_SEH(".seh_endprologue\n\t")
"ldr x0, [sp]\n\t" /* args */
"ldp w1, w2, [sp, #0x08]\n\t" /* len, id */
"bl " __ASM_NAME("dispatch_callback") "\n\t"
"bl " __ASM_NAME("dispatch_user_callback") "\n\t"
"mov x2, x0\n\t" /* status */
"mov x1, #0\n\t" /* ret_len */
"mov x0, x1\n\t" /* ret_ptr */
"bl " __ASM_NAME("NtCallbackReturn") "\n\t"
"bl " __ASM_NAME("RtlRaiseStatus") "\n\t"
"brk #1" )
......
......@@ -294,21 +294,9 @@ __ASM_STDCALL_FUNC( KiUserApcDispatcher, 20,
*/
void WINAPI KiUserCallbackDispatcher( ULONG id, void *args, ULONG len )
{
NTSTATUS status;
__TRY
{
KERNEL_CALLBACK_PROC func = NtCurrentTeb()->Peb->KernelCallbackTable[id];
status = NtCallbackReturn( NULL, 0, func( args, len ));
}
__EXCEPT_ALL
{
ERR_(seh)( "ignoring exception\n" );
status = NtCallbackReturn( 0, 0, 0 );
}
__ENDTRY
RtlRaiseStatus( status );
NTSTATUS status = dispatch_user_callback( args, len, id );
status = NtCallbackReturn( NULL, 0, status );
for (;;) RtlRaiseStatus( status );
}
......
......@@ -691,24 +691,6 @@ __ASM_GLOBAL_FUNC( KiUserApcDispatcher,
/*******************************************************************
* KiUserCallbackDispatcher (NTDLL.@)
*/
void WINAPI dispatch_callback( void *args, ULONG len, ULONG id )
{
NTSTATUS status;
__TRY
{
KERNEL_CALLBACK_PROC func = NtCurrentTeb()->Peb->KernelCallbackTable[id];
status = NtCallbackReturn( NULL, 0, func( args, len ));
}
__EXCEPT_ALL
{
ERR_(seh)( "ignoring exception\n" );
status = NtCallbackReturn( 0, 0, 0 );
}
__ENDTRY
RtlRaiseStatus( status );
}
__ASM_GLOBAL_FUNC( KiUserCallbackDispatcher,
__ASM_SEH(".seh_pushframe\n\t")
__ASM_SEH(".seh_stackalloc 0x30\n\t")
......@@ -720,7 +702,14 @@ __ASM_GLOBAL_FUNC( KiUserCallbackDispatcher,
"movq 0x20(%rsp),%rcx\n\t" /* args */
"movl 0x28(%rsp),%edx\n\t" /* len */
"movl 0x2c(%rsp),%r8d\n\t" /* id */
"call " __ASM_NAME("dispatch_callback") )
"call " __ASM_NAME("dispatch_user_callback") "\n\t"
"xorq %rcx,%rcx\n\t" /* ret_ptr */
"xorl %edx,%edx\n\t" /* ret_len */
"movl %eax,%r8d\n\t" /* status */
"call " __ASM_NAME("NtCallbackReturn") "\n\t"
"movl %eax,%ecx\n\t" /* status */
"call " __ASM_NAME("RtlRaiseStatus") "\n\t"
"int3" )
/**************************************************************************
......
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