|
HyperDbg Debugger
|
This file describes the routines in Hypervisor. More...
#include "pch.h"Functions | |
| UINT32 | HvAdjustControls (UINT32 Ctl, UINT32 Msr) |
| Adjust controls for VMCS based on processor capability. | |
| BOOLEAN | HvSetGuestSelector (PVOID GdtBase, UINT32 SegmentRegister, UINT16 Selector) |
| Set guest's selector registers. | |
| VOID | HvHandleCpuid (VIRTUAL_MACHINE_STATE *VCpu) |
| Handle Cpuid Vmexits. | |
| VOID | HvHandleControlRegisterAccess (VIRTUAL_MACHINE_STATE *VCpu, VMX_EXIT_QUALIFICATION_MOV_CR *CrExitQualification) |
| Handles Guest Access to control registers. | |
| VOID | HvFillGuestSelectorData (PVOID GdtBase, UINT32 SegmentRegister, UINT16 Selector) |
| Fill the guest's selector data. | |
| VOID | HvResumeToNextInstruction () |
| Add the current instruction length to guest rip to resume to next instruction. | |
| VOID | HvSuppressRipIncrement (VIRTUAL_MACHINE_STATE *VCpu) |
| Suppress the incrementation of RIP. | |
| VOID | HvPerformRipIncrement (VIRTUAL_MACHINE_STATE *VCpu) |
| Perform the incrementation of RIP. | |
| VOID | HvSetMonitorTrapFlag (BOOLEAN Set) |
| Set the monitor trap flag. | |
| VOID | HvSetRflagTrapFlag (BOOLEAN Set) |
| Set the rflag's trap flag. | |
| VOID | HvSetLoadDebugControls (VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set) |
| Set LOAD DEBUG CONTROLS on Vm-entry controls. | |
| VOID | HvSetLoadGuestIa32LbrCtl (VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set) |
| Set LOAD GUEST IA32_LBR_CTL on Vm-entry controls. | |
| VOID | HvSetSaveDebugControls (VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set) |
| Set SAVE DEBUG CONTROLS on Vm-exit controls. | |
| VOID | HvSetClearGuestIa32LbrCtl (VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set) |
| Set SAVE GUEST IA32_LBR_CTL on Vm-exit controls. | |
| VOID | HvRestoreRegisters () |
| Reset GDTR/IDTR and other old when you do vmxoff as the patchguard will detect them left modified. | |
| VOID | HvSetPmcVmexit (BOOLEAN Set) |
| Set vm-exit for rdpmc instructions. | |
| VOID | HvSetMovControlRegsExiting (BOOLEAN Set, UINT64 ControlRegister, UINT64 MaskRegister) |
| Set vm-exit for mov-to-cr0/4. | |
| VOID | HvSetMovToCr3Vmexit (VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set) |
| Set vm-exit for mov-to-cr3. | |
| VOID | HvWriteExceptionBitmap (UINT32 BitmapMask) |
| Write on exception bitmap in VMCS DO NOT CALL IT DIRECTLY, instead use HvSetExceptionBitmap. | |
| UINT32 | HvReadExceptionBitmap () |
| Read exception bitmap in VMCS. | |
| VOID | HvSetInterruptWindowExiting (BOOLEAN Set) |
| Set Interrupt-window exiting. | |
| VOID | HvSetPmlEnableFlag (BOOLEAN Set) |
| Set Page Modification Logging Enable bit. | |
| VOID | HvSetModeBasedExecutionEnableFlag (BOOLEAN Set) |
| Set Mode-based Execution Control (MBEC) Enable bit. | |
| VOID | HvSetNmiWindowExiting (BOOLEAN Set) |
| Set NMI-window exiting. | |
| VOID | HvHandleMovDebugRegister (VIRTUAL_MACHINE_STATE *VCpu) |
| Handle Mov to Debug Registers Exitings. | |
| VOID | HvSetNmiExiting (BOOLEAN Set) |
| Set the NMI Exiting. | |
| VOID | HvSetVmxPreemptionTimerExiting (BOOLEAN Set) |
| Set the VMX preemption timer. | |
| VOID | HvSetExceptionBitmap (VIRTUAL_MACHINE_STATE *VCpu, UINT32 IdtIndex) |
| Set exception bitmap in VMCS. | |
| VOID | HvUnsetExceptionBitmap (VIRTUAL_MACHINE_STATE *VCpu, UINT32 IdtIndex) |
| Unset exception bitmap in VMCS. | |
| VOID | HvSetExternalInterruptExiting (VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set) |
| Set the External Interrupt Exiting. | |
| VOID | HvEnableAndCheckForPreviousExternalInterrupts (VIRTUAL_MACHINE_STATE *VCpu) |
| Checks to enable and reinject previous interrupts. | |
| VOID | HvSetRdtscExiting (VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set) |
| Set the RDTSC/P Exiting. | |
| VOID | HvSetMovDebugRegsExiting (VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set) |
| Set or unset the Mov to Debug Registers Exiting. | |
| UINT16 | HvGetCsSelector () |
| Read CS selector. | |
| UINT64 | HvGetRflags () |
| Read guest's RFLAGS. | |
| VOID | HvSetRflags (UINT64 Rflags) |
| Set guest's RFLAGS. | |
| UINT64 | HvGetRip () |
| Read guest's RIP. | |
| VOID | HvSetRip (UINT64 Rip) |
| Set guest's RIP. | |
| UINT64 | HvGetInterruptibilityState () |
| Read guest's interruptibility state. | |
| UINT64 | HvClearSteppingBits (UINT64 Interruptibility) |
| Clear STI and MOV SS bits. | |
| VOID | HvSetInterruptibilityState (UINT64 InterruptibilityState) |
| Set guest's interruptibility state. | |
| VOID | HvInjectPendingExternalInterrupts (VIRTUAL_MACHINE_STATE *VCpu) |
| Inject pending external interrupts. | |
| VOID | HvCheckAndEnableExternalInterrupts (VIRTUAL_MACHINE_STATE *VCpu) |
| Check and enable external interrupts. | |
| VOID | HvDisableExternalInterruptsAndInterruptWindow (VIRTUAL_MACHINE_STATE *VCpu) |
| Disable external-interrupts and interrupt window. | |
| BOOLEAN | HvInitVmm (VMM_CALLBACKS *VmmCallbacks) |
| Initializes the hypervisor. | |
| VOID | HvEnableMtfAndChangeExternalInterruptState (VIRTUAL_MACHINE_STATE *VCpu) |
| Enables MTF and adjust external interrupt state. | |
| VOID | HvPreventExternalInterrupts (VIRTUAL_MACHINE_STATE *VCpu) |
| Adjust external interrupt state. | |
| UINT64 | HvGetPendingDebugExceptions () |
| Get the guest state of pending debug exceptions. | |
| VOID | HvSetPendingDebugExceptions (UINT64 Value) |
| Set the guest state of pending debug exceptions. | |
| UINT64 | HvGetDebugctl () |
| Get the guest state of IA32_DEBUGCTL. | |
| UINT64 | HvGetGuestIa32LbrCtl () |
| Get the guest state of IA32_LBR_CTL. | |
| VOID | HvGetAndStoreDebugctl (UINT64 *StoreDebugctl) |
| Get and store the guest state of IA32_DEBUGCTL. | |
| VOID | HvGetAndStoreGuestIa32LbrCtl (UINT64 *StoreGuestIa32Lbr) |
| Get and store the guest state of IA32_LBR_CTL. | |
| VOID | HvSetDebugctl (UINT64 Value) |
| Set the guest state of IA32_DEBUGCTL. | |
| VOID | HvSetGuestIa32LbrCtl (UINT64 Value) |
| Set the guest state of IA32_LBR_CTL. | |
| VOID | HvSetLbrSelect (UINT64 FilterOptions) |
| Set LBR selector. | |
| BOOLEAN | HvCheckCpuSupportForSaveAndLoadDebugControls () |
| Check if CPU support save and load debug controls on exit and load entries. | |
| BOOLEAN | HvCheckCpuSupportForLoadAndClearGuestIa32LbrCtlControls () |
| Check if CPU support load and clear guest IA32_LBR_CTL controls on entry and exit. | |
| VOID | HvSetDebugReg7 (UINT64 Value) |
| Set the guest state of DR7. | |
| VOID | HvHandleTrapFlag () |
| Handle the case when the trap flag is set, and we need to inject the single-step exception right after vm-entry. | |
This file describes the routines in Hypervisor.
vmx related routines
Adjust controls for VMCS based on processor capability.
Returns the Cpu Based and Secondary Processor Based Controls and other controls based on hardware support.
| Ctl | |
| Msr |
Adjust controls for VMCS based on processor capability.
| Ctl | |
| Msr |
| VOID HvCheckAndEnableExternalInterrupts | ( | VIRTUAL_MACHINE_STATE * | VCpu | ) |
Check and enable external interrupts.
| VCpu | The virtual processor's state |
| BOOLEAN HvCheckCpuSupportForLoadAndClearGuestIa32LbrCtlControls | ( | ) |
Check if CPU support load and clear guest IA32_LBR_CTL controls on entry and exit.
Check if CPU support load and clear guest IA32_LBR_CTL controls on VM-entry and VM-exit.
Check if CPU support load and clear guest IA32_LBR_CTL controls on entry and exit.
| BOOLEAN HvCheckCpuSupportForSaveAndLoadDebugControls | ( | ) |
Check if CPU support save and load debug controls on exit and load entries.
| UINT64 HvClearSteppingBits | ( | UINT64 | Interruptibility | ) |
Clear STI and MOV SS bits.
| VOID HvDisableExternalInterruptsAndInterruptWindow | ( | VIRTUAL_MACHINE_STATE * | VCpu | ) |
Disable external-interrupts and interrupt window.
| VCpu | The virtual processor's state |
| VOID HvEnableAndCheckForPreviousExternalInterrupts | ( | VIRTUAL_MACHINE_STATE * | VCpu | ) |
Checks to enable and reinject previous interrupts.
| VCpu | The virtual processor's state |
| VCpu | The virtual processor's state |
| Set | Set or unset the External Interrupt Exiting |
| VOID HvEnableMtfAndChangeExternalInterruptState | ( | VIRTUAL_MACHINE_STATE * | VCpu | ) |
Enables MTF and adjust external interrupt state.
| VCpu | The virtual processor's state |
Fill the guest's selector data.
Fill guest selector data.
| GdtBase | |
| SegmentRegister | |
| Selector |
Fill the guest's selector data.
| GdtBase | |
| SegmentRegister | |
| Selector |
| VOID HvGetAndStoreDebugctl | ( | UINT64 * | StoreDebugctl | ) |
Get and store the guest state of IA32_DEBUGCTL.
mainly used from the VMCALL handler
| StoreDebugctl |
| VOID HvGetAndStoreGuestIa32LbrCtl | ( | UINT64 * | StoreGuestIa32Lbr | ) |
Get and store the guest state of IA32_LBR_CTL.
mainly used from the VMCALL handler
| StoreGuestIa32Lbr |
| UINT16 HvGetCsSelector | ( | ) |
Read CS selector.
| UINT64 HvGetDebugctl | ( | ) |
Get the guest state of IA32_DEBUGCTL.
| UINT64 HvGetGuestIa32LbrCtl | ( | ) |
Get the guest state of IA32_LBR_CTL.
| UINT64 HvGetInterruptibilityState | ( | ) |
Read guest's interruptibility state.
| UINT64 HvGetPendingDebugExceptions | ( | ) |
Get the guest state of pending debug exceptions.
| UINT64 HvGetRflags | ( | ) |
Read guest's RFLAGS.
| UINT64 HvGetRip | ( | ) |
Read guest's RIP.
| VOID HvHandleControlRegisterAccess | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
| VMX_EXIT_QUALIFICATION_MOV_CR * | CrExitQualification ) |
Handles Guest Access to control registers.
Handle Guest's Control Registers Access.
| VCpu | The virtual processor's state |
Handles Guest Access to control registers.
| VCpu |
| VOID HvHandleCpuid | ( | VIRTUAL_MACHINE_STATE * | VCpu | ) |
Handle Cpuid Vmexits.
Handle Cpuid.
| VCpu | The virtual processor's state |
Handle Cpuid Vmexits.
| VCpu |
| VOID HvHandleMovDebugRegister | ( | VIRTUAL_MACHINE_STATE * | VCpu | ) |
Handle Mov to Debug Registers Exitings.
| VCpu | The virtual processor's state |
| VCpu |
| VOID HvHandleTrapFlag | ( | ) |
Handle the case when the trap flag is set, and we need to inject the single-step exception right after vm-entry.
| BOOLEAN HvInitVmm | ( | VMM_CALLBACKS * | VmmCallbacks | ) |
Initializes the hypervisor.
| VmmCallbacks |
| VOID HvInjectPendingExternalInterrupts | ( | VIRTUAL_MACHINE_STATE * | VCpu | ) |
Inject pending external interrupts.
| VCpu | The virtual processor's state |
|
inline |
Perform the incrementation of RIP.
| VCpu | The virtual processor's state |
| VOID HvPreventExternalInterrupts | ( | VIRTUAL_MACHINE_STATE * | VCpu | ) |
Adjust external interrupt state.
| VCpu | The virtual processor's state |
| UINT32 HvReadExceptionBitmap | ( | ) |
Read exception bitmap in VMCS.
Read the exception bitmap.
Should be called in vmx-root
Read exception bitmap in VMCS.
| VOID HvRestoreRegisters | ( | ) |
Reset GDTR/IDTR and other old when you do vmxoff as the patchguard will detect them left modified.
| VOID HvResumeToNextInstruction | ( | ) |
Add the current instruction length to guest rip to resume to next instruction.
Resume GUEST_RIP to next instruction.
Add the current instruction length to guest rip to resume to next instruction.
| VOID HvSetClearGuestIa32LbrCtl | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
| BOOLEAN | Set ) |
Set SAVE GUEST IA32_LBR_CTL on Vm-exit controls.
| VCpu | |
| Set | Set or unset |
| VOID HvSetDebugctl | ( | UINT64 | Value | ) |
Set the guest state of IA32_DEBUGCTL.
| Value | The new state |
| VOID HvSetDebugReg7 | ( | UINT64 | Value | ) |
Set the guest state of DR7.
| Value | The new value for DR7 |
| VOID HvSetExceptionBitmap | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
| UINT32 | IdtIndex ) |
Set exception bitmap in VMCS.
Should be called in vmx-root
| VCpu | The virtual processor's state |
| IdtIndex | Interrupt Descriptor Table index of exception |
Should be called in vmx-root
| IdtIndex |
| VOID HvSetExternalInterruptExiting | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
| BOOLEAN | Set ) |
Set the External Interrupt Exiting.
| VCpu | The virtual processor's state |
| Set | Set or unset the External Interrupt Exiting |
| Set |
| VOID HvSetGuestIa32LbrCtl | ( | UINT64 | Value | ) |
Set the guest state of IA32_LBR_CTL.
| Value | The new state |
Set guest's selector registers.
Set Guest Selector Registers.
| GdtBase | |
| SegmentRegister | |
| Selector |
Set guest's selector registers.
| GdtBase | |
| SegmentRegister | |
| Selector |
| VOID HvSetInterruptibilityState | ( | UINT64 | InterruptibilityState | ) |
Set guest's interruptibility state.
| InterruptibilityState |
| VOID HvSetInterruptWindowExiting | ( | BOOLEAN | Set | ) |
Set Interrupt-window exiting.
| Set | Set or unset the Interrupt-window exiting |
| Set |
| VOID HvSetLbrSelect | ( | UINT64 | FilterOptions | ) |
Set LBR selector.
If VMM is active, this should be done in vmx-root, otherwise, it doesn't work
| FilterOptions | The value to write on MSR_LEGACY_LBR_SELECT |
| VOID HvSetLoadDebugControls | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
| BOOLEAN | Set ) |
Set LOAD DEBUG CONTROLS on Vm-entry controls.
| VCpu | |
| Set | Set or unset |
| VOID HvSetLoadGuestIa32LbrCtl | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
| BOOLEAN | Set ) |
Set LOAD GUEST IA32_LBR_CTL on Vm-entry controls.
| VCpu | |
| Set | Set or unset |
| VOID HvSetModeBasedExecutionEnableFlag | ( | BOOLEAN | Set | ) |
Set Mode-based Execution Control (MBEC) Enable bit.
| Set | Set or unset the MBEC |
| VOID HvSetMonitorTrapFlag | ( | BOOLEAN | Set | ) |
Set the monitor trap flag.
Set or unset the monitor trap flags.
| Set | Set or unset the MTFs |
Set the monitor trap flag.
| Set |
| VOID HvSetMovControlRegsExiting | ( | BOOLEAN | Set, |
| UINT64 | ControlRegister, | ||
| UINT64 | MaskRegister ) |
Set vm-exit for mov-to-cr0/4.
Should be called in vmx-root
| Set | or unset the vm-exits |
| Control | Register |
| Mask | Register |
| Set | |
| ControlRegister | |
| MaskRegister |
| VOID HvSetMovDebugRegsExiting | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
| BOOLEAN | Set ) |
Set or unset the Mov to Debug Registers Exiting.
Set the Mov to Debug Registers Exiting.
| VCpu | The virtual processor's state |
| Set | Set or unset the Mov to Debug Registers Exiting |
Set or unset the Mov to Debug Registers Exiting.
| Set |
| VOID HvSetMovToCr3Vmexit | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
| BOOLEAN | Set ) |
Set vm-exit for mov-to-cr3.
Should be called in vmx-root
| VCpu | The virtual processor's state |
| Set | Set or unset the vm-exits |
| Set |
| VOID HvSetNmiExiting | ( | BOOLEAN | Set | ) |
Set the NMI Exiting.
| Set | Set or unset the NMI Exiting |
| Set |
| VOID HvSetNmiWindowExiting | ( | BOOLEAN | Set | ) |
Set NMI-window exiting.
| Set | Set or unset the NMI-window exiting |
| Set |
| VOID HvSetPendingDebugExceptions | ( | UINT64 | Value | ) |
Set the guest state of pending debug exceptions.
| Value | The new state |
| VOID HvSetPmcVmexit | ( | BOOLEAN | Set | ) |
Set vm-exit for rdpmc instructions.
Should be called in vmx-root
| Set | Set or unset the vm-exits |
| Set |
| VOID HvSetPmlEnableFlag | ( | BOOLEAN | Set | ) |
Set Page Modification Logging Enable bit.
| Set | Set or unset the PML |
| VOID HvSetRdtscExiting | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
| BOOLEAN | Set ) |
Set the RDTSC/P Exiting.
| VCpu | The virtual processor's state |
| Set | Set or unset the RDTSC/P Exiting |
| Set |
| VOID HvSetRflags | ( | UINT64 | Rflags | ) |
Set guest's RFLAGS.
| Rflags |
| VOID HvSetRflagTrapFlag | ( | BOOLEAN | Set | ) |
Set the rflag's trap flag.
| Set | Set or unset the TF |
| VOID HvSetRip | ( | UINT64 | Rip | ) |
| VOID HvSetSaveDebugControls | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
| BOOLEAN | Set ) |
Set SAVE DEBUG CONTROLS on Vm-exit controls.
| VCpu | |
| Set | Set or unset |
| VOID HvSetVmxPreemptionTimerExiting | ( | BOOLEAN | Set | ) |
Set the VMX preemption timer.
Set the VMX Preemptiom Timer.
| Set | Set or unset the VMX preemption timer |
Set the VMX preemption timer.
| Set |
|
inline |
Suppress the incrementation of RIP.
| VCpu | The virtual processor's state |
| VOID HvUnsetExceptionBitmap | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
| UINT32 | IdtIndex ) |
Unset exception bitmap in VMCS.
Should be called in vmx-root
| VCpu | The virtual processor's state |
| IdtIndex | Interrupt Descriptor Table index of exception |
Should be called in vmx-root
| IdtIndex |
| VOID HvWriteExceptionBitmap | ( | UINT32 | BitmapMask | ) |
Write on exception bitmap in VMCS DO NOT CALL IT DIRECTLY, instead use HvSetExceptionBitmap.
Write to the exception bitmap.
Should be called in vmx-root
| BitmapMask | The content to write on exception bitmap |
Write on exception bitmap in VMCS DO NOT CALL IT DIRECTLY, instead use HvSetExceptionBitmap.
| BitmapMask |