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

BYTE g_CurrentRunningInstruction [MAXIMUM_INSTR_SIZE]
 Current executing instructions.
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
 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).
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.
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.

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
1628{
1629 //
1630 // Create a listening thead in debuggee
1631 //
1633
1634 return 0;
1635}
BOOLEAN ListeningSerialPortInDebuggee()
Check if the remote debugger needs to pause the system.
Definition kernel-listening.cpp:1437

◆ ListeningSerialPauseDebuggerThread()

DWORD WINAPI ListeningSerialPauseDebuggerThread ( PVOID Param)

Check if the remote debuggee needs to pause the system.

Parameters
Param
Returns
BOOLEAN
1611{
1612 //
1613 // Create a listening thead in debugger
1614 //
1616
1617 return 0;
1618}
BOOLEAN ListeningSerialPortInDebugger()
Check if the remote debuggee needs to pause the system and also process the debuggee's messages.
Definition kernel-listening.cpp:42

◆ ListeningSerialPortInDebuggee()

BOOLEAN ListeningSerialPortInDebuggee ( )

Check if the remote debugger needs to pause the system.

Parameters
SerialHandle
Returns
BOOLEAN
1438{
1439StartAgain:
1440
1441 BOOL Status; /* Status */
1442 CHAR SerialBuffer[MaxSerialPacketSize] = {
1443 0}; /* Buffer to send and receive data */
1444 DWORD EventMask = 0; /* Event mask to trigger */
1445 char ReadData = NULL; /* temperory Character */
1446 DWORD NoBytesRead = 0; /* Bytes read by ReadFile() */
1447 UINT32 Loop = 0;
1448 PDEBUGGER_REMOTE_PACKET TheActualPacket = (PDEBUGGER_REMOTE_PACKET)SerialBuffer;
1449
1450 //
1451 // Setting Receive Mask
1452 //
1453 Status = SetCommMask(g_SerialRemoteComPortHandle, EV_RXCHAR);
1454 if (Status == FALSE)
1455 {
1456 // ShowMessages("warning, there is an error in setting CommMask\n");
1457
1458 //
1459 // Sometimes, this error happens
1460 //
1461 // return FALSE;
1462 }
1463
1464 //
1465 // Setting WaitComm() Event
1466 //
1467 Status = WaitCommEvent(g_SerialRemoteComPortHandle, &EventMask, NULL); /* Wait for the character to be received */
1468
1469 if (Status == FALSE)
1470 {
1471 //
1472 // Can be ignored
1473 //
1474 // ShowMessages("err, in setting WaitCommEvent\n");
1475 // return FALSE;
1476 }
1477
1478 //
1479 // Read data and store in a buffer
1480 //
1481 do
1482 {
1483 Status = ReadFile(g_SerialRemoteComPortHandle, &ReadData, sizeof(ReadData), &NoBytesRead, NULL);
1484
1485 //
1486 // Check to make sure that we don't pass the boundaries
1487 //
1488 if (!Status || !(MaxSerialPacketSize > Loop))
1489 {
1490 //
1491 // Invalid buffer
1492 //
1493 ShowMessages("err, a buffer received in debuggee which exceeds the "
1494 "buffer limitation\n");
1495 goto StartAgain;
1496 }
1497
1498 SerialBuffer[Loop] = ReadData;
1499
1500 if (KdCheckForTheEndOfTheBuffer(&Loop, (BYTE *)SerialBuffer))
1501 {
1502 break;
1503 }
1504
1505 ++Loop;
1506 } while (NoBytesRead > 0);
1507
1508 //
1509 // Because we used overlapped I/O on the other side, sometimes
1510 // the debuggee might cancel the read so it returns, if it returns
1511 // then we should restart reading again
1512 //
1513 if (Loop == 1 && SerialBuffer[0] == NULL)
1514 {
1515 //
1516 // Chunk data to cancel non async read
1517 //
1518 goto StartAgain;
1519 }
1520
1521 //
1522 // Get actual length of received data
1523 //
1524 // ShowMessages("\nNumber of bytes received = %d\n", Loop);
1525 // for (size_t i = 0; i < Loop; i++) {
1526 // ShowMessages("%x ", SerialBuffer[i]);
1527 // }
1528 // ShowMessages("\n");
1529 //
1530
1531 if (TheActualPacket->Indicator == INDICATOR_OF_HYPERDBG_PACKET)
1532 {
1533 //
1534 // Check checksum
1535 //
1536 if (KdComputeDataChecksum((PVOID)&TheActualPacket->Indicator,
1537 Loop - sizeof(BYTE)) != TheActualPacket->Checksum)
1538 {
1539 ShowMessages("err checksum is invalid\n");
1540 goto StartAgain;
1541 }
1542
1543 //
1544 // Check if the packet type is correct
1545 //
1547 {
1548 //
1549 // sth wrong happened, the packet is not belonging to use
1550 // nothing to do, just wait again
1551 //
1552 ShowMessages("err, unknown packet received from the debugger\n");
1553 goto StartAgain;
1554 }
1555
1556 //
1557 // It's a HyperDbg packet
1558 //
1559 switch (TheActualPacket->RequestedActionOfThePacket)
1560 {
1562
1563 if (!DebuggerPauseDebuggee())
1564 {
1565 ShowMessages("err, debugger tries to pause the debuggee but the "
1566 "attempt was unsuccessful\n");
1567 }
1568
1569 break;
1570
1572
1573 //
1574 // Not read anymore
1575 //
1576 return TRUE;
1577
1578 break;
1579
1580 default:
1581
1582 ShowMessages("err, unknown packet action received from the debugger\n");
1583
1584 break;
1585 }
1586 }
1587 else
1588 {
1589 //
1590 // It's not a HyperDbg packet, it's probably a GDB packet
1591 //
1592 DebugBreak();
1593 }
1594
1595 //
1596 // Wait for debug pause command again
1597 //
1598 goto StartAgain;
1599
1600 return TRUE;
1601}
_Use_decl_annotations_ BYTE KdComputeDataChecksum(PVOID Buffer, UINT32 Length)
calculate the checksum of received buffer from debugger
Definition Kd.c:275
int BOOL
Definition BasicTypes.h:25
void * PVOID
Definition BasicTypes.h:56
unsigned char BYTE
Definition BasicTypes.h:40
#define TRUE
Definition BasicTypes.h:114
#define FALSE
Definition BasicTypes.h:113
unsigned long DWORD
Definition BasicTypes.h:38
unsigned int UINT32
Definition BasicTypes.h:54
char CHAR
Definition BasicTypes.h:33
struct _DEBUGGER_REMOTE_PACKET * PDEBUGGER_REMOTE_PACKET
@ DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGER_TO_DEBUGGEE_EXECUTE_ON_USER_MODE
Definition Connection.h:173
@ 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:504
#define MaxSerialPacketSize
size of buffer for serial
Definition Constants.h:202
BOOLEAN DebuggerPauseDebuggee()
pauses the debuggee
Definition debugger.cpp:722
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:246
NULL()
Definition test-case-generator.py:530
DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION RequestedActionOfThePacket
Definition Connection.h:201
DEBUGGER_REMOTE_PACKET_TYPE TypeOfThePacket
Definition Connection.h:200
BYTE Checksum
Definition Connection.h:198
UINT64 Indicator
Definition Connection.h:199

◆ ListeningSerialPortInDebugger()

BOOLEAN ListeningSerialPortInDebugger ( )

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

Returns
BOOLEAN
43{
45 PDEBUGGER_REMOTE_PACKET TheActualPacket;
47 PDEBUGGEE_MESSAGE_PACKET MessagePacket;
48 PDEBUGGEE_CHANGE_CORE_PACKET ChangeCorePacket;
49 PDEBUGGEE_SCRIPT_PACKET ScriptPacket;
50 PDEBUGGEE_FORMATS_PACKET FormatsPacket;
51 PDEBUGGER_EVENT_AND_ACTION_RESULT EventAndActionPacket;
52 PDEBUGGER_UPDATE_SYMBOL_TABLE SymbolUpdatePacket;
53 PDEBUGGER_MODIFY_EVENTS EventModifyAndQueryPacket;
54 PDEBUGGEE_SYMBOL_UPDATE_RESULT SymbolReloadFinishedPacket;
56 PDEBUGGEE_RESULT_OF_SEARCH_PACKET SearchResultsPacket;
59 PDEBUGGER_CALLSTACK_REQUEST CallstackPacket;
60 PDEBUGGER_SINGLE_CALLSTACK_FRAME CallstackFramePacket;
62 PDEBUGGEE_REGISTER_READ_DESCRIPTION ReadRegisterPacket;
63 PDEBUGGEE_REGISTER_WRITE_DESCRIPTION WriteRegisterPacket;
64 PDEBUGGER_APIC_REQUEST ApicRequestPacket;
65 PDEBUGGER_READ_MEMORY ReadMemoryPacket;
66 PDEBUGGER_EDIT_MEMORY EditMemoryPacket;
67 PDEBUGGEE_BP_PACKET BpPacket;
68 PDEBUGGER_SHORT_CIRCUITING_EVENT ShortCircuitingPacket;
70 PSMI_OPERATION_PACKETS SmiOperationPacket;
71 PHYPERTRACE_LBR_DUMP_PACKETS HyperTraceLbrdumpPacket;
72 PHYPERTRACE_PT_OPERATION_PACKETS HyperTracePtOperationPacket;
73 PDEBUGGER_PAGE_IN_REQUEST PageinPacket;
75 PDEBUGGEE_BP_LIST_OR_MODIFY_PACKET ListOrModifyBreakpointPacket;
76 BOOLEAN ShowSignatureWhenDisconnected = FALSE;
77 PVOID CallerAddress = NULL;
78 UINT32 CallerSize = NULL_ZERO;
82
83StartAgain:
84
85 CHAR BufferToReceive[MaxSerialPacketSize] = {0};
86 UINT32 LengthReceived = 0;
87
88 //
89 // Wait for handshake to complete or in other words
90 // get the receive packet
91 //
92 if (!KdReceivePacketFromDebuggee(BufferToReceive, &LengthReceived))
93 {
94 if (LengthReceived == 0 && BufferToReceive[0] == NULL)
95 {
96 //
97 // The remote computer (debuggee) closed the connection
98 //
99 ShowMessages("\nthe remote connection is closed\n");
100
102 {
103 //
104 // Remove and reset all the events
105 //
107
109 {
110 ShowSignatureWhenDisconnected = TRUE;
111 }
112 }
113
115
116 if (ShowSignatureWhenDisconnected)
117 {
118 ShowSignatureWhenDisconnected = FALSE;
119 ShowMessages("\n");
120 }
121 return FALSE;
122 }
123 else
124 {
125 ShowMessages("err, invalid buffer received\n");
126 goto StartAgain;
127 }
128 }
129
130 //
131 // Check for invalid close packets
132 //
133 if (LengthReceived == 1 && BufferToReceive[0] == NULL)
134 {
135 goto StartAgain;
136 }
137
138 TheActualPacket = (PDEBUGGER_REMOTE_PACKET)BufferToReceive;
139
140 if (TheActualPacket->Indicator == INDICATOR_OF_HYPERDBG_PACKET)
141 {
142 //
143 // Check checksum
144 //
145 if (KdComputeDataChecksum((PVOID)&TheActualPacket->Indicator,
146 LengthReceived - sizeof(BYTE)) != TheActualPacket->Checksum)
147 {
148 ShowMessages("\nerr, checksum is invalid\n");
149 goto StartAgain;
150 }
151
152 //
153 // Check if the packet type is correct
154 //
156 {
157 //
158 // sth wrong happened, the packet is not belonging to use
159 // nothing to do, just wait again
160 //
161 ShowMessages("\nerr, unknown packet received from the debuggee\n");
162 goto StartAgain;
163 }
164
165 //
166 // It's a HyperDbg packet
167 //
168 switch (TheActualPacket->RequestedActionOfThePacket)
169 {
171
172 //
173 // Send the handshake response
174 //
176
177 break;
178
180
181 InitPacket = (DEBUGGER_PREPARE_DEBUGGEE *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
182
183 //
184 // Set the kernel base address
185 //
187
188 ShowMessages("connected to debuggee %s\n", InitPacket->OsName);
189
190 //
191 // Signal the event that the debugger started
192 //
194
195 break;
196
198
199 MessagePacket = (DEBUGGEE_MESSAGE_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
200
201 //
202 // Check if there are available output sources
203 //
205 MessagePacket->Message,
206 (UINT32)strlen(MessagePacket->Message)))
207 {
208 //
209 // We check g_IgnoreNewLoggingMessages here because we want to
210 // avoid messages when the debuggee is halted
211 //
213 {
214 ShowMessages("%s", MessagePacket->Message);
215 }
216 }
217
218 break;
219
221
222 //
223 // Pause logging mechanism
224 //
226
227 PausePacket = (DEBUGGEE_KD_PAUSED_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
228
229 //
230 // Debuggee is not running
231 //
233
234 //
235 // Set the current core
236 //
237 g_CurrentRemoteCore = PausePacket->CurrentCore;
238
239 //
240 // Save the current operating instruction and operating mode
241 //
244
246
247 //
248 // Show additional messages before showing assembly and pausing
249 //
250 switch (PausePacket->PausingReason)
251 {
253
254 if (PausePacket->EventTag != NULL)
255 {
256 //
257 // It's a breakpoint id
258 //
259 ShowMessages("breakpoint 0x%x hit\n",
260 PausePacket->EventTag);
261 }
262
263 break;
264
266
267 if (PausePacket->EventTag != NULL)
268 {
269 //
270 // It's an event tag
271 //
273 {
274 ShowMessages("event 0x%x triggered (post)\n",
275 PausePacket->EventTag - DebuggerEventTagStartSeed);
276 }
277 else
278 {
279 ShowMessages("event 0x%x triggered (pre)\n",
280 PausePacket->EventTag - DebuggerEventTagStartSeed);
281 }
282 }
283
284 break;
285
287
288 ShowMessages("switched to the specified process\n");
289
290 break;
291
293
294 ShowMessages("switched to the specified thread\n");
295
296 break;
297
299
300 ShowMessages("the target module is loaded and a breakpoint is set to the entrypoint\n"
301 "press 'g' to reach to the entrypoint of the main module...\n");
302
303 break;
304
305 default:
306 break;
307 }
308
309 if (!PausePacket->IgnoreDisassembling)
310 {
311 //
312 // Check if the instruction is received completely or not
313 //
314 if (PausePacket->ReadInstructionLen != MAXIMUM_INSTR_SIZE)
315 {
316 //
317 // We check if the disassembled buffer has greater size
318 // than what is retrieved
319 //
322 PausePacket->IsProcessorOn32BitMode ? FALSE : TRUE) > PausePacket->ReadInstructionLen)
323 {
324 ShowMessages("oOh, no! there might be a misinterpretation in disassembling the current instruction\n");
325 }
326 }
327
328 if (!PausePacket->IsProcessorOn32BitMode)
329 {
330 //
331 // Show diassembles
332 //
334 PausePacket->Rip,
336 1,
337 TRUE,
338 (PRFLAGS)&PausePacket->Rflags);
339 }
340 else
341 {
342 //
343 // Show diassembles
344 //
346 PausePacket->Rip,
348 1,
349 TRUE,
350 (PRFLAGS)&PausePacket->Rflags);
351 }
352 }
353
354 switch (PausePacket->PausingReason)
355 {
362
363 //
364 // Unpause the debugger to get commands
365 //
367
368 break;
369
371
372 //
373 // Handle the tracking of the 'ret' and the 'call' instructions
374 //
377 PausePacket->IsProcessorOn32BitMode ? FALSE : TRUE,
378 PausePacket->Rip);
379
380 //
381 // Unpause the debugger to get commands
382 //
384
385 break;
386
388
389 //
390 // Unpause the debugger to get commands
391 //
392 ShowMessages("\n");
394
395 break;
396
398
399 //
400 // Nothing
401 //
402 break;
403
405
406 //
407 // Signal the event relating to receiving result of core change
408 //
410
411 break;
412
414
415 //
416 // Signal the event relating to result of command execution finished
417 //
418 ShowMessages("\n");
420
421 break;
422
424
425 //
426 // Signal the event relating to commands that are waiting for
427 // the details of a halted debuggeee
428 //
430
431 break;
432
433 default:
434
435 ShowMessages("err, unknown pausing reason is received\n");
436
437 break;
438 }
439
440 break;
441
443
444 ChangeCorePacket = (DEBUGGEE_CHANGE_CORE_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
445
446 if (ChangeCorePacket->Result == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
447 {
448 ShowMessages("current operating core changed to 0x%x\n",
449 ChangeCorePacket->NewCore);
450 }
451 else
452 {
453 ShowErrorMessage(ChangeCorePacket->Result);
454
455 //
456 // Signal the event relating to receiving result of core change
457 //
459 }
460
461 break;
462
464
465 ChangeProcessPacket = (DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
466
467 if (ChangeProcessPacket->Result == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
468 {
470 {
471 ShowMessages("process id: %x\nprocess (_EPROCESS): %s\nprocess name (16-Byte): %s\n",
472 ChangeProcessPacket->ProcessId,
473 SeparateTo64BitValue(ChangeProcessPacket->Process).c_str(),
474 &ChangeProcessPacket->ProcessName);
475 }
476 else if (ChangeProcessPacket->ActionType == DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_PERFORM_SWITCH)
477 {
478 ShowMessages(
479 "press 'g' to continue the debuggee, if the pid or the "
480 "process object address is valid then the debuggee will "
481 "be automatically paused when it attached to the target process\n");
482 }
483 }
484 else
485 {
486 ShowErrorMessage(ChangeProcessPacket->Result);
487 }
488
489 //
490 // Signal the event relating to receiving result of process change
491 //
493
494 break;
495
497
498 SearchResultsPacket = (DEBUGGEE_RESULT_OF_SEARCH_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
499
500 if (SearchResultsPacket->Result == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
501 {
502 if (SearchResultsPacket->CountOfResults == 0)
503 {
504 ShowMessages("not found\n");
505 }
506 }
507 else
508 {
509 ShowErrorMessage(SearchResultsPacket->Result);
510 }
511
512 //
513 // Signal the event relating to receiving result of search query
514 //
516
517 break;
518
520
521 ChangeThreadPacket = (DEBUGGEE_DETAILS_AND_SWITCH_THREAD_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
522
523 if (ChangeThreadPacket->Result == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
524 {
526 {
527 ShowMessages("thread id: %x (pid: %x)\nthread (_ETHREAD): %s\nprocess (_EPROCESS): %s\nprocess name (16-Byte): %s\n",
528 ChangeThreadPacket->ThreadId,
529 ChangeThreadPacket->ProcessId,
530 SeparateTo64BitValue(ChangeThreadPacket->Thread).c_str(),
531 SeparateTo64BitValue(ChangeThreadPacket->Process).c_str(),
532 &ChangeThreadPacket->ProcessName);
533 }
535 {
536 ShowMessages(
537 "press 'g' to continue the debuggee, if the tid or the "
538 "thread object address is valid then the debuggee will "
539 "be automatically paused when it attached to the target thread\n");
540 }
541 }
542 else
543 {
544 ShowErrorMessage(ChangeThreadPacket->Result);
545 }
546
547 //
548 // Signal the event relating to receiving result of thread change
549 //
551
552 break;
553
555
556 FlushPacket = (DEBUGGER_FLUSH_LOGGING_BUFFERS *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
557
559 {
560 //
561 // The amount of message that are deleted are the amount of
562 // vmx-root messages and vmx non-root messages
563 //
564 ShowMessages("flushing buffers was successful, total %d messages were "
565 "cleared.\n",
567 }
568 else
569 {
570 ShowErrorMessage(FlushPacket->KernelStatus);
571 }
572
573 //
574 // Signal the event relating to receiving result of flushing
575 //
577
578 break;
579
581
582 CallstackPacket = (DEBUGGER_CALLSTACK_REQUEST *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
583 CallstackFramePacket = (DEBUGGER_SINGLE_CALLSTACK_FRAME *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET) + sizeof(DEBUGGER_CALLSTACK_REQUEST));
584
585 if (CallstackPacket->KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
586 {
587 //
588 // Show the callstack
589 //
590 CallstackShowFrames(CallstackFramePacket,
591 CallstackPacket->FrameCount,
592 CallstackPacket->DisplayMethod,
593 CallstackPacket->Is32Bit);
594 }
595 else
596 {
597 ShowErrorMessage(CallstackPacket->KernelStatus);
598 }
599
600 //
601 // Signal the event relating to receiving result of callstack
602 //
604
605 break;
606
608
609 TestQueryPacket = (DEBUGGER_DEBUGGER_TEST_QUERY_BUFFER *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
610
611 if (TestQueryPacket->KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
612 {
613 switch (TestQueryPacket->RequestType)
614 {
616
617 ShowMessages("breakpoint interception (#BP) is deactivated\n"
618 "from now, the breakpoints will be re-injected into the guest debuggee\n");
619
620 break;
621
623
624 ShowMessages("breakpoint interception (#BP) is activated\n");
625
626 break;
627
629
630 ShowMessages("debug break interception (#DB) is deactivated\n"
631 "from now, the debug breaks will be re-injected into the guest debuggee\n");
632
633 break;
634
636
637 ShowMessages("debug break interception (#DB) is activated\n");
638
639 break;
640
641 default:
642 break;
643 }
644 }
645 else
646 {
647 ShowErrorMessage(TestQueryPacket->KernelStatus);
648 }
649
650 //
651 // Signal the event relating to receiving result of test query
652 //
654
655 break;
656
658
659 ScriptPacket = (DEBUGGEE_SCRIPT_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
660
661 if (ScriptPacket->Result == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
662 {
663 //
664 // Nothing to do
665 //
666 }
667 else
668 {
669 ShowErrorMessage(ScriptPacket->Result);
670 }
671
672 if (ScriptPacket->IsFormat)
673 {
674 //
675 // Signal the event relating to receiving result of the '.formats' command
676 //
678 }
679
680 //
681 // Signal the event relating to receiving result of running script
682 //
684
685 break;
686
688
689 FormatsPacket = (DEBUGGEE_FORMATS_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
690
691 //
692 // We'll just save the result of expression to the global variables
693 // and let the debuggee to decide whether wants to show error or not
694 // and let the debuggee to decide whether wants to show error or not
695 //
697 g_ResultOfEvaluatedExpression = FormatsPacket->Value;
698
699 break;
700
702
703 EventAndActionPacket = (DEBUGGER_EVENT_AND_ACTION_RESULT *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
704
705 //
706 // Move the buffer to the global variable
707 //
708 memcpy(&g_DebuggeeResultOfRegisteringEvent, EventAndActionPacket, sizeof(DEBUGGER_EVENT_AND_ACTION_RESULT));
709
710 //
711 // Signal the event relating to receiving result of register event
712 //
714
715 break;
716
718
719 EventAndActionPacket = (DEBUGGER_EVENT_AND_ACTION_RESULT *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
720
721 //
722 // Move the buffer to the global variable
723 //
724 memcpy(&g_DebuggeeResultOfAddingActionsToEvent, EventAndActionPacket, sizeof(DEBUGGER_EVENT_AND_ACTION_RESULT));
725
726 //
727 // Signal the event relating to receiving result of adding action to event
728 //
730
731 break;
732
734
735 EventModifyAndQueryPacket = (DEBUGGER_MODIFY_EVENTS *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
736
737 //
738 // Set the result of query
739 //
740 if (EventModifyAndQueryPacket->KernelStatus != DEBUGGER_OPERATION_WAS_SUCCESSFUL)
741 {
742 //
743 // There was an error
744 //
745 ShowErrorMessage((UINT32)EventModifyAndQueryPacket->KernelStatus);
746 }
747 else if (EventModifyAndQueryPacket->TypeOfAction == DEBUGGER_MODIFY_EVENTS_QUERY_STATE)
748 {
749 //
750 // Set the global state
751 //
752 g_SharedEventStatus = EventModifyAndQueryPacket->IsEnabled;
753 }
754 else
755 {
756 CommandEventsHandleModifiedEvent(EventModifyAndQueryPacket->Tag,
757 EventModifyAndQueryPacket);
758 }
759
760 //
761 // Signal the event relating to receiving result of event query and
762 // modification
763 //
765
766 break;
767
769
770 SymbolReloadFinishedPacket = (DEBUGGEE_SYMBOL_UPDATE_RESULT *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
771
772 //
773 // Show messages as the result of updating symbols
774 //
775 if (SymbolReloadFinishedPacket->KernelStatus != DEBUGGER_OPERATION_WAS_SUCCESSFUL)
776 {
777 //
778 // There was an error
779 //
780 ShowErrorMessage((UINT32)SymbolReloadFinishedPacket->KernelStatus);
781 }
782 else
783 {
784 //
785 // Load the symbols
786 //
788 }
789
790 //
791 // Signal the event relating to receiving result of symbol reload
792 //
794
795 break;
796
798
799 ReadRegisterPacket = (DEBUGGEE_REGISTER_READ_DESCRIPTION *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
800
801 //
802 // Get the address and size of the caller
803 //
805
806 //
807 // Copy the memory buffer for the caller
808 //
809 memcpy(CallerAddress, ReadRegisterPacket, CallerSize);
810
811 //
812 // Signal the event relating to receiving result of reading registers
813 //
815
816 break;
817
819
820 WriteRegisterPacket = (DEBUGGEE_REGISTER_WRITE_DESCRIPTION *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
821
822 //
823 // Get the address and size of the caller
824 //
826
827 //
828 // Copy the memory buffer for the caller
829 //
830 memcpy(CallerAddress, WriteRegisterPacket, CallerSize);
831
832 //
833 // Signal the event relating to receiving result of writing register
834 //
836
837 break;
838
840
841 ApicRequestPacket = (DEBUGGER_APIC_REQUEST *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
842
843 //
844 // Get the address and size of the caller
845 //
847
848 //
849 // Copy the memory buffer for the caller
850 //
851 memcpy(CallerAddress, ApicRequestPacket, CallerSize);
852
853 //
854 // Signal the event relating to receiving result of performing actions into APIC
855 //
857
858 break;
859
861
862 IdtEntryRequestPacket = (INTERRUPT_DESCRIPTOR_TABLE_ENTRIES_PACKETS *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
863
864 //
865 // Get the address and size of the caller
866 //
868
869 //
870 // Copy the memory buffer for the caller
871 //
872 memcpy(CallerAddress, IdtEntryRequestPacket, CallerSize);
873
874 //
875 // Signal the event relating to receiving result of querying IDT entries
876 //
878
879 break;
880
882
883 ReadMemoryPacket = (DEBUGGER_READ_MEMORY *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
884
885 //
886 // Get the address and size of the caller
887 //
889
890 //
891 // Copy the memory buffer for the caller
892 //
893 memcpy(CallerAddress, ReadMemoryPacket, CallerSize);
894
895 //
896 // Signal the event relating to receiving result of reading memory
897 //
899
900 break;
901
903
904 EditMemoryPacket = (DEBUGGER_EDIT_MEMORY *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
905
906 //
907 // Get the address and size of the caller
908 //
910
911 //
912 // Copy the memory buffer for the caller
913 //
914 memcpy(CallerAddress, EditMemoryPacket, CallerSize);
915
916 //
917 // Signal the event relating to receiving result of editing memory
918 //
920
921 break;
922
924
925 BpPacket = (DEBUGGEE_BP_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
926
928 {
929 //
930 // Everything was okay, nothing to do
931 //
932 }
933 else
934 {
935 ShowErrorMessage(BpPacket->Result);
936 }
937
938 //
939 // Signal the event relating to receiving result of putting breakpoints
940 //
942
943 break;
944
946
947 ShortCircuitingPacket = (DEBUGGER_SHORT_CIRCUITING_EVENT *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
948
949 if (ShortCircuitingPacket->KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
950 {
951 ShowMessages("the event's short-circuiting state changed to %s\n", ShortCircuitingPacket->IsShortCircuiting ? "'on'" : "'off'");
952 }
953 else
954 {
955 ShowErrorMessage((UINT32)ShortCircuitingPacket->KernelStatus);
956 }
957
958 //
959 // Signal the event relating to receiving result of changing the short circuiting state
960 //
962
963 break;
964
966
967 PtePacket = (DEBUGGER_READ_PAGE_TABLE_ENTRIES_DETAILS *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
968
970 {
971 //
972 // Show the Page Tables result
973 //
974 CommandPteShowResults(PtePacket->VirtualAddress, PtePacket);
975 }
976 else
977 {
978 ShowErrorMessage(PtePacket->KernelStatus);
979 }
980
981 //
982 // Signal the event relating to receiving result of PTE query
983 //
985
986 break;
987
989
990 SmiOperationPacket = (SMI_OPERATION_PACKETS *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
991
992 //
993 // Get the address and size of the caller
994 //
996
997 //
998 // Copy the memory buffer for the caller
999 //
1000 memcpy(CallerAddress, SmiOperationPacket, CallerSize);
1001
1002 //
1003 // Signal the event relating to receiving result of SMI operation
1004 //
1006
1007 break;
1008
1010
1011 HyperTraceLbrdumpPacket = (HYPERTRACE_LBR_DUMP_PACKETS *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
1012
1013 //
1014 // Get the address and size of the caller
1015 //
1017
1018 //
1019 // Copy the memory buffer for the caller
1020 //
1021 memcpy(CallerAddress, HyperTraceLbrdumpPacket, CallerSize);
1022
1023 //
1024 // Signal the event relating to receiving result of HyperTrace LBR dump
1025 //
1027
1028 break;
1029
1031
1032 HyperTracePtOperationPacket = (HYPERTRACE_PT_OPERATION_PACKETS *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
1033
1034 //
1035 // Get the address and size of the caller
1036 //
1038
1039 //
1040 // Copy the memory buffer for the caller
1041 //
1042 memcpy(CallerAddress, HyperTracePtOperationPacket, CallerSize);
1043
1044 //
1045 // Signal the event relating to receiving result of HyperTrace PT operation
1046 //
1048
1049 break;
1050
1052
1053 PageinPacket = (DEBUGGER_PAGE_IN_REQUEST *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
1054
1056 {
1057 //
1058 // Show the successful delivery of the packet
1059 //
1060 ShowMessages("the page-fault is delivered to the target thread\n"
1061 "press 'g' to continue debuggee (the current thread will execute ONLY one instruction and will be halted again)...\n");
1062 }
1063 else
1064 {
1065 ShowErrorMessage(PageinPacket->KernelStatus);
1066 }
1067
1068 //
1069 // Signal the event relating to receiving result of page-in request
1070 //
1072
1073 break;
1074
1076
1077 Va2paPa2vaPacket = (DEBUGGER_VA2PA_AND_PA2VA_COMMANDS *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
1078
1079 if (Va2paPa2vaPacket->KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
1080 {
1081 if (Va2paPa2vaPacket->IsVirtual2Physical)
1082 {
1083 ShowMessages("%llx\n", Va2paPa2vaPacket->PhysicalAddress);
1084 }
1085 else
1086 {
1087 ShowMessages("%llx\n", Va2paPa2vaPacket->VirtualAddress);
1088 }
1089 }
1090 else
1091 {
1092 ShowErrorMessage(Va2paPa2vaPacket->KernelStatus);
1093 }
1094
1095 //
1096 // Signal the event relating to receiving result of VA2PA or PA2VA queries
1097 //
1099
1100 break;
1101
1103
1104 ListOrModifyBreakpointPacket = (DEBUGGEE_BP_LIST_OR_MODIFY_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
1105
1106 if (ListOrModifyBreakpointPacket->Result == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
1107 {
1108 //
1109 // Everything was okay, nothing to do
1110 //
1111 }
1112 else
1113 {
1114 ShowErrorMessage(ListOrModifyBreakpointPacket->Result);
1115 }
1116
1117 //
1118 // Signal the event relating to receiving result of modifying or listing
1119 // breakpoints
1120 //
1122
1123 break;
1124
1126
1127 SymbolUpdatePacket = (DEBUGGER_UPDATE_SYMBOL_TABLE *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
1128 //
1129 // Perform updates for the symbol table
1130 //
1132
1133 break;
1134
1136
1137 PcitreePacket = (DEBUGGEE_PCITREE_REQUEST_RESPONSE_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
1138
1139 if (PcitreePacket->KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
1140 {
1141 //
1142 // Print PCI device tree
1143 //
1144 ShowMessages("%-12s | %-9s | %-17s | %s \n%s\n", "DBDF", "VID:DID", "Vendor Name", "Device Name", "----------------------------------------------------------------------");
1145 for (UINT8 i = 0; i < (PcitreePacket->DeviceInfoListNum < DEV_MAX_NUM ? PcitreePacket->DeviceInfoListNum : DEV_MAX_NUM); i++)
1146 {
1147 Vendor * CurrentVendor = GetVendorById(PcitreePacket->DeviceInfoList[i].ConfigSpace.VendorId);
1148 char * CurrentVendorName = (char *)"N/A";
1149 char * CurrentDeviceName = (char *)"N/A";
1150
1151 if (CurrentVendor != NULL)
1152 {
1153 CurrentVendorName = CurrentVendor->VendorName;
1154 Device * CurrentDevice = GetDeviceFromVendor(CurrentVendor, PcitreePacket->DeviceInfoList[i].ConfigSpace.DeviceId);
1155
1156 if (CurrentDevice != NULL)
1157 {
1158 CurrentDeviceName = CurrentDevice->DeviceName;
1159 }
1160 }
1161
1162 ShowMessages("%04x:%02x:%02x:%x | %04x:%04x | %-17.*s | %.*s\n",
1163 0, // TODO: Add support for domains beyond 0000
1164 PcitreePacket->DeviceInfoList[i].Bus,
1165 PcitreePacket->DeviceInfoList[i].Device,
1166 PcitreePacket->DeviceInfoList[i].Function,
1167 PcitreePacket->DeviceInfoList[i].ConfigSpace.VendorId,
1168 PcitreePacket->DeviceInfoList[i].ConfigSpace.DeviceId,
1169 strnlen_s(CurrentVendorName, PCI_NAME_STR_LENGTH),
1170 CurrentVendorName,
1171 strnlen_s(CurrentDeviceName, PCI_NAME_STR_LENGTH),
1172 CurrentDeviceName
1173
1174 );
1175
1176 FreeVendor(CurrentVendor);
1177 }
1179 }
1180 else
1181 {
1182 ShowErrorMessage(PcitreePacket->KernelStatus);
1183 }
1184
1185 //
1186 // Signal the event relating to receiving result of pcitree query
1187 //
1189
1190 break;
1191
1193
1194 PcidevinfoPacket = (DEBUGGEE_PCIDEVINFO_REQUEST_RESPONSE_PACKET *)(((CHAR *)TheActualPacket) + sizeof(DEBUGGER_REMOTE_PACKET));
1195
1196 if (PcidevinfoPacket->KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
1197 {
1198 // For some reason, MSVC refuses to initialize these at top of case
1199 const CHAR * PciHeaderTypeAsString[] = {"Endpoint", "PCI-to-PCI Bridge", "PCI-to-CardBus Bridge"};
1200 const CHAR * PciMmioBarTypeAsString[] = {"32-bit Wide",
1201 "Reserved",
1202 "64-bit Wide",
1203 "Reserved"};
1204 UINT8 BarNumOffset = 0;
1205
1206 ShowMessages("PCI configuration space (CAM) for device %04x:%02x:%02x:%x\n",
1207 0, // TODO: Add support for domains beyond 0000
1208 PcidevinfoPacket->DeviceInfo.Bus,
1209 PcidevinfoPacket->DeviceInfo.Device,
1210 PcidevinfoPacket->DeviceInfo.Function);
1211
1212 if (!PcidevinfoPacket->PrintRaw)
1213 {
1214 Vendor * CurrentVendor = GetVendorById(PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.VendorId);
1215 CHAR * CurrentVendorName = (CHAR *)"N/A";
1216 CHAR * CurrentDeviceName = (CHAR *)"N/A";
1217
1218 if (CurrentVendor != NULL)
1219 {
1220 CurrentVendorName = CurrentVendor->VendorName;
1221 Device * CurrentDevice = GetDeviceFromVendor(CurrentVendor, PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.DeviceId);
1222
1223 if (CurrentDevice != NULL)
1224 {
1225 CurrentDeviceName = CurrentDevice->DeviceName;
1226 }
1227 }
1228
1229 ShowMessages("\nCommon Header:\nVID:DID: %04x:%04x\nVendor Name: %-17.*s\nDevice Name: %.*s\nCommand: %04x\n",
1230 PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.VendorId,
1231 PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.DeviceId,
1232 strnlen_s(CurrentVendorName, PCI_NAME_STR_LENGTH),
1233 CurrentVendorName,
1234 strnlen_s(CurrentDeviceName, PCI_NAME_STR_LENGTH),
1235 CurrentDeviceName,
1236 PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.Command);
1237
1238 if ((PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.HeaderType & 0x01) << 7 == 0) // Only applicable to endpoints
1239 {
1240 ShowMessages(" Memory Space: %u\n I/O Space: %u\n",
1241 (PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.Command & 0x2) >> 1,
1242 (PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.Command & 0x1));
1243 }
1244
1245 ShowMessages("Status: %04x\nRevision ID: %02x\nClass Code: %06x\nCacheLineSize: %02x\nPrimaryLatencyTimer: %02x\nHeaderType: %s (%02x)\n Multi-function Device: %s\nBist: %02x\n",
1246 PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.Status,
1248 PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.ClassCode,
1251 (PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.HeaderType & 0x3f) < 2 ? PciHeaderTypeAsString[(PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.HeaderType & 0x1)] : "Unknown",
1253 (PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.HeaderType & 0x1) ? "True" : "False",
1254 PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.Bist);
1255 FreeVendor(CurrentVendor);
1257
1258 ShowMessages("\nDevice Header:\n");
1259
1260 if ((PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.HeaderType & 0x01) << 7 == 0) // Endpoint
1261 {
1262 for (UINT8 i = 0; i < 5; i++)
1263 {
1264 // Memory I/O
1265 if ((PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpaceEp.Bar[i] & 0x1) == 0)
1266 {
1267 // 64-bit BAR
1268 if (((PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpaceEp.Bar[i] & 0x6) >> 1) == 2)
1269 {
1270 UINT64 BarMsb = PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpaceEp.Bar[i + 1];
1271 UINT64 BarLsb = PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpaceEp.Bar[i];
1272 UINT64 ActualBar = ((BarMsb & 0xFFFFFFFF) << 32) + (BarLsb & 0xFFFFFFF0);
1273
1274 ShowMessages("BAR%u %s\n BAR Type: MMIO\n MMIO BAR Type: %s (%02x)\n BAR MSB: %08x\n BAR LSB: %08x\n BAR (actual): %016llx\n Prefetchable: %s\n",
1275 i - BarNumOffset,
1276 ((PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.Command & 0x2) >> 1 == 0) || !PcidevinfoPacket->DeviceInfo.MmioBarInfo[i].IsEnabled ? "[disabled]" : "",
1277 PciMmioBarTypeAsString[(PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpaceEp.Bar[i] & 0x6) >> 1],
1278 (PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpaceEp.Bar[i] & 0x6) >> 1,
1279 BarMsb,
1280 BarLsb,
1281 ActualBar,
1282 (PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpaceEp.Bar[i] & 0x8 >> 3) ? "True" : "False");
1283 i++;
1284 BarNumOffset++;
1285 }
1286 // 32-bit BAR
1287 else
1288 {
1289 UINT32 ActualBar = (PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpaceEp.Bar[i] & 0xFFFFFFF0);
1290
1291 ShowMessages("BAR%u %s\n BAR Type: MMIO\n BAR: %08x\n BAR (actual): %08x\n Prefetchable: %s\n",
1292 i - BarNumOffset,
1293 ((PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.Command & 0x2) >> 1 == 0) || !PcidevinfoPacket->DeviceInfo.MmioBarInfo[i].IsEnabled ? "[disabled]" : "",
1295 ActualBar,
1296 (PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpaceEp.Bar[i] & 0x8 >> 3) ? "True" : "False");
1297 }
1298 }
1299 // Port I/O
1300 else
1301 {
1302 // 32-bit BAR is the only flavor we have here
1303 UINT32 ActualBar32 = PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpaceEp.Bar[i] & 0xFFFFFFFC;
1304
1305 ShowMessages("BAR%u %s\n BAR Type: Port IO\n BAR: %08x\n BAR (actual): %08x\n Reserved: %u\n",
1306 i - BarNumOffset,
1307 ((PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.Command & 0x1) == 0) ? "[disabled]" : "",
1309 ActualBar32,
1310 (PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpaceEp.Bar[i] & 0x2) >> 1);
1311 }
1312 }
1313
1314 ShowMessages("Cardbus CIS Pointer: %08x\nSubsystem Vendor ID: %04x\nSubsystem ID: %04x\nROM BAR: %08x\nCapabilities Pointer: %02x\nReserved (0xD): %06x\nReserved (0xE): %08x\nInterrupt Line: %02x\nInterrupt Pin: %02x\nMin Grant: %02x\nMax latency: %02x\n",
1326 }
1327 else if ((PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.HeaderType & 0x3f) == 1) // PCI-to-PCI Bridge
1328 {
1329 ShowMessages("BAR0: %08x\nBAR1: %08x\n", PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpacePtpBridge.Bar[0], PcidevinfoPacket->DeviceInfo.ConfigSpace.DeviceHeader.ConfigSpacePtpBridge.Bar[1]);
1330
1331 ShowMessages("Primary Bus Number: %02x\nSecondary Bus Number: %02x\nSubordinate Bus Number: %02x\nSecondary Latency Timer: %02x\nI/O Base: %02x\nI/O Limit: %02x\nSecondary Status: %04x\nMemory Base: %04x\nMemory Limit: %04x\nPrefetchable Memory Base: %04x\nPrefetchable Memory Limit: %04x\nPrefetchable Base Upper 32 Bits: %08x\nPrefetchable Limit Upper 32 Bits: %08x\nI/O Base Upper 16 Bits: %04x\nI/O Limit Upper 16 Bits: %04x\nCapability Pointer: %02x\nReserved: %06x\nROM BAR: %08x\nInterrupt Line: %02x\nInterrupt Pin: %02x\nBridge Control: %04x\n",
1353 }
1354 else if ((PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.HeaderType & 0x3f) == 2) // PCI-to-CardBus Bridge
1355 {
1356 ShowMessages("Parsing header type %s (%02x) currently unsupported\n", PciHeaderTypeAsString[PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.HeaderType & 0x01], PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.HeaderType & 0x01);
1357 }
1358 else
1359 {
1360 ShowMessages("\nDevice Header:\nUnknown header type %02x\n", (PcidevinfoPacket->DeviceInfo.ConfigSpace.CommonHeader.HeaderType & 0x3f));
1361 }
1362 }
1363 else
1364 {
1365 UINT32 * cs = (UINT32 *)&PcidevinfoPacket->DeviceInfo.ConfigSpace; // Overflows into .ConfigSpaceAdditional - no padding due to pack(0)
1366
1367 ShowMessages(" 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f\n");
1368
1369 for (UINT16 i = 0; i < CAM_CONFIG_SPACE_LENGTH; i += 16)
1370 {
1371 ShowMessages("%02x: ", i);
1372 for (UINT8 j = 0; j < 16; j++)
1373 {
1374 ShowMessages("%02x ", *(((BYTE *)cs) + j));
1375 }
1376
1377 // Print ASCII representation
1378 // Replace non-printable characters with "."
1379 for (UINT8 j = 0; j < 16; j++)
1380 {
1381 CHAR c = (CHAR) * (cs + j);
1382 if (c >= 32 && c <= 126)
1383 {
1384 ShowMessages("%c", c);
1385 }
1386 else
1387 {
1388 ShowMessages(".");
1389 }
1390 }
1391 ShowMessages("\n");
1392 cs += 4;
1393 }
1394 }
1395 }
1396 else
1397 {
1398 ShowErrorMessage(PcidevinfoPacket->KernelStatus);
1399 }
1400
1401 //
1402 // Signal the event relating to receiving result of pcitree query
1403 //
1405
1406 break;
1407
1408 default:
1409 ShowMessages("err, unknown packet action received from the debugger\n");
1410 break;
1411 }
1412 }
1413 else
1414 {
1415 //
1416 // It's not a HyperDbg packet, it's probably a GDB packet
1417 //
1418 ShowMessages("err, invalid packet received\n");
1419 // DebugBreak();
1420 }
1421
1422 //
1423 // Wait for debug pause command again
1424 //
1425 goto StartAgain;
1426
1427 return TRUE;
1428}
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
Shows if the debugger was connected to remote debuggee over (A remote guest).
Definition globals.h:253
unsigned short UINT16
Definition BasicTypes.h:53
UCHAR BOOLEAN
Definition BasicTypes.h:35
#define NULL_ZERO
Definition BasicTypes.h:110
unsigned char UINT8
Definition BasicTypes.h:52
@ DEBUGGER_REMOTE_PACKET_TYPE_DEBUGGEE_TO_DEBUGGER
Definition Connection.h:178
@ 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:129
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RELOAD_SYMBOL_FINISHED
Definition Connection.h:133
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_PTE
Definition Connection.h:135
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_TEST_QUERY
Definition Connection.h:121
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RELOAD_SEARCH_QUERY
Definition Connection.h:134
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_PCITREE
Definition Connection.h:139
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_SHORT_CIRCUITING_STATE
Definition Connection.h:130
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_FLUSH
Definition Connection.h:119
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_APIC_REQUESTS
Definition Connection.h:140
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_ADDING_ACTION_TO_EVENT
Definition Connection.h:123
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_READING_REGISTERS
Definition Connection.h:126
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_LOGGING_MECHANISM
Definition Connection.h:112
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_READING_MEMORY
Definition Connection.h:127
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_REGISTERING_EVENT
Definition Connection.h:122
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_WRITE_REGISTER
Definition Connection.h:138
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_VA2PA_AND_PA2VA
Definition Connection.h:136
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_QUERY_IDT_ENTRIES_REQUESTS
Definition Connection.h:142
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_EDITING_MEMORY
Definition Connection.h:128
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CHANGING_THREAD
Definition Connection.h:116
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_SMI_OPERATION_REQUESTS
Definition Connection.h:143
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_STARTED
Definition Connection.h:111
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_HYPERTRACE_PT_OPERATION_REQUESTS
Definition Connection.h:145
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_HYPERTRACE_LBR_DUMP_REQUESTS
Definition Connection.h:144
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_PCIDEVINFO
Definition Connection.h:141
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_PAUSED_AND_CURRENT_INSTRUCTION
Definition Connection.h:113
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_RUNNING_SCRIPT
Definition Connection.h:117
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_BRINGING_PAGES_IN
Definition Connection.h:137
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_QUERY_AND_MODIFY_EVENT
Definition Connection.h:124
@ DEBUGGER_REMOTE_PACKET_PING_AND_SEND_SUPPORTED_VERSION
Definition Connection.h:68
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CALLSTACK
Definition Connection.h:120
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CHANGING_CORE
Definition Connection.h:114
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_LIST_OR_MODIFY_BREAKPOINTS
Definition Connection.h:131
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_UPDATE_SYMBOL_INFO
Definition Connection.h:132
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_CHANGING_PROCESS
Definition Connection.h:115
@ DEBUGGER_REMOTE_PACKET_REQUESTED_ACTION_DEBUGGEE_RESULT_OF_FORMATS
Definition Connection.h:118
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:470
#define DebuggerEventTagStartSeed
The seeds that user-mode codes use as the starter of their events' tag.
Definition Constants.h:230
struct _DEBUGGEE_KD_PAUSED_PACKET DEBUGGEE_KD_PAUSED_PACKET
The structure of pausing packet in kHyperDbg.
@ VMM_CALLBACK_CALLING_STAGE_POST_EVENT_EMULATION
Definition DataTypes.h:127
struct _DEBUGGEE_MESSAGE_PACKET * PDEBUGGEE_MESSAGE_PACKET
struct _DEBUGGEE_MESSAGE_PACKET DEBUGGEE_MESSAGE_PACKET
The structure of message packet in HyperDbg.
struct _DEBUGGEE_KD_PAUSED_PACKET * PDEBUGGEE_KD_PAUSED_PACKET
#define DEBUGGER_OPERATION_WAS_SUCCESSFUL
General value to indicate that the operation or request was successful.
Definition ErrorCodes.h:23
struct _DEBUGGER_SHORT_CIRCUITING_EVENT * PDEBUGGER_SHORT_CIRCUITING_EVENT
@ DEBUGGER_MODIFY_EVENTS_QUERY_STATE
Definition Events.h:234
struct _DEBUGGER_MODIFY_EVENTS * PDEBUGGER_MODIFY_EVENTS
struct _DEBUGGER_EVENT_AND_ACTION_RESULT * PDEBUGGER_EVENT_AND_ACTION_RESULT
struct _DEBUGGER_SHORT_CIRCUITING_EVENT DEBUGGER_SHORT_CIRCUITING_EVENT
request for performing a short-circuiting event
struct _DEBUGGER_MODIFY_EVENTS DEBUGGER_MODIFY_EVENTS
request for modifying events (enable/disable/clear)
struct _DEBUGGER_EVENT_AND_ACTION_RESULT DEBUGGER_EVENT_AND_ACTION_RESULT
Status of register buffers.
#define DEV_MAX_NUM
Definition Pcie.h:42
#define CAM_CONFIG_SPACE_LENGTH
Definition Pcie.h:43
struct _HYPERTRACE_PT_OPERATION_PACKETS HYPERTRACE_PT_OPERATION_PACKETS
The structure of HyperTrace PT result packet in HyperDbg.
struct _DEBUGGER_READ_PAGE_TABLE_ENTRIES_DETAILS * PDEBUGGER_READ_PAGE_TABLE_ENTRIES_DETAILS
struct _DEBUGGEE_SCRIPT_PACKET * PDEBUGGEE_SCRIPT_PACKET
struct _DEBUGGEE_REGISTER_WRITE_DESCRIPTION * PDEBUGGEE_REGISTER_WRITE_DESCRIPTION
struct _DEBUGGEE_SCRIPT_PACKET DEBUGGEE_SCRIPT_PACKET
The structure of script packet in HyperDbg.
struct _DEBUGGEE_PCIDEVINFO_REQUEST_RESPONSE_PACKET DEBUGGEE_PCIDEVINFO_REQUEST_RESPONSE_PACKET
PCI device info Request-Response Packet, used by !pcicam and future PCI-related commands....
struct _DEBUGGER_APIC_REQUEST * PDEBUGGER_APIC_REQUEST
struct _DEBUGGEE_CHANGE_CORE_PACKET * PDEBUGGEE_CHANGE_CORE_PACKET
struct _HYPERTRACE_PT_OPERATION_PACKETS * PHYPERTRACE_PT_OPERATION_PACKETS
struct _DEBUGGEE_RESULT_OF_SEARCH_PACKET DEBUGGEE_RESULT_OF_SEARCH_PACKET
The structure of result of search packet in HyperDbg.
struct _DEBUGGER_PREPARE_DEBUGGEE DEBUGGER_PREPARE_DEBUGGEE
request to make this computer to a debuggee
struct _DEBUGGER_CALLSTACK_REQUEST * PDEBUGGER_CALLSTACK_REQUEST
struct _DEBUGGEE_PCITREE_REQUEST_RESPONSE_PACKET * PDEBUGGEE_PCITREE_REQUEST_RESPONSE_PACKET
struct _INTERRUPT_DESCRIPTOR_TABLE_ENTRIES_PACKETS INTERRUPT_DESCRIPTOR_TABLE_ENTRIES_PACKETS
The structure of IDT entries result packet in HyperDbg.
struct _DEBUGGER_PAGE_IN_REQUEST DEBUGGER_PAGE_IN_REQUEST
requests for the '.pagein' command
struct _DEBUGGER_SINGLE_CALLSTACK_FRAME * PDEBUGGER_SINGLE_CALLSTACK_FRAME
struct _DEBUGGEE_REGISTER_READ_DESCRIPTION * PDEBUGGEE_REGISTER_READ_DESCRIPTION
struct _DEBUGGEE_DETAILS_AND_SWITCH_THREAD_PACKET * PDEBUGGEE_DETAILS_AND_SWITCH_THREAD_PACKET
struct _DEBUGGEE_FORMATS_PACKET * PDEBUGGEE_FORMATS_PACKET
struct _DEBUGGEE_RESULT_OF_SEARCH_PACKET * PDEBUGGEE_RESULT_OF_SEARCH_PACKET
struct _DEBUGGER_FLUSH_LOGGING_BUFFERS DEBUGGER_FLUSH_LOGGING_BUFFERS
request for flushing buffers
struct _DEBUGGEE_BP_LIST_OR_MODIFY_PACKET DEBUGGEE_BP_LIST_OR_MODIFY_PACKET
The structure of breakpoint modification requests packet in HyperDbg.
struct _DEBUGGER_READ_MEMORY DEBUGGER_READ_MEMORY
request for reading virtual and physical memory
struct _DEBUGGEE_BP_PACKET * PDEBUGGEE_BP_PACKET
struct _SMI_OPERATION_PACKETS * PSMI_OPERATION_PACKETS
@ TEST_BREAKPOINT_TURN_OFF_DBS
Definition RequestStructures.h:347
@ TEST_BREAKPOINT_TURN_OFF_BPS
Definition RequestStructures.h:340
@ TEST_BREAKPOINT_TURN_ON_DBS
Definition RequestStructures.h:348
@ TEST_BREAKPOINT_TURN_ON_BPS
Definition RequestStructures.h:341
struct _DEBUGGEE_REGISTER_WRITE_DESCRIPTION DEBUGGEE_REGISTER_WRITE_DESCRIPTION
Register Descriptor Structure to write on registers.
struct _DEBUGGER_CALLSTACK_REQUEST DEBUGGER_CALLSTACK_REQUEST
request for callstack frames
struct _DEBUGGEE_PCIDEVINFO_REQUEST_RESPONSE_PACKET * PDEBUGGEE_PCIDEVINFO_REQUEST_RESPONSE_PACKET
struct _DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_PACKET DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_PACKET
The structure of changing process and show process packet in HyperDbg.
struct _DEBUGGER_PAGE_IN_REQUEST * PDEBUGGER_PAGE_IN_REQUEST
@ DEBUGGEE_DETAILS_AND_SWITCH_THREAD_PERFORM_SWITCH
Definition RequestStructures.h:1007
@ DEBUGGEE_DETAILS_AND_SWITCH_THREAD_GET_THREAD_DETAILS
Definition RequestStructures.h:1008
struct _DEBUGGEE_FORMATS_PACKET DEBUGGEE_FORMATS_PACKET
check so the INTERRUPT_DESCRIPTOR_TABLE_ENTRIES_PACKETS should be smaller than packet size
struct _HYPERTRACE_LBR_DUMP_PACKETS HYPERTRACE_LBR_DUMP_PACKETS
The structure of HyperTrace LBR dump result packet in HyperDbg.
struct _DEBUGGEE_REGISTER_READ_DESCRIPTION DEBUGGEE_REGISTER_READ_DESCRIPTION
Register Descriptor Structure to use in r command.
struct _HYPERTRACE_LBR_DUMP_PACKETS * PHYPERTRACE_LBR_DUMP_PACKETS
struct _DEBUGGEE_BP_PACKET DEBUGGEE_BP_PACKET
The structure of bp command packet in HyperDbg.
struct _SMI_OPERATION_PACKETS SMI_OPERATION_PACKETS
The structure of I/O APIC result packet in HyperDbg.
struct _DEBUGGER_PREPARE_DEBUGGEE * PDEBUGGER_PREPARE_DEBUGGEE
struct _DEBUGGER_EDIT_MEMORY * PDEBUGGER_EDIT_MEMORY
struct _DEBUGGER_READ_MEMORY * PDEBUGGER_READ_MEMORY
struct _DEBUGGER_EDIT_MEMORY DEBUGGER_EDIT_MEMORY
request for edit virtual and physical memory
struct _DEBUGGEE_PCITREE_REQUEST_RESPONSE_PACKET DEBUGGEE_PCITREE_REQUEST_RESPONSE_PACKET
Pcitree Request-Response Packet. Represents PCI device tree.
struct _DEBUGGEE_DETAILS_AND_SWITCH_THREAD_PACKET DEBUGGEE_DETAILS_AND_SWITCH_THREAD_PACKET
The structure of changing thead and show thread packet in HyperDbg.
struct _DEBUGGER_APIC_REQUEST DEBUGGER_APIC_REQUEST
The structure of actions for APIC.
struct _DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_PACKET * PDEBUGGEE_DETAILS_AND_SWITCH_PROCESS_PACKET
struct _DEBUGGER_DEBUGGER_TEST_QUERY_BUFFER DEBUGGER_DEBUGGER_TEST_QUERY_BUFFER
request for test query buffers
struct _DEBUGGER_FLUSH_LOGGING_BUFFERS * PDEBUGGER_FLUSH_LOGGING_BUFFERS
struct _DEBUGGEE_BP_LIST_OR_MODIFY_PACKET * PDEBUGGEE_BP_LIST_OR_MODIFY_PACKET
@ DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_GET_PROCESS_DETAILS
Definition RequestStructures.h:968
@ DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_PERFORM_SWITCH
Definition RequestStructures.h:970
struct _DEBUGGER_SINGLE_CALLSTACK_FRAME DEBUGGER_SINGLE_CALLSTACK_FRAME
The structure for saving the callstack frame of one parameter.
struct _DEBUGGER_VA2PA_AND_PA2VA_COMMANDS DEBUGGER_VA2PA_AND_PA2VA_COMMANDS
requests for !va2pa and !pa2va commands
struct _DEBUGGER_VA2PA_AND_PA2VA_COMMANDS * PDEBUGGER_VA2PA_AND_PA2VA_COMMANDS
struct _INTERRUPT_DESCRIPTOR_TABLE_ENTRIES_PACKETS * PINTERRUPT_DESCRIPTOR_TABLE_ENTRIES_PACKETS
struct _DEBUGGER_READ_PAGE_TABLE_ENTRIES_DETAILS DEBUGGER_READ_PAGE_TABLE_ENTRIES_DETAILS
request for !pte command
struct _DEBUGGEE_CHANGE_CORE_PACKET DEBUGGEE_CHANGE_CORE_PACKET
The structure of changing core packet in HyperDbg.
struct _DEBUGGER_DEBUGGER_TEST_QUERY_BUFFER * PDEBUGGER_DEBUGGER_TEST_QUERY_BUFFER
struct _DEBUGGEE_SYMBOL_UPDATE_RESULT * PDEBUGGEE_SYMBOL_UPDATE_RESULT
struct _DEBUGGER_UPDATE_SYMBOL_TABLE * PDEBUGGER_UPDATE_SYMBOL_TABLE
struct _DEBUGGER_UPDATE_SYMBOL_TABLE DEBUGGER_UPDATE_SYMBOL_TABLE
request to add new symbol detail or update a previous symbol table entry
struct _DEBUGGEE_SYMBOL_UPDATE_RESULT DEBUGGEE_SYMBOL_UPDATE_RESULT
request that shows, symbol reload process is finished
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)
ULONG g_CurrentRemoteCore
Current core that the debuggee is debugging.
Definition globals.h:285
UINT64 g_KernelBaseAddress
Shows the kernel base address.
Definition globals.h:576
BOOLEAN ShowErrorMessage(UINT32 Error)
shows the error message
Definition debugger.cpp:40
UINT32 HyperDbgLengthDisassemblerEngine(UCHAR *BufferToDisassemble, UINT64 BuffLength, BOOLEAN Isx86_64)
Length Disassembler engine based on Zydis.
Definition disassembler.cpp:856
INT HyperDbgDisassembler64(UCHAR *BufferToDisassemble, UINT64 BaseAddress, UINT64 Size, UINT32 MaximumInstrDecoded, BOOLEAN ShowBranchIsTakenOrNot, PRFLAGS Rflags)
Disassemble x64 assemblies.
Definition disassembler.cpp:333
INT HyperDbgDisassembler32(UCHAR *BufferToDisassemble, UINT64 BaseAddress, UINT64 Size, UINT32 MaximumInstrDecoded, BOOLEAN ShowBranchIsTakenOrNot, PRFLAGS Rflags)
Disassemble 32 bit assemblies.
Definition disassembler.cpp:373
VOID CommandEventsHandleModifiedEvent(UINT64 Tag, PDEBUGGER_MODIFY_EVENTS ModifyEventRequest)
Handle events after modification.
Definition events.cpp:503
VOID CommandEventsClearAllEventsAndResetTags()
Clears all the events and resets the tag.
Definition events.cpp:474
BOOLEAN ForwardingCheckAndPerformEventForwarding(UINT32 OperationCode, CHAR *Message, UINT32 MessageLength)
Check and send the event result to the corresponding sources.
Definition forwarding.cpp:439
BOOLEAN g_IsRunningInstruction32Bit
whether the Current executing instructions is 32-bit or 64 bit
Definition globals.h:232
BYTE g_CurrentRunningInstruction[MAXIMUM_INSTR_SIZE]
Current executing instructions.
Definition globals.h:226
RFLAGS * PRFLAGS
Definition pch.h:34
DEBUGGER_EVENT_AND_ACTION_RESULT g_DebuggeeResultOfRegisteringEvent
Holds the result of registering events from the remote debuggee.
Definition globals.h:305
BOOLEAN KdCloseConnection()
Send close packet to the debuggee and debugger.
Definition kd.cpp:3056
BOOLEAN g_IsDebuggeeRunning
Shows if the debuggee is running or not.
Definition globals.h:272
BOOLEAN KdSendResponseOfThePingPacket()
Respond to the debuggee with the version and build date of the debugger.
Definition kd.cpp:2121
BOOLEAN g_IgnoreNewLoggingMessages
Shows if the debugger should show debuggee's messages or not.
Definition globals.h:279
DEBUGGER_EVENT_AND_ACTION_RESULT g_DebuggeeResultOfAddingActionsToEvent
Holds the result of adding action to events from the remote debuggee.
Definition globals.h:311
BOOLEAN KdReceivePacketFromDebuggee(CHAR *BufferToSave, UINT32 *LengthReceived)
Receive packet from the debuggee.
Definition kd.cpp:1558
BOOLEAN g_SharedEventStatus
This is an OVERLAPPED structure for managing simultaneous read and writes for debugger (in current de...
Definition globals.h:331
UINT64 g_ResultOfEvaluatedExpression
Result of the expression that is evaluated in the debuggee.
Definition globals.h:640
UINT32 g_ErrorStateOfResultOfEvaluatedExpression
Shows the state of the evaluation of expression which whether contains error or not.
Definition globals.h:647
#define DbgWaitGetKernelRequestData(KernelSyncObjectId, ReqData, ReqSize)
Definition common.h:142
#define DbgReceivedKernelResponse(KernelSyncObjectId)
Definition common.h:168
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_ADD_ACTION_TO_EVENT
Definition debugger.h:44
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_DEBUGGEE_FINISHED_COMMAND_EXECUTION
Definition debugger.h:41
#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:33
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SCRIPT_FORMATS_RESULT
Definition debugger.h:40
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SEARCH_QUERY_RESULT
Definition debugger.h:54
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_FLUSH_RESULT
Definition debugger.h:42
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PCITREE_RESULT
Definition debugger.h:60
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_MODIFY_AND_QUERY_EVENT
Definition debugger.h:45
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SHORT_CIRCUITING_EVENT_STATE
Definition debugger.h:57
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_LIST_OR_MODIFY_BREAKPOINTS
Definition debugger.h:48
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_HYPERTRACE_LBR_DUMP_RESULT
Definition debugger.h:65
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_THREAD_SWITCHING_RESULT
Definition debugger.h:38
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_BP
Definition debugger.h:47
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_TEST_QUERY
Definition debugger.h:52
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_CALLSTACK_RESULT
Definition debugger.h:53
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_REGISTER_EVENT
Definition debugger.h:43
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PTE_RESULT
Definition debugger.h:56
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_APIC_ACTIONS
Definition debugger.h:61
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PCIDEVINFO_RESULT
Definition debugger.h:62
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_VA2PA_AND_PA2VA_RESULT
Definition debugger.h:55
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SMI_OPERATION_RESULT
Definition debugger.h:64
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SCRIPT_RUNNING_RESULT
Definition debugger.h:39
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_WRITE_REGISTER
Definition debugger.h:59
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_READ_REGISTERS
Definition debugger.h:46
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_IDT_ENTRIES
Definition debugger.h:63
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_CORE_SWITCHING_RESULT
Definition debugger.h:36
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PROCESS_SWITCHING_RESULT
Definition debugger.h:37
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_HYPERTRACE_PT_OPERATION_RESULT
Definition debugger.h:66
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PAUSED_DEBUGGEE_DETAILS
Definition debugger.h:35
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_STARTED_PACKET_RECEIVED
Definition debugger.h:34
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_PAGE_IN_STATE
Definition debugger.h:58
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_SYMBOL_RELOAD
Definition debugger.h:51
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_EDIT_MEMORY
Definition debugger.h:50
#define DEBUGGER_SYNCRONIZATION_OBJECT_KERNEL_DEBUGGER_READ_MEMORY
Definition debugger.h:49
BOOLEAN g_OutputSourcesInitialized
it shows whether the debugger started using output sources or not or in other words,...
Definition globals.h:418
Device * GetDeviceFromVendor(Vendor *VendorToUse, UINT16 DeviceId)
Returns Device entry corresponding to DeviceId.
Definition pci-id.cpp:339
Vendor * GetVendorById(UINT16 VendorId)
Returns Vendor entry, including corresponding devices and subdevices.
Definition pci-id.cpp:305
VOID FreePciIdDatabase()
Frees PciIdDatabaseBuffer.
Definition pci-id.cpp:288
VOID FreeVendor(Vendor *VendorToFree)
Frees Vendor and all of its members.
Definition pci-id.cpp:260
#define PCI_NAME_STR_LENGTH
Definition pci-id.h:15
VOID CommandPteShowResults(UINT64 TargetVa, PDEBUGGER_READ_PAGE_TABLE_ENTRIES_DETAILS PteRead)
show results of !pte command
Definition pte.cpp:48
UINT32 Result
Definition RequestStructures.h:1556
UINT32 Result
Definition RequestStructures.h:1523
UINT32 Result
Definition RequestStructures.h:649
UINT32 NewCore
Definition RequestStructures.h:648
UINT32 ProcessId
Definition RequestStructures.h:982
UINT64 Process
Definition RequestStructures.h:983
DEBUGGEE_DETAILS_AND_SWITCH_PROCESS_TYPE ActionType
Definition RequestStructures.h:981
UINT32 Result
Definition RequestStructures.h:987
UCHAR ProcessName[16]
Definition RequestStructures.h:985
UCHAR ProcessName[16]
Definition RequestStructures.h:1025
DEBUGGEE_DETAILS_AND_SWITCH_THREAD_TYPE ActionType
Definition RequestStructures.h:1019
UINT64 Thread
Definition RequestStructures.h:1022
UINT64 Process
Definition RequestStructures.h:1023
UINT32 ProcessId
Definition RequestStructures.h:1021
UINT32 ThreadId
Definition RequestStructures.h:1020
UINT32 Result
Definition RequestStructures.h:1027
UINT32 Result
Definition RequestStructures.h:1493
UINT64 Value
Definition RequestStructures.h:1492
UINT16 ReadInstructionLen
Definition DataTypes.h:250
UINT64 Rip
Definition DataTypes.h:241
UINT64 Rflags
Definition DataTypes.h:248
BOOLEAN IsProcessorOn32BitMode
Definition DataTypes.h:242
DEBUGGEE_PAUSING_REASON PausingReason
Definition DataTypes.h:244
UINT64 EventTag
Definition DataTypes.h:246
ULONG CurrentCore
Definition DataTypes.h:245
BYTE InstructionBytesOnRip[MAXIMUM_INSTR_SIZE]
Definition DataTypes.h:249
BOOLEAN IgnoreDisassembling
Definition DataTypes.h:243
VMM_CALLBACK_EVENT_CALLING_STAGE_TYPE EventCallingStage
Definition DataTypes.h:247
UINT32 OperationCode
Definition DataTypes.h:301
CHAR Message[PacketChunkSize]
Definition DataTypes.h:302
PCI_DEV DeviceInfo
Definition RequestStructures.h:1674
UINT32 KernelStatus
Definition RequestStructures.h:1672
BOOL PrintRaw
Definition RequestStructures.h:1673
UINT8 DeviceInfoListNum
Definition RequestStructures.h:1649
UINT32 KernelStatus
Definition RequestStructures.h:1648
PCI_DEV_MINIMAL DeviceInfoList[DEV_MAX_NUM]
Definition RequestStructures.h:1650
UINT32 CountOfResults
Definition RequestStructures.h:1604
UINT32 Result
Definition RequestStructures.h:1605
BOOLEAN IsFormat
Definition RequestStructures.h:1586
UINT32 Result
Definition RequestStructures.h:1588
UINT64 KernelStatus
Definition Symbols.h:92
UINT32 KernelStatus
Definition RequestStructures.h:845
UINT32 FrameCount
Definition RequestStructures.h:848
BOOLEAN Is32Bit
Definition RequestStructures.h:844
DEBUGGER_CALLSTACK_DISPLAY_METHOD DisplayMethod
Definition RequestStructures.h:846
UINT32 KernelStatus
Definition RequestStructures.h:360
DEBUGGER_TEST_QUERY_STATE RequestType
Definition RequestStructures.h:358
UINT32 CountOfMessagesThatSetAsReadFromVmxRoot
Definition RequestStructures.h:321
UINT32 CountOfMessagesThatSetAsReadFromVmxNonRoot
Definition RequestStructures.h:322
UINT32 KernelStatus
Definition RequestStructures.h:320
DEBUGGER_MODIFY_EVENTS_TYPE TypeOfAction
Definition Events.h:249
BOOLEAN IsEnabled
Definition Events.h:250
UINT64 KernelStatus
Definition Events.h:247
UINT64 Tag
Definition Events.h:246
UINT32 KernelStatus
Definition RequestStructures.h:109
UINT64 KernelBaseAddress
Definition RequestStructures.h:634
CHAR OsName[MAXIMUM_CHARACTER_FOR_OS_NAME]
Definition RequestStructures.h:636
UINT64 VirtualAddress
Definition RequestStructures.h:55
UINT32 KernelStatus
Definition RequestStructures.h:70
BOOLEAN IsShortCircuiting
Definition Events.h:263
UINT64 KernelStatus
Definition Events.h:262
MODULE_SYMBOL_DETAIL SymbolDetailPacket
Definition Symbols.h:78
BOOLEAN IsVirtual2Physical
Definition RequestStructures.h:89
UINT32 KernelStatus
Definition RequestStructures.h:90
UINT64 PhysicalAddress
Definition RequestStructures.h:87
UINT64 VirtualAddress
Definition RequestStructures.h:86
PORTABLE_PCI_CONFIG_SPACE_HEADER_MINIMAL ConfigSpace
Definition Pcie.h:137
UINT8 Bus
Definition Pcie.h:134
UINT8 Function
Definition Pcie.h:136
UINT8 Device
Definition Pcie.h:135
BOOL IsEnabled
Definition Pcie.h:147
UINT8 Device
Definition Pcie.h:169
UINT8 Bus
Definition Pcie.h:168
UINT8 Function
Definition Pcie.h:170
PCI_DEV_MMIOBAR_INFO MmioBarInfo[6]
Definition Pcie.h:173
PORTABLE_PCI_CONFIG_SPACE_HEADER ConfigSpace
Definition Pcie.h:171
UINT8 Bist
Definition Pcie.h:60
UINT8 ClassCode[3]
Definition Pcie.h:56
UINT8 RevisionId
Definition Pcie.h:55
UINT16 Command
Definition Pcie.h:53
UINT8 CacheLineSize
Definition Pcie.h:57
UINT16 VendorId
Definition Pcie.h:51
UINT16 DeviceId
Definition Pcie.h:52
UINT8 HeaderType
Definition Pcie.h:59
UINT16 Status
Definition Pcie.h:54
UINT8 PrimaryLatencyTimer
Definition Pcie.h:58
UINT16 VendorId
Definition Pcie.h:123
UINT16 DeviceId
Definition Pcie.h:124
PORTABLE_PCI_COMMON_HEADER CommonHeader
Definition Pcie.h:158
PORTABLE_PCI_DEVICE_HEADER DeviceHeader
Definition Pcie.h:159
Definition pci-id.h:26
CHAR DeviceName[PCI_NAME_STR_LENGTH]
Definition pci-id.h:28
Definition pci-id.h:34
CHAR VendorName[PCI_NAME_STR_LENGTH]
Definition pci-id.h:36
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:1210
VOID SymbolInitialReload()
Initial load of symbols (for previously download symbols).
Definition symbol.cpp:33
VOID CommandTrackHandleReceivedInstructions(UCHAR *BufferToDisassemble, UINT32 BuffLength, BOOLEAN Isx86_64, UINT64 RipAddress)
Handle received 'call' or 'ret'.
Definition track.cpp:212
struct _PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_EP_HEADER ConfigSpaceEp
struct _PORTABLE_PCI_DEVICE_HEADER::_PORTABLE_PCI_BRIDGE_HEADER ConfigSpacePtpBridge

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.

226{0};

◆ g_DebuggeeResultOfAddingActionsToEvent

DEBUGGER_EVENT_AND_ACTION_RESULT g_DebuggeeResultOfAddingActionsToEvent
extern

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

311 {
312 0};

◆ g_DebuggeeResultOfRegisteringEvent

DEBUGGER_EVENT_AND_ACTION_RESULT g_DebuggeeResultOfRegisteringEvent
extern

Holds the result of registering events from the remote debuggee.

305{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.

220{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_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

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

Shows whether the queried event is enabled or disabled