From 005f75bd61d9c1cf08d702dbae6ff4b38ab089ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 19 Apr 2025 18:00:12 +0200 Subject: [PATCH] [RTL] x64/ARM: Alias RtlpBreakWithStatusInstruction to DbgBreakPointWithStatus; x64: fix a bug. RtlpBreakWithStatusInstruction is just a label for KD. On machines that have register calling conventions (basically all except x86), the `Status` parameter for `DbgBreakPointWithStatus` is stored in the first argument register. https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-dbgbreakpointwithstatus On the x64 platform, `DbgBreakPointWithStatus` only uses the ECX register and leaves EAX untouched. Verified on Windows. --- sdk/lib/rtl/amd64/debug_asm.S | 21 +++++++-------------- sdk/lib/rtl/arm/debug_asm.S | 6 +----- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/sdk/lib/rtl/amd64/debug_asm.S b/sdk/lib/rtl/amd64/debug_asm.S index 00cbe7163bd..7db8e89d122 100644 --- a/sdk/lib/rtl/amd64/debug_asm.S +++ b/sdk/lib/rtl/amd64/debug_asm.S @@ -8,37 +8,29 @@ #include -/* GLOBALS ****************************************************************/ - -PUBLIC DbgBreakPoint -PUBLIC DbgBreakPointWithStatus -PUBLIC DbgUserBreakPoint -PUBLIC DebugService -PUBLIC DebugService2 -PUBLIC RtlpBreakWithStatusInstruction - /* FUNCTIONS ***************************************************************/ .code64 +PUBLIC DbgUserBreakPoint DbgUserBreakPoint: +PUBLIC DbgBreakPoint .PROC DbgBreakPoint .endprolog int 3 ret .ENDP +PUBLIC RtlpBreakWithStatusInstruction +RtlpBreakWithStatusInstruction: +PUBLIC DbgBreakPointWithStatus .PROC DbgBreakPointWithStatus - .endprolog - mov eax, ecx -.ENDP - -.PROC RtlpBreakWithStatusInstruction .endprolog int 3 ret .ENDP +PUBLIC DebugService2 DebugService2: /* Pass the service number in eax */ @@ -56,6 +48,7 @@ DebugService2: * IN PVOID Argument1, // = [rsp + 32] * IN PVOID Argument2); // [rsp + 40] */ +PUBLIC DebugService DebugService: /* Prepare registers for interrupt */ diff --git a/sdk/lib/rtl/arm/debug_asm.S b/sdk/lib/rtl/arm/debug_asm.S index c223edcb344..21e21269020 100644 --- a/sdk/lib/rtl/arm/debug_asm.S +++ b/sdk/lib/rtl/arm/debug_asm.S @@ -21,11 +21,7 @@ LEAF_END DbgUserBreakPoint LEAF_ENTRY DbgBreakPointWithStatus - __debugbreak - bx lr - LEAF_END - - LEAF_ENTRY RtlpBreakWithStatusInstruction + ALTERNATE_ENTRY RtlpBreakWithStatusInstruction __debugbreak bx lr LEAF_END