| HyperDbg Debugger
    | 
Implementation of Debugger functions. More...
#include "pch.h"| Functions | |
| UINT64 | DebuggerGetRegValueWrapper (PGUEST_REGS GuestRegs, UINT32 RegId) | 
| A wrapper for GetRegValue() in script-engine. | |
| UINT32 | DebuggerGetLastError () | 
| Debugger get the last error. | |
| VOID | DebuggerSetLastError (UINT32 LastError) | 
| Debugger set the last error. | |
| BOOLEAN | DebuggerInitialize () | 
| Initialize Debugger Structures and Routines. | |
| VOID | DebuggerUninitialize () | 
| Uninitialize Debugger Structures and Routines. | |
| PDEBUGGER_EVENT | DebuggerCreateEvent (BOOLEAN Enabled, UINT32 CoreId, UINT32 ProcessId, VMM_EVENT_TYPE_ENUM EventType, UINT64 Tag, DEBUGGER_EVENT_OPTIONS *Options, UINT32 ConditionsBufferSize, PVOID ConditionBuffer, PDEBUGGER_EVENT_AND_ACTION_RESULT ResultsToReturn, BOOLEAN InputFromVmxRoot) | 
| Create an Event Object. | |
| PVOID | DebuggerAllocateSafeRequestedBuffer (SIZE_T SizeOfRequestedSafeBuffer, PDEBUGGER_EVENT_AND_ACTION_RESULT ResultsToReturn, BOOLEAN InputFromVmxRoot) | 
| Allocates buffer for requested safe buffer. | |
| PDEBUGGER_EVENT_ACTION | DebuggerAddActionToEvent (PDEBUGGER_EVENT Event, DEBUGGER_EVENT_ACTION_TYPE_ENUM ActionType, BOOLEAN SendTheResultsImmediately, PDEBUGGER_EVENT_REQUEST_CUSTOM_CODE InTheCaseOfCustomCode, PDEBUGGER_EVENT_ACTION_RUN_SCRIPT_CONFIGURATION InTheCaseOfRunScript, PDEBUGGER_EVENT_AND_ACTION_RESULT ResultsToReturn, BOOLEAN InputFromVmxRoot) | 
| Create an action and add the action to an event. | |
| BOOLEAN | DebuggerRegisterEvent (PDEBUGGER_EVENT Event) | 
| Register an event to a list of active events. | |
| VMM_CALLBACK_TRIGGERING_EVENT_STATUS_TYPE | DebuggerTriggerEvents (VMM_EVENT_TYPE_ENUM EventType, VMM_CALLBACK_EVENT_CALLING_STAGE_TYPE CallingStage, PVOID Context, BOOLEAN *PostEventRequired, GUEST_REGS *Regs) | 
| Trigger events of a special type to be managed by debugger. | |
| VOID | DebuggerPerformActions (PROCESSOR_DEBUGGING_STATE *DbgState, DEBUGGER_EVENT *Event, DEBUGGER_TRIGGERED_EVENT_DETAILS *EventTriggerDetail) | 
| Run a special event's action(s) | |
| BOOLEAN | DebuggerPerformRunScript (PROCESSOR_DEBUGGING_STATE *DbgState, DEBUGGER_EVENT_ACTION *Action, DEBUGGEE_SCRIPT_PACKET *ScriptDetails, DEBUGGER_TRIGGERED_EVENT_DETAILS *EventTriggerDetail) | 
| Managing run script action. | |
| VOID | DebuggerPerformRunTheCustomCode (PROCESSOR_DEBUGGING_STATE *DbgState, DEBUGGER_EVENT_ACTION *Action, DEBUGGER_TRIGGERED_EVENT_DETAILS *EventTriggerDetail) | 
| Manage running the custom code action. | |
| VOID | DebuggerPerformBreakToDebugger (PROCESSOR_DEBUGGING_STATE *DbgState, DEBUGGER_EVENT_ACTION *Action, DEBUGGER_TRIGGERED_EVENT_DETAILS *EventTriggerDetail) | 
| Manage breaking to the debugger action. | |
| PDEBUGGER_EVENT | DebuggerGetEventByTag (UINT64 Tag) | 
| Find event object by tag. | |
| BOOLEAN | DebuggerEnableOrDisableAllEvents (BOOLEAN IsEnable) | 
| Enable or disable all events from all the types. | |
| BOOLEAN | DebuggerTerminateAllEvents (BOOLEAN InputFromVmxRoot) | 
| Terminate effect and configuration to vmx-root and non-root for all the events. | |
| BOOLEAN | DebuggerRemoveAllEvents (BOOLEAN PoolManagerAllocatedMemory) | 
| Remove all the events from all the lists and also de-allocate their structures and actions. | |
| UINT32 | DebuggerEventListCount (PLIST_ENTRY TargetEventList) | 
| Count the list of events in a special list. | |
| PLIST_ENTRY | DebuggerGetEventListByEventType (VMM_EVENT_TYPE_ENUM EventType) | 
| Get List of event based on event type. | |
| UINT32 | DebuggerEventListCountByCore (PLIST_ENTRY TargetEventList, UINT32 TargetCore) | 
| Count the list of events in a special list that are activate on a target core. | |
| UINT32 | DebuggerEventListCountByEventType (VMM_EVENT_TYPE_ENUM EventType, UINT32 TargetCore) | 
| Count the list of events by a special event type that are activate on a target core. | |
| UINT32 | DebuggerExceptionEventBitmapMask (UINT32 CoreIndex) | 
| Get the mask related to the !exception command for the target core. | |
| BOOLEAN | DebuggerEnableEvent (UINT64 Tag) | 
| Enable an event by tag. | |
| BOOLEAN | DebuggerQueryStateEvent (UINT64 Tag) | 
| returns whether an event is enabled/disabled by tag | |
| BOOLEAN | DebuggerDisableEvent (UINT64 Tag) | 
| Disable an event by tag. | |
| BOOLEAN | DebuggerClearEvent (UINT64 Tag, BOOLEAN InputFromVmxRoot, BOOLEAN PoolManagerAllocatedMemory) | 
| Clear an event by tag. | |
| VOID | DebuggerClearAllEvents (BOOLEAN InputFromVmxRoot, BOOLEAN PoolManagerAllocatedMemory) | 
| Clear all events. | |
| BOOLEAN | DebuggerIsTagValid (UINT64 Tag) | 
| Detect whether the tag exists or not. | |
| BOOLEAN | DebuggerQueryDebuggerStatus () | 
| Detect whether the user or kernel debugger is active or not. | |
| BOOLEAN | DebuggerRemoveEventFromEventList (UINT64 Tag) | 
| Remove the event from event list by its tag. | |
| BOOLEAN | DebuggerRemoveAllActionsFromEvent (PDEBUGGER_EVENT Event, BOOLEAN PoolManagerAllocatedMemory) | 
| Remove the actions and de-allocate its buffer. | |
| BOOLEAN | DebuggerRemoveEvent (UINT64 Tag, BOOLEAN PoolManagerAllocatedMemory) | 
| Remove the event by its tags and also remove its actions and de-allocate their buffers. | |
| BOOLEAN | DebuggerValidateEvent (PDEBUGGER_GENERAL_EVENT_DETAIL EventDetails, PDEBUGGER_EVENT_AND_ACTION_RESULT ResultsToReturn, BOOLEAN InputFromVmxRoot) | 
| validating events | |
| BOOLEAN | DebuggerApplyEvent (PDEBUGGER_EVENT Event, PDEBUGGER_EVENT_AND_ACTION_RESULT ResultsToReturn, BOOLEAN InputFromVmxRoot) | 
| Applying events. | |
| BOOLEAN | DebuggerParseEvent (PDEBUGGER_GENERAL_EVENT_DETAIL EventDetails, PDEBUGGER_EVENT_AND_ACTION_RESULT ResultsToReturn, BOOLEAN InputFromVmxRoot) | 
| Routine for parsing events. | |
| BOOLEAN | DebuggerParseAction (PDEBUGGER_GENERAL_ACTION ActionDetails, PDEBUGGER_EVENT_AND_ACTION_RESULT ResultsToReturn, BOOLEAN InputFromVmxRoot) | 
| Routine for validating and parsing actions that are coming from the user-mode. | |
| BOOLEAN | DebuggerTerminateEvent (UINT64 Tag, BOOLEAN InputFromVmxRoot) | 
| Terminate one event's effect by its tag. | |
| BOOLEAN | DebuggerParseEventsModification (PDEBUGGER_MODIFY_EVENTS DebuggerEventModificationRequest, BOOLEAN InputFromVmxRoot, BOOLEAN PoolManagerAllocatedMemory) | 
| Parse and validate requests to enable/disable/clear from the user-mode. | |
Implementation of Debugger functions.
| PDEBUGGER_EVENT_ACTION DebuggerAddActionToEvent | ( | PDEBUGGER_EVENT | Event, | 
| DEBUGGER_EVENT_ACTION_TYPE_ENUM | ActionType, | ||
| BOOLEAN | SendTheResultsImmediately, | ||
| PDEBUGGER_EVENT_REQUEST_CUSTOM_CODE | InTheCaseOfCustomCode, | ||
| PDEBUGGER_EVENT_ACTION_RUN_SCRIPT_CONFIGURATION | InTheCaseOfRunScript, | ||
| PDEBUGGER_EVENT_AND_ACTION_RESULT | ResultsToReturn, | ||
| BOOLEAN | InputFromVmxRoot ) | 
Create an action and add the action to an event.
| Event | Target event object | 
| ActionType | Type of action | 
| SendTheResultsImmediately | whether the results should be received by the user-mode immediately | 
| InTheCaseOfCustomCode | Custom code structure (if any) | 
| InTheCaseOfRunScript | Run script structure (if any) | 
| ResultsToReturn | The buffer address that should be returned to the user-mode as the result | 
| InputFromVmxRoot | Whether the input comes from VMX root-mode or IOCTL | 
| PVOID DebuggerAllocateSafeRequestedBuffer | ( | SIZE_T | SizeOfRequestedSafeBuffer, | 
| PDEBUGGER_EVENT_AND_ACTION_RESULT | ResultsToReturn, | ||
| BOOLEAN | InputFromVmxRoot ) | 
Allocates buffer for requested safe buffer.
| SizeOfRequestedSafeBuffer | The size of the requested safe buffer | 
| ResultsToReturn | The buffer address that should be returned to the user-mode as the result | 
| InputFromVmxRoot | Whether the input comes from VMX root-mode or IOCTL | 
| BOOLEAN DebuggerApplyEvent | ( | PDEBUGGER_EVENT | Event, | 
| PDEBUGGER_EVENT_AND_ACTION_RESULT | ResultsToReturn, | ||
| BOOLEAN | InputFromVmxRoot ) | 
Applying events.
| Event | The created event object | 
| ResultsToReturn | Result buffer that should be returned to the user-mode | 
| InputFromVmxRoot | Whether the input comes from VMX root-mode or IOCTL | 
Clear all events.
| InputFromVmxRoot | Whether the input comes from VMX root-mode or IOCTL | 
| PoolManagerAllocatedMemory | Whether the pools are allocated from the pool manager or original OS pools | 
| BOOLEAN DebuggerClearEvent | ( | UINT64 | Tag, | 
| BOOLEAN | InputFromVmxRoot, | ||
| BOOLEAN | PoolManagerAllocatedMemory ) | 
Clear an event by tag.
| Tag | Tag of target event | 
| InputFromVmxRoot | Whether the input comes from VMX root-mode or IOCTL | 
| PoolManagerAllocatedMemory | Whether the pools are allocated from the pool manager or original OS pools | 
| PDEBUGGER_EVENT DebuggerCreateEvent | ( | BOOLEAN | Enabled, | 
| UINT32 | CoreId, | ||
| UINT32 | ProcessId, | ||
| VMM_EVENT_TYPE_ENUM | EventType, | ||
| UINT64 | Tag, | ||
| DEBUGGER_EVENT_OPTIONS * | Options, | ||
| UINT32 | ConditionsBufferSize, | ||
| PVOID | ConditionBuffer, | ||
| PDEBUGGER_EVENT_AND_ACTION_RESULT | ResultsToReturn, | ||
| BOOLEAN | InputFromVmxRoot ) | 
Create an Event Object.
should NOT be called in vmx-root
| Enabled | Is the event enabled or disabled | 
| CoreId | The core id that this event is allowed to run | 
| ProcessId | The process id that this event is allowed to run | 
| EventType | The type of event | 
| Tag | User-mode generated unique tag (id) of the event | 
| Options | Optional parameters for the event | 
| ConditionsBufferSize | Size of condition code buffer (if any) | 
| ConditionBuffer | Address of condition code buffer (if any) | 
| ResultsToReturn | Result buffer that should be returned to the user-mode | 
| InputFromVmxRoot | Whether the input comes from VMX root-mode or IOCTL | 
Disable an event by tag.
| Tag | Tag of target event | 
Enable an event by tag.
| Tag | Tag of target event | 
Enable or disable all events from all the types.
| IsEnable | If you want to enable then true and if you want to disable then false | 
| UINT32 DebuggerEventListCount | ( | PLIST_ENTRY | TargetEventList | ) | 
Count the list of events in a special list.
| TargetEventList | target event list | 
Count the list of events in a special list that are activate on a target core.
| TargetEventList | target event list | 
| TargetCore | target core | 
| UINT32 DebuggerEventListCountByEventType | ( | VMM_EVENT_TYPE_ENUM | EventType, | 
| UINT32 | TargetCore ) | 
Count the list of events by a special event type that are activate on a target core.
| EventType | target event type | 
| TargetCore | target core | 
Get the mask related to the !exception command for the target core.
| CoreIndex | The index of core | 
| PDEBUGGER_EVENT DebuggerGetEventByTag | ( | UINT64 | Tag | ) | 
Find event object by tag.
| Tag | Tag of event | 
| PLIST_ENTRY DebuggerGetEventListByEventType | ( | VMM_EVENT_TYPE_ENUM | EventType | ) | 
Get List of event based on event type.
| EventType | type of event | 
| UINT32 DebuggerGetLastError | ( | ) | 
Debugger get the last error.
| UINT64 DebuggerGetRegValueWrapper | ( | PGUEST_REGS | GuestRegs, | 
| UINT32 | RegId ) | 
A wrapper for GetRegValue() in script-engine.
| BOOLEAN DebuggerInitialize | ( | ) | 
Initialize Debugger Structures and Routines.
Detect whether the tag exists or not.
| Tag | Tag of target event | 
| BOOLEAN DebuggerParseAction | ( | PDEBUGGER_GENERAL_ACTION | ActionDetails, | 
| PDEBUGGER_EVENT_AND_ACTION_RESULT | ResultsToReturn, | ||
| BOOLEAN | InputFromVmxRoot ) | 
Routine for validating and parsing actions that are coming from the user-mode.
| ActionDetails | Structure that describes the action that comes from the user-mode | 
| ResultsToReturn | The buffer address that should be returned to the user-mode as the result | 
| InputFromVmxRoot | Whether the input comes from VMX root-mode or IOCTL | 
| BOOLEAN DebuggerParseEvent | ( | PDEBUGGER_GENERAL_EVENT_DETAIL | EventDetails, | 
| PDEBUGGER_EVENT_AND_ACTION_RESULT | ResultsToReturn, | ||
| BOOLEAN | InputFromVmxRoot ) | 
Routine for parsing events.
| EventDetails | The structure that describes event that came from the user-mode | 
| ResultsToReturn | Result buffer that should be returned to the user-mode | 
| InputFromVmxRoot | Whether the input comes from VMX root-mode or IOCTL | 
| BOOLEAN DebuggerParseEventsModification | ( | PDEBUGGER_MODIFY_EVENTS | DebuggerEventModificationRequest, | 
| BOOLEAN | InputFromVmxRoot, | ||
| BOOLEAN | PoolManagerAllocatedMemory ) | 
Parse and validate requests to enable/disable/clear from the user-mode.
| DebuggerEventModificationRequest | event modification request details | 
| InputFromVmxRoot | Whether the input comes from VMX root-mode or IOCTL | 
| PoolManagerAllocatedMemory | Whether the pools are allocated from the pool manager or original OS pools | 
| VOID DebuggerPerformActions | ( | PROCESSOR_DEBUGGING_STATE * | DbgState, | 
| DEBUGGER_EVENT * | Event, | ||
| DEBUGGER_TRIGGERED_EVENT_DETAILS * | EventTriggerDetail ) | 
Run a special event's action(s)
| DbgState | The state of the debugger on the current core | 
| Event | Event Object | 
| EventTriggerDetail | Event trigger details | 
| VOID DebuggerPerformBreakToDebugger | ( | PROCESSOR_DEBUGGING_STATE * | DbgState, | 
| DEBUGGER_EVENT_ACTION * | Action, | ||
| DEBUGGER_TRIGGERED_EVENT_DETAILS * | EventTriggerDetail ) | 
Manage breaking to the debugger action.
| DbgState | The state of the debugger on the current core | 
| Tag | Tag of event | 
| Action | Action object | 
| EventTriggerDetail | Event trigger detail | 
| BOOLEAN DebuggerPerformRunScript | ( | PROCESSOR_DEBUGGING_STATE * | DbgState, | 
| DEBUGGER_EVENT_ACTION * | Action, | ||
| DEBUGGEE_SCRIPT_PACKET * | ScriptDetails, | ||
| DEBUGGER_TRIGGERED_EVENT_DETAILS * | EventTriggerDetail ) | 
Managing run script action.
| DbgState | The state of the debugger on the current core | 
| Action | Action object | 
| ScriptDetails | Details of script | 
| EventTriggerDetail | Event trigger detail | 
| VOID DebuggerPerformRunTheCustomCode | ( | PROCESSOR_DEBUGGING_STATE * | DbgState, | 
| DEBUGGER_EVENT_ACTION * | Action, | ||
| DEBUGGER_TRIGGERED_EVENT_DETAILS * | EventTriggerDetail ) | 
Manage running the custom code action.
| DbgState | The state of the debugger on the current core | 
| Action | Action object | 
| EventTriggerDetail | Event trigger detail | 
| BOOLEAN DebuggerQueryDebuggerStatus | ( | ) | 
Detect whether the user or kernel debugger is active or not.
returns whether an event is enabled/disabled by tag
this function won't check for Tag validity and if not found then returns false
| Tag | Tag of target event | 
| BOOLEAN DebuggerRegisterEvent | ( | PDEBUGGER_EVENT | Event | ) | 
Register an event to a list of active events.
| Event | Event structure | 
| BOOLEAN DebuggerRemoveAllActionsFromEvent | ( | PDEBUGGER_EVENT | Event, | 
| BOOLEAN | PoolManagerAllocatedMemory ) | 
Remove the actions and de-allocate its buffer.
should not be called from vmx-root mode, also it won't terminate their effects, so the events should be terminated first then we can remove them *
| Event | Event Object | 
| PoolManagerAllocatedMemory | Whether the pools are allocated from the pool manager or original OS pools | 
Remove all the events from all the lists and also de-allocate their structures and actions.
should not be called from vmx-root mode, also it won't terminate their effects, so the events should be terminated first then we can remove them
| PoolManagerAllocatedMemory | Whether the pools are allocated from the pool manager or original OS pools | 
Remove the event by its tags and also remove its actions and de-allocate their buffers.
it won't terminate their effects, so the events should be terminated first then we can remove them
| Tag | Target event tag | 
| PoolManagerAllocatedMemory | Whether the pools are allocated from the pool manager or original OS pools | 
Remove the event from event list by its tag.
should not be called from vmx-root mode, also it won't terminate their effects, so the events should be terminated first then we can remove them
| Tag | Target events tag | 
Debugger set the last error.
| LastError | The value of last error | 
Terminate effect and configuration to vmx-root and non-root for all the events.
| InputFromVmxRoot | Whether the input comes from VMX root-mode or IOCTL | 
Terminate one event's effect by its tag.
This function won't remove the event from the lists of event or de-allocated them, this should be called BEFORE the removing function
| Tag | Target event's tag | 
| InputFromVmxRoot | Whether the input comes from VMX root-mode or IOCTL | 
| VMM_CALLBACK_TRIGGERING_EVENT_STATUS_TYPE DebuggerTriggerEvents | ( | VMM_EVENT_TYPE_ENUM | EventType, | 
| VMM_CALLBACK_EVENT_CALLING_STAGE_TYPE | CallingStage, | ||
| PVOID | Context, | ||
| BOOLEAN * | PostEventRequired, | ||
| GUEST_REGS * | Regs ) | 
Trigger events of a special type to be managed by debugger.
| EventType | Type of events | 
| CallingStage | Stage of calling (pre-event or post-event) | 
| Context | An optional parameter (different in each event) | 
| PostEventRequired | Whether the caller is requested to trigger a post-event event | 
| Regs | Guest gp-registers | 
| VOID DebuggerUninitialize | ( | ) | 
Uninitialize Debugger Structures and Routines.
| BOOLEAN DebuggerValidateEvent | ( | PDEBUGGER_GENERAL_EVENT_DETAIL | EventDetails, | 
| PDEBUGGER_EVENT_AND_ACTION_RESULT | ResultsToReturn, | ||
| BOOLEAN | InputFromVmxRoot ) | 
validating events
| EventDetails | The structure that describes event that came from the user-mode or VMX-root mode | 
| ResultsToReturn | Result buffer that should be returned to the user-mode | 
| InputFromVmxRoot | Whether the input comes from VMX root-mode or IOCTL |