From 42e038f227bf0deeb9134e19851bf25d74f6472f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sun, 22 Sep 2024 21:39:09 +0200 Subject: [PATCH] [NTOS:KD64] Implement KdSystemDebugControl: SysDbgReadPhysical/SysDbgWritePhysical --- ntoskrnl/kd64/kdapi.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/ntoskrnl/kd64/kdapi.c b/ntoskrnl/kd64/kdapi.c index f6e375dbc7d..d6506701841 100644 --- a/ntoskrnl/kd64/kdapi.c +++ b/ntoskrnl/kd64/kdapi.c @@ -2335,6 +2335,35 @@ KdSystemDebugControl( case SysDbgReadPhysical: case SysDbgWritePhysical: + if (InputBufferLength != sizeof(SYSDBG_PHYSICAL)) + { + Status = STATUS_INFO_LENGTH_MISMATCH; + } + else + { + SYSDBG_PHYSICAL Request = *(PSYSDBG_PHYSICAL)InputBuffer; + PVOID LockedBuffer; + PMDL LockVariable; + + Status = ExLockUserBuffer(Request.Buffer, + Request.Request, + PreviousMode, + Command == SysDbgReadVirtual ? IoWriteAccess : IoReadAccess, + &LockedBuffer, + &LockVariable); + if (NT_SUCCESS(Status)) + { + Status = KdpCopyMemoryChunks(Request.Address.QuadPart, + Request.Buffer, + Request.Request, + 0, + MMDBG_COPY_PHYSICAL | (Command == SysDbgReadVirtual ? 0 : MMDBG_COPY_WRITE), + &Length); + ExUnlockUserBuffer(LockVariable); + } + } + break; + case SysDbgReadControlSpace: case SysDbgWriteControlSpace: case SysDbgReadIoSpace: