[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.
This commit is contained in:
Hermès Bélusca-Maïto 2025-04-19 18:00:12 +02:00
parent a7d86fe3a7
commit 005f75bd61
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 8 additions and 19 deletions

View file

@ -8,37 +8,29 @@
#include <asm.inc> #include <asm.inc>
/* GLOBALS ****************************************************************/
PUBLIC DbgBreakPoint
PUBLIC DbgBreakPointWithStatus
PUBLIC DbgUserBreakPoint
PUBLIC DebugService
PUBLIC DebugService2
PUBLIC RtlpBreakWithStatusInstruction
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
.code64 .code64
PUBLIC DbgUserBreakPoint
DbgUserBreakPoint: DbgUserBreakPoint:
PUBLIC DbgBreakPoint
.PROC DbgBreakPoint .PROC DbgBreakPoint
.endprolog .endprolog
int 3 int 3
ret ret
.ENDP .ENDP
PUBLIC RtlpBreakWithStatusInstruction
RtlpBreakWithStatusInstruction:
PUBLIC DbgBreakPointWithStatus
.PROC DbgBreakPointWithStatus .PROC DbgBreakPointWithStatus
.endprolog
mov eax, ecx
.ENDP
.PROC RtlpBreakWithStatusInstruction
.endprolog .endprolog
int 3 int 3
ret ret
.ENDP .ENDP
PUBLIC DebugService2
DebugService2: DebugService2:
/* Pass the service number in eax */ /* Pass the service number in eax */
@ -56,6 +48,7 @@ DebugService2:
* IN PVOID Argument1, // <r9> = [rsp + 32] * IN PVOID Argument1, // <r9> = [rsp + 32]
* IN PVOID Argument2); // [rsp + 40] * IN PVOID Argument2); // [rsp + 40]
*/ */
PUBLIC DebugService
DebugService: DebugService:
/* Prepare registers for interrupt */ /* Prepare registers for interrupt */

View file

@ -21,11 +21,7 @@
LEAF_END DbgUserBreakPoint LEAF_END DbgUserBreakPoint
LEAF_ENTRY DbgBreakPointWithStatus LEAF_ENTRY DbgBreakPointWithStatus
__debugbreak ALTERNATE_ENTRY RtlpBreakWithStatusInstruction
bx lr
LEAF_END
LEAF_ENTRY RtlpBreakWithStatusInstruction
__debugbreak __debugbreak
bx lr bx lr
LEAF_END LEAF_END