From 123e0dd790ce41bbac96b0ce122e00a6fb547109 Mon Sep 17 00:00:00 2001 From: Nikzad Date: Mon, 17 Aug 2026 22:08:37 +0330 Subject: [PATCH] fixed problem for user i/o instruction --- .../code/debugger/commands/DebuggerCommands.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/hyperdbg/hyperkd/code/debugger/commands/DebuggerCommands.c b/hyperdbg/hyperkd/code/debugger/commands/DebuggerCommands.c index 7b62b2e9..ca8b920f 100644 --- a/hyperdbg/hyperkd/code/debugger/commands/DebuggerCommands.c +++ b/hyperdbg/hyperkd/code/debugger/commands/DebuggerCommands.c @@ -1542,10 +1542,17 @@ DebuggerCommandUserIn(PDEBUGGER_USER_IN_REQUEST_RESPONSE DebuggerUserInRequest) USHORT Port = DebuggerUserInRequest->PortAddress; // - // Zero out memory buffer + // Zero out memory buffer (maybe its not needed, but anyway lets zero out memory, we dont like garbage + // and some weird undefined behavior) // RtlZeroMemory(DebuggerUserInRequest, SIZEOF_DEBUGGER_USER_IN_REQUEST_RESPONSE); + // + // because we zeroed out, everything wiped out! but we need to restore correct values into their related fields + // + DebuggerUserInRequest->UserChosenRegister = Register; + DebuggerUserInRequest->PortAddress = Port; + // // we're already in kernel mode, so there is no need to check for CPL and IOPL, TSS and etc. // @@ -1593,10 +1600,18 @@ DebuggerCommandUserOut(PDEBUGGER_USER_OUT_REQUEST_RESPONSE DebuggerUserOutReques UINT32 Value = DebuggerUserOutRequest->Value; // - // Zero out memory buffer + // Same as IN instruction, zero out memory buffer (maybe its not needed, but anyway lets zero out memory, + // we dont like garbage and some weird undefined behavior) // RtlZeroMemory(DebuggerUserOutRequest, SIZEOF_DEBUGGER_USER_OUT_REQUEST_RESPONSE); + // + // because we zeroed out, everything wiped out! but we need to restore correct values into their related fields + // + DebuggerUserOutRequest->UserChosenRegister = Register; + DebuggerUserOutRequest->PortAddress = Port; + DebuggerUserOutRequest->Value = Value; + // // we're already in kernel mode, so there is no need to check for CPL and IOPL, TSS and etc. //