From b9852e83d294f7f047943ca5eaa89e9aa24462d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sun, 22 Sep 2024 21:43:25 +0200 Subject: [PATCH] [NTOS:EX] HACK: on livecd, disable security features in NtSystemDebugControl WinDBG can do some local debugging using 'windbg -kl'. In that case, WinDBG tries to directly use NtSystemDebugControl. If this function returns an error, WinDBG extracts a driver from its resources. WinDBG will send IOCTLs to this driver, and this driver will call KdSystemDebugControl. However, on livecd (where %SYSTEMROOT% is read-only), WinDBG is unable to extract the driver from its resources, and can't use the driver to call KdSystemDebugControl. As a work-around, allow all control classes in NtSystemDebugControl in case of livecd. WinDBG local debugging now also works on livecd (windbg -kl). --- ntoskrnl/ex/dbgctrl.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ntoskrnl/ex/dbgctrl.c b/ntoskrnl/ex/dbgctrl.c index a62345ee692..5ed32619fee 100644 --- a/ntoskrnl/ex/dbgctrl.c +++ b/ntoskrnl/ex/dbgctrl.c @@ -267,7 +267,17 @@ NtSystemDebugControl( case SysDbgWriteBusData: case SysDbgCheckLowMemory: /* Those are implemented in KdSystemDebugControl */ - Status = STATUS_NOT_IMPLEMENTED; + if (InitIsWinPEMode) + { + Status = KdSystemDebugControl(Command, + InputBuffer, InputBufferLength, + OutputBuffer, OutputBufferLength, + &Length, PreviousMode); + } + else + { + Status = STATUS_NOT_IMPLEMENTED; + } break; case SysDbgBreakPoint: