HyperDbg Debugger
Loading...
Searching...
No Matches
kernel-listening.cpp File Reference

Listening for remote connections on kernel debugger. More...

#include "pch.h"

Functions

BOOLEAN ListeningSerialPortInDebugger ()
 Check if the remote debuggee needs to pause the system and also process the debuggee's messages.
 
BOOLEAN ListeningSerialPortInDebuggee ()
 Check if the remote debugger needs to pause the system.
 
DWORD WINAPI ListeningSerialPauseDebuggerThread (PVOID Param)
 Check if the remote debuggee needs to pause the system.
 
DWORD WINAPI ListeningSerialPauseDebuggeeThread (PVOID Param)
 Check if the remote debugger needs to pause the system.
 

Variables

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.
 
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
 
HANDLE g_SerialRemoteComPortHandle
 In debugger (not debuggee), we save the handle of the user-mode listening thread for remote system here.
 
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
 Shows if the debugger was connected to remote debuggee over (A remote guest)
 
BOOLEAN g_IsDebuggeeRunning
 Shows if the debuggee is running or not.
 
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_OutputSourcesInitialized
 it shows whether the debugger started using output sources or not or in other words, is g_OutputSources initialized with a variable or it is empty
 
ULONG g_CurrentRemoteCore
 Current core that the debuggee is debugging.
 
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.
 
UINT64 g_ResultOfEvaluatedExpression
 Result of the expression that is evaluated in the debuggee.
 
UINT32 g_ErrorStateOfResultOfEvaluatedExpression
 Shows the state of the evaluation of expression which whether contains error or not.
 
UINT64 g_KernelBaseAddress
 Shows the kernel base address.
 

Detailed Description

Listening for remote connections on kernel debugger.

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Alee Amini (alee@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
Version
0.1
Date
2020-12-20

Function Documentation

◆ ListeningSerialPauseDebuggeeThread()

DWORD WINAPI ListeningSerialPauseDebuggeeThread ( PVOID Param)

Check if the remote debugger needs to pause the system.

Parameters
SerialHandle
Returns
BOOLEAN
1245{
1246 //
1247 // Create a listening thead in debuggee
1248 //
1250
1251 return 0;
1252}
BOOLEAN ListeningSerialPortInDebuggee()
Check if the remote debugger needs to pause the system.
Definition kernel-listening.cpp:1054

◆ ListeningSerialPauseDebuggerThread()

DWORD WINAPI ListeningSerialPauseDebuggerThread ( PVOID Param)

Check if the remote debuggee needs to pause the system.

Parameters
Param
Returns
BOOLEAN
1228{
1229 //
1230 // Create a listening thead in debugger
1231 //
1233
1234 return 0;
1235}
BOOLEAN ListeningSerialPortInDebugger()
Check if the remote debuggee needs to pause the system and also process the debuggee's messages.
Definition kernel-listening.cpp:44

◆ ListeningSerialPortInDebuggee()

BOOLEAN ListeningSerialPortInDebuggee ( )

Check if the remote debugger needs to pause the system.

Parameters
SerialHandle
Returns
BOOLEAN
1055{
1056StartAgain:
1057
1058 BOOL Status; /* Status */
1059 char SerialBuffer[MaxSerialPacketSize] = {
1060 0}; /* Buffer to send and receive data */
1061 DWORD EventMask = 0; /* Event mask to trigger */
1062 char ReadData = NULL; /* temperory Character */
1063 DWORD NoBytesRead = 0; /* Bytes read by ReadFile() */
1064 UINT32 Loop = 0;
1065 PDEBUGGER_REMOTE_PACKET TheActualPacket = (PDEBUGGER_REMOTE_PACKET)SerialBuffer;
1066
1067 //
1068 // Setting Receive Mask
1069 //
1070 Status = SetCommMask(g_SerialRemoteComPortHandle, EV_RXCHAR);
1071 if (Status == FALSE)
1072 {
1073 // ShowMessages("warning, there is an error in setting CommMask\n");
1074
1075 //
1076 // Sometimes, this error happens
1077 //
1078 // return FALSE;
1079 }
1080
1081 //
1082 // Setting WaitComm() Event
1083 //
1084 Status = WaitCommEvent(g_SerialRemoteComPortHandle, &EventMask, NULL); /* Wait for the character to be received */
1085
1086 if (Status == FALSE)
1087 {
1088 //
1089 // Can be ignored
1090 //
1091 // ShowMessages("err, in setting WaitCommEvent\n");
1092 // return FALSE;
1093 }
1094
1095 //
1096 // Read data and store in a buffer
1097 //
1098 do
1099 {
1100 Status = ReadFile(g_SerialRemoteComPortHandle, &ReadData, sizeof(ReadData), &NoBytesRead, NULL);
1101
1102 //
1103 // Check to make sure that we don't pass the boundaries
1104 //
1105 if (!Status || !(MaxSerialPacketSize > Loop))
1106 {
1107 //
1108 // Invalid buffer
1109 //
1110 ShowMessages("err, a buffer received in debuggee which exceeds the "
1111 "buffer limitation\n");
1112 goto StartAgain;
1113 }
1114
1115 SerialBuffer[Loop] = ReadData;
1116
1117 if (KdCheckForTheEndOfTheBuffer(&Loop, (BYTE *)SerialBuffer))
1118 {
1119 break;
1120 }
1121
1122 ++Loop;
1123 } while (NoBytesRead > 0);
1124
1125 //
1126 // Because we used overlapped I/O on the other side, sometimes
1127 // the debuggee might cancel the read so it returns, if it returns
1128 // then we should restart reading again
1129 //
1130 if (Loop == 1 && SerialBuffer[0] == NULL)
1131 {
1132 //
1133 // Chunk data to cancel non async read
1134 //
1135 goto StartAgain;
1136 }
1137
1138 //
1139 // Get actual length of received data
1140 //
1141 // ShowMessages("\nNumber of bytes received = %d\n", Loop);
1142 // for (size_t i = 0; i < Loop; i++) {
1143 // ShowMessages("%x ", SerialBuffer[i]);
1144 // }
1145 // ShowMessages("\n");
1146 //
1147
1148 if (TheActualPacket->Indicator == INDICATOR_OF_HYPERDBG_PACKET)
1149 {
1150 //
1151 // Check checksum
1152 //
1153 if (KdComputeDataChecksum((PVOID)&TheActualPacket->Indicator,
1154 Loop - sizeof(BYTE)) != TheActualPacket->Checksum)
1155 {
1156 ShowMessages("err checksum is invalid\n");
1157 goto StartAgain;
1158 }
1159
1160 //
1161 // Check if the packet type is correct
1162 //
1164 {
1165 //
1166 // sth wrong happened, the packet is not belonging to use
1167 // nothing to do, just wait again
1168 //
1169 ShowMessages("err, unknown packet received from the debugger\n");
1170 goto StartAgain;
1171 }
1172
1173 //
1174 // It's a HyperDbg packet
1175 //
1176 switch (TheActualPacket->RequestedActionOfThePacket)
1177 {
1179
1180 if (!DebuggerPauseDebuggee())
1181 {
1182 ShowMessages("err, debugger tries to pause the debuggee but the "
1183 "attempt was unsuccessful\n");
1184 }
1185
1186 break;
1187
1189
1190 //
1191 // Not read anymore
1192 //
1193 return TRUE;
1194
1195 break;
1196
1197 default:
1198
1199 ShowMessages("err, unknown packet action received from the debugger\n");
1200
1201 break;
1202 }
1203 }
1204 else
1205 {
1206 //
1207 // It's not a HyperDbg packet, it's probably a GDB packet
1208 //
1209 DebugBreak();
1210 }
1211
1212 //
1213 // Wait for debug pause command again
1214 //
1215 goto StartAgain;
1216
1217 return TRUE;
1218}
int BOOL
Definition BasicTypes.h:23
unsigned char BYTE
Definition BasicTypes.h:24
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
unsigned long DWORD
Definition BasicTypes.h:22
unsigned int UINT32
Definition BasicTypes.h:48
struct _DEBUGGER_REMOTE_PACKET * PDEBUGGER_REMOTE_PACKET
@ 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
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_ON_USER_MODE_DO_NOT_READ_ANY_PACKET
Definition Connection.h:62
#define INDICATOR_OF_HYPERDBG_PACKET
constant indicator of a HyperDbg packet
Definition Constants.h:502
#define MaxSerialPacketSize
size of buffer for serial
Definition Constants.h:194
_Use_decl_annotations_ BYTE KdComputeDataChecksum(PVOID Buffer, UINT32 Length)
calculate the checksum of received buffer from debugger
Definition Kd.c:270
BOOLEAN DebuggerPauseDebuggee()
pauses the debuggee
Definition debugger.cpp:617
BOOLEAN KdCheckForTheEndOfTheBuffer(PUINT32 CurrentLoopIndex, BYTE *Buffer)
compares the buffer with a string
Definition kd.cpp:56
HANDLE g_SerialRemoteComPortHandle
In debugger (not debuggee), we save the handle of the user-mode listening thread for remote system he...
Definition globals.h:224
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
NULL()
Definition test-case-generator.py:530
The structure of remote packets in HyperDbg.
Definition Connection.h:183
DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION RequestedActionOfThePacket
Definition Connection.h:187
DEBUGGER_REMOTE_PACKET_TYPE TypeOfThePacket
Definition Connection.h:186
BYTE Checksum
Definition Connection.h:184
UINT64 Indicator
Definition Connection.h:185

◆ ListeningSerialPortInDebugger()

BOOLEAN ListeningSerialPortInDebugger ( )

Check if the remote debuggee needs to pause the system and also process the debuggee's messages.

Returns
BOOLEAN
45{
47 PDEBUGGER_REMOTE_PACKET TheActualPacket;
49 PDEBUGGEE_MESSAGE_PACKET MessagePacket;
50 PDEBUGGEE_CHANGE_CORE_PACKET ChangeCorePacket;
51 PDEBUGGEE_SCRIPT_PACKET ScriptPacket;
52 PDEBUGGEE_FORMATS_PACKET FormatsPacket;
53 PDEBUGGER_EVENT_AND_ACTION_RESULT EventAndActionPacket;
54 PDEBUGGER_UPDATE_SYMBOL_TABLE SymbolUpdatePacket;
55 PDEBUGGER_MODIFY_EVENTS EventModifyAndQueryPacket;
56 PDEBUGGEE_SYMBOL_UPDATE_RESULT SymbolReloadFinishedPacket;
58 PDEBUGGEE_RESULT_OF_SEARCH_PACKET SearchResultsPacket;
61 PDEBUGGER_CALLSTACK_REQUEST CallstackPacket;
62 PDEBUGGER_SINGLE_CALLSTACK_FRAME CallstackFramePacket;
64 PDEBUGGEE_REGISTER_READ_DESCRIPTION ReadRegisterPacket;
65 PDEBUGGEE_REGISTER_WRITE_DESCRIPTION WriteRegisterPacket;
66 PDEBUGGER_READ_MEMORY ReadMemoryPacket;
67 PDEBUGGER_EDIT_MEMORY EditMemoryPacket;
68 PDEBUGGEE_BP_PACKET BpPacket;
69 PDEBUGGER_SHORT_CIRCUITING_EVENT ShortCircuitingPacket;
71 PDEBUGGER_PAGE_IN_REQUEST PageinPacket;
73 PDEBUGGEE_BP_LIST_OR_MODIFY_PACKET ListOrModifyBreakpointPacket;
74 BOOLEAN ShowSignatureWhenDisconnected = FALSE;
75 PVOID CallerAddress = NULL;
76 UINT32 CallerSize = NULL_ZERO;
77
78StartAgain:
79
80 CHAR BufferToReceive[MaxSerialPacketSize] = {0};
81 UINT32 LengthReceived = 0;
82
83 //
84 // Wait for handshake to complete or in other words
85 // get the receive packet
86 //
87 if (!KdReceivePacketFromDebuggee(BufferToReceive, &LengthReceived))
88 {
89 if (LengthReceived == 0 && BufferToReceive[0] == NULL)
90 {
91 //
92 // The remote computer (debuggee) closed the connection
93 //
94 ShowMessages("\nthe remote connection is closed\n");
95
97 {
98 //
99 // Remove and reset all the events
100 //
102
104 {
105 ShowSignatureWhenDisconnected = TRUE;
106 }
107 }
108
110
111 if (ShowSignatureWhenDisconnected)
112 {
113 ShowSignatureWhenDisconnected = FALSE;
114 ShowMessages("\n");
115 }
116 return FALSE;
117 }
118 else
119 {
120 ShowMessages("err, invalid buffer received\n");
121 goto StartAgain;
122 }
123 }
124
125 //
126 // Check for invalid close packets
127 //
128 if (LengthReceived == 1 && BufferToReceive[0] == NULL)
129 {
130 goto StartAgain;
131 }
132
133 TheActualPacket = (PDEBUGGER_REMOTE_PACKET)BufferToReceive;
134
135 if (TheActualPacket->Indicator == INDICATOR_OF_HYPERDBG_PACKET)
136 {
137 //
138 // Check checksum
139 //
140 if (KdComputeDataChecksum((PVOID)&TheActualPacket->Indicator,
141 LengthReceived - sizeof(BYTE)) != TheActualPacket->Checksum)
142 {
143 ShowMessages("\nerr, checksum is invalid\n");
144 goto StartAgain;
145 }
146
147 //
148 // Check if the packet type is correct
149 //
151 {
152 //
153 // sth wrong happened, the packet is not belonging to use
154 // nothing to do, just wait again
155 //
156 ShowMessages("\nerr, unknown packet received from the debuggee\n");
157 goto StartAgain;
158 }
159
160 //
161 // It's a HyperDbg packet
162 //
163 switch (TheActualPacket->RequestedActionOfThePacket)
164 {
166
167 //
168 // Send the handshake response
169 //
171
172 break;
173
175
176 InitPacket = (DEBUGGER_PREPARE_DEBUGGEE *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
177
178 //
179 // Set the kernel base address
180 //
182
183 ShowMessages("connected to debuggee %s\n", InitPacket->OsName);
184
185 //
186 // Signal the event that the debugger started
187 //
189
190 break;
191
193
194 MessagePacket = (DEBUGGEE_MESSAGE_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
195
196 //
197 // Check if there are available output sources
198 //
200 MessagePacket->Message,
201 (UINT32)strlen(MessagePacket->Message)))
202 {
203 //
204 // We check g_IgnoreNewLoggingMessages here because we want to
205 // avoid messages when the debuggee is halted
206 //
208 {
209 ShowMessages("%s", MessagePacket->Message);
210 }
211 }
212
213 break;
214
216
217 //
218 // Pause logging mechanism
219 //
221
222 PausePacket = (DEBUGGEE_KD_PAUSED_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
223
224 //
225 // Debuggee is not running
226 //
228
229 //
230 // Set the current core
231 //
232 g_CurrentRemoteCore = PausePacket->CurrentCore;
233
234 //
235 // Save the current operating instruction and operating mode
236 //
239
241
242 //
243 // Show additional messages before showing assembly and pausing
244 //
245 switch (PausePacket->PausingReason)
246 {
248
249 if (PausePacket->EventTag != NULL)
250 {
251 //
252 // It's a breakpoint id
253 //
254 ShowMessages("breakpoint 0x%x hit\n",
255 PausePacket->EventTag);
256 }
257
258 break;
259
261
262 if (PausePacket->EventTag != NULL)
263 {
264 //
265 // It's an event tag
266 //
268 {
269 ShowMessages("event 0x%x triggered (post)\n",
270 PausePacket->EventTag - DebuggerEventTagStartSeed);
271 }
272 else
273 {
274 ShowMessages("event 0x%x triggered (pre)\n",
275 PausePacket->EventTag - DebuggerEventTagStartSeed);
276 }
277 }
278
279 break;
280
282
283 ShowMessages("switched to the specified process\n");
284
285 break;
286
288
289 ShowMessages("switched to the specified thread\n");
290
291 break;
292
294
295 ShowMessages("the target module is loaded and a breakpoint is set to the entrypoint\n"
296 "press 'g' to reach to the entrypoint of the main module...\n");
297
298 break;
299
300 default:
301 break;
302 }
303
304 if (!PausePacket->IgnoreDisassembling)
305 {
306 //
307 // Check if the instruction is received completely or not
308 //
309 if (PausePacket->ReadInstructionLen != MAXIMUM_INSTR_SIZE)
310 {
311 //
312 // We check if the disassembled buffer has greater size
313 // than what is retrieved
314 //
317 PausePacket->IsProcessorOn32BitMode ? FALSE : TRUE) > PausePacket->ReadInstructionLen)
318 {
319 ShowMessages("oOh, no! there might be a misinterpretation in disassembling the current instruction\n");
320 }
321 }
322
323 if (!PausePacket->IsProcessorOn32BitMode)
324 {
325 //
326 // Show diassembles
327 //
329 PausePacket->Rip,
331 1,
332 TRUE,
333 (PRFLAGS)&PausePacket->Rflags);
334 }
335 else
336 {
337 //
338 // Show diassembles
339 //
341 PausePacket->Rip,
343 1,
344 TRUE,
345 (PRFLAGS)&PausePacket->Rflags);
346 }
347 }
348
349 switch (PausePacket->PausingReason)
350 {
357
358 //
359 // Unpause the debugger to get commands
360 //
362
363 break;
364
366
367 //
368 // Handle the tracking of the 'ret' and the 'call' instructions
369 //
372 PausePacket->IsProcessorOn32BitMode ? FALSE : TRUE,
373 PausePacket->Rip);
374
375 //
376 // Unpause the debugger to get commands
377 //
379
380 break;
381
383
384 //
385 // Unpause the debugger to get commands
386 //
387 ShowMessages("\n");
389
390 break;
391
393
394 //
395 // Nothing
396 //
397 break;
398
400
401 //
402 // Signal the event relating to receiving result of core change
403 //
405
406 break;
407
409
410 //
411 // Signal the event relating to result of command execution finished
412 //
413 ShowMessages("\n");
415
416 break;
417
419
420 //
421 // Signal the event relating to commands that are waiting for
422 // the details of a halted debuggeee
423 //
425
426 break;
427
428 default:
429
430 ShowMessages("err, unknown pausing reason is received\n");
431
432 break;
433 }
434
435 break;
436
438
439 ChangeCorePacket = (DEBUGGEE_CHANGE_CORE_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
440
441 if (ChangeCorePacket->Result == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
442 {
443 ShowMessages("current operating core changed to 0x%x\n",
444 ChangeCorePacket->NewCore);
445 }
446 else
447 {
448 ShowErrorMessage(ChangeCorePacket->Result);
449
450 //
451 // Signal the event relating to receiving result of core change
452 //
454 }
455
456 break;
457
459
460 ChangeProcessPacket = (DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
461
462 if (ChangeProcessPacket->Result == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
463 {
465 {
466 ShowMessages("process id: %x\nprocess (_EPROCESS): %s\nprocess name (16-Byte): %s\n",
467 ChangeProcessPacket->ProcessId,
468 SeparateTo64BitValue(ChangeProcessPacket->Process).c_str(),
469 &ChangeProcessPacket->ProcessName);
470 }
471 else if (ChangeProcessPacket->ActionType == DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_PERFORM_SWITCH)
472 {
474 "press 'g' to continue the debuggee, if the pid or the "
475 "process object address is valid then the debuggee will "
476 "be automatically paused when it attached to the target process\n");
477 }
478 }
479 else
480 {
481 ShowErrorMessage(ChangeProcessPacket->Result);
482 }
483
484 //
485 // Signal the event relating to receiving result of process change
486 //
488
489 break;
490
492
493 SearchResultsPacket = (DEBUGGEE_RESULT_OF_SEARCH_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
494
495 if (SearchResultsPacket->Result == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
496 {
497 if (SearchResultsPacket->CountOfResults == 0)
498 {
499 ShowMessages("not found\n");
500 }
501 }
502 else
503 {
504 ShowErrorMessage(SearchResultsPacket->Result);
505 }
506
507 //
508 // Signal the event relating to receiving result of search query
509 //
511
512 break;
513
515
516 ChangeThreadPacket = (DEBUGGEE_DETAILS_AND_SWITCH_THREAD_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
517
518 if (ChangeThreadPacket->Result == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
519 {
521 {
522 ShowMessages("thread id: %x (pid: %x)\nthread (_ETHREAD): %s\nprocess (_EPROCESS): %s\nprocess name (16-Byte): %s\n",
523 ChangeThreadPacket->ThreadId,
524 ChangeThreadPacket->ProcessId,
525 SeparateTo64BitValue(ChangeThreadPacket->Thread).c_str(),
526 SeparateTo64BitValue(ChangeThreadPacket->Process).c_str(),
527 &ChangeThreadPacket->ProcessName);
528 }
530 {
532 "press 'g' to continue the debuggee, if the tid or the "
533 "thread object address is valid then the debuggee will "
534 "be automatically paused when it attached to the target thread\n");
535 }
536 }
537 else
538 {
539 ShowErrorMessage(ChangeThreadPacket->Result);
540 }
541
542 //
543 // Signal the event relating to receiving result of thread change
544 //
546
547 break;
548
550
551 FlushPacket = (DEBUGGER_FLUSH_LOGGING_BUFFERS *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
552
554 {
555 //
556 // The amount of message that are deleted are the amount of
557 // vmx-root messages and vmx non-root messages
558 //
559 ShowMessages("flushing buffers was successful, total %d messages were "
560 "cleared.\n",
562 }
563 else
564 {
565 ShowErrorMessage(FlushPacket->KernelStatus);
566 }
567
568 //
569 // Signal the event relating to receiving result of flushing
570 //
572
573 break;
574
576
577 CallstackPacket = (DEBUGGER_CALLSTACK_REQUEST *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
578 CallstackFramePacket = (DEBUGGER_SINGLE_CALLSTACK_FRAME *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET) + sizeof(DEBUGGER_CALLSTACK_REQUEST));
579
580 if (CallstackPacket->KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
581 {
582 //
583 // Show the callstack
584 //
585 CallstackShowFrames(CallstackFramePacket,
586 CallstackPacket->FrameCount,
587 CallstackPacket->DisplayMethod,
588 CallstackPacket->Is32Bit);
589 }
590 else
591 {
592 ShowErrorMessage(CallstackPacket->KernelStatus);
593 }
594
595 //
596 // Signal the event relating to receiving result of callstack
597 //
599
600 break;
601
603
604 TestQueryPacket = (DEBUGGER_DEBUGGER_TEST_QUERY_BUFFER *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
605
606 if (TestQueryPacket->KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
607 {
608 switch (TestQueryPacket->RequestType)
609 {
611
612 ShowMessages("breakpoint interception (#BP) is deactivated\n"
613 "from now, the breakpoints will be re-injected into the guest debuggee\n");
614
615 break;
616
618
619 ShowMessages("breakpoint interception (#BP) is activated\n");
620
621 break;
622
624
625 ShowMessages("debug break interception (#DB) is deactivated\n"
626 "from now, the debug breaks will be re-injected into the guest debuggee\n");
627
628 break;
629
631
632 ShowMessages("debug break interception (#DB) is activated\n");
633
634 break;
635
636 default:
637 break;
638 }
639 }
640 else
641 {
642 ShowErrorMessage(TestQueryPacket->KernelStatus);
643 }
644
645 //
646 // Signal the event relating to receiving result of test query
647 //
649
650 break;
651
653
654 ScriptPacket = (DEBUGGEE_SCRIPT_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
655
656 if (ScriptPacket->Result == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
657 {
658 //
659 // Nothing to do
660 //
661 }
662 else
663 {
664 ShowErrorMessage(ScriptPacket->Result);
665 }
666
667 if (ScriptPacket->IsFormat)
668 {
669 //
670 // Signal the event relating to receiving result of the '.formats' command
671 //
673 }
674
675 //
676 // Signal the event relating to receiving result of running script
677 //
679
680 break;
681
683
684 FormatsPacket = (DEBUGGEE_FORMATS_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
685
686 //
687 // We'll just save the result of expression to the global variables
688 // and let the debuggee to decide whether wants to show error or not
689 // and let the debuggee to decide whether wants to show error or not
690 //
692 g_ResultOfEvaluatedExpression = FormatsPacket->Value;
693
694 break;
695
697
698 EventAndActionPacket = (DEBUGGER_EVENT_AND_ACTION_RESULT *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
699
700 //
701 // Move the buffer to the global variable
702 //
703 memcpy(&g_DebuggeeResultOfRegisteringEvent, EventAndActionPacket, sizeof(DEBUGGER_EVENT_AND_ACTION_RESULT));
704
705 //
706 // Signal the event relating to receiving result of register event
707 //
709
710 break;
711
713
714 EventAndActionPacket = (DEBUGGER_EVENT_AND_ACTION_RESULT *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
715
716 //
717 // Move the buffer to the global variable
718 //
719 memcpy(&g_DebuggeeResultOfAddingActionsToEvent, EventAndActionPacket, sizeof(DEBUGGER_EVENT_AND_ACTION_RESULT));
720
721 //
722 // Signal the event relating to receiving result of adding action to event
723 //
725
726 break;
727
729
730 EventModifyAndQueryPacket = (DEBUGGER_MODIFY_EVENTS *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
731
732 //
733 // Set the result of query
734 //
735 if (EventModifyAndQueryPacket->KernelStatus != DEBUGGER_OPERATION_WAS_SUCCESSFUL)
736 {
737 //
738 // There was an error
739 //
740 ShowErrorMessage((UINT32)EventModifyAndQueryPacket->KernelStatus);
741 }
742 else if (EventModifyAndQueryPacket->TypeOfAction == DEBUGGER_MODIFY_EVENTS_QUERY_STATE)
743 {
744 //
745 // Set the global state
746 //
747 g_SharedEventStatus = EventModifyAndQueryPacket->IsEnabled;
748 }
749 else
750 {
751 CommandEventsHandleModifiedEvent(EventModifyAndQueryPacket->Tag,
752 EventModifyAndQueryPacket);
753 }
754
755 //
756 // Signal the event relating to receiving result of event query and
757 // modification
758 //
760
761 break;
762
764
765 SymbolReloadFinishedPacket = (DEBUGGEE_SYMBOL_UPDATE_RESULT *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
766
767 //
768 // Show messages as the result of updating symbols
769 //
770 if (SymbolReloadFinishedPacket->KernelStatus != DEBUGGER_OPERATION_WAS_SUCCESSFUL)
771 {
772 //
773 // There was an error
774 //
775 ShowErrorMessage((UINT32)SymbolReloadFinishedPacket->KernelStatus);
776 }
777 else
778 {
779 //
780 // Load the symbols
781 //
783 }
784
785 //
786 // Signal the event relating to receiving result of symbol reload
787 //
789
790 break;
791
793
794 ReadRegisterPacket = (DEBUGGEE_REGISTER_READ_DESCRIPTION *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
795
796 //
797 // Get the address and size of the caller
798 //
800
801 //
802 // Copy the memory buffer for the caller
803 //
804 memcpy(CallerAddress, ReadRegisterPacket, CallerSize);
805
806 //
807 // Signal the event relating to receiving result of reading registers
808 //
810
811 break;
812
814
815 WriteRegisterPacket = (DEBUGGEE_REGISTER_WRITE_DESCRIPTION *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
816
817 //
818 // Get the address and size of the caller
819 //
821
822 //
823 // Copy the memory buffer for the caller
824 //
825 memcpy(CallerAddress, WriteRegisterPacket, CallerSize);
826
827 //
828 // Signal the event relating to receiving result of writing register
829 //
831
832 break;
833
835
836 ReadMemoryPacket = (DEBUGGER_READ_MEMORY *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
837
838 //
839 // Get the address and size of the caller
840 //
842
843 //
844 // Copy the memory buffer for the caller
845 //
846 memcpy(CallerAddress, ReadMemoryPacket, CallerSize);
847
848 //
849 // Signal the event relating to receiving result of reading memory
850 //
852
853 break;
854
856
857 EditMemoryPacket = (DEBUGGER_EDIT_MEMORY *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
858
859 //
860 // Get the address and size of the caller
861 //
863
864 //
865 // Copy the memory buffer for the caller
866 //
867 memcpy(CallerAddress, EditMemoryPacket, CallerSize);
868
869 //
870 // Signal the event relating to receiving result of editing memory
871 //
873
874 break;
875
877
878 BpPacket = (DEBUGGEE_BP_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
879
881 {
882 //
883 // Everything was okay, nothing to do
884 //
885 }
886 else
887 {
888 ShowErrorMessage(BpPacket->Result);
889 }
890
891 //
892 // Signal the event relating to receiving result of putting breakpoints
893 //
895
896 break;
897
899
900 ShortCircuitingPacket = (DEBUGGER_SHORT_CIRCUITING_EVENT *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
901
902 if (ShortCircuitingPacket->KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
903 {
904 ShowMessages("the event's short-circuiting state changed to %s\n", ShortCircuitingPacket->IsShortCircuiting ? "'on'" : "'off'");
905 }
906 else
907 {
908 ShowErrorMessage((UINT32)ShortCircuitingPacket->KernelStatus);
909 }
910
911 //
912 // Signal the event relating to receiving result of changing the short circuiting state
913 //
915
916 break;
917
919
920 PtePacket = (DEBUGGER_READ_PAGE_TABLE_ENTRIES_DETAILS *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
921
923 {
924 //
925 // Show the Page Tables result
926 //
927 CommandPteShowResults(PtePacket->VirtualAddress, PtePacket);
928 }
929 else
930 {
931 ShowErrorMessage(PtePacket->KernelStatus);
932 }
933
934 //
935 // Signal the event relating to receiving result of PTE query
936 //
938
939 break;
940
942
943 PageinPacket = (DEBUGGER_PAGE_IN_REQUEST *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
944
946 {
947 //
948 // Show the successful delivery of the packet
949 //
950 ShowMessages("the page-fault is delivered to the target thread\n"
951 "press 'g' to continue debuggee (the current thread will execute ONLY one instruction and will be halted again)...\n");
952 }
953 else
954 {
955 ShowErrorMessage(PageinPacket->KernelStatus);
956 }
957
958 //
959 // Signal the event relating to receiving result of page-in request
960 //
962
963 break;
964
966
967 Va2paPa2vaPacket = (DEBUGGER_VA2PA_AND_PA2VA_COMMANDS *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
968
969 if (Va2paPa2vaPacket->KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
970 {
971 if (Va2paPa2vaPacket->IsVirtual2Physical)
972 {
973 ShowMessages("%llx\n", Va2paPa2vaPacket->PhysicalAddress);
974 }
975 else
976 {
977 ShowMessages("%llx\n", Va2paPa2vaPacket->VirtualAddress);
978 }
979 }
980 else
981 {
982 ShowErrorMessage(Va2paPa2vaPacket->KernelStatus);
983 }
984
985 //
986 // Signal the event relating to receiving result of VA2PA or PA2VA queries
987 //
989
990 break;
991
993
994 ListOrModifyBreakpointPacket = (DEBUGGEE_BP_LIST_OR_MODIFY_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
995
996 if (ListOrModifyBreakpointPacket->Result == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
997 {
998 //
999 // Everything was okay, nothing to do
1000 //
1001 }
1002 else
1003 {
1004 ShowErrorMessage(ListOrModifyBreakpointPacket->Result);
1005 }
1006
1007 //
1008 // Signal the event relating to receiving result of modifying or listing
1009 // breakpoints
1010 //
1012
1013 break;
1014
1016
1017 SymbolUpdatePacket = (DEBUGGER_UPDATE_SYMBOL_TABLE *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
1018 //
1019 // Perform updates for the symbol table
1020 //
1022
1023 break;
1024
1025 default:
1026 ShowMessages("err, unknown packet action received from the debugger\n");
1027 break;
1028 }
1029 }
1030 else
1031 {
1032 //
1033 // It's not a HyperDbg packet, it's probably a GDB packet
1034 //
1035 ShowMessages("err, invalid packet received\n");
1036 // DebugBreak();
1037 }
1038
1039 //
1040 // Wait for debug pause command again
1041 //
1042 goto StartAgain;
1043
1044 return TRUE;
1045}
UCHAR BOOLEAN
Definition BasicTypes.h:39
#define NULL_ZERO
Definition BasicTypes.h:51
char CHAR
Definition BasicTypes.h:31
@ DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGEE_TO_DEBUGGER
Definition Connection.h:164
@ DEBUGGEE_PAUSING_REASON_DEBUGGEE_SOFTWARE_BREAKPOINT_HIT
Definition Connection.h:29
@ DEBUGGEE_PAUSING_REASON_DEBUGGEE_PROCESS_SWITCHED
Definition Connection.h:32
@ DEBUGGEE_PAUSING_REASON_DEBUGGEE_STEPPED
Definition Connection.h:27
@ DEBUGGEE_PAUSING_REASON_DEBUGGEE_EVENT_TRIGGERED
Definition Connection.h:35
@ DEBUGGEE_PAUSING_REASON_DEBUGGEE_THREAD_SWITCHED
Definition Connection.h:33
@ DEBUGGEE_PAUSING_REASON_PAUSE
Definition Connection.h:25
@ DEBUGGEE_PAUSING_REASON_DEBUGGEE_TRACKING_STEPPED
Definition Connection.h:28
@ DEBUGGEE_PAUSING_REASON_REQUEST_FROM_DEBUGGER
Definition Connection.h:26
@ DEBUGGEE_PAUSING_REASON_DEBUGGEE_STARTING_MODULE_LOADED
Definition Connection.h:36
@ DEBUGGEE_PAUSING_REASON_DEBUGGEE_COMMAND_EXECUTION_FINISHED
Definition Connection.h:34
@ DEBUGGEE_PAUSING_REASON_DEBUGGEE_HARDWARE_DEBUG_REGISTER_HIT
Definition Connection.h:30
@ DEBUGGEE_PAUSING_REASON_DEBUGGEE_CORE_SWITCHED
Definition Connection.h:31
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_BP
Definition Connection.h:122
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RELOAD_SYMBOL_FINISHED
Definition Connection.h:126
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_PTE
Definition Connection.h:128
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_TEST_QUERY
Definition Connection.h:114
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RELOAD_SEARCH_QUERY
Definition Connection.h:127
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_SHORT_CIRCUITING_STATE
Definition Connection.h:123
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_FLUSH
Definition Connection.h:112
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_ADDING_ACTION_TO_EVENT
Definition Connection.h:116
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_READING_REGISTERS
Definition Connection.h:119
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_LOGGING_MECHANISM
Definition Connection.h:105
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_READING_MEMORY
Definition Connection.h:120
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_REGISTERING_EVENT
Definition Connection.h:115
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_WRITE_REGISTER
Definition Connection.h:131
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_VA2PA_AND_PA2VA
Definition Connection.h:129
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_EDITING_MEMORY
Definition Connection.h:121
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CHANGING_THREAD
Definition Connection.h:109
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_STARTED
Definition Connection.h:104
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_PAUSED_AND_CURRENT_INSTRUCTION
Definition Connection.h:106
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_RUNNING_SCRIPT
Definition Connection.h:110
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_BRINGING_PAGES_IN
Definition Connection.h:130
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_QUERY_AND_MODIFY_EVENT
Definition Connection.h:117
@ DEBUGGER_REMOTE_PACKET_PING_AND_SEND_SUPPORTED_VERSION
Definition Connection.h:68
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CALLSTACK
Definition Connection.h:113
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CHANGING_CORE
Definition Connection.h:107
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_LIST_OR_MODIFY_BREAKPOINTS
Definition Connection.h:124
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_UPDATE_SYMBOL_INFO
Definition Connection.h:125
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CHANGING_PROCESS
Definition Connection.h:108
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_FORMATS
Definition Connection.h:111
struct _DEBUGGER_REMOTE_PACKET DEBUGGER_REMOTE_PACKET
The structure of remote packets in HyperDbg.
#define MAXIMUM_INSTR_SIZE
maximum instruction size in Intel
Definition Constants.h:468
#define DebuggerEventTagStartSeed
The seeds that user-mode codes use as the starter of their events' tag.
Definition Constants.h:222
@ VMM_CALLBACK_CALLING_STAGE_POST_EVENT_EMULATION
Definition DataTypes.h:94
#define DEBUGGER_OPERATION_WAS_SUCCESSFUL
General value to indicate that the operation or request was successful.
Definition ErrorCodes.h:23
@ TEST_BREAKPOINT_TURN_OFF_DBS
Definition RequestStructures.h:323
@ TEST_BREAKPOINT_TURN_OFF_BPS
Definition RequestStructures.h:316
@ TEST_BREAKPOINT_TURN_ON_DBS
Definition RequestStructures.h:324
@ TEST_BREAKPOINT_TURN_ON_BPS
Definition RequestStructures.h:317
struct _DEBUGGER_CALLSTACK_REQUEST DEBUGGER_CALLSTACK_REQUEST
request for callstack frames
@ DEBUGGEE_DETAILS_AND_SWITCH_THREAD_PERFORM_SWITCH
Definition RequestStructures.h:952
@ DEBUGGEE_DETAILS_AND_SWITCH_THREAD_GET_THREAD_DETAILS
Definition RequestStructures.h:953
@ DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_GET_PROCESS_DETAILS
Definition RequestStructures.h:912
@ DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_PERFORM_SWITCH
Definition RequestStructures.h:914
VOID CallstackShowFrames(PDEBUGGER_SINGLE_CALLSTACK_FRAME CallstackFrames, UINT32 FrameCount, DEBUGGER_CALLSTACK_DISPLAY_METHOD DisplayMethod, BOOLEAN Is32Bit)
Show stack frames.
Definition callstack.cpp:212
string SeparateTo64BitValue(UINT64 Value)
add ` between 64 bit values and convert them to string
Definition common.cpp:27
BOOLEAN ShowErrorMessage(UINT32 Error)
shows the error message
Definition debugger.cpp:38
int HyperDbgDisassembler32(unsigned char *BufferToDisassemble, UINT64 BaseAddress, UINT64 Size, UINT32 MaximumInstrDecoded, BOOLEAN ShowBranchIsTakenOrNot, PRFLAGS Rflags)
Disassemble 32 bit assemblies.
Definition disassembler.cpp:373
int HyperDbgDisassembler64(unsigned char *BufferToDisassemble, UINT64 BaseAddress, UINT64 Size, UINT32 MaximumInstrDecoded, BOOLEAN ShowBranchIsTakenOrNot, PRFLAGS Rflags)
Disassemble x64 assemblies.
Definition disassembler.cpp:333
UINT32 HyperDbgLengthDisassemblerEngine(unsigned char *BufferToDisassemble, UINT64 BuffLength, BOOLEAN Isx86_64)
Length Disassembler engine based on Zydis.
Definition disassembler.cpp:856
VOID CommandEventsHandleModifiedEvent(UINT64 Tag, PDEBUGGER_MODIFY_EVENTS ModifyEventRequest)
Handle events after modification.
Definition events.cpp:499
VOID CommandEventsClearAllEventsAndResetTags()
Clears all the events and resets the tag.
Definition events.cpp:470
BOOLEAN ForwardingCheckAndPerformEventForwarding(UINT32 OperationCode, CHAR *Message, UINT32 MessageLength)
Check and send the event result to the corresponding sources.
Definition forwarding.cpp:439
@ DEBUGGER_MODIFY_EVENTS_QUERY_STATE
Definition Events.h:231
ULONG g_CurrentRemoteCore
Current core that the debuggee is debugging.
Definition globals.h:263
DEBUGGER_EVENT_AND_ACTION_RESULT g_DebuggeeResultOfRegisteringEvent
Holds the result of registering events from the remote debuggee.
Definition globals.h:283
BOOLEAN g_OutputSourcesInitialized
it shows whether the debugger started using output sources or not or in other words,...
Definition globals.h:408
BOOLEAN g_IsDebuggeeRunning
Shows if the debuggee is running or not.
Definition globals.h:250
UINT64 g_ResultOfEvaluatedExpression
Result of the expression that is evaluated in the debuggee.
Definition globals.h:630
BOOLEAN g_IsRunningInstruction32Bit
whether the Current executing instructions is 32-bit or 64 bit
Definition globals.h:210
BOOLEAN g_IgnoreNewLoggingMessages
Shows if the debugger should show debuggee's messages or not.
Definition globals.h:257
DEBUGGER_EVENT_AND_ACTION_RESULT g_DebuggeeResultOfAddingActionsToEvent
Holds the result of adding action to events from the remote debuggee.
Definition globals.h:289
UINT64 g_KernelBaseAddress
Shows the kernel base address.
Definition globals.h:566
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
Shows if the debugger was connected to remote debuggee over (A remote guest)
Definition globals.h:231
UINT32 g_ErrorStateOfResultOfEvaluatedExpression
Shows the state of the evaluation of expression which whether contains error or not.
Definition globals.h:637
BYTE g_CurrentRunningInstruction[MAXIMUM_INSTR_SIZE]
Current executing instructions.
Definition globals.h:204
BOOLEAN g_SharedEventStatus
Shows whether the queried event is enabled or disabled.
Definition globals.h:307
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_ADD_ACTION_TO_EVENT
Definition debugger.h:43
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_DEBUGGEE_FINISHED_COMMAND_EXECUTION
Definition debugger.h:40
#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
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SCRIPT_FORMATS_RESULT
Definition debugger.h:39
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SEARCH_QUERY_RESULT
Definition debugger.h:53
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_FLUSH_RESULT
Definition debugger.h:41
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_MODIFY_AND_QUERY_EVENT
Definition debugger.h:44
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SHORT_CIRCUITING_EVENT_STATE
Definition debugger.h:56
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_LIST_OR_MODIFY_BREAKPOINTS
Definition debugger.h:47
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_THREAD_SWITCHING_RESULT
Definition debugger.h:37
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_BP
Definition debugger.h:46
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_TEST_QUERY
Definition debugger.h:51
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_CALLSTACK_RESULT
Definition debugger.h:52
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_REGISTER_EVENT
Definition debugger.h:42
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PTE_RESULT
Definition debugger.h:55
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_VA2PA_AND_PA2VA_RESULT
Definition debugger.h:54
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SCRIPT_RUNNING_RESULT
Definition debugger.h:38
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_WRITE_REGISTER
Definition debugger.h:58
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_READ_REGISTERS
Definition debugger.h:45
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_CORE_SWITCHING_RESULT
Definition debugger.h:35
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PROCESS_SWITCHING_RESULT
Definition debugger.h:36
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PAUSED_DEBUGGEE_DETAILS
Definition debugger.h:34
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_STARTED_PACKET_RECEIVED
Definition debugger.h:33
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PAGE_IN_STATE
Definition debugger.h:57
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SYMBOL_RELOAD
Definition debugger.h:50
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_EDIT_MEMORY
Definition debugger.h:49
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_READ_MEMORY
Definition debugger.h:48
#define DbgWaitGetRequestData(KernelSyncObjectId, ReqData, ReqSize)
Definition kd.h:40
BOOLEAN KdCloseConnection()
BOOLEAN KdSendResponseOfThePingPacket()
BOOLEAN KdReceivePacketFromDebuggee(CHAR *BufferToSave, UINT32 *LengthReceived)
#define DbgReceivedKernelResponse(KernelSyncObjectId)
Definition kd.h:53
RFLAGS * PRFLAGS
Definition pch.h:34
VOID CommandPteShowResults(UINT64 TargetVa, PDEBUGGER_READ_PAGE_TABLE_ENTRIES_DETAILS PteRead)
show results of !pte command
Definition pte.cpp:47
The structure of breakpoint modification requests packet in HyperDbg.
Definition RequestStructures.h:1090
UINT32 Result
Definition RequestStructures.h:1093
The structure of bp command packet in HyperDbg.
Definition RequestStructures.h:1060
UINT32 Result
Definition RequestStructures.h:1067
The structure of changing core packet in HyperDbg.
Definition RequestStructures.h:599
UINT32 Result
Definition RequestStructures.h:601
UINT32 NewCore
Definition RequestStructures.h:600
The structure of changing process and show process packet in HyperDbg.
Definition RequestStructures.h:924
UINT32 ProcessId
Definition RequestStructures.h:926
UINT64 Process
Definition RequestStructures.h:927
DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_TYPE ActionType
Definition RequestStructures.h:925
UINT32 Result
Definition RequestStructures.h:931
UCHAR ProcessName[16]
Definition RequestStructures.h:929
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
UINT64 Process
Definition RequestStructures.h:968
UINT32 ProcessId
Definition RequestStructures.h:966
UCHAR ProcessName[16]
Definition RequestStructures.h:970
UINT32 ThreadId
Definition RequestStructures.h:965
UINT32 Result
Definition RequestStructures.h:972
The structure of .formats result packet in HyperDbg.
Definition RequestStructures.h:1033
UINT32 Result
Definition RequestStructures.h:1035
UINT64 Value
Definition RequestStructures.h:1034
The structure of pausing packet in kHyperDbg.
Definition DataTypes.h:207
UINT16 ReadInstructionLen
Definition DataTypes.h:217
UINT64 Rip
Definition DataTypes.h:208
UINT64 Rflags
Definition DataTypes.h:215
BYTE InstructionBytesOnRip[MAXIMUM_INSTR_SIZE]
Definition DataTypes.h:216
BOOLEAN IsProcessorOn32BitMode
Definition DataTypes.h:209
DEBUGGEE_PAUSING_REASON PausingReason
Definition DataTypes.h:211
UINT64 EventTag
Definition DataTypes.h:213
ULONG CurrentCore
Definition DataTypes.h:212
BOOLEAN IgnoreDisassembling
Definition DataTypes.h:210
VMM_CALLBACK_EVENT_CALLING_STAGE_TYPE EventCallingStage
Definition DataTypes.h:214
The structure of message packet in HyperDbg.
Definition DataTypes.h:268
UINT32 OperationCode
Definition DataTypes.h:269
CHAR Message[PacketChunkSize]
Definition DataTypes.h:270
Register Descriptor Structure to use in r command.
Definition RequestStructures.h:1156
Register Descriptor Structure to write on registers.
Definition RequestStructures.h:1171
The structure of result of search packet in HyperDbg.
Definition RequestStructures.h:1142
UINT32 CountOfResults
Definition RequestStructures.h:1143
UINT32 Result
Definition RequestStructures.h:1144
The structure of script packet in HyperDbg.
Definition RequestStructures.h:1122
BOOLEAN IsFormat
Definition RequestStructures.h:1125
UINT32 Result
Definition RequestStructures.h:1126
request that shows, symbol reload process is finished
Definition Symbols.h:89
UINT64 KernelStatus
Definition Symbols.h:90
request for callstack frames
Definition RequestStructures.h:789
UINT32 KernelStatus
Definition RequestStructures.h:791
UINT32 FrameCount
Definition RequestStructures.h:794
BOOLEAN Is32Bit
Definition RequestStructures.h:790
DEBUGGER_CALLSTACK_DISPLAY_METHOD DisplayMethod
Definition RequestStructures.h:792
request for test query buffers
Definition RequestStructures.h:333
UINT32 KernelStatus
Definition RequestStructures.h:336
DEBUGGER_TEST_QUERY_STATE RequestType
Definition RequestStructures.h:334
request for edit virtual and physical memory
Definition RequestStructures.h:482
Status of register buffers.
Definition Events.h:423
request for flushing buffers
Definition RequestStructures.h:294
UINT32 CountOfMessagesThatSetAsReadFromVmxRoot
Definition RequestStructures.h:296
UINT32 CountOfMessagesThatSetAsReadFromVmxNonRoot
Definition RequestStructures.h:297
UINT32 KernelStatus
Definition RequestStructures.h:295
request for modifying events (enable/disable/clear)
Definition Events.h:242
DEBUGGER_MODIFY_EVENTS_TYPE TypeOfAction
Definition Events.h:246
BOOLEAN IsEnabled
Definition Events.h:247
UINT64 KernelStatus
Definition Events.h:244
UINT64 Tag
Definition Events.h:243
requests for the '.pagein' command
Definition RequestStructures.h:73
UINT32 KernelStatus
Definition RequestStructures.h:78
request to make this computer to a debuggee
Definition RequestStructures.h:582
UINT64 KernelBaseAddress
Definition RequestStructures.h:585
CHAR OsName[MAXIMUM_CHARACTER_FOR_OS_NAME]
Definition RequestStructures.h:587
request for reading virtual and physical memory
Definition RequestStructures.h:266
request for !pte command
Definition RequestStructures.h:22
UINT64 VirtualAddress
Definition RequestStructures.h:23
UINT32 KernelStatus
Definition RequestStructures.h:38
request for performing a short-circuiting event
Definition Events.h:256
BOOLEAN IsShortCircuiting
Definition Events.h:258
UINT64 KernelStatus
Definition Events.h:257
The structure for saving the callstack frame of one parameter.
Definition RequestStructures.h:761
request to add new symbol detail or update a previous symbol table entry
Definition Symbols.h:73
MODULE_SYMBOL_DETAIL SymbolDetailPacket
Definition Symbols.h:76
requests for !va2pa and !pa2va commands
Definition RequestStructures.h:54
BOOLEAN IsVirtual2Physical
Definition RequestStructures.h:58
UINT32 KernelStatus
Definition RequestStructures.h:59
UINT64 PhysicalAddress
Definition RequestStructures.h:56
UINT64 VirtualAddress
Definition RequestStructures.h:55
BOOLEAN SymbolBuildAndUpdateSymbolTable(PMODULE_SYMBOL_DETAIL SymbolDetail)
Allocate (build) and update the symbol table whenever a debuggee is attached on the debugger mode.
Definition symbol.cpp:940
VOID SymbolInitialReload()
Initial load of symbols (for previously download symbols)
Definition symbol.cpp:34
VOID CommandTrackHandleReceivedInstructions(unsigned char *BufferToDisassemble, UINT32 BuffLength, BOOLEAN Isx86_64, UINT64 RipAddress)
Handle received 'call' or 'ret'.
Definition track.cpp:211

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_ErrorStateOfResultOfEvaluatedExpression

UINT32 g_ErrorStateOfResultOfEvaluatedExpression
extern

Shows the state of the evaluation of expression which whether contains error or not.

◆ g_IgnoreNewLoggingMessages

BOOLEAN g_IgnoreNewLoggingMessages
extern

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

◆ g_IsDebuggeeRunning

BOOLEAN g_IsDebuggeeRunning
extern

Shows if the debuggee is running or not.

◆ 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_KernelBaseAddress

UINT64 g_KernelBaseAddress
extern

Shows the kernel base address.

◆ 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_OutputSourcesInitialized

BOOLEAN g_OutputSourcesInitialized
extern

it shows whether the debugger started using output sources or not or in other words, is g_OutputSources initialized with a variable or it is empty

◆ 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_ResultOfEvaluatedExpression

UINT64 g_ResultOfEvaluatedExpression
extern

Result of the expression that is evaluated in the debuggee.

◆ 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.