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

events commands More...

#include "pch.h"

Functions

VOID CommandEventsHelp ()
 help of the events command
VOID CommandEvents (vector< CommandToken > CommandTokens, string Command)
 events command handler
BOOLEAN CommandEventQueryEventState (UINT64 Tag)
 Check the kernel whether the event is enabled or disabled.
VOID CommandEventsShowEvents ()
 print every active and disabled events
BOOLEAN CommandEventDisableEvent (UINT64 Tag)
 Disable a special event.
BOOLEAN CommandEventEnableEvent (UINT64 Tag)
 enables a special event
BOOLEAN CommandEventClearEvent (UINT64 Tag)
 disable and remove a special event
VOID CommandEventsClearAllEventsAndResetTags ()
 Clears all the events and resets the tag.
VOID CommandEventsHandleModifiedEvent (UINT64 Tag, PDEBUGGER_MODIFY_EVENTS ModifyEventRequest)
 Handle events after modification.
BOOLEAN CommandEventsModifyAndQueryEvents (UINT64 Tag, DEBUGGER_MODIFY_EVENTS_TYPE TypeOfAction)
 modify a special event (enable/disable/clear) and send the request directly to the kernel

Variables

LIST_ENTRY g_EventTrace
 Holds a list of events in kernel and the state of events and the commands to show the state of each command (disabled/enabled).
BOOLEAN g_EventTraceInitialized
 it shows whether the debugger started using events or not or in other words, is g_EventTrace initialized with a variable or it is empty
BOOLEAN g_BreakPrintingOutput
 Shows whether the pause command or CTRL+C or CTRL+Break is executed or not.
BOOLEAN g_AutoFlush
 Whether auto-flush mode is enabled or not enabled.
BOOLEAN g_IsVmmModuleLoaded
 shows whether the VMM module is loaded or not
BOOLEAN g_IsConnectedToRemoteDebuggee
 Shows whether the current debugger is the host and connected to a remote debuggee (guest).
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
 Shows if the debugger was connected to remote debuggee over (A remote guest).
BOOLEAN g_IsSerialConnectedToRemoteDebugger
 Shows if the debugger was connected to remote debugger (A remote host).
UINT64 g_EventTag
 This variable holds the trace and generate numbers for new tags of events.

Detailed Description

events commands

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

Function Documentation

◆ CommandEventClearEvent()

BOOLEAN CommandEventClearEvent ( UINT64 Tag)

disable and remove a special event

Parameters
Tagthe tag of the target event
Returns
BOOLEAN if the operation was successful then it returns true otherwise it returns false
391{
392 PLIST_ENTRY TempList = 0;
393 BOOLEAN Result = FALSE;
394 PDEBUGGER_GENERAL_EVENT_DETAIL TmpCommandDetail = NULL;
395
396 TempList = &g_EventTrace;
397 while (&g_EventTrace != TempList->Flink)
398 {
399 TempList = TempList->Flink;
400
401 PDEBUGGER_GENERAL_EVENT_DETAIL CommandDetail = CONTAINING_RECORD(TempList, DEBUGGER_GENERAL_EVENT_DETAIL, CommandsEventList);
402
403 if (CommandDetail->Tag == Tag || Tag == DEBUGGER_MODIFY_EVENTS_APPLY_TO_ALL_TAG)
404 {
405 //
406 // Free the buffer for string of command
407 //
408 free(CommandDetail->CommandStringBuffer);
409
410 if (!Result)
411 {
412 Result = TRUE;
413 //
414 // We'll save one element so we can traverse and deallocate
415 // all of the elements
416 //
417 TmpCommandDetail = CommandDetail;
418 }
419
421 {
422 //
423 // Remove it from the list
424 //
425 RemoveEntryList(&CommandDetail->CommandsEventList);
426
427 //
428 // Free the event it self
429 //
430 free(CommandDetail);
431
432 //
433 // Only, one command exist with a tag, so we need to return as we
434 // find it
435 //
436
437 return TRUE;
438 }
439 }
440 }
441
443 {
444 //
445 // We have to deallocate all the elements (note that CommandDetail->CommandStringBuffer is
446 // already deallocated)
447 //
448 while ((UINT64)TmpCommandDetail != (UINT64)&g_EventTrace.Flink)
449 {
450 PVOID Temp = (PVOID)TmpCommandDetail;
451 TmpCommandDetail = (PDEBUGGER_GENERAL_EVENT_DETAIL)TmpCommandDetail->CommandsEventList.Flink;
452
453 free(Temp);
454 }
455
456 //
457 // Reinitialize list head
458 //
459 InitializeListHead(&g_EventTrace);
460 }
461
462 //
463 // Either not found or DEBUGGER_MODIFY_EVENTS_APPLY_TO_ALL_TAG is specified
464 //
465 return Result;
466}
POOL_TYPE SIZE_T ULONG Tag
Definition Hooks.h:89
UCHAR BOOLEAN
Definition BasicTypes.h:35
void * PVOID
Definition BasicTypes.h:56
#define TRUE
Definition BasicTypes.h:114
#define FALSE
Definition BasicTypes.h:113
#define DEBUGGER_MODIFY_EVENTS_APPLY_TO_ALL_TAG
Apply event modifications to all tags.
Definition Constants.h:714
struct _DEBUGGER_GENERAL_EVENT_DETAIL DEBUGGER_GENERAL_EVENT_DETAIL
Each command is like the following struct, it also used for tracing works in user mode and sending it...
struct _DEBUGGER_GENERAL_EVENT_DETAIL * PDEBUGGER_GENERAL_EVENT_DETAIL
LIST_ENTRY g_EventTrace
Holds a list of events in kernel and the state of events and the commands to show the state of each c...
Definition globals.h:410
NULL()
Definition test-case-generator.py:530
#define CONTAINING_RECORD(address, type, field)
Definition nt-list.h:36
UINT64 Tag
Definition Events.h:393
PVOID CommandStringBuffer
Definition Events.h:398
LIST_ENTRY CommandsEventList
Definition Events.h:359

◆ CommandEventDisableEvent()

BOOLEAN CommandEventDisableEvent ( UINT64 Tag)

Disable a special event.

Parameters
Tagthe tag of the target event
Returns
BOOLEAN if the operation was successful then it returns true otherwise it returns false
291{
292 PLIST_ENTRY TempList = 0;
293 BOOLEAN Result = FALSE;
294
295 TempList = &g_EventTrace;
296 while (&g_EventTrace != TempList->Blink)
297 {
298 TempList = TempList->Blink;
299
300 PDEBUGGER_GENERAL_EVENT_DETAIL CommandDetail = CONTAINING_RECORD(TempList, DEBUGGER_GENERAL_EVENT_DETAIL, CommandsEventList);
301
302 if (CommandDetail->Tag == Tag ||
304 {
305 //
306 // Put it to FALSE, to indicate that it's not active
307 //
308 CommandDetail->IsEnabled = FALSE;
309
310 if (!Result)
311 {
312 Result = TRUE;
313 }
314
316 {
317 //
318 // Only, one command exist with a tag, so we need to return as we
319 // find it
320 //
321 return TRUE;
322 }
323 }
324 }
325
326 //
327 // Not found
328 //
329 return Result;
330}
BOOLEAN IsEnabled
Definition Events.h:369

◆ CommandEventEnableEvent()

BOOLEAN CommandEventEnableEvent ( UINT64 Tag)

enables a special event

Parameters
Tagthe tag of the target event
Returns
BOOLEAN if the operation was successful then it returns true otherwise it returns false
341{
342 PLIST_ENTRY TempList = 0;
343 BOOLEAN Result = FALSE;
344
345 TempList = &g_EventTrace;
346 while (&g_EventTrace != TempList->Blink)
347 {
348 TempList = TempList->Blink;
349
350 PDEBUGGER_GENERAL_EVENT_DETAIL CommandDetail = CONTAINING_RECORD(TempList, DEBUGGER_GENERAL_EVENT_DETAIL, CommandsEventList);
351
352 if (CommandDetail->Tag == Tag ||
354 {
355 //
356 // Put it to TRUE, to indicate that it's active
357 //
358 CommandDetail->IsEnabled = TRUE;
359
360 if (!Result)
361 {
362 Result = TRUE;
363 }
364
366 {
367 //
368 // Only, one command exist with a tag, so we need to return as we
369 // find it
370 //
371 return TRUE;
372 }
373 }
374 }
375
376 //
377 // Not found
378 //
379 return Result;
380}

◆ CommandEventQueryEventState()

BOOLEAN CommandEventQueryEventState ( UINT64 Tag)

Check the kernel whether the event is enabled or disabled.

Parameters
Tagthe tag of the target event
Returns
BOOLEAN if the event was enabled and false if event was disabled
189{
190 BOOLEAN IsEnabled;
191
193 {
194 //
195 // It's a remote debugger in Debugger Mode
196 //
198 Tag,
200 &IsEnabled))
201 {
202 return IsEnabled;
203 }
204 else
205 {
206 ShowMessages("err, unable to get the state of the event\n");
207 return FALSE;
208 }
209 }
210 else
211 {
212 //
213 // It's a local debugging in VMI Mode
214 //
216 Tag,
218 }
219 //
220 // By default, disabled, even if there was an error
221 //
222 return FALSE;
223}
BOOLEAN g_IsSerialConnectedToRemoteDebuggee
Shows if the debugger was connected to remote debuggee over (A remote guest).
Definition globals.h:253
@ DEBUGGER_MODIFY_EVENTS_QUERY_STATE
Definition Events.h:234
BOOLEAN CommandEventsModifyAndQueryEvents(UINT64 Tag, DEBUGGER_MODIFY_EVENTS_TYPE TypeOfAction)
modify a special event (enable/disable/clear) and send the request directly to the kernel
Definition events.cpp:658
BOOLEAN KdSendEventQueryAndModifyPacketToDebuggee(UINT64 Tag, DEBUGGER_MODIFY_EVENTS_TYPE TypeOfAction, BOOLEAN *IsEnabled)
Sends a query or request to enable/disable/clear for event.
Definition kd.cpp:265

◆ CommandEvents()

VOID CommandEvents ( vector< CommandToken > CommandTokens,
string Command )

events command handler

Parameters
CommandTokens
Command
Returns
VOID
68{
69 DEBUGGER_MODIFY_EVENTS_TYPE RequestedAction;
70 UINT64 RequestedTag;
71
72 //
73 // Validate the parameters (size)
74 //
75 if (CommandTokens.size() != 1 && CommandTokens.size() != 3)
76 {
77 ShowMessages("incorrect use of the '%s'\n\n",
78 GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
80 return;
81 }
82
83 if (CommandTokens.size() == 1)
84 {
86 {
87 ShowMessages("no active/disabled events \n");
88 return;
89 }
90
92
93 //
94 // No need to continue any further
95 //
96 return;
97 }
98
99 //
100 // Validate second argument as it's not just a simple
101 // events without any parameter
102 //
103 if (CompareLowerCaseStrings(CommandTokens.at(1), "e"))
104 {
105 RequestedAction = DEBUGGER_MODIFY_EVENTS_ENABLE;
106 }
107 else if (CompareLowerCaseStrings(CommandTokens.at(1), "d"))
108 {
109 RequestedAction = DEBUGGER_MODIFY_EVENTS_DISABLE;
110 }
111 else if (CompareLowerCaseStrings(CommandTokens.at(1), "c"))
112 {
113 RequestedAction = DEBUGGER_MODIFY_EVENTS_CLEAR;
114 }
115 else if (CompareLowerCaseStrings(CommandTokens.at(1), "sc"))
116 {
117 if (CompareLowerCaseStrings(CommandTokens.at(2), "on"))
118 {
120 }
121 else if (CompareLowerCaseStrings(CommandTokens.at(2), "off"))
122 {
124 }
125 else
126 {
127 ShowMessages(
128 "please specify a correct 'on' or 'off' state for the short-circuiting state\n\n");
130 return;
131 }
132
133 //
134 // No need to further continue
135 //
136 return;
137 }
138 else
139 {
140 //
141 // unknown second command
142 //
143 ShowMessages("incorrect use of the '%s'\n\n",
144 GetCaseSensitiveStringFromCommandToken(CommandTokens.at(0)).c_str());
146 return;
147 }
148
149 //
150 // Validate third argument as it's not just a simple
151 // events without any parameter
152 //
153 if (CompareLowerCaseStrings(CommandTokens.at(2), "all"))
154 {
156 }
157 else if (!ConvertTokenToUInt64(CommandTokens.at(2), &RequestedTag))
158 {
159 ShowMessages(
160 "please specify a correct hex value for tag id (event number)\n\n");
162 return;
163 }
164
165 //
166 // Send the request to the kernel, we add it to a constant
167 // that's because we want start tags from that constant
168 //
169 if (RequestedTag != DEBUGGER_MODIFY_EVENTS_APPLY_TO_ALL_TAG)
170 {
171 RequestedTag = RequestedTag + DebuggerEventTagStartSeed;
172 }
173
174 //
175 // Perform event related tasks
176 //
177 CommandEventsModifyAndQueryEvents(RequestedTag, RequestedAction);
178}
#define DebuggerEventTagStartSeed
The seeds that user-mode codes use as the starter of their events' tag.
Definition Constants.h:230
@ DEBUGGER_MODIFY_EVENTS_ENABLE
Definition Events.h:235
@ DEBUGGER_MODIFY_EVENTS_DISABLE
Definition Events.h:236
@ DEBUGGER_MODIFY_EVENTS_CLEAR
Definition Events.h:237
enum _DEBUGGER_MODIFY_EVENTS_TYPE DEBUGGER_MODIFY_EVENTS_TYPE
different types of modifying events request (enable/disable/clear)
std::string GetCaseSensitiveStringFromCommandToken(CommandToken TargetToken)
Get case sensitive string from command token.
Definition common.cpp:467
BOOLEAN CompareLowerCaseStrings(CommandToken TargetToken, const CHAR *StringToCompare)
Compare lower case strings.
Definition common.cpp:503
BOOLEAN ConvertTokenToUInt64(CommandToken TargetToken, PUINT64 Result)
add ` between 64 bit values and convert them to string
Definition common.cpp:447
VOID CommandEventsShowEvents()
print every active and disabled events
Definition events.cpp:231
VOID CommandEventsHelp()
help of the events command
Definition events.cpp:33
BOOLEAN g_EventTraceInitialized
it shows whether the debugger started using events or not or in other words, is g_EventTrace initiali...
Definition globals.h:400
BOOLEAN KdSendShortCircuitingEventToDebuggee(BOOLEAN IsEnabled)
Sends a short-circuiting event request to debuggee.
Definition kd.cpp:226

◆ CommandEventsClearAllEventsAndResetTags()

VOID CommandEventsClearAllEventsAndResetTags ( )

Clears all the events and resets the tag.

Returns
VOID
475{
476 //
477 // Check if events are initialized
478 //
480 {
482
483 //
484 // Indicate that it's not initialized
485 //
487
488 //
489 // Reset tag numbering mechanism
490 //
492 }
493}
BOOLEAN CommandEventClearEvent(UINT64 Tag)
disable and remove a special event
Definition events.cpp:390
UINT64 g_EventTag
This variable holds the trace and generate numbers for new tags of events.
Definition globals.h:385

◆ CommandEventsHandleModifiedEvent()

VOID CommandEventsHandleModifiedEvent ( UINT64 Tag,
PDEBUGGER_MODIFY_EVENTS ModifyEventRequest )

Handle events after modification.

Parameters
Tagthe tag of the target event
ModifyEventRequestResults
Returns
VOID
506{
507 if (ModifyEventRequest->KernelStatus == DEBUGGER_OPERATION_WAS_SUCCESSFUL)
508 {
509 //
510 // Successful, nothing to show but we should also
511 // do the same (change) the user-mode structures
512 // that hold the event data
513 //
514 if (ModifyEventRequest->TypeOfAction == DEBUGGER_MODIFY_EVENTS_ENABLE)
515 {
517 {
518 ShowMessages("err, the event was successfully, "
519 "(enabled|disabled|cleared) but "
520 "can't apply it to the user-mode structures\n");
521 }
522 }
523 else if (ModifyEventRequest->TypeOfAction == DEBUGGER_MODIFY_EVENTS_DISABLE)
524 {
526 {
527 ShowMessages("err, the event was successfully, "
528 "(enabled|disabled|cleared) but "
529 "can't apply it to the user-mode structures\n");
530 }
531 else
532 {
533 //
534 // The action was applied successfully
535 //
537 {
538 //
539 // It is because we didn't query the target debuggee auto-flush
540 // variable
541 //
545 {
546 if (!g_AutoFlush)
547 {
548 ShowMessages(
549 "auto-flush mode is disabled, if there is still "
550 "messages or buffers in the kernel, you continue to see "
551 "the messages when you run 'g' until the kernel "
552 "buffers are empty. you can run 'settings autoflush "
553 "on' and after disabling and clearing events, "
554 "kernel buffers will be flushed automatically\n");
555 }
556 else
557 {
558 //
559 // We should flush buffers here
560 //
562 }
563 }
564 }
565 }
566 }
567 else if (ModifyEventRequest->TypeOfAction == DEBUGGER_MODIFY_EVENTS_CLEAR)
568 {
570 {
571 ShowMessages("err, the event was successfully, "
572 "(enabled|disabled|cleared) but "
573 "can't apply it to the user-mode structures\n");
574 }
575 else
576 {
577 //
578 // If HyperDbg is operating at the Debugger Mode, we'll indicate that
579 // the event will be cleared after continuing the debuggee
580 //
582 {
583 ShowMessages("%s successfully cleared, but please note in the Debugger Mode (current mode), HyperDbg "
584 "cannot clear events instantly. Instead, it first disables the events, and when "
585 "you continue the debuggee (e.g., by pressing the 'g' command), the event will be cleared. "
586 "Reapplying the same event without first continuing the debuggee may result in undefined behavior\n",
587 Tag == DEBUGGER_MODIFY_EVENTS_APPLY_TO_ALL_TAG ? "events are" : "the event is");
588 }
589
590 //
591 // The action was applied successfully
592 //
594 {
595 //
596 // It is because we didn't query the target debuggee auto-flush
597 // variable
598 //
600 {
601 if (!g_AutoFlush)
602 {
603 ShowMessages(
604 "auto-flush mode is disabled, if there is still "
605 "messages or buffers in the kernel, you continue to see "
606 "the messages when you run 'g' until the kernel "
607 "buffers are empty. you can run 'settings autoflush "
608 "on' and after disabling and clearing events, "
609 "kernel buffers will be flushed automatically\n");
610 }
611 else
612 {
613 //
614 // We should flush buffers here
615 //
617 }
618 }
619 }
620 }
621 }
622 else if (ModifyEventRequest->TypeOfAction ==
624 {
625 //
626 // Nothing to show
627 //
628 }
629 else
630 {
631 ShowMessages(
632 "err, the event was successfully, (enabled|disabled|cleared) but "
633 "can't apply it to the user-mode structures\n");
634 }
635 }
636 else
637 {
638 //
639 // Interpret error
640 //
641 ShowErrorMessage((UINT32)ModifyEventRequest->KernelStatus);
642 return;
643 }
644}
unsigned int UINT32
Definition BasicTypes.h:54
#define DEBUGGER_OPERATION_WAS_SUCCESSFUL
General value to indicate that the operation or request was successful.
Definition ErrorCodes.h:23
BOOLEAN ShowErrorMessage(UINT32 Error)
shows the error message
Definition debugger.cpp:40
BOOLEAN g_IsConnectedToRemoteDebuggee
Shows whether the current debugger is the host and connected to a remote debuggee (guest).
Definition globals.h:96
BOOLEAN CommandEventEnableEvent(UINT64 Tag)
enables a special event
Definition events.cpp:340
BOOLEAN CommandEventDisableEvent(UINT64 Tag)
Disable a special event.
Definition events.cpp:290
BOOLEAN g_AutoFlush
Whether auto-flush mode is enabled or not enabled.
Definition globals.h:601
VOID CommandFlushRequestFlush()
flush command handler
Definition flush.cpp:40
BOOLEAN g_IsSerialConnectedToRemoteDebugger
Shows if the debugger was connected to remote debugger (A remote host).
Definition rev.cpp:18
BOOLEAN g_BreakPrintingOutput
Shows whether the pause command or CTRL+C or CTRL+Break is executed or not.
Definition globals.h:509
DEBUGGER_MODIFY_EVENTS_TYPE TypeOfAction
Definition Events.h:249
UINT64 KernelStatus
Definition Events.h:247

◆ CommandEventsHelp()

VOID CommandEventsHelp ( )

help of the events command

Returns
VOID
34{
35 ShowMessages("events : shows active and disabled events\n");
36
37 ShowMessages("syntax : \tevents\n");
38 ShowMessages("syntax : \tevents [e|d|c all|EventNumber (hex)]\n");
39 ShowMessages("syntax : \tevents [sc State (on|off)]\n");
40
41 ShowMessages("e : enable\n");
42 ShowMessages("d : disable\n");
43 ShowMessages("c : clear\n");
44
45 ShowMessages("note : If you specify 'all' then e, d, or c will be applied to "
46 "all of the events.\n\n");
47
48 ShowMessages("\n");
49 ShowMessages("\te.g : events \n");
50 ShowMessages("\te.g : events e 12\n");
51 ShowMessages("\te.g : events d 10\n");
52 ShowMessages("\te.g : events c 10\n");
53 ShowMessages("\te.g : events c all\n");
54 ShowMessages("\te.g : events sc on\n");
55 ShowMessages("\te.g : events sc off\n");
56}

◆ CommandEventsModifyAndQueryEvents()

BOOLEAN CommandEventsModifyAndQueryEvents ( UINT64 Tag,
DEBUGGER_MODIFY_EVENTS_TYPE TypeOfAction )

modify a special event (enable/disable/clear) and send the request directly to the kernel

if you pass DEBUGGER_MODIFY_EVENTS_APPLY_TO_ALL_TAG as the tag then it will be applied to all the active/disabled events in the kernel

Parameters
Tagthe tag of the target event
TypeOfActionwhether its a enable/disable/clear
Returns
BOOLEAN Shows whether the event is enabled or disabled
660{
661 BOOLEAN Status;
662 ULONG ReturnedLength;
663 DEBUGGER_MODIFY_EVENTS ModifyEventRequest = {0};
664
665 //
666 // Check if there is no event, then we shouldn't apply the
667 // enable, disable, or clear commands, this command also
668 // checks for DEBUGGER_MODIFY_EVENTS_APPLY_TO_ALL_TAG to
669 // see if at least one tag exists or not; however, it's not
670 // necessary as the kernel will check for the validity of
671 // tag too, but let's not send it to kernel as we can prevent
672 // invalid requests from user-mode too
673 //
674 if (!IsTagExist(Tag))
675 {
677 {
678 ShowMessages("there is no event\n");
679 }
680 else
681 {
682 ShowMessages("err, tag id is invalid\n");
683 }
684 return FALSE;
685 }
686
688 {
689 //
690 // Remote debuggee Debugger Mode
691 //
693 }
694 else
695 {
696 //
697 // Local debugging VMI-Mode
698 //
699
700 //
701 // Check if the VMM module is loaded or not
702 //
704
705 //
706 // Fill the structure to send it to the kernel
707 //
708 ModifyEventRequest.Tag = Tag;
709 ModifyEventRequest.TypeOfAction = TypeOfAction;
710
711 //
712 // Send the request to the kernel
713 //
714 Status =
715 DeviceIoControl(g_DeviceHandle, // Handle to device
716 IOCTL_DEBUGGER_MODIFY_EVENTS, // IO Control Code (IOCTL)
717 &ModifyEventRequest, // Input Buffer to driver.
718 SIZEOF_DEBUGGER_MODIFY_EVENTS, // Input buffer length
719 &ModifyEventRequest, // Output Buffer from driver.
720 SIZEOF_DEBUGGER_MODIFY_EVENTS, // Length of output
721 // buffer in bytes.
722 &ReturnedLength, // Bytes placed in buffer.
723 NULL // synchronous call
724 );
725
726 if (!Status)
727 {
728 ShowMessages("ioctl failed with code 0x%x\n", GetLastError());
729 return FALSE;
730 }
731
732 //
733 // Perform further actions
734 //
735 CommandEventsHandleModifiedEvent(Tag, &ModifyEventRequest);
736
737 if (TypeOfAction == DEBUGGER_MODIFY_EVENTS_QUERY_STATE)
738 {
739 return ModifyEventRequest.IsEnabled;
740 }
741 }
742
743 //
744 // in all the cases except query state it shows whether the operation was
745 // successful or not
746 //
747 return TRUE;
748}
unsigned long ULONG
Definition BasicTypes.h:31
#define SIZEOF_DEBUGGER_MODIFY_EVENTS
Definition Events.h:254
struct _DEBUGGER_MODIFY_EVENTS DEBUGGER_MODIFY_EVENTS
request for modifying events (enable/disable/clear)
#define IOCTL_DEBUGGER_MODIFY_EVENTS
ioctl, request to modify an event (enable/disable/clear)
Definition Ioctls.h:206
BOOLEAN IsTagExist(UINT64 Tag)
Check whether the tag exists or not, if the tag is DEBUGGER_MODIFY_EVENTS_APPLY_TO_ALL_TAG then if we...
Definition debugger.cpp:824
VOID CommandEventsHandleModifiedEvent(UINT64 Tag, PDEBUGGER_MODIFY_EVENTS ModifyEventRequest)
Handle events after modification.
Definition events.cpp:503
#define AssertShowMessageReturnStmt(expr1, expr2, message1, message2, rc)
Definition common.h:59
#define ASSERT_MESSAGE_VMM_NOT_LOADED
Definition common.h:31
#define ASSERT_MESSAGE_DRIVER_NOT_LOADED
Definition common.h:27
#define AssertReturnFalse
Definition common.h:21
HANDLE g_DeviceHandle
Holds the global handle of device which is used to send the request to the kernel by IOCTL,...
Definition globals.h:481
BOOLEAN g_IsVmmModuleLoaded
shows whether the VMM module is loaded or not
Definition globals.h:28
BOOLEAN IsEnabled
Definition Events.h:250
UINT64 Tag
Definition Events.h:246

◆ CommandEventsShowEvents()

VOID CommandEventsShowEvents ( )

print every active and disabled events

this function will not show cleared events

Returns
VOID
232{
233 //
234 // It's an events without any argument so we have to show
235 // all the currently active events
236 //
237 PLIST_ENTRY TempList = 0;
238 BOOLEAN IsThereAnyEvents = FALSE;
239
240 TempList = &g_EventTrace;
241 while (&g_EventTrace != TempList->Blink)
242 {
243 TempList = TempList->Blink;
244
245 PDEBUGGER_GENERAL_EVENT_DETAIL CommandDetail = CONTAINING_RECORD(TempList, DEBUGGER_GENERAL_EVENT_DETAIL, CommandsEventList);
246 string CommandMessage((char *)CommandDetail->CommandStringBuffer);
247
248 //
249 // Do not show the \n(s)
250 //
251 ReplaceAll(CommandMessage, "\n", " ");
252
253 //
254 // Only show portion of message
255 //
256 if (CommandMessage.length() > 70)
257 {
258 CommandMessage = CommandMessage.substr(0, 70);
259 CommandMessage += "...";
260 }
261
262 ShowMessages("%x\t(%s)\t %s\n",
263 CommandDetail->Tag - DebuggerEventTagStartSeed,
264 // CommandDetail->IsEnabled ? "enabled" : "disabled",
265 CommandEventQueryEventState(CommandDetail->Tag)
266 ? "enabled"
267 : "disabled", /* Query is live now */
268 CommandMessage.c_str());
269
270 if (!IsThereAnyEvents)
271 {
272 IsThereAnyEvents = TRUE;
273 }
274 }
275
276 if (!IsThereAnyEvents)
277 {
278 ShowMessages("no active/disabled events \n");
279 }
280}
BOOLEAN CommandEventQueryEventState(UINT64 Tag)
Check the kernel whether the event is enabled or disabled.
Definition events.cpp:188
VOID ReplaceAll(string &str, const string &from, const string &to)

Variable Documentation

◆ g_AutoFlush

BOOLEAN g_AutoFlush
extern

Whether auto-flush mode is enabled or not enabled.

it is disabled by default

◆ g_BreakPrintingOutput

BOOLEAN g_BreakPrintingOutput
extern

Shows whether the pause command or CTRL+C or CTRL+Break is executed or not.

◆ g_EventTag

UINT64 g_EventTag
extern

This variable holds the trace and generate numbers for new tags of events.

◆ g_EventTrace

LIST_ENTRY g_EventTrace
extern

Holds a list of events in kernel and the state of events and the commands to show the state of each command (disabled/enabled).

this list is not have any relation with the things that HyperDbg holds for each event in the kernel

410{0};

◆ g_EventTraceInitialized

BOOLEAN g_EventTraceInitialized
extern

it shows whether the debugger started using events or not or in other words, is g_EventTrace initialized with a variable or it is empty

◆ g_IsConnectedToRemoteDebuggee

BOOLEAN g_IsConnectedToRemoteDebuggee
extern

Shows whether the current debugger is the host and connected to a remote debuggee (guest).

◆ g_IsSerialConnectedToRemoteDebuggee

BOOLEAN g_IsSerialConnectedToRemoteDebuggee
extern

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

◆ g_IsSerialConnectedToRemoteDebugger

BOOLEAN g_IsSerialConnectedToRemoteDebugger
extern

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

◆ g_IsVmmModuleLoaded

BOOLEAN g_IsVmmModuleLoaded
extern

shows whether the VMM module is loaded or not