From 8e26b7e0077dc3eab5d3ce9fc322e1484f31824f Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 27 Feb 2024 16:48:25 +0100 Subject: [PATCH] ntdll: Use a .seh handler in DbgUiRemoteBreakin on ARM64EC. --- dlls/ntdll/signal_arm64ec.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/dlls/ntdll/signal_arm64ec.c b/dlls/ntdll/signal_arm64ec.c index a2b21f51ead..5fc4b113a97 100644 --- a/dlls/ntdll/signal_arm64ec.c +++ b/dlls/ntdll/signal_arm64ec.c @@ -1792,26 +1792,30 @@ __ASM_GLOBAL_FUNC( "#process_breakpoint", "mov w0, #0\n\t" /* ExceptionContinueExecution */ "ret" ) + /*********************************************************************** * DbgUiRemoteBreakin (NTDLL.@) */ -void WINAPI DbgUiRemoteBreakin( void *arg ) +void __attribute__((naked)) DbgUiRemoteBreakin( void *arg ) { - if (NtCurrentTeb()->Peb->BeingDebugged) - { - __TRY - { - DbgBreakPoint(); - } - __EXCEPT_ALL - { - /* do nothing */ - } - __ENDTRY - } - RtlExitUserThread( STATUS_SUCCESS ); + asm( ".seh_proc DbgUiRemoteBreakin\n\t" + "stp x29, x30, [sp, #-16]!\n\t" + ".seh_save_fplr_x 16\n\t" + ".seh_endprologue\n\t" + ".seh_handler DbgUiRemoteBreakin_handler, @except\n\t" + "ldr x0, [x18, #0x60]\n\t" /* NtCurrentTeb()->Peb */ + "ldrb w0, [x0, 0x02]\n\t" /* peb->BeingDebugged */ + "cbz w0, 1f\n\t" + "bl DbgBreakPoint\n" + "1:\tmov w0, #0\n\t" + "bl RtlExitUserThread\n" + "DbgUiRemoteBreakin_handler:\n\t" + "mov sp, x1\n\t" /* frame */ + "b 1b\n\t" + ".seh_endproc" ); } + /********************************************************************** * DbgBreakPoint (NTDLL.@) */