HyperDbg Debugger
Loading...
Searching...
No Matches
kd.cpp File Reference

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.
 

Detailed Description

routines to kernel debugging

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.1
Date
2020-12-22

Function Documentation

◆ KdCheckForTheEndOfTheBuffer()

BOOLEAN KdCheckForTheEndOfTheBuffer ( PUINT32 CurrentLoopIndex,
BYTE * Buffer )

compares the buffer with a string

Parameters
CurrentLoopIndexNumber of previously read bytes
Buffer
Returns
BOOLEAN
57{
58 UINT32 ActualBufferLength;
59
60 ActualBufferLength = *CurrentLoopIndex;
61
62 //
63 // End of buffer is 4 character long
64 //
65 if (*CurrentLoopIndex <= 3)
66 {
67 return FALSE;
68 }
69
70 if (Buffer[ActualBufferLength] == SERIAL_END_OF_BUFFER_CHAR_4 &&
71 Buffer[ActualBufferLength - 1] == SERIAL_END_OF_BUFFER_CHAR_3 &&
72 Buffer[ActualBufferLength - 2] == SERIAL_END_OF_BUFFER_CHAR_2 &&
73 Buffer[ActualBufferLength - 3] == SERIAL_END_OF_BUFFER_CHAR_1)
74 {
75 //
76 // Clear the end character
77 //
78 Buffer[ActualBufferLength - 3] = NULL;
79 Buffer[ActualBufferLength - 2] = NULL;
80 Buffer[ActualBufferLength - 1] = NULL;
81 Buffer[ActualBufferLength] = NULL;
82
83 //
84 // Set the new length
85 //
86 *CurrentLoopIndex = ActualBufferLength - 3;
87
88 return TRUE;
89 }
90 return FALSE;
91}
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned int UINT32
Definition BasicTypes.h:48
#define SERIAL_END_OF_BUFFER_CHAR_4
Definition Constants.h:435
#define SERIAL_END_OF_BUFFER_CHAR_2
Definition Constants.h:433
#define SERIAL_END_OF_BUFFER_CHAR_1
characters of the buffer that we set at the end of buffers for serial
Definition Constants.h:432
#define SERIAL_END_OF_BUFFER_CHAR_3
Definition Constants.h:434
NULL()
Definition test-case-generator.py:530

◆ KdCompareBufferWithString()

BOOLEAN KdCompareBufferWithString ( CHAR * Buffer,
const CHAR * CompareBuffer )

compares the buffer with a string

Parameters
Buffer
CompareBuffer
Returns
BOOLEAN
102{
103 int Result;
104
105 Result = strcmp(Buffer, CompareBuffer);
106
107 if (Result == 0)
108 return TRUE;
109 else
110 return FALSE;
111}

◆ KdComputeDataChecksum()

BYTE KdComputeDataChecksum ( PVOID Buffer,
UINT32 Length )

calculate the checksum of received buffer from debugger

Parameters
Buffer
LengthReceived
Returns
BYTE
122{
123 BYTE CalculatedCheckSum = 0;
124 BYTE Temp = 0;
125 while (Length--)
126 {
127 Temp = *(BYTE *)Buffer;
128 CalculatedCheckSum = CalculatedCheckSum + Temp;
129 Buffer = (PVOID)((UINT64)Buffer + 1);
130 }
131 return CalculatedCheckSum;
132}
unsigned char BYTE
Definition BasicTypes.h:24
unsigned __int64 UINT64
Definition BasicTypes.h:21

◆ KdGetWindowVersion()

BOOLEAN KdGetWindowVersion ( CHAR * BufferToSave)

Get Windows name, version and build to send to debugger.

Parameters
BufferToSave
Returns
BOOLEAN

◆ KdInterpretPausedDebuggee()

VOID KdInterpretPausedDebuggee ( )

Interpret the packets from debuggee in the case of paused.

Returns
VOID
141{
142 //
143 // Wait for handshake to complete or in other words
144 // get the receive packet
145 //
147}
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PAUSED_DEBUGGEE_DETAILS
Definition debugger.h:34
#define DbgWaitForKernelResponse(KernelSyncObjectId)
Definition kd.h:18

◆ KdSendAddActionToEventPacketToDebuggee()

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

Parameters
GeneralAction
GeneralActionLength
Returns
PDEBUGGER_EVENT_AND_ACTION_RESULT
739{
741 UINT32 Len;
742
743 Len = GeneralActionLength +
745
747
748 if (Header == NULL)
749 {
750 return NULL;
751 }
752
753 RtlZeroMemory(Header, Len);
754
755 //
756 // Set length in header
757 //
758 Header->Length = GeneralActionLength;
759
760 //
761 // Move buffer
762 //
763 memcpy((PVOID)((UINT64)Header +
765 (PVOID)GeneralAction,
766 GeneralActionLength);
767
770
771 //
772 // Send add action to event packet
773 //
777 (CHAR *)Header,
778 Len))
779 {
780 free(Header);
781 return NULL;
782 }
783
784 //
785 // Wait until the result of adding action to event received
786 //
788
789 free(Header);
790
792}
char CHAR
Definition BasicTypes.h:31
@ DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGER_TO_DEBUGGEE_EXECUTE_ON_VMX_ROOT
Definition Connection.h:154
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_ADD_ACTION_TO_EVENT
Definition Connection.h:86
struct _DEBUGGEE_EVENT_AND_ACTION_HEADER_FOR_REMOTE_PACKET DEBUGGEE_EVENT_AND_ACTION_HEADER_FOR_REMOTE_PACKET
The structure of user-input packet in HyperDbg.
struct _DEBUGGEE_EVENT_AND_ACTION_HEADER_FOR_REMOTE_PACKET * PDEBUGGEE_EVENT_AND_ACTION_HEADER_FOR_REMOTE_PACKET
DEBUGGER_EVENT_AND_ACTION_RESULT g_DebuggeeResultOfAddingActionsToEvent
Holds the result of adding action to events from the remote debuggee.
Definition globals.h:289
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_ADD_ACTION_TO_EVENT
Definition debugger.h:43
BOOLEAN KdCommandPacketAndBufferToDebuggee(DEBUGGER_REMOTE_PACKET_TYPE PacketType, DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION RequestedAction, CHAR *Buffer, UINT32 BufferLength)
The structure of user-input packet in HyperDbg.
Definition DataTypes.h:156
Status of register buffers.
Definition Events.h:423

◆ KdSendBpPacketToDebuggee()

BOOLEAN KdSendBpPacketToDebuggee ( PDEBUGGEE_BP_PACKET BpPacket)

Sends a breakpoint set or 'bp' command packet to the debuggee.

Parameters
BpPacket
Returns
BOOLEAN
995{
996 //
997 // Send 'bp' as a breakpoint packet
998 //
1002 (CHAR *)BpPacket,
1003 sizeof(DEBUGGEE_BP_PACKET)))
1004 {
1005 return FALSE;
1006 }
1007
1008 //
1009 // Wait until the result of putting breakpoint is received
1010 //
1012
1013 return TRUE;
1014}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_BP
Definition Connection.h:91
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_BP
Definition debugger.h:46
The structure of bp command packet in HyperDbg.
Definition RequestStructures.h:1060

◆ KdSendCallStackPacketToDebuggee()

BOOLEAN KdSendCallStackPacketToDebuggee ( UINT64 BaseAddress,
UINT32 Size,
DEBUGGER_CALLSTACK_DISPLAY_METHOD DisplayMethod,
BOOLEAN Is32Bit )

Send a callstack request to the debuggee.

Parameters
BaseAddress
Size
DisplayMethod
Is32Bit
Returns
BOOLEAN
352{
353 UINT32 FrameCount;
354 UINT32 CallstackRequestSize = 0;
355 PDEBUGGER_CALLSTACK_REQUEST CallstackPacket = NULL;
356
357 if (Size == 0)
358 {
359 return FALSE;
360 }
361
362 if (Is32Bit)
363 {
364 FrameCount = Size / sizeof(UINT32);
365 }
366 else
367 {
368 FrameCount = Size / sizeof(UINT64);
369 }
370
371 CallstackRequestSize = sizeof(DEBUGGER_CALLSTACK_REQUEST) + (sizeof(DEBUGGER_SINGLE_CALLSTACK_FRAME) * FrameCount);
372
373 //
374 // Allocate buffer for request
375 //
376 CallstackPacket = (PDEBUGGER_CALLSTACK_REQUEST)malloc(CallstackRequestSize);
377
378 if (CallstackPacket == NULL)
379 {
380 return FALSE;
381 }
382
383 RtlZeroMemory(CallstackPacket, CallstackRequestSize);
384
385 //
386 // Set the details
387 //
388 CallstackPacket->BaseAddress = BaseAddress;
389 CallstackPacket->Is32Bit = Is32Bit;
390 CallstackPacket->Size = Size;
391 CallstackPacket->BufferSize = CallstackRequestSize;
392 CallstackPacket->FrameCount = FrameCount;
393 CallstackPacket->DisplayMethod = DisplayMethod;
394
395 //
396 // Send 'k' command as callstack request packet
397 //
401 (CHAR *)CallstackPacket,
402 CallstackRequestSize))
403 {
404 free(CallstackPacket);
405 return FALSE;
406 }
407
408 //
409 // Wait until the result of callstack is received
410 //
412
413 free(CallstackPacket);
414 return TRUE;
415}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CALLSTACK
Definition Connection.h:78
struct _DEBUGGER_CALLSTACK_REQUEST * PDEBUGGER_CALLSTACK_REQUEST
struct _DEBUGGER_CALLSTACK_REQUEST DEBUGGER_CALLSTACK_REQUEST
request for callstack frames
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_CALLSTACK_RESULT
Definition debugger.h:52
request for callstack frames
Definition RequestStructures.h:789
UINT32 Size
Definition RequestStructures.h:793
UINT32 FrameCount
Definition RequestStructures.h:794
UINT64 BufferSize
Definition RequestStructures.h:796
BOOLEAN Is32Bit
Definition RequestStructures.h:790
DEBUGGER_CALLSTACK_DISPLAY_METHOD DisplayMethod
Definition RequestStructures.h:792
UINT64 BaseAddress
Definition RequestStructures.h:795
The structure for saving the callstack frame of one parameter.
Definition RequestStructures.h:761

◆ KdSendContinuePacketToDebuggee()

BOOLEAN KdSendContinuePacketToDebuggee ( )

Sends a continue or 'g' command packet to the debuggee.

Returns
BOOLEAN
156{
157 //
158 // No core
159 //
161
162 //
163 // Send 'g' as continue packet
164 //
168 {
169 return FALSE;
170 }
171
172 return TRUE;
173}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CONTINUE
Definition Connection.h:74
#define DEBUGGER_DEBUGGEE_IS_RUNNING_NO_CORE
Apply the event to all the cores.
Definition Constants.h:605
ULONG g_CurrentRemoteCore
Current core that the debuggee is debugging.
Definition globals.h:263
BOOLEAN KdCommandPacketToDebuggee(DEBUGGER_REMOTE_PACKET_TYPE PacketType, DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION RequestedAction)

◆ KdSendEditMemoryPacketToDebuggee()

BOOLEAN KdSendEditMemoryPacketToDebuggee ( PDEBUGGER_EDIT_MEMORY EditMem,
UINT32 Size )

Send an Edit memory packet to the debuggee.

Parameters
EditMem
Size
Returns
BOOLEAN
634{
635 //
636 // Set the request data
637 //
639
640 //
641 // Send d command as read memory packet
642 //
646 (CHAR *)EditMem,
647 Size))
648 {
649 return FALSE;
650 }
651
652 //
653 // Wait until the result of read registers received
654 //
656
657 return TRUE;
658}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_EDIT_MEMORY
Definition Connection.h:90
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_EDIT_MEMORY
Definition debugger.h:49
#define DbgWaitSetRequestData(KernelSyncObjectId, ReqData, ReqSize)
Definition kd.h:29
request for edit virtual and physical memory
Definition RequestStructures.h:482

◆ KdSendEventQueryAndModifyPacketToDebuggee()

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

Parameters
Tag
TypeOfAction
IsEnabledIf it's a query state then this argument can be used
Returns
BOOLEAN
269{
270 DEBUGGER_MODIFY_EVENTS ModifyAndQueryEventPacket = {0};
271
273
274 //
275 // Fill the structure of packet
276 //
277 ModifyAndQueryEventPacket.Tag = Tag;
278 ModifyAndQueryEventPacket.TypeOfAction = TypeOfAction;
279
280 //
281 // Send modify and query event packet
282 //
286 (CHAR *)&ModifyAndQueryEventPacket,
287 sizeof(DEBUGGER_MODIFY_EVENTS)))
288 {
289 return FALSE;
290 }
291
292 //
293 // Wait until the result of query and modify event is received
294 //
296
297 if (TypeOfAction == DEBUGGER_MODIFY_EVENTS_QUERY_STATE)
298 {
299 //
300 // We should read the results to set IsEnabled variable
301 //
302 *IsEnabled = g_SharedEventStatus;
303 }
304
305 return TRUE;
306}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_QUERY_AND_MODIFY_EVENT
Definition Connection.h:87
POOL_TYPE SIZE_T ULONG Tag
Definition Hooks.h:168
@ DEBUGGER_MODIFY_EVENTS_QUERY_STATE
Definition Events.h:231
BOOLEAN g_SharedEventStatus
Shows whether the queried event is enabled or disabled.
Definition globals.h:307
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_MODIFY_AND_QUERY_EVENT
Definition debugger.h:44
request for modifying events (enable/disable/clear)
Definition Events.h:242
DEBUGGER_MODIFY_EVENTS_TYPE TypeOfAction
Definition Events.h:246
UINT64 Tag
Definition Events.h:243

◆ KdSendFlushPacketToDebuggee()

BOOLEAN KdSendFlushPacketToDebuggee ( )

Send a flush request to the debuggee.

Returns
BOOLEAN
315{
316 DEBUGGER_FLUSH_LOGGING_BUFFERS FlushPacket = {0};
317
318 //
319 // Send 'flush' command as flush packet
320 //
324 (CHAR *)&FlushPacket,
326 {
327 return FALSE;
328 }
329
330 //
331 // Wait until the result of flushing received
332 //
334
335 return TRUE;
336}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_FLUSH_BUFFERS
Definition Connection.h:77
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_FLUSH_RESULT
Definition debugger.h:41
request for flushing buffers
Definition RequestStructures.h:294

◆ KdSendListOrModifyPacketToDebuggee()

BOOLEAN KdSendListOrModifyPacketToDebuggee ( PDEBUGGEE_BP_LIST_OR_MODIFY_PACKET ListOrModifyPacket)

Sends a breakpoint list or modification packet to the debuggee.

Parameters
ListOrModifyPacket
Returns
BOOLEAN
1025{
1026 //
1027 // Send list or modify breakpoint packet
1028 //
1032 (CHAR *)ListOrModifyPacket,
1034 {
1035 return FALSE;
1036 }
1037
1038 //
1039 // Wait until the result of listing or modifying breakpoints is received
1040 //
1042
1043 return TRUE;
1044}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_LIST_OR_MODIFY_BREAKPOINTS
Definition Connection.h:92
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_LIST_OR_MODIFY_BREAKPOINTS
Definition debugger.h:47
The structure of breakpoint modification requests packet in HyperDbg.
Definition RequestStructures.h:1090

◆ KdSendPageinPacketToDebuggee()

BOOLEAN KdSendPageinPacketToDebuggee ( PDEBUGGER_PAGE_IN_REQUEST PageinPacket)

Sends a page-in or '.pagein' command packet to the debuggee.

Parameters
PageinPacket
Returns
BOOLEAN
937{
938 //
939 // Send the '.pagein' packet
940 //
944 (CHAR *)PageinPacket,
946 {
947 return FALSE;
948 }
949
950 //
951 // Wait until the result of page-in packet is received
952 //
954
955 return TRUE;
956}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_INJECT_PAGE_FAULT
Definition Connection.h:97
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PAGE_IN_STATE
Definition debugger.h:57
requests for the '.pagein' command
Definition RequestStructures.h:73

◆ KdSendPausePacketToDebuggee()

BOOLEAN KdSendPausePacketToDebuggee ( )

Sends a PAUSE packet to the debuggee.

Returns
BOOLEAN
1288{
1289 //
1290 // Send the pause packet to debuggee
1291 //
1295 {
1296 return FALSE;
1297 }
1298
1299 //
1300 // Handle the paused state (show rip, instructions, etc.)
1301 //
1303
1304 return TRUE;
1305}
@ DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGER_TO_DEBUGGEE_EXECUTE_ON_USER_MODE
Definition Connection.h:159
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_USER_MODE_PAUSE
Definition Connection.h:61
VOID KdInterpretPausedDebuggee()
Interpret the packets from debuggee in the case of paused.
Definition kd.cpp:140

◆ KdSendPtePacketToDebuggee()

BOOLEAN KdSendPtePacketToDebuggee ( PDEBUGGER_READ_PAGE_TABLE_ENTRIES_DETAILS PtePacket)

Sends a PTE or '!pte' command packet to the debuggee.

Parameters
PtePacket
Returns
BOOLEAN
908{
909 //
910 // Send the '!pte' packet
911 //
915 (CHAR *)PtePacket,
917 {
918 return FALSE;
919 }
920
921 //
922 // Wait until the result of PTE packet is received
923 //
925
926 return TRUE;
927}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_SYMBOL_QUERY_PTE
Definition Connection.h:95
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PTE_RESULT
Definition debugger.h:55
request for !pte command
Definition RequestStructures.h:22

◆ KdSendReadMemoryPacketToDebuggee()

BOOLEAN KdSendReadMemoryPacketToDebuggee ( PDEBUGGER_READ_MEMORY ReadMem,
UINT32 RequestSize )

Send a Read memory packet to the debuggee.

Parameters
ReadMem
Size
Returns
BOOLEAN
598{
599 //
600 // Set the request data
601 //
603
604 //
605 // Send u-d command as read memory packet
606 //
610 (CHAR *)ReadMem,
611 sizeof(DEBUGGER_READ_MEMORY) // only the header is enough, no need to send the entire buffer
612 ))
613 {
614 return FALSE;
615 }
616
617 //
618 // Wait until the result of read registers received
619 //
621
622 return TRUE;
623}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_READ_MEMORY
Definition Connection.h:89
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_READ_MEMORY
Definition debugger.h:48
request for reading virtual and physical memory
Definition RequestStructures.h:266

◆ KdSendReadRegisterPacketToDebuggee()

BOOLEAN KdSendReadRegisterPacketToDebuggee ( PDEBUGGEE_REGISTER_READ_DESCRIPTION RegDes,
UINT32 RegBuffSize )

Send a read register packet to the debuggee.

Parameters
RegDes
RegBuffSize
Returns
BOOLEAN
528{
529 //
530 // Set the request data
531 //
533
534 //
535 // Send the 'r' command as read register packet
536 //
540 (CHAR *)RegDes,
541 sizeof(DEBUGGEE_REGISTER_READ_DESCRIPTION) // only the header is enough, no need to send the entire buffer
542 ))
543 {
544 return FALSE;
545 }
546
547 //
548 // Wait until the result of read registers received
549 //
551
552 return TRUE;
553}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_READ_REGISTERS
Definition Connection.h:88
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_READ_REGISTERS
Definition debugger.h:45
Register Descriptor Structure to use in r command.
Definition RequestStructures.h:1156

◆ KdSendRegisterEventPacketToDebuggee()

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

Parameters
Event
EventBufferLength
Returns
PDEBUGGER_EVENT_AND_ACTION_RESULT
672{
674 UINT32 Len;
675
676 Len = EventBufferLength +
678
680
681 if (Header == NULL)
682 {
683 return NULL;
684 }
685
686 RtlZeroMemory(Header, Len);
687
688 //
689 // Set length in header
690 //
691 Header->Length = EventBufferLength;
692
693 //
694 // Move buffer
695 //
696 memcpy((PVOID)((UINT64)Header +
698 (PVOID)Event,
699 EventBufferLength);
700
703
704 //
705 // Send register event packet
706 //
710 (CHAR *)Header,
711 Len))
712 {
713 free(Header);
714 return NULL;
715 }
716
717 //
718 // Wait until the result of registering received
719 //
721
722 free(Header);
723
725}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_REGISTER_EVENT
Definition Connection.h:85
DEBUGGER_EVENT_AND_ACTION_RESULT g_DebuggeeResultOfRegisteringEvent
Holds the result of registering events from the remote debuggee.
Definition globals.h:283
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_REGISTER_EVENT
Definition debugger.h:42

◆ KdSendScriptPacketToDebuggee()

BOOLEAN KdSendScriptPacketToDebuggee ( UINT64 BufferAddress,
UINT32 BufferLength,
UINT32 Pointer,
BOOLEAN IsFormat )

Sends a script packet to the debuggee.

Parameters
BufferAddress
BufferLength
Pointer
IsFormat
Returns
BOOLEAN
1057{
1058 PDEBUGGEE_SCRIPT_PACKET ScriptPacket;
1059 UINT32 SizeOfStruct = 0;
1060
1061 SizeOfStruct = sizeof(DEBUGGEE_SCRIPT_PACKET) + BufferLength;
1062
1063 ScriptPacket = (DEBUGGEE_SCRIPT_PACKET *)malloc(SizeOfStruct);
1064
1065 RtlZeroMemory(ScriptPacket, SizeOfStruct);
1066
1067 //
1068 // Fill the script packet buffer
1069 //
1070 ScriptPacket->ScriptBufferSize = BufferLength;
1071 ScriptPacket->ScriptBufferPointer = Pointer;
1072 ScriptPacket->IsFormat = IsFormat;
1073
1074 //
1075 // Move the buffer at the bottom of the script packet
1076 //
1077 memcpy((PVOID)((UINT64)ScriptPacket + sizeof(DEBUGGEE_SCRIPT_PACKET)),
1078 (PVOID)BufferAddress,
1079 BufferLength);
1080
1081 //
1082 // Send script packet
1083 //
1087 (CHAR *)ScriptPacket,
1088 SizeOfStruct))
1089 {
1090 free(ScriptPacket);
1091 return FALSE;
1092 }
1093
1094 if (IsFormat)
1095 {
1096 //
1097 // Wait for formats results too
1098 //
1100 }
1101
1102 //
1103 // Wait until the result of script engine received
1104 //
1106
1107 free(ScriptPacket);
1108 return TRUE;
1109}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_RUN_SCRIPT
Definition Connection.h:82
UINT64 BOOLEAN PVOID BufferAddress
Definition HyperDbgScriptImports.h:67
struct _DEBUGGEE_SCRIPT_PACKET DEBUGGEE_SCRIPT_PACKET
The structure of script packet in HyperDbg.
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SCRIPT_FORMATS_RESULT
Definition debugger.h:39
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SCRIPT_RUNNING_RESULT
Definition debugger.h:38
The structure of script packet in HyperDbg.
Definition RequestStructures.h:1122
BOOLEAN IsFormat
Definition RequestStructures.h:1125
UINT32 ScriptBufferPointer
Definition RequestStructures.h:1124
UINT32 ScriptBufferSize
Definition RequestStructures.h:1123

◆ KdSendSearchRequestPacketToDebuggee()

BOOLEAN KdSendSearchRequestPacketToDebuggee ( UINT64 * SearchRequestBuffer,
UINT32 SearchRequestBufferSize )

Sends search query request packet to the debuggee.

Parameters
SearchRequestBuffer
SearchRequestBufferSize
Returns
BOOLEAN
1179{
1180 //
1181 // Send search request packet
1182 //
1186 (CHAR *)SearchRequestBuffer,
1187 SearchRequestBufferSize))
1188 {
1189 return FALSE;
1190 }
1191
1192 //
1193 // Wait until the result of search request received
1194 //
1196
1197 return TRUE;
1198}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_SEARCH_QUERY
Definition Connection.h:84
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SEARCH_QUERY_RESULT
Definition debugger.h:53

◆ KdSendShortCircuitingEventToDebuggee()

BOOLEAN KdSendShortCircuitingEventToDebuggee ( BOOLEAN IsEnabled)

Sends a short-circuiting event request to debuggee.

Parameters
IsEnabled
Returns
BOOLEAN
227{
228 DEBUGGER_SHORT_CIRCUITING_EVENT ShortCircuitEventPacket = {0};
229
230 //
231 // Fill the structure of the packet
232 //
233 ShortCircuitEventPacket.IsShortCircuiting = IsEnabled;
234
235 //
236 // Send modify and query event packet
237 //
241 (CHAR *)&ShortCircuitEventPacket,
243 {
244 return FALSE;
245 }
246
247 //
248 // Wait until the result of setting short-circuiting event state is received
249 //
251
252 return TRUE;
253}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_SET_SHORT_CIRCUITING_STATE
Definition Connection.h:96
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SHORT_CIRCUITING_EVENT_STATE
Definition debugger.h:56
request for performing a short-circuiting event
Definition Events.h:256
BOOLEAN IsShortCircuiting
Definition Events.h:258

◆ KdSendStepPacketToDebuggee()

BOOLEAN KdSendStepPacketToDebuggee ( DEBUGGER_REMOTE_STEPPING_REQUEST StepRequestType)

Sends p (step out) and t (step in) packet to the debuggee.

Returns
BOOLEAN
1207{
1208 DEBUGGEE_STEP_PACKET StepPacket = {0};
1209 UINT32 CallInstructionSize;
1210
1211 //
1212 // Set the type of step packet
1213 //
1214 StepPacket.StepType = StepRequestType;
1215
1216 //
1217 // Check if it's a step-over
1218 //
1219 if (StepRequestType == DEBUGGER_REMOTE_STEPPING_REQUEST_STEP_OVER ||
1221 {
1222 //
1223 // It's not needed to check for DEBUGGER_REMOTE_STEPPING_REQUEST_STEP_OVER_FOR_GU_LAST_INSTRUCTION
1224 // as the last instruction is a 'RET' not a 'CALL'
1225 //
1226
1227 //
1228 // We should check whether the current instruction is a 'call'
1229 // instruction or not, if yes we have to compute the length of call
1230 //
1234 g_IsRunningInstruction32Bit ? FALSE : TRUE, // equals to !g_IsRunningInstruction32Bit
1235 &CallInstructionSize))
1236 {
1237 //
1238 // It's a call in step-over
1239 //
1240 StepPacket.IsCurrentInstructionACall = TRUE;
1241 StepPacket.CallLength = CallInstructionSize;
1242 }
1243 }
1244
1245 //
1246 // Set the debuggee is running after this command
1247 //
1248 if (StepRequestType == DEBUGGER_REMOTE_STEPPING_REQUEST_STEP_OVER ||
1251 {
1252 //
1253 // The debuggee is also running after this type of command
1254 // This is because this way the debuggee is running after the step-over or step-in
1255 // so, if the program either terminates or couldn't run the next instruction, the
1256 // user could pause the debuggee again
1257 //
1259 }
1260
1261 //
1262 // Send step packet to the serial
1263 //
1267 (CHAR *)&StepPacket,
1268 sizeof(DEBUGGEE_STEP_PACKET)))
1269 {
1270 return FALSE;
1271 }
1272
1273 //
1274 // Wait until the result of user-input received
1275 //
1277
1278 return TRUE;
1279}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_STEP
Definition Connection.h:73
#define MAXIMUM_INSTR_SIZE
maximum instruction size in Intel
Definition Constants.h:468
@ DEBUGGER_REMOTE_STEPPING_REQUEST_STEP_IN
Definition RequestStructures.h:992
@ DEBUGGER_REMOTE_STEPPING_REQUEST_STEP_OVER_FOR_GU
Definition RequestStructures.h:997
@ DEBUGGER_REMOTE_STEPPING_REQUEST_STEP_OVER
Definition RequestStructures.h:996
BOOLEAN HyperDbgCheckWhetherTheCurrentInstructionIsCall(unsigned char *BufferToDisassemble, UINT64 BuffLength, BOOLEAN Isx86_64, PUINT32 CallLength)
Check whether the current instruction is a 'call' or not.
Definition disassembler.cpp:755
BOOLEAN g_IsDebuggeeRunning
Shows if the debuggee is running or not.
Definition globals.h:250
BOOLEAN g_IsRunningInstruction32Bit
whether the Current executing instructions is 32-bit or 64 bit
Definition globals.h:210
BYTE g_CurrentRunningInstruction[MAXIMUM_INSTR_SIZE]
Current executing instructions.
Definition globals.h:204
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_IS_DEBUGGER_RUNNING
An event to show whether the debugger is running or not in kernel-debugger.
Definition debugger.h:32
The structure of stepping packet in HyperDbg.
Definition RequestStructures.h:1007
BOOLEAN IsCurrentInstructionACall
Definition RequestStructures.h:1014
UINT32 CallLength
Definition RequestStructures.h:1015
DEBUGGER_REMOTE_STEPPING_REQUEST StepType
Definition RequestStructures.h:1008

◆ KdSendSwitchCorePacketToDebuggee()

BOOLEAN KdSendSwitchCorePacketToDebuggee ( UINT32 NewCore)

Sends a change core or '~ x' command packet to the debuggee.

Returns
BOOLEAN
182{
183 DEBUGGEE_CHANGE_CORE_PACKET CoreChangePacket = {0};
184
185 CoreChangePacket.NewCore = NewCore;
186
187 if (CoreChangePacket.NewCore == g_CurrentRemoteCore)
188 {
189 //
190 // We show an error message here when there is no core change (because the
191 // target core and current operating core is the same)
192 //
193 ShowMessages("the current operating core is %x (not changed)\n",
194 CoreChangePacket.NewCore);
195
196 return FALSE;
197 }
198
199 //
200 // Send '~' as switch packet
201 //
205 (CHAR *)&CoreChangePacket,
207 {
208 return FALSE;
209 }
210
211 //
212 // Wait until the result of core change received
213 //
215
216 return TRUE;
217}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CHANGE_CORE
Definition Connection.h:76
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_CORE_SWITCHING_RESULT
Definition debugger.h:35
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
The structure of changing core packet in HyperDbg.
Definition RequestStructures.h:599
UINT32 NewCore
Definition RequestStructures.h:600

◆ KdSendSwitchProcessPacketToDebuggee()

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.

Parameters
ActionType
NewPid
NewProcess
SetChangeByClockInterrupt
SymDetailsForProcessList
Returns
BOOLEAN
810{
811 DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_PACKET ProcessChangePacket = {0};
812
813 ProcessChangePacket.ActionType = ActionType;
814 ProcessChangePacket.ProcessId = NewPid;
815 ProcessChangePacket.Process = NewProcess;
816 ProcessChangePacket.IsSwitchByClkIntr = SetChangeByClockInterrupt;
817
818 //
819 // Check if the command really needs these information or not
820 // it's because some of the command don't need symbol offset information
821 //
822 if (SymDetailsForProcessList != NULL)
823 {
824 memcpy(&ProcessChangePacket.ProcessListSymDetails, SymDetailsForProcessList, sizeof(DEBUGGEE_PROCESS_LIST_NEEDED_DETAILS));
825 }
826
827 //
828 // Send '.process' as switch packet
829 //
833 (CHAR *)&ProcessChangePacket,
835 {
836 return FALSE;
837 }
838
839 //
840 // Wait until the result of process change received
841 //
843
844 return TRUE;
845}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CHANGE_PROCESS
Definition Connection.h:80
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PROCESS_SWITCHING_RESULT
Definition debugger.h:36
The structure of changing process and show process packet in HyperDbg.
Definition RequestStructures.h:924
DEBUGGEE_PROCESS_LIST_NEEDED_DETAILS ProcessListSymDetails
Definition RequestStructures.h:930
UINT32 ProcessId
Definition RequestStructures.h:926
UINT64 Process
Definition RequestStructures.h:927
DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_TYPE ActionType
Definition RequestStructures.h:925
BOOLEAN IsSwitchByClkIntr
Definition RequestStructures.h:928
The structure of needed information to get the details of the process from nt!_EPROCESS and location ...
Definition RequestStructures.h:684

◆ KdSendSwitchThreadPacketToDebuggee()

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.

Parameters
ActionType
NewTid
NewThread
CheckByClockInterrupt
SymDetailsForThreadList
Returns
BOOLEAN
863{
864 DEBUGGEE_DETAILS_AND_SWITCH_THREAD_PACKET ThreadChangePacket = {0};
865
866 ThreadChangePacket.ActionType = ActionType;
867 ThreadChangePacket.ThreadId = NewTid;
868 ThreadChangePacket.Thread = NewThread;
869 ThreadChangePacket.CheckByClockInterrupt = CheckByClockInterrupt;
870
871 //
872 // Check if the command really needs these information or not
873 // it's because some of the command don't need symbol offset information
874 //
875 if (SymDetailsForThreadList != NULL)
876 {
877 memcpy(&ThreadChangePacket.ThreadListSymDetails, SymDetailsForThreadList, sizeof(DEBUGGEE_THREAD_LIST_NEEDED_DETAILS));
878 }
879
880 //
881 // Send '.thread' as switch packet
882 //
886 (CHAR *)&ThreadChangePacket,
888 {
889 return FALSE;
890 }
891
892 //
893 // Wait until the result of thread change received
894 //
896
897 return TRUE;
898}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_CHANGE_THREAD
Definition Connection.h:81
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_THREAD_SWITCHING_RESULT
Definition debugger.h:37
The structure of changing thead and show thread packet in HyperDbg.
Definition RequestStructures.h:963
DEBUGGEE_DETAILS_AND_SWITCH_THREAD_TYPE ActionType
Definition RequestStructures.h:964
UINT64 Thread
Definition RequestStructures.h:967
DEBUGGEE_THREAD_LIST_NEEDED_DETAILS ThreadListSymDetails
Definition RequestStructures.h:971
UINT32 ThreadId
Definition RequestStructures.h:965
BOOLEAN CheckByClockInterrupt
Definition RequestStructures.h:969
The structure of needed information to get the details of the thread from nt!_ETHREAD and location of...
Definition RequestStructures.h:698

◆ KdSendSymbolReloadPacketToDebuggee()

BOOLEAN KdSendSymbolReloadPacketToDebuggee ( UINT32 ProcessId)

Send symbol reload packet to the debuggee.

Returns
BOOLEAN
494{
495 DEBUGGEE_SYMBOL_REQUEST_PACKET SymbolRequest = {0};
496
497 SymbolRequest.ProcessId = ProcessId;
498
499 //
500 // Send '.sym reload' as symbol reload packet
501 //
505 (CHAR *)&SymbolRequest,
507 {
508 return FALSE;
509 }
510
511 //
512 // Wait until all of the symbol packets are received
513 //
515
516 return TRUE;
517}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_SYMBOL_RELOAD
Definition Connection.h:93
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SYMBOL_RELOAD
Definition debugger.h:50
The structure of .sym reload packet in HyperDbg.
Definition RequestStructures.h:1047
UINT32 ProcessId
Definition RequestStructures.h:1048

◆ KdSendTestQueryPacketToDebuggee()

BOOLEAN KdSendTestQueryPacketToDebuggee ( DEBUGGER_TEST_QUERY_STATE Type)

Send a test query request to the debuggee.

Parameters
Type
Returns
BOOLEAN
426{
427 DEBUGGER_DEBUGGER_TEST_QUERY_BUFFER TestQueryPacket = {0};
428
429 TestQueryPacket.RequestType = Type;
430
431 //
432 // Send 'test query' command as query packet
433 //
437 (CHAR *)&TestQueryPacket,
439 {
440 return FALSE;
441 }
442
443 //
444 // Wait until the result of test query is received
445 //
447
448 return TRUE;
449}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_MODE_TEST_QUERY
Definition Connection.h:79
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_TEST_QUERY
Definition debugger.h:51
request for test query buffers
Definition RequestStructures.h:333
DEBUGGER_TEST_QUERY_STATE RequestType
Definition RequestStructures.h:334

◆ KdSendTestQueryPacketWithContextToDebuggee()

BOOLEAN KdSendTestQueryPacketWithContextToDebuggee ( DEBUGGER_TEST_QUERY_STATE Type,
UINT64 Context )

Send a test query request to the debuggee with the specified context.

Parameters
Type
Context
Returns
BOOLEAN
461{
462 DEBUGGER_DEBUGGER_TEST_QUERY_BUFFER TestQueryPacket = {0};
463
464 TestQueryPacket.RequestType = Type;
465 TestQueryPacket.Context = Context;
466
467 //
468 // Send 'test query' command as query packet
469 //
473 (CHAR *)&TestQueryPacket,
475 {
476 return FALSE;
477 }
478
479 //
480 // Wait until the result of test query is received
481 //
483
484 return TRUE;
485}
NTKERNELAPI _In_opt_ PVOID Context
Definition Dpc.h:25
UINT64 Context
Definition RequestStructures.h:335

◆ KdSendUserInputPacketToDebuggee()

BOOLEAN KdSendUserInputPacketToDebuggee ( const char * Sendbuf,
int Len,
BOOLEAN IgnoreBreakingAgain )

Sends user input packet to the debuggee.

Parameters
Sendbuf
Len
IgnoreBreakingAgain
Returns
BOOLEAN
1121{
1122 PDEBUGGEE_USER_INPUT_PACKET UserInputPacket;
1123 UINT32 SizeOfStruct = 0;
1124
1125 SizeOfStruct = sizeof(DEBUGGEE_USER_INPUT_PACKET) + Len;
1126
1127 UserInputPacket = (DEBUGGEE_USER_INPUT_PACKET *)malloc(SizeOfStruct);
1128
1129 RtlZeroMemory(UserInputPacket, SizeOfStruct);
1130
1131 //
1132 // Fill the script packet buffer descriptors
1133 //
1134 UserInputPacket->CommandLen = Len;
1135 UserInputPacket->IgnoreFinishedSignal = IgnoreBreakingAgain;
1136
1137 //
1138 // Move the user input buffer at the bottom of the structure packet
1139 //
1140 memcpy((PVOID)((UINT64)UserInputPacket + sizeof(DEBUGGEE_USER_INPUT_PACKET)),
1141 (PVOID)Sendbuf,
1142 Len);
1143
1144 //
1145 // Send user-input packet
1146 //
1150 (CHAR *)UserInputPacket,
1151 SizeOfStruct))
1152 {
1153 free(UserInputPacket);
1154 return FALSE;
1155 }
1156
1157 //
1158 // Wait until the result of user-input received
1159 //
1160 if (!IgnoreBreakingAgain)
1161 {
1163 }
1164
1165 free(UserInputPacket);
1166
1167 return TRUE;
1168}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_USER_INPUT_BUFFER
Definition Connection.h:83
struct _DEBUGGEE_USER_INPUT_PACKET DEBUGGEE_USER_INPUT_PACKET
The structure of user-input packet in HyperDbg.
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_DEBUGGEE_FINISHED_COMMAND_EXECUTION
Definition debugger.h:40
The structure of user-input packet in HyperDbg.
Definition DataTypes.h:140
UINT32 CommandLen
Definition DataTypes.h:141
BOOLEAN IgnoreFinishedSignal
Definition DataTypes.h:142

◆ KdSendVa2paAndPa2vaPacketToDebuggee()

BOOLEAN KdSendVa2paAndPa2vaPacketToDebuggee ( PDEBUGGER_VA2PA_AND_PA2VA_COMMANDS Va2paAndPa2vaPacket)

Sends VA2PA and PA2VA packest, or '!va2pa' and '!pa2va' commands packet to the debuggee.

Parameters
Va2paAndPa2vaPacket
Returns
BOOLEAN
966{
967 //
968 // Send '!va2pa' or '!pa2va' as a query packet
969 //
973 (CHAR *)Va2paAndPa2vaPacket,
975 {
976 return FALSE;
977 }
978
979 //
980 // Wait until the result of VA2PA or PA2VA packet is received
981 //
983
984 return TRUE;
985}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_QUERY_PA2VA_AND_VA2PA
Definition Connection.h:94
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_VA2PA_AND_PA2VA_RESULT
Definition debugger.h:54
requests for !va2pa and !pa2va commands
Definition RequestStructures.h:54

◆ KdSendWriteRegisterPacketToDebuggee()

BOOLEAN KdSendWriteRegisterPacketToDebuggee ( PDEBUGGEE_REGISTER_WRITE_DESCRIPTION RegDes)

Send a write register packet to the debuggee.

Parameters
RegDes
Returns
BOOLEAN
563{
564 //
565 // Set the request data
566 //
568
569 //
570 // Send write register packet
571 //
575 (CHAR *)RegDes,
577 {
578 return FALSE;
579 }
580
581 //
582 // Wait until the result of write register received
583 //
585
586 return TRUE;
587}
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_VMX_ROOT_WRITE_REGISTER
Definition Connection.h:98
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_WRITE_REGISTER
Definition debugger.h:58
Register Descriptor Structure to write on registers.
Definition RequestStructures.h:1171

Variable Documentation

◆ g_CurrentRemoteCore

ULONG g_CurrentRemoteCore
extern

Current core that the debuggee is debugging.

◆ g_CurrentRunningInstruction

BYTE g_CurrentRunningInstruction[MAXIMUM_INSTR_SIZE]
extern

Current executing instructions.

204{0};

◆ g_DebuggeeResultOfAddingActionsToEvent

DEBUGGER_EVENT_AND_ACTION_RESULT g_DebuggeeResultOfAddingActionsToEvent
extern

Holds the result of adding action to events from the remote debuggee.

289 {
290 0};

◆ g_DebuggeeResultOfRegisteringEvent

DEBUGGER_EVENT_AND_ACTION_RESULT g_DebuggeeResultOfRegisteringEvent
extern

Holds the result of registering events from the remote debuggee.

283{0};

◆ g_DebuggeeStopCommandEventHandle

HANDLE g_DebuggeeStopCommandEventHandle
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.

◆ g_EndOfBufferCheckSerial

BYTE g_EndOfBufferCheckSerial[4]
extern

the buffer that we set at the end of buffers for serial

◆ g_IgnoreNewLoggingMessages

BOOLEAN g_IgnoreNewLoggingMessages
extern

Shows if the debugger should show debuggee's messages or not.

◆ g_IgnorePauseRequests

BOOLEAN g_IgnorePauseRequests
extern

Show whether the pause request (CTRL+C or CTRL+BREAK) should be ignored or not.

◆ g_IsConnectedToHyperDbgLocally

BOOLEAN g_IsConnectedToHyperDbgLocally
extern

Shows whether the user is allowed to use 'load' command to load modules locally in VMI (virtual machine introspection) mode.

◆ g_IsDebuggeeInHandshakingPhase

BOOLEAN g_IsDebuggeeInHandshakingPhase
extern

Shows if the debuggee is in the handshake phase or not.

◆ g_IsDebuggeeRunning

BOOLEAN g_IsDebuggeeRunning
extern

Shows if the debuggee is running or not.

◆ g_IsDebuggerConntectedToNamedPipe

BOOLEAN g_IsDebuggerConntectedToNamedPipe
extern

Shows if the debugger is connected to the guest using named pipe.

◆ g_IsDebuggerModulesLoaded

BOOLEAN g_IsDebuggerModulesLoaded
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)

◆ g_IsRunningInstruction32Bit

BOOLEAN g_IsRunningInstruction32Bit
extern

whether the Current executing instructions is 32-bit or 64 bit

◆ g_IsSerialConnectedToRemoteDebuggee

BOOLEAN g_IsSerialConnectedToRemoteDebuggee
extern

Shows if the debugger was connected to remote debuggee over (A remote guest)

◆ g_IsSerialConnectedToRemoteDebugger

BOOLEAN g_IsSerialConnectedToRemoteDebugger
extern

Shows if the debugger was connected to remote debugger (A remote host)

◆ g_KernelSyncronizationObjectsHandleTable

In debugger (not debuggee), we save the handle of the user-mode listening thread for pauses here for kernel debugger.

198{0};

◆ g_OverlappedIoStructureForReadDebuggee

OVERLAPPED g_OverlappedIoStructureForReadDebuggee
extern
301{0};

◆ g_OverlappedIoStructureForReadDebugger

OVERLAPPED g_OverlappedIoStructureForReadDebugger
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)

298{0};

◆ g_OverlappedIoStructureForWriteDebugger

OVERLAPPED g_OverlappedIoStructureForWriteDebugger
extern
299{0};

◆ g_SerialConnectionAlreadyClosed

BOOLEAN g_SerialConnectionAlreadyClosed
extern

In both debuggee and debugger we save the state of the closed connection to avoid double close.

◆ g_SerialListeningThreadHandle

HANDLE g_SerialListeningThreadHandle
extern

In debuggee and debugger, we save the handle of the user-mode listening thread for pauses here.

◆ g_SerialRemoteComPortHandle

HANDLE g_SerialRemoteComPortHandle
extern

In debugger (not debuggee), we save the handle of the user-mode listening thread for remote system here.

◆ g_SharedEventStatus

BOOLEAN g_SharedEventStatus
extern

Shows whether the queried event is enabled or disabled.

◆ g_ShouldPreviousCommandBeContinued

BOOLEAN g_ShouldPreviousCommandBeContinued
extern

Shows whether the previous command should be continued or not.

◆ g_SymbolTable

PMODULE_SYMBOL_DETAIL g_SymbolTable
extern

The buffer that stores the details of symbol table.

◆ g_SymbolTableCurrentIndex

UINT32 g_SymbolTableCurrentIndex
extern

The index to hold the track of added symbols.

◆ g_SymbolTableSize

UINT32 g_SymbolTableSize
extern

The buffer that stores size of the details of symbol table.