HyperDbg Debugger
|
routines to kernel debugging More...
#include "pch.h"
Functions | |
BOOLEAN | KdCheckForTheEndOfTheBuffer (PUINT32 CurrentLoopIndex, BYTE *Buffer) |
compares the buffer with a string | |
BOOLEAN | KdCompareBufferWithString (CHAR *Buffer, const CHAR *CompareBuffer) |
compares the buffer with a string | |
BYTE | KdComputeDataChecksum (PVOID Buffer, UINT32 Length) |
calculate the checksum of received buffer from debugger | |
VOID | KdInterpretPausedDebuggee () |
Interpret the packets from debuggee in the case of paused. | |
BOOLEAN | KdSendContinuePacketToDebuggee () |
Sends a continue or 'g' command packet to the debuggee. | |
BOOLEAN | KdSendSwitchCorePacketToDebuggee (UINT32 NewCore) |
Sends a change core or '~ x' command packet to the debuggee. | |
BOOLEAN | KdSendShortCircuitingEventToDebuggee (BOOLEAN IsEnabled) |
Sends a short-circuiting event request to debuggee. | |
BOOLEAN | KdSendEventQueryAndModifyPacketToDebuggee (UINT64 Tag, DEBUGGER_MODIFY_EVENTS_TYPE TypeOfAction, BOOLEAN *IsEnabled) |
Sends a query or request to enable/disable/clear for event. | |
BOOLEAN | KdSendFlushPacketToDebuggee () |
Send a flush request to the debuggee. | |
BOOLEAN | KdSendCallStackPacketToDebuggee (UINT64 BaseAddress, UINT32 Size, DEBUGGER_CALLSTACK_DISPLAY_METHOD DisplayMethod, BOOLEAN Is32Bit) |
Send a callstack request to the debuggee. | |
BOOLEAN | KdSendTestQueryPacketToDebuggee (DEBUGGER_TEST_QUERY_STATE Type) |
Send a test query request to the debuggee. | |
BOOLEAN | KdSendTestQueryPacketWithContextToDebuggee (DEBUGGER_TEST_QUERY_STATE Type, UINT64 Context) |
Send a test query request to the debuggee with the specified context. | |
BOOLEAN | KdSendSymbolReloadPacketToDebuggee (UINT32 ProcessId) |
Send symbol reload packet to the debuggee. | |
BOOLEAN | KdSendReadRegisterPacketToDebuggee (PDEBUGGEE_REGISTER_READ_DESCRIPTION RegDes, UINT32 RegBuffSize) |
Send a read register packet to the debuggee. | |
BOOLEAN | KdSendWriteRegisterPacketToDebuggee (PDEBUGGEE_REGISTER_WRITE_DESCRIPTION RegDes) |
Send a write register packet to the debuggee. | |
BOOLEAN | KdSendReadMemoryPacketToDebuggee (PDEBUGGER_READ_MEMORY ReadMem, UINT32 RequestSize) |
Send a Read memory packet to the debuggee. | |
BOOLEAN | KdSendEditMemoryPacketToDebuggee (PDEBUGGER_EDIT_MEMORY EditMem, UINT32 Size) |
Send an Edit memory packet to the debuggee. | |
PDEBUGGER_EVENT_AND_ACTION_RESULT | KdSendRegisterEventPacketToDebuggee (PDEBUGGER_GENERAL_EVENT_DETAIL Event, UINT32 EventBufferLength) |
Send a register event request to the debuggee. | |
PDEBUGGER_EVENT_AND_ACTION_RESULT | KdSendAddActionToEventPacketToDebuggee (PDEBUGGER_GENERAL_ACTION GeneralAction, UINT32 GeneralActionLength) |
Send an add action to event request to the debuggee. | |
BOOLEAN | KdSendSwitchProcessPacketToDebuggee (DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_TYPE ActionType, UINT32 NewPid, UINT64 NewProcess, BOOLEAN SetChangeByClockInterrupt, PDEBUGGEE_PROCESS_LIST_NEEDED_DETAILS SymDetailsForProcessList) |
Sends a change process or show process details packet to the debuggee. | |
BOOLEAN | KdSendSwitchThreadPacketToDebuggee (DEBUGGEE_DETAILS_AND_SWITCH_THREAD_TYPE ActionType, UINT32 NewTid, UINT64 NewThread, BOOLEAN CheckByClockInterrupt, PDEBUGGEE_THREAD_LIST_NEEDED_DETAILS SymDetailsForThreadList) |
Sends a change thread or show threads detail packet to the debuggee. | |
BOOLEAN | KdSendPtePacketToDebuggee (PDEBUGGER_READ_PAGE_TABLE_ENTRIES_DETAILS PtePacket) |
Sends a PTE or '!pte' command packet to the debuggee. | |
BOOLEAN | KdSendPageinPacketToDebuggee (PDEBUGGER_PAGE_IN_REQUEST PageinPacket) |
Sends a page-in or '.pagein' command packet to the debuggee. | |
BOOLEAN | KdSendVa2paAndPa2vaPacketToDebuggee (PDEBUGGER_VA2PA_AND_PA2VA_COMMANDS Va2paAndPa2vaPacket) |
Sends VA2PA and PA2VA packest, or '!va2pa' and '!pa2va' commands packet to the debuggee. | |
BOOLEAN | KdSendBpPacketToDebuggee (PDEBUGGEE_BP_PACKET BpPacket) |
Sends a breakpoint set or 'bp' command packet to the debuggee. | |
BOOLEAN | KdSendListOrModifyPacketToDebuggee (PDEBUGGEE_BP_LIST_OR_MODIFY_PACKET ListOrModifyPacket) |
Sends a breakpoint list or modification packet to the debuggee. | |
BOOLEAN | KdSendScriptPacketToDebuggee (UINT64 BufferAddress, UINT32 BufferLength, UINT32 Pointer, BOOLEAN IsFormat) |
Sends a script packet to the debuggee. | |
BOOLEAN | KdSendUserInputPacketToDebuggee (const char *Sendbuf, int Len, BOOLEAN IgnoreBreakingAgain) |
Sends user input packet to the debuggee. | |
BOOLEAN | KdSendSearchRequestPacketToDebuggee (UINT64 *SearchRequestBuffer, UINT32 SearchRequestBufferSize) |
Sends search query request packet to the debuggee. | |
BOOLEAN | KdSendStepPacketToDebuggee (DEBUGGER_REMOTE_STEPPING_REQUEST StepRequestType) |
Sends p (step out) and t (step in) packet to the debuggee. | |
BOOLEAN | KdSendPausePacketToDebuggee () |
Sends a PAUSE packet to the debuggee. | |
BOOLEAN | KdGetWindowVersion (CHAR *BufferToSave) |
Get Windows name, version and build to send to debugger. | |
Variables | |
PMODULE_SYMBOL_DETAIL | g_SymbolTable |
The buffer that stores the details of symbol table. | |
UINT32 | g_SymbolTableSize |
The buffer that stores size of the details of symbol table. | |
UINT32 | g_SymbolTableCurrentIndex |
The index to hold the track of added symbols. | |
HANDLE | g_SerialListeningThreadHandle |
In debuggee and debugger, we save the handle of the user-mode listening thread for pauses here. | |
HANDLE | g_SerialRemoteComPortHandle |
In debugger (not debuggee), we save the handle of the user-mode listening thread for remote system here. | |
HANDLE | g_DebuggeeStopCommandEventHandle |
An event to make sure that the user won't give any command in debuggee and all the commands are coming from just the debugger. | |
DEBUGGER_SYNCRONIZATION_EVENTS_STATE | g_KernelSyncronizationObjectsHandleTable [DEBUGGER_MAXIMUM_SYNCRONIZATION_KERNEL_DEBUGGER_OBJECTS] |
In debugger (not debuggee), we save the handle of the user-mode listening thread for pauses here for kernel debugger. | |
BYTE | g_CurrentRunningInstruction [MAXIMUM_INSTR_SIZE] |
Current executing instructions. | |
BOOLEAN | g_IsConnectedToHyperDbgLocally |
Shows whether the user is allowed to use 'load' command to load modules locally in VMI (virtual machine introspection) mode. | |
OVERLAPPED | g_OverlappedIoStructureForReadDebugger |
This is an OVERLAPPED structure for managing simultaneous read and writes for debugger (in current design debuggee is not needed to write simultaneously but it's needed for write) | |
OVERLAPPED | g_OverlappedIoStructureForWriteDebugger |
OVERLAPPED | g_OverlappedIoStructureForReadDebuggee |
DEBUGGER_EVENT_AND_ACTION_RESULT | g_DebuggeeResultOfRegisteringEvent |
Holds the result of registering events from the remote debuggee. | |
DEBUGGER_EVENT_AND_ACTION_RESULT | g_DebuggeeResultOfAddingActionsToEvent |
Holds the result of adding action to events from the remote debuggee. | |
BOOLEAN | g_IsSerialConnectedToRemoteDebuggee |
Shows if the debugger was connected to remote debuggee over (A remote guest) | |
BOOLEAN | g_IsSerialConnectedToRemoteDebugger |
Shows if the debugger was connected to remote debugger (A remote host) | |
BOOLEAN | g_IsDebuggerConntectedToNamedPipe |
Shows if the debugger is connected to the guest using named pipe. | |
BOOLEAN | g_IsDebuggeeRunning |
Shows if the debuggee is running or not. | |
BOOLEAN | g_IsDebuggerModulesLoaded |
this variable is used to indicate that modules are loaded so we make sure to later use a trace of loading in 'unload' command (used in Debugger VMM) | |
BOOLEAN | g_SerialConnectionAlreadyClosed |
In both debuggee and debugger we save the state of the closed connection to avoid double close. | |
BOOLEAN | g_IgnoreNewLoggingMessages |
Shows if the debugger should show debuggee's messages or not. | |
BOOLEAN | g_SharedEventStatus |
Shows whether the queried event is enabled or disabled. | |
BOOLEAN | g_IsRunningInstruction32Bit |
whether the Current executing instructions is 32-bit or 64 bit | |
BOOLEAN | g_IgnorePauseRequests |
Show whether the pause request (CTRL+C or CTRL+BREAK) should be ignored or not. | |
BOOLEAN | g_IsDebuggeeInHandshakingPhase |
Shows if the debuggee is in the handshake phase or not. | |
BOOLEAN | g_ShouldPreviousCommandBeContinued |
Shows whether the previous command should be continued or not. | |
BYTE | g_EndOfBufferCheckSerial [4] |
the buffer that we set at the end of buffers for serial | |
ULONG | g_CurrentRemoteCore |
Current core that the debuggee is debugging. | |
routines to kernel debugging
compares the buffer with a string
CurrentLoopIndex | Number of previously read bytes |
Buffer |
calculate the checksum of received buffer from debugger
Buffer | |
LengthReceived |
Get Windows name, version and build to send to debugger.
BufferToSave |
VOID KdInterpretPausedDebuggee | ( | ) |
Interpret the packets from debuggee in the case of paused.
PDEBUGGER_EVENT_AND_ACTION_RESULT KdSendAddActionToEventPacketToDebuggee | ( | PDEBUGGER_GENERAL_ACTION | GeneralAction, |
UINT32 | GeneralActionLength ) |
Send an add action to event request to the debuggee.
as this command uses one global variable to transfer the buffers so should not be called simultaneously
GeneralAction | |
GeneralActionLength |
BOOLEAN KdSendBpPacketToDebuggee | ( | PDEBUGGEE_BP_PACKET | BpPacket | ) |
Sends a breakpoint set or 'bp' command packet to the debuggee.
BpPacket |
BOOLEAN KdSendCallStackPacketToDebuggee | ( | UINT64 | BaseAddress, |
UINT32 | Size, | ||
DEBUGGER_CALLSTACK_DISPLAY_METHOD | DisplayMethod, | ||
BOOLEAN | Is32Bit ) |
Send a callstack request to the debuggee.
BaseAddress | |
Size | |
DisplayMethod | |
Is32Bit |
BOOLEAN KdSendContinuePacketToDebuggee | ( | ) |
Sends a continue or 'g' command packet to the debuggee.
BOOLEAN KdSendEditMemoryPacketToDebuggee | ( | PDEBUGGER_EDIT_MEMORY | EditMem, |
UINT32 | Size ) |
Send an Edit memory packet to the debuggee.
EditMem | |
Size |
BOOLEAN KdSendEventQueryAndModifyPacketToDebuggee | ( | UINT64 | Tag, |
DEBUGGER_MODIFY_EVENTS_TYPE | TypeOfAction, | ||
BOOLEAN * | IsEnabled ) |
Sends a query or request to enable/disable/clear for event.
if IsQueryState is TRUE then TypeOfAction is ignored
Tag | |
TypeOfAction | |
IsEnabled | If it's a query state then this argument can be used |
BOOLEAN KdSendFlushPacketToDebuggee | ( | ) |
Send a flush request to the debuggee.
BOOLEAN KdSendListOrModifyPacketToDebuggee | ( | PDEBUGGEE_BP_LIST_OR_MODIFY_PACKET | ListOrModifyPacket | ) |
Sends a breakpoint list or modification packet to the debuggee.
ListOrModifyPacket |
BOOLEAN KdSendPageinPacketToDebuggee | ( | PDEBUGGER_PAGE_IN_REQUEST | PageinPacket | ) |
Sends a page-in or '.pagein' command packet to the debuggee.
PageinPacket |
BOOLEAN KdSendPausePacketToDebuggee | ( | ) |
Sends a PAUSE packet to the debuggee.
BOOLEAN KdSendPtePacketToDebuggee | ( | PDEBUGGER_READ_PAGE_TABLE_ENTRIES_DETAILS | PtePacket | ) |
Sends a PTE or '!pte' command packet to the debuggee.
PtePacket |
BOOLEAN KdSendReadMemoryPacketToDebuggee | ( | PDEBUGGER_READ_MEMORY | ReadMem, |
UINT32 | RequestSize ) |
Send a Read memory packet to the debuggee.
ReadMem | |
Size |
BOOLEAN KdSendReadRegisterPacketToDebuggee | ( | PDEBUGGEE_REGISTER_READ_DESCRIPTION | RegDes, |
UINT32 | RegBuffSize ) |
Send a read register packet to the debuggee.
RegDes | |
RegBuffSize |
PDEBUGGER_EVENT_AND_ACTION_RESULT KdSendRegisterEventPacketToDebuggee | ( | PDEBUGGER_GENERAL_EVENT_DETAIL | Event, |
UINT32 | EventBufferLength ) |
Send a register event request to the debuggee.
as this command uses one global variable to transfer the buffers so should not be called simultaneously
Event | |
EventBufferLength |
BOOLEAN KdSendScriptPacketToDebuggee | ( | UINT64 | BufferAddress, |
UINT32 | BufferLength, | ||
UINT32 | Pointer, | ||
BOOLEAN | IsFormat ) |
Sends a script packet to the debuggee.
BufferAddress | |
BufferLength | |
Pointer | |
IsFormat |
BOOLEAN KdSendSearchRequestPacketToDebuggee | ( | UINT64 * | SearchRequestBuffer, |
UINT32 | SearchRequestBufferSize ) |
Sends search query request packet to the debuggee.
SearchRequestBuffer | |
SearchRequestBufferSize |
Sends a short-circuiting event request to debuggee.
IsEnabled |
BOOLEAN KdSendStepPacketToDebuggee | ( | DEBUGGER_REMOTE_STEPPING_REQUEST | StepRequestType | ) |
Sends p (step out) and t (step in) packet to the debuggee.
Sends a change core or '~ x' command packet to the debuggee.
BOOLEAN KdSendSwitchProcessPacketToDebuggee | ( | DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_TYPE | ActionType, |
UINT32 | NewPid, | ||
UINT64 | NewProcess, | ||
BOOLEAN | SetChangeByClockInterrupt, | ||
PDEBUGGEE_PROCESS_LIST_NEEDED_DETAILS | SymDetailsForProcessList ) |
Sends a change process or show process details packet to the debuggee.
ActionType | |
NewPid | |
NewProcess | |
SetChangeByClockInterrupt | |
SymDetailsForProcessList |
BOOLEAN KdSendSwitchThreadPacketToDebuggee | ( | DEBUGGEE_DETAILS_AND_SWITCH_THREAD_TYPE | ActionType, |
UINT32 | NewTid, | ||
UINT64 | NewThread, | ||
BOOLEAN | CheckByClockInterrupt, | ||
PDEBUGGEE_THREAD_LIST_NEEDED_DETAILS | SymDetailsForThreadList ) |
Sends a change thread or show threads detail packet to the debuggee.
ActionType | |
NewTid | |
NewThread | |
CheckByClockInterrupt | |
SymDetailsForThreadList |
Send symbol reload packet to the debuggee.
BOOLEAN KdSendTestQueryPacketToDebuggee | ( | DEBUGGER_TEST_QUERY_STATE | Type | ) |
Send a test query request to the debuggee.
Type |
BOOLEAN KdSendTestQueryPacketWithContextToDebuggee | ( | DEBUGGER_TEST_QUERY_STATE | Type, |
UINT64 | Context ) |
Send a test query request to the debuggee with the specified context.
Type | |
Context |
BOOLEAN KdSendUserInputPacketToDebuggee | ( | const char * | Sendbuf, |
int | Len, | ||
BOOLEAN | IgnoreBreakingAgain ) |
Sends user input packet to the debuggee.
Sendbuf | |
Len | |
IgnoreBreakingAgain |
BOOLEAN KdSendVa2paAndPa2vaPacketToDebuggee | ( | PDEBUGGER_VA2PA_AND_PA2VA_COMMANDS | Va2paAndPa2vaPacket | ) |
Sends VA2PA and PA2VA packest, or '!va2pa' and '!pa2va' commands packet to the debuggee.
Va2paAndPa2vaPacket |
BOOLEAN KdSendWriteRegisterPacketToDebuggee | ( | PDEBUGGEE_REGISTER_WRITE_DESCRIPTION | RegDes | ) |
Send a write register packet to the debuggee.
RegDes |
|
extern |
Current core that the debuggee is debugging.
|
extern |
Current executing instructions.
|
extern |
Holds the result of adding action to events from the remote debuggee.
|
extern |
Holds the result of registering events from the remote debuggee.
|
extern |
An event to make sure that the user won't give any command in debuggee and all the commands are coming from just the debugger.
|
extern |
the buffer that we set at the end of buffers for serial
|
extern |
Shows if the debugger should show debuggee's messages or not.
|
extern |
Show whether the pause request (CTRL+C or CTRL+BREAK) should be ignored or not.
|
extern |
Shows whether the user is allowed to use 'load' command to load modules locally in VMI (virtual machine introspection) mode.
|
extern |
Shows if the debuggee is in the handshake phase or not.
|
extern |
Shows if the debuggee is running or not.
|
extern |
Shows if the debugger is connected to the guest using named pipe.
|
extern |
this variable is used to indicate that modules are loaded so we make sure to later use a trace of loading in 'unload' command (used in Debugger VMM)
|
extern |
whether the Current executing instructions is 32-bit or 64 bit
|
extern |
Shows if the debugger was connected to remote debuggee over (A remote guest)
|
extern |
Shows if the debugger was connected to remote debugger (A remote host)
|
extern |
In debugger (not debuggee), we save the handle of the user-mode listening thread for pauses here for kernel debugger.
|
extern |
|
extern |
This is an OVERLAPPED structure for managing simultaneous read and writes for debugger (in current design debuggee is not needed to write simultaneously but it's needed for write)
|
extern |
|
extern |
In both debuggee and debugger we save the state of the closed connection to avoid double close.
|
extern |
In debuggee and debugger, we save the handle of the user-mode listening thread for pauses here.
|
extern |
In debugger (not debuggee), we save the handle of the user-mode listening thread for remote system here.
|
extern |
Shows whether the queried event is enabled or disabled.
|
extern |
Shows whether the previous command should be continued or not.
|
extern |
The buffer that stores the details of symbol table.
|
extern |
The index to hold the track of added symbols.
|
extern |
The buffer that stores size of the details of symbol table.