HyperDbg Debugger
Loading...
Searching...
No Matches
ProtectedHv.h File Reference

Header files for protected hypervisor resources. More...

Go to the source code of this file.

Functions

VOID ProtectedHvSetExceptionBitmap (VIRTUAL_MACHINE_STATE *VCpu, UINT32 IdtIndex)
 Set exception bitmap in VMCS.
 
VOID ProtectedHvUnsetExceptionBitmap (VIRTUAL_MACHINE_STATE *VCpu, UINT32 IdtIndex)
 Unset exception bitmap in VMCS.
 
VOID ProtectedHvResetExceptionBitmapToClearEvents (VIRTUAL_MACHINE_STATE *VCpu)
 Reset exception bitmap in VMCS because of clearing !exception commands.
 
VOID ProtectedHvRemoveUndefinedInstructionForDisablingSyscallSysretCommands (VIRTUAL_MACHINE_STATE *VCpu)
 Reset exception bitmap in VMCS because of clearing !exception commands.
 
VOID ProtectedHvSetExternalInterruptExiting (VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set)
 Set the External Interrupt Exiting.
 
VOID ProtectedHvExternalInterruptExitingForDisablingInterruptCommands (VIRTUAL_MACHINE_STATE *VCpu)
 Clear events of !interrupt.
 
VOID ProtectedHvSetRdtscExiting (VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set)
 Set the RDTSC/P Exiting.
 
VOID ProtectedHvDisableRdtscExitingForDisablingTscCommands (VIRTUAL_MACHINE_STATE *VCpu)
 Clear events of !tsc.
 
VOID ProtectedHvSetMovDebugRegsExiting (VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set)
 Set MOV to HW Debug Regs Exiting.
 
VOID ProtectedHvDisableMovDebugRegsExitingForDisablingDrCommands (VIRTUAL_MACHINE_STATE *VCpu)
 Clear events of !dr.
 
VOID ProtectedHvDisableMovControlRegsExitingForDisablingCrCommands (VIRTUAL_MACHINE_STATE *VCpu, UINT64 ControlRegister, UINT64 MaskRegister)
 Clear events of !crwrite.
 
VOID ProtectedHvSetMov2CrExiting (BOOLEAN Set, UINT64 ControlRegister, UINT64 MaskRegister)
 Set MOV to CR0/4 Exiting.
 
VOID ProtectedHvSetMov2Cr3Exiting (VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set)
 Set MOV to CR3 Exiting.
 

Detailed Description

Header files for protected hypervisor resources.

Author
Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)

Protected Hypervisor Routines are those resource that are used in different parts of the debugger or hypervisor, these resources need extra checks to avoid integrity problems

Version
0.1
Date
2021-10-04

Function Documentation

◆ ProtectedHvDisableMovControlRegsExitingForDisablingCrCommands()

VOID ProtectedHvDisableMovControlRegsExitingForDisablingCrCommands ( VIRTUAL_MACHINE_STATE * VCpu,
UINT64 ControlRegister,
UINT64 MaskRegister )

Clear events of !crwrite.

Parameters
VCpuThe virtual processor's state
ControlRegister
MaskRegister
Returns
VOID
610{
612}
#define FALSE
Definition BasicTypes.h:54
VOID ProtectedHvSetMovControlRegsVmexit(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set, PROTECTED_HV_RESOURCES_PASSING_OVERS PassOver, UINT64 ControlRegister, UINT64 MaskRegister)
Set vm-exit for mov to control registers.
Definition ProtectedHv.c:448
@ PASSING_OVER_MOV_TO_CONTROL_REGS_EVENTS
Definition Events.h:316

◆ ProtectedHvDisableMovDebugRegsExitingForDisablingDrCommands()

VOID ProtectedHvDisableMovDebugRegsExitingForDisablingDrCommands ( VIRTUAL_MACHINE_STATE * VCpu)

Clear events of !dr.

Parameters
VCpuThe virtual processor's state
Returns
VOID
596{
598}
VOID ProtectedHvSetMovDebugRegsVmexit(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set, PROTECTED_HV_RESOURCES_PASSING_OVERS PassOver)
Set vm-exit for mov to debug registers.
Definition ProtectedHv.c:351
@ PASSING_OVER_MOV_TO_HW_DEBUG_REGS_EVENTS
Definition Events.h:311

◆ ProtectedHvDisableRdtscExitingForDisablingTscCommands()

VOID ProtectedHvDisableRdtscExitingForDisablingTscCommands ( VIRTUAL_MACHINE_STATE * VCpu)

Clear events of !tsc.

Parameters
VCpuThe virtual processor's state
Returns
VOID
571{
573}
VOID ProtectedHvSetTscVmexit(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set, PROTECTED_HV_RESOURCES_PASSING_OVERS PassOver)
Set vm-exit for tsc instructions (rdtsc/rdtscp)
Definition ProtectedHv.c:286
@ PASSING_OVER_TSC_EVENTS
Definition Events.h:306

◆ ProtectedHvExternalInterruptExitingForDisablingInterruptCommands()

VOID ProtectedHvExternalInterruptExitingForDisablingInterruptCommands ( VIRTUAL_MACHINE_STATE * VCpu)

Clear events of !interrupt.

Returns
VOID
270{
272}
VOID ProtectedHvApplySetExternalInterruptExiting(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set, PROTECTED_HV_RESOURCES_PASSING_OVERS PassOver)
Set the External Interrupt Exiting.
Definition ProtectedHv.c:191
@ PASSING_OVER_INTERRUPT_EVENTS
Definition Events.h:301

◆ ProtectedHvRemoveUndefinedInstructionForDisablingSyscallSysretCommands()

VOID ProtectedHvRemoveUndefinedInstructionForDisablingSyscallSysretCommands ( VIRTUAL_MACHINE_STATE * VCpu)

Reset exception bitmap in VMCS because of clearing !exception commands.

Should be called in vmx-root

Parameters
VCpuThe virtual processor's state
Returns
VOID
161{
162 UINT32 ExceptionBitmap = 0;
163
164 //
165 // Read the current bitmap
166 //
167 ExceptionBitmap = HvReadExceptionBitmap();
168
169 //
170 // Unset exception bitmap for #UD
171 //
172 ExceptionBitmap &= ~(1 << EXCEPTION_VECTOR_UNDEFINED_OPCODE);
173
174 //
175 // Set the new value
176 //
178}
unsigned int UINT32
Definition BasicTypes.h:48
UINT32 HvReadExceptionBitmap()
Read exception bitmap in VMCS.
Definition Hv.c:587
VOID ProtectedHvChangeExceptionBitmapWithIntegrityCheck(VIRTUAL_MACHINE_STATE *VCpu, UINT32 CurrentMask, PROTECTED_HV_RESOURCES_PASSING_OVERS PassOver)
Add extra mask to this resource and write it.
Definition ProtectedHv.c:31
@ PASSING_OVER_UD_EXCEPTIONS_FOR_SYSCALL_SYSRET_HOOK
Definition Events.h:295
@ EXCEPTION_VECTOR_UNDEFINED_OPCODE
Definition Events.h:30

◆ ProtectedHvResetExceptionBitmapToClearEvents()

VOID ProtectedHvResetExceptionBitmapToClearEvents ( VIRTUAL_MACHINE_STATE * VCpu)

Reset exception bitmap in VMCS because of clearing !exception commands.

Should be called in vmx-root

Parameters
VCpuThe virtual processor's state
Returns
VOID
142{
143 UINT32 ExceptionBitmap = 0;
144
145 //
146 // Set the new value
147 //
149}
@ PASSING_OVER_EXCEPTION_EVENTS
Definition Events.h:296

◆ ProtectedHvSetExceptionBitmap()

VOID ProtectedHvSetExceptionBitmap ( VIRTUAL_MACHINE_STATE * VCpu,
UINT32 IdtIndex )

Set exception bitmap in VMCS.

Should be called in vmx-root

Parameters
VCpuThe virtual processor's state
IdtIndexInterrupt Descriptor Table index of exception
Returns
VOID
76{
77 UINT32 ExceptionBitmap = 0;
78
79 //
80 // Read the current bitmap
81 //
82 ExceptionBitmap = HvReadExceptionBitmap();
83
85 {
86 ExceptionBitmap = 0xffffffff;
87 }
88 else
89 {
90 ExceptionBitmap |= 1 << IdtIndex;
91 }
92
93 //
94 // Set the new value
95 //
97}
#define DEBUGGER_EVENT_EXCEPTIONS_ALL_FIRST_32_ENTRIES
Apply to all first 32 exceptions.
Definition Constants.h:629
@ PASSING_OVER_NONE
Definition Events.h:294

◆ ProtectedHvSetExternalInterruptExiting()

VOID ProtectedHvSetExternalInterruptExiting ( VIRTUAL_MACHINE_STATE * VCpu,
BOOLEAN Set )

Set the External Interrupt Exiting.

Parameters
VCpuThe virtual processor's state
SetSet or unset the External Interrupt Exiting
Returns
VOID

◆ ProtectedHvSetMov2Cr3Exiting()

VOID ProtectedHvSetMov2Cr3Exiting ( VIRTUAL_MACHINE_STATE * VCpu,
BOOLEAN Set )

Set MOV to CR3 Exiting.

Parameters
VCpuThe virtual processor's state
SetSet or unset the MOV to CR3 Exiting
Returns
VOID
623{
625}
VOID ProtectedHvSetMovToCr3Vmexit(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set, PROTECTED_HV_RESOURCES_PASSING_OVERS PassOver)
Set vm-exit for mov to cr3 register.
Definition ProtectedHv.c:484

◆ ProtectedHvSetMov2CrExiting()

VOID ProtectedHvSetMov2CrExiting ( BOOLEAN Set,
UINT64 ControlRegister,
UINT64 MaskRegister )

Set MOV to CR0/4 Exiting.

Parameters
Setor unset the MOV to CR0/4 Exiting
ControlRegister
MaskRegister
Returns
VOID
637{
638 ProtectedHvSetMovToCrVmexit(Set, ControlRegister, MaskRegister);
639}
VOID ProtectedHvSetMovToCrVmexit(BOOLEAN Set, UINT64 ControlRegister, UINT64 MaskRegister)
Set vm-exit for mov to cr0 / cr4 register.
Definition ProtectedHv.c:405

◆ ProtectedHvSetMovDebugRegsExiting()

VOID ProtectedHvSetMovDebugRegsExiting ( VIRTUAL_MACHINE_STATE * VCpu,
BOOLEAN Set )

Set MOV to HW Debug Regs Exiting.

Parameters
VCpuThe virtual processor's state
SetSet or unset the MOV to HW Debug Regs Exiting
Returns
VOID

◆ ProtectedHvSetRdtscExiting()

VOID ProtectedHvSetRdtscExiting ( VIRTUAL_MACHINE_STATE * VCpu,
BOOLEAN Set )

Set the RDTSC/P Exiting.

Parameters
VCpuThe virtual processor's state
SetSet or unset the RDTSC/P Exiting
Returns
VOID
559{
561}

◆ ProtectedHvUnsetExceptionBitmap()

VOID ProtectedHvUnsetExceptionBitmap ( VIRTUAL_MACHINE_STATE * VCpu,
UINT32 IdtIndex )

Unset exception bitmap in VMCS.

Should be called in vmx-root

Parameters
VCpuThe virtual processor's state
IdtIndexInterrupt Descriptor Table index of exception
Returns
VOID
109{
110 UINT32 ExceptionBitmap = 0;
111
112 //
113 // Read the current bitmap
114 //
115 ExceptionBitmap = HvReadExceptionBitmap();
116
118 {
119 ExceptionBitmap = 0x0;
120 }
121 else
122 {
123 ExceptionBitmap &= ~(1 << IdtIndex);
124 }
125
126 //
127 // Set the new value
128 //
130}