Skip to content

Commit 2995806

Browse files
committed
[NTOS:KD64] kdx64.c: Implement KdpAllowDisable() the same as in x86 (reactos#7538)
AMD64 has the same DR7 register as x86 with the same bits meanings, thus the same implementation can be used. References: - https://en.wikipedia.org/wiki/X86_debug_register#DR7_-_Debug_control - AMD64 Architecture Programmer’s Manual, Volume 2: System Programming https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/24593.pdf Section "13.1.1.4 Debug-Control Register (DR7)" pgs. 393-396 (pgs. 455-458 of the PDF) - Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 3 (3A, 3B, 3C, & 3D): System Programming Guide https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html Section "19.2.4 Debug Control Register (DR7)" (pgs. 644-646) Section "19.2.6 Debug Registers and Intel® 64 Processors" (pg. 647)
1 parent 61feb64 commit 2995806

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

ntoskrnl/kd64/amd64/kdx64.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,21 @@ NTSTATUS
363363
NTAPI
364364
KdpAllowDisable(VOID)
365365
{
366-
UNIMPLEMENTED;
367-
return STATUS_ACCESS_DENIED;
366+
ULONG i;
367+
368+
/* Loop every processor */
369+
for (i = 0; i < KeNumberProcessors; i++)
370+
{
371+
PKPROCESSOR_STATE ProcessorState = &KiProcessorBlock[i]->ProcessorState;
372+
373+
/* If any processor breakpoints are active,
374+
* we can't allow running without a debugger */
375+
if (ProcessorState->SpecialRegisters.KernelDr7 & 0xFF)
376+
return STATUS_ACCESS_DENIED;
377+
}
378+
379+
/* No processor breakpoints, allow disabling the debugger */
380+
return STATUS_SUCCESS;
368381
}
369382

370383
/* EOF */

0 commit comments

Comments
 (0)