HyperDbg Debugger
Loading...
Searching...
No Matches
Vmcall.c File Reference

The main VMCALL and Hypercall handler. More...

#include "pch.h"

Functions

_Use_decl_annotations_ NTSTATUS VmxHypervVmcallHandler (VIRTUAL_MACHINE_STATE *VCpu, PGUEST_REGS GuestRegs)
 Handle vm-exits of VMCALLs.
_Use_decl_annotations_ NTSTATUS VmxHandleVmcallVmExit (VIRTUAL_MACHINE_STATE *VCpu)
 Handle vm-exits of VMCALLs.
NTSTATUS VmxVmcallDirectVmcallHandler (VIRTUAL_MACHINE_STATE *VCpu, UINT64 VmcallNumber, DIRECT_VMCALL_PARAMETERS *DirectVmcallOptions)
 Direct Vmcall Handler.
_Use_decl_annotations_ NTSTATUS VmxVmcallHandler (VIRTUAL_MACHINE_STATE *VCpu, UINT64 VmcallNumber, UINT64 OptionalParam1, UINT64 OptionalParam2, UINT64 OptionalParam3)
 Main Vmcall Handler.
NTSTATUS VmcallTest (_In_ UINT64 Param1, _In_ UINT64 Param2, _In_ UINT64 Param3)
 Test Vmcall (VMCALL_TEST).

Detailed Description

The main VMCALL and Hypercall handler.

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

Function Documentation

◆ VmcallTest()

NTSTATUS VmcallTest ( _In_ UINT64 Param1,
_In_ UINT64 Param2,
_In_ UINT64 Param3 )

Test Vmcall (VMCALL_TEST).

Test function which shows a message to test a successful VMCALL.

Parameters
Param1
Param2
Param3
Returns
NTSTATUS

Test Vmcall (VMCALL_TEST).

Parameters
Param1
Param2
Param3
Returns
NTSTATUS
634{
635 LogDebugInfo("VmcallTest called with @Param1 = 0x%llx , @Param2 = 0x%llx , @Param3 = 0x%llx",
636 Param1,
637 Param2,
638 Param3);
639
640 //
641 // Send one byte buffer to show that Hypervisor
642 // is successfully loaded
643 //
645 "$",
646 sizeof(CHAR),
647 TRUE);
648
649 return STATUS_SUCCESS;
650}
#define TRUE
Definition BasicTypes.h:114
char CHAR
Definition BasicTypes.h:33
#define OPERATION_HYPERVISOR_DRIVER_IS_SUCCESSFULLY_LOADED
Definition Constants.h:387
IMPORT_EXPORT_HYPERLOG BOOLEAN LogCallbackSendBuffer(_In_ UINT32 OperationCode, _In_reads_bytes_(BufferLength) PVOID Buffer, _In_ UINT32 BufferLength, _In_ BOOLEAN Priority)
routines callback for sending buffer
Definition HyperLogCallback.c:123
#define LogDebugInfo(format,...)
Log, initialize boot information and debug information.
Definition HyperDbgHyperLogIntrinsics.h:155

◆ VmxHandleVmcallVmExit()

_Use_decl_annotations_ NTSTATUS VmxHandleVmcallVmExit ( VIRTUAL_MACHINE_STATE * VCpu)

Handle vm-exits of VMCALLs.

Parameters
VCpuThe virtual processor's state
Returns
NTSTATUS
75{
76 BOOLEAN IsHyperDbgVmcall = FALSE;
77 GUEST_REGS * GuestRegs = VCpu->Regs;
78
79 IsHyperDbgVmcall = (GuestRegs->r10 == 0x48564653 && GuestRegs->r11 == 0x564d43414c4c && GuestRegs->r12 == 0x4e4f485950455256);
80 //
81 // Check if it's our routines that request the VMCALL, or it relates to the Hyper-V
82 //
83 if (IsHyperDbgVmcall)
84 {
85 GuestRegs->rax = VmxVmcallHandler(VCpu,
86 GuestRegs->rcx,
87 GuestRegs->rdx,
88 GuestRegs->r8,
89 GuestRegs->r9);
90 }
91 else
92 {
93 return VmxHypervVmcallHandler(VCpu, GuestRegs);
94 }
95
96 return STATUS_SUCCESS;
97}
_Use_decl_annotations_ NTSTATUS VmxVmcallHandler(VIRTUAL_MACHINE_STATE *VCpu, UINT64 VmcallNumber, UINT64 OptionalParam1, UINT64 OptionalParam2, UINT64 OptionalParam3)
Main Vmcall Handler.
Definition Vmcall.c:132
_Use_decl_annotations_ NTSTATUS VmxHypervVmcallHandler(VIRTUAL_MACHINE_STATE *VCpu, PGUEST_REGS GuestRegs)
Handle vm-exits of VMCALLs.
Definition Vmcall.c:24
UCHAR BOOLEAN
Definition BasicTypes.h:35
#define FALSE
Definition BasicTypes.h:113
GUEST_REGS * Regs
Definition State.h:326
Definition BasicTypes.h:136
UINT64 rax
Definition BasicTypes.h:141
UINT64 r12
Definition BasicTypes.h:153
UINT64 r9
Definition BasicTypes.h:150
UINT64 r8
Definition BasicTypes.h:149
UINT64 r10
Definition BasicTypes.h:151
UINT64 rcx
Definition BasicTypes.h:142
UINT64 r11
Definition BasicTypes.h:152
UINT64 rdx
Definition BasicTypes.h:143

◆ VmxHypervVmcallHandler()

_Use_decl_annotations_ NTSTATUS VmxHypervVmcallHandler ( VIRTUAL_MACHINE_STATE * VCpu,
PGUEST_REGS GuestRegs )

Handle vm-exits of VMCALLs.

Parameters
VCpuThe virtual processor's state
GuestRegs
Returns
NTSTATUS
25{
26 UINT64 GuestRsp = NULL64_ZERO;
27 HYPERCALL_INPUT_VALUE InputValue = {.Flags = GuestRegs->rcx};
28
29 switch (InputValue.Fields.CallCode)
30 {
36
38 break;
39
42
44 break;
45 }
46
47 //
48 // Save the guest rsp as it will be modified during the Hyper-V's
49 // VMCALL process
50 //
51 GuestRsp = GuestRegs->rsp;
52
53 //
54 // Let the top-level hypervisor to manage it
55 //
56 AsmHypervVmcall((UINT64)GuestRegs);
57
58 //
59 // Restore the guest's RSP
60 //
61 GuestRegs->rsp = GuestRsp;
62
63 return STATUS_SUCCESS;
64}
VOID AsmHypervVmcall(UINT64 GuestRegisters)
Hyper-v vmcall handler.
UCHAR EptInveptSingleContext(_In_ UINT64 EptPointer)
Invalidates a single context in ept cache table.
Definition Invept.c:40
@ HvSwitchVirtualAddressSpace
Definition Vmx.h:98
@ HvCallFlushVirtualAddressListEx
Definition Vmx.h:114
@ HvFlushVirtualAddressList
Definition Vmx.h:100
@ HvFlushVirtualAddressSpace
Definition Vmx.h:99
@ HvCallFlushVirtualAddressSpaceEx
Definition Vmx.h:113
@ HvCallFlushGuestPhysicalAddressList
Definition Vmx.h:205
@ HvCallFlushGuestPhysicalAddressSpace
Definition Vmx.h:204
union _HYPERCALL_INPUT_VALUE HYPERCALL_INPUT_VALUE
Hypercalls for Hyper-V.
VOID VpidInvvpidAllContext()
INVVPID All Contexts.
Definition Vpid.c:80
#define NULL64_ZERO
Definition BasicTypes.h:111
EPT_POINTER EptPointer
Definition State.h:363
UINT64 rsp
Definition BasicTypes.h:145
UINT64 CallCode
Definition Vmx.h:79
struct _HYPERCALL_INPUT_VALUE::@010010145126055261317211351336342156317071247225 Fields

◆ VmxVmcallDirectVmcallHandler()

NTSTATUS VmxVmcallDirectVmcallHandler ( VIRTUAL_MACHINE_STATE * VCpu,
UINT64 VmcallNumber,
DIRECT_VMCALL_PARAMETERS * DirectVmcallOptions )

Direct Vmcall Handler.

Parameters
VCpuThe virtual processor's state
VmcallNumberThe number of the VMCALL
DirectVmcallOptions
Returns
NTSTATUS
112{
113 return VmxVmcallHandler(VCpu,
114 VmcallNumber,
115 DirectVmcallOptions->OptionalParam1,
116 DirectVmcallOptions->OptionalParam2,
117 DirectVmcallOptions->OptionalParam3);
118}
UINT64 OptionalParam2
Definition DataTypes.h:328
UINT64 OptionalParam3
Definition DataTypes.h:329
UINT64 OptionalParam1
Definition DataTypes.h:327

◆ VmxVmcallHandler()

_Use_decl_annotations_ NTSTATUS VmxVmcallHandler ( VIRTUAL_MACHINE_STATE * VCpu,
UINT64 VmcallNumber,
UINT64 OptionalParam1,
UINT64 OptionalParam2,
UINT64 OptionalParam3 )

Main Vmcall Handler.

Parameters
VCpuThe virtual processor's state
VmcallNumber
OptionalParam1
OptionalParam2
OptionalParam3
Returns
NTSTATUS
137{
138 NTSTATUS VmcallStatus = STATUS_UNSUCCESSFUL;
139
140 //
141 // Check for top-level driver's VMCALLs
142 //
144 {
145 if (VmmCallbackVmcallHandler(VCpu->CoreId, VmcallNumber, OptionalParam1, OptionalParam2, OptionalParam3))
146 {
147 return STATUS_SUCCESS;
148 }
149 else
150 {
151 return STATUS_UNSUCCESSFUL;
152 }
153 }
154
155 //
156 // Only 32bit of Vmcall is valid, this way we can use the upper 32 bit of the Vmcall
157 //
158 switch (VmcallNumber)
159 {
160 case VMCALL_TEST:
161 {
162 VmcallStatus = VmcallTest(OptionalParam1, OptionalParam2, OptionalParam3);
163 break;
164 }
165 case VMCALL_VMXOFF:
166 {
167 VmxPerformVmxoff(VCpu);
168 VmcallStatus = STATUS_SUCCESS;
169
170 break;
171 }
173 {
174 BOOLEAN HookResult = FALSE;
175 CR3_TYPE ProcCr3 = {.Flags = OptionalParam3};
176
178 (PVOID)OptionalParam1 /* hook details */,
179 ProcCr3 /* Process cr3 */,
180 (UINT32)OptionalParam2 /* PageHookMask */);
181
182 VmcallStatus = (HookResult == TRUE) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
183
184 break;
185 }
187 {
188 EptInveptSingleContext(OptionalParam1);
189 VmcallStatus = STATUS_SUCCESS;
190 break;
191 }
193 {
195 VmcallStatus = STATUS_SUCCESS;
196 break;
197 }
199 {
201 VmcallStatus = STATUS_SUCCESS;
202 break;
203 }
205 {
206 if (EptHookRestoreSingleHookToOriginalEntry(VCpu, OptionalParam1, OptionalParam2))
207 VmcallStatus = STATUS_SUCCESS;
208 else
209 VmcallStatus = STATUS_UNSUCCESSFUL;
210
211 break;
212 }
214 {
216 VmcallStatus = STATUS_SUCCESS;
217 break;
218 }
220 {
222 VmcallStatus = STATUS_SUCCESS;
223 break;
224 }
226 {
227 MsrHandlePerformMsrBitmapReadChange(VCpu, (UINT32)OptionalParam1);
228 VmcallStatus = STATUS_SUCCESS;
229 break;
230 }
232 {
233 MsrHandlePerformMsrBitmapWriteChange(VCpu, (UINT32)OptionalParam1);
234 VmcallStatus = STATUS_SUCCESS;
235 break;
236 }
238 {
239 HvSetRdtscExiting(VCpu, TRUE);
240 VmcallStatus = STATUS_SUCCESS;
241 break;
242 }
244 {
246 VmcallStatus = STATUS_SUCCESS;
247 break;
248 }
250 {
251 HvSetExceptionBitmap(VCpu, (UINT32)OptionalParam1);
252 VmcallStatus = STATUS_SUCCESS;
253 break;
254 }
256 {
258 VmcallStatus = STATUS_SUCCESS;
259 break;
260 }
262 {
264 VmcallStatus = STATUS_SUCCESS;
265 break;
266 }
268 {
269 IoHandlePerformIoBitmapChange(VCpu, (UINT32)OptionalParam1);
270 VmcallStatus = STATUS_SUCCESS;
271 break;
272 }
274 {
275 BOOLEAN HookResult = FALSE;
276 CR3_TYPE ProcCr3 = {.Flags = OptionalParam2};
277
278 HookResult = EptHookPerformPageHook(VCpu,
279 (PVOID)OptionalParam1, /* TargetAddress */
280 ProcCr3); /* process cr3 */
281
282 VmcallStatus = (HookResult == TRUE) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
283
284 break;
285 }
287 {
289 VmcallStatus = STATUS_SUCCESS;
290 break;
291 }
293 {
295 VmcallStatus = STATUS_SUCCESS;
296 break;
297
298 break;
299 }
301 {
303 VmcallStatus = STATUS_SUCCESS;
304 break;
305 }
307 {
309 VmcallStatus = STATUS_SUCCESS;
310 break;
311 }
313 {
315 VmcallStatus = STATUS_SUCCESS;
316 break;
317 }
319 {
321 VmcallStatus = STATUS_SUCCESS;
322 break;
323 }
325 {
327 VmcallStatus = STATUS_SUCCESS;
328 break;
329 }
331 {
333 VmcallStatus = STATUS_SUCCESS;
334 break;
335 }
337 {
338 HvSetMovControlRegsExiting(TRUE, OptionalParam1, OptionalParam2);
339 VmcallStatus = STATUS_SUCCESS;
340 break;
341 }
343 {
344 HvSetMovControlRegsExiting(FALSE, OptionalParam1, OptionalParam2);
345 VmcallStatus = STATUS_SUCCESS;
346 break;
347 }
349 {
351 VmcallStatus = STATUS_SUCCESS;
352 break;
353 }
355 {
357 VmcallStatus = STATUS_SUCCESS;
358 break;
359 }
361 {
362 HvUnsetExceptionBitmap(VCpu, (UINT32)OptionalParam1);
363 VmcallStatus = STATUS_SUCCESS;
364 break;
365 }
367 {
369 VmcallStatus = STATUS_SUCCESS;
370 break;
371 }
373 {
375 VmcallStatus = STATUS_SUCCESS;
376 break;
377 }
379 {
381 VmcallStatus = STATUS_SUCCESS;
382 break;
383 }
385 {
387 VmcallStatus = STATUS_SUCCESS;
388 break;
389 }
391 {
393 VmcallStatus = STATUS_SUCCESS;
394 break;
395 }
397 {
399 VmcallStatus = STATUS_SUCCESS;
400 break;
401 }
403 {
405 VmcallStatus = STATUS_SUCCESS;
406 break;
407 }
409 {
411 VmcallStatus = STATUS_SUCCESS;
412 break;
413 }
415 {
416 ProtectedHvDisableMovControlRegsExitingForDisablingCrCommands(VCpu, OptionalParam1, OptionalParam2);
417 VmcallStatus = STATUS_SUCCESS;
418 break;
419 }
421 {
422 if (DirtyLoggingEnable(VCpu))
423 {
424 VmcallStatus = STATUS_SUCCESS;
425 }
426 else
427 {
428 VmcallStatus = STATUS_UNSUCCESSFUL;
429 }
430
431 break;
432 }
434 {
436
437 VmcallStatus = STATUS_SUCCESS;
438 break;
439 }
441 {
443
444 VmcallStatus = STATUS_SUCCESS;
445 break;
446 }
448 {
450
451 VmcallStatus = STATUS_SUCCESS;
452 break;
453 }
455 {
456 ModeBasedExecHookEnableOrDisable(VCpu, (UINT32)OptionalParam1);
457
458 VmcallStatus = STATUS_SUCCESS;
459 break;
460 }
462 {
463 if (ReadPhysicalMemoryUsingMapIoSpace((PVOID)OptionalParam1, (PVOID)OptionalParam2, (SIZE_T)OptionalParam3))
464 {
465 VmcallStatus = STATUS_SUCCESS;
466 }
467 else
468 {
469 VmcallStatus = STATUS_UNSUCCESSFUL;
470 }
471
472 break;
473 }
475 {
476 if (WritePhysicalMemoryUsingMapIoSpace((PVOID)OptionalParam1, (PVOID)OptionalParam2, (SIZE_T)OptionalParam3))
477 {
478 VmcallStatus = STATUS_SUCCESS;
479 }
480 else
481 {
482 VmcallStatus = STATUS_UNSUCCESSFUL;
483 }
484
485 break;
486 }
488 {
489 //
490 // Check whether the physical memory is valid or not
491 //
492 if (!CheckAddressPhysical(OptionalParam1))
493 {
494 VmcallStatus = STATUS_SUCCESS;
495 break;
496 }
497
498 //
499 // Perform the read operation
500 //
501 if (MemoryMapperReadMemorySafeByPhysicalAddress((UINT64)OptionalParam1, (UINT64)OptionalParam2, (SIZE_T)OptionalParam3))
502 {
503 VmcallStatus = STATUS_SUCCESS;
504 }
505 else
506 {
507 VmcallStatus = STATUS_UNSUCCESSFUL;
508 }
509
510 break;
511 }
513 {
514 //
515 // Check whether the physical memory is valid or not
516 //
517 if (!CheckAddressPhysical(OptionalParam1))
518 {
519 VmcallStatus = STATUS_SUCCESS;
520 break;
521 }
522
523 //
524 // Perform the write operation
525 //
526 if (MemoryMapperWriteMemorySafeByPhysicalAddress((UINT64)OptionalParam1, (UINT64)OptionalParam2, (SIZE_T)OptionalParam3))
527 {
528 VmcallStatus = STATUS_SUCCESS;
529 }
530 else
531 {
532 VmcallStatus = STATUS_UNSUCCESSFUL;
533 }
534
535 break;
536 }
538 {
539 //
540 // Perform getting DEBUGCTL from VMCS
541 //
542 HvGetAndStoreDebugctl((UINT64 *)OptionalParam1);
543
544 VmcallStatus = STATUS_SUCCESS;
545 break;
546 }
548 {
549 //
550 // Perform setting DEBUGCTL from VMCS
551 //
552 HvSetDebugctl(OptionalParam1);
553
554 VmcallStatus = STATUS_SUCCESS;
555
556 break;
557 }
559 {
560 //
561 // Perform setting MSR_LEGACY_LBR_SELECT
562 //
563 HvSetLbrSelect(OptionalParam1);
564 VmcallStatus = STATUS_SUCCESS;
565 break;
566 }
568 {
569 //
570 // Perform getting guest IA32_LBR_CTL from VMCS
571 //
572 HvGetAndStoreGuestIa32LbrCtl((UINT64 *)OptionalParam1);
573
574 VmcallStatus = STATUS_SUCCESS;
575 break;
576 }
578 {
579 //
580 // Perform setting guest IA32_LBR_CTL on VMCS
581 //
582 HvSetGuestIa32LbrCtl(OptionalParam1);
583
584 VmcallStatus = STATUS_SUCCESS;
585 break;
586 }
588 {
590 VmcallStatus = STATUS_SUCCESS;
591 break;
592 }
594 {
596 VmcallStatus = STATUS_SUCCESS;
597 break;
598 }
600 {
602 VmcallStatus = STATUS_SUCCESS;
603 break;
604 }
606 {
608 VmcallStatus = STATUS_SUCCESS;
609 break;
610 }
611 default:
612 {
613 LogError("Err, unsupported VMCALL (%llx)", VmcallNumber);
614 VmcallStatus = STATUS_UNSUCCESSFUL;
615 break;
616 }
617 }
618
619 return VmcallStatus;
620}
BOOLEAN VmmCallbackVmcallHandler(UINT32 CoreId, UINT64 VmcallNumber, UINT64 OptionalParam1, UINT64 OptionalParam2, UINT64 OptionalParam3)
routine callback to handle external VMCALLs
Definition Callback.c:72
VOID DirtyLoggingDisable(VIRTUAL_MACHINE_STATE *VCpu)
Disables the dirty logging mechanism in VMX-root mode.
Definition DirtyLogging.c:156
BOOLEAN DirtyLoggingEnable(VIRTUAL_MACHINE_STATE *VCpu)
Enables the dirty logging mechanism in VMX-root mode.
Definition DirtyLogging.c:105
VOID SyscallHookConfigureEFER(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN EnableEFERSyscallHook)
This function enables or disables EFER syscall hoo.
Definition EferHook.c:31
BOOLEAN EptHookRestoreSingleHookToOriginalEntry(VIRTUAL_MACHINE_STATE *VCpu, SIZE_T PhysicalAddress, UINT64 OriginalEntry)
Remove and Invalidate Hook in TLB (Hidden Detours and if counter of hidden breakpoint is zero).
Definition EptHook.c:671
VOID EptHookRestoreAllHooksToOriginalEntry(VIRTUAL_MACHINE_STATE *VCpu)
Remove and Invalidate Hook in TLB.
Definition EptHook.c:719
BOOLEAN EptHookPerformPageHook(VIRTUAL_MACHINE_STATE *VCpu, PVOID TargetAddress, CR3_TYPE ProcessCr3)
The main function that performs EPT page hook with hidden breakpoint.
Definition EptHook.c:480
BOOLEAN EptHookPerformPageHookMonitorAndInlineHook(VIRTUAL_MACHINE_STATE *VCpu, PVOID HookingDetails, CR3_TYPE ProcessCr3, UINT32 PageHookMask)
The main function that performs EPT page hook with hidden detours and monitor.
Definition EptHook.c:995
VOID ExecTrapRestoreToNormalEptp(VIRTUAL_MACHINE_STATE *VCpu)
restore to normal EPTP
Definition ExecTrap.c:480
VOID ExecTrapChangeToUserDisabledMbecEptp(VIRTUAL_MACHINE_STATE *VCpu)
change to user-disabled MBEC EPTP
Definition ExecTrap.c:500
VOID HvSetPmcVmexit(BOOLEAN Set)
Set vm-exit for rdpmc instructions.
Definition Hv.c:553
VOID HvGetAndStoreDebugctl(UINT64 *StoreDebugctl)
Get and store the guest state of IA32_DEBUGCTL.
Definition Hv.c:1561
VOID HvSetSaveDebugControls(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set)
Set SAVE DEBUG CONTROLS on Vm-exit controls.
Definition Hv.c:446
VOID HvSetNmiExiting(BOOLEAN Set)
Set the NMI Exiting.
Definition Hv.c:1000
VOID HvUnsetExceptionBitmap(VIRTUAL_MACHINE_STATE *VCpu, UINT32 IdtIndex)
Unset exception bitmap in VMCS.
Definition Hv.c:1086
VOID HvSetGuestIa32LbrCtl(UINT64 Value)
Set the guest state of IA32_LBR_CTL.
Definition Hv.c:1620
VOID HvSetMovDebugRegsExiting(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set)
Set or unset the Mov to Debug Registers Exiting.
Definition Hv.c:1167
VOID HvSetDebugctl(UINT64 Value)
Set the guest state of IA32_DEBUGCTL.
Definition Hv.c:1607
VOID HvSetExternalInterruptExiting(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set)
Set the External Interrupt Exiting.
Definition Hv.c:1102
VOID HvSetClearGuestIa32LbrCtl(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set)
Set SAVE GUEST IA32_LBR_CTL on Vm-exit controls.
Definition Hv.c:459
VOID HvGetAndStoreGuestIa32LbrCtl(UINT64 *StoreGuestIa32Lbr)
Get and store the guest state of IA32_LBR_CTL.
Definition Hv.c:1585
VOID HvSetLbrSelect(UINT64 FilterOptions)
Set LBR selector.
Definition Hv.c:1633
VOID HvSetMovControlRegsExiting(BOOLEAN Set, UINT64 ControlRegister, UINT64 MaskRegister)
Set vm-exit for mov-to-cr0/4.
Definition Hv.c:587
VOID HvSetRdtscExiting(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set)
Set the RDTSC/P Exiting.
Definition Hv.c:1154
VOID HvSetLoadDebugControls(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set)
Set LOAD DEBUG CONTROLS on Vm-entry controls.
Definition Hv.c:399
VOID HvSetMovToCr3Vmexit(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set)
Set vm-exit for mov-to-cr3.
Definition Hv.c:602
VOID HvSetLoadGuestIa32LbrCtl(VIRTUAL_MACHINE_STATE *VCpu, BOOLEAN Set)
Set LOAD GUEST IA32_LBR_CTL on Vm-entry controls.
Definition Hv.c:412
VOID HvSetExceptionBitmap(VIRTUAL_MACHINE_STATE *VCpu, UINT32 IdtIndex)
Set exception bitmap in VMCS.
Definition Hv.c:1069
UCHAR EptInveptAllContexts()
Invalidates all contexts in EPT cache table.
Definition Invept.c:54
VOID IoHandlePerformIoBitmapReset(VIRTUAL_MACHINE_STATE *VCpu)
Reset I/O Bitmap.
Definition IoHandler.c:268
VOID IoHandlePerformIoBitmapChange(VIRTUAL_MACHINE_STATE *VCpu, UINT32 Port)
Change I/O Bitmap.
Definition IoHandler.c:241
VOID ModeBasedExecHookEnableOrDisable(VIRTUAL_MACHINE_STATE *VCpu, UINT32 State)
Enable/disable MBEC.
Definition ModeBasedExecHook.c:189
VOID MsrHandlePerformMsrBitmapWriteChange(VIRTUAL_MACHINE_STATE *VCpu, UINT32 MsrMask)
Change MSR Bitmap for write.
Definition MsrHandlers.c:565
VOID MsrHandlePerformMsrBitmapWriteReset(VIRTUAL_MACHINE_STATE *VCpu)
Reset MSR Bitmap for write.
Definition MsrHandlers.c:596
VOID MsrHandlePerformMsrBitmapReadChange(VIRTUAL_MACHINE_STATE *VCpu, UINT32 MsrMask)
Change MSR Bitmap for read.
Definition MsrHandlers.c:518
VOID MsrHandlePerformMsrBitmapReadReset(VIRTUAL_MACHINE_STATE *VCpu)
Reset MSR Bitmap for read.
Definition MsrHandlers.c:549
VOID ProtectedHvDisableRdtscExitingForDisablingTscCommands(VIRTUAL_MACHINE_STATE *VCpu)
Clear events of !tsc.
Definition ProtectedHv.c:683
VOID ProtectedHvResetExceptionBitmapToClearEvents(VIRTUAL_MACHINE_STATE *VCpu)
Reset exception bitmap in VMCS because of clearing !exception commands.
Definition ProtectedHv.c:142
VOID ProtectedHvExternalInterruptExitingForDisablingInterruptCommands(VIRTUAL_MACHINE_STATE *VCpu)
Clear events of !interrupt.
Definition ProtectedHv.c:270
VOID ProtectedHvDisableMovControlRegsExitingForDisablingCrCommands(VIRTUAL_MACHINE_STATE *VCpu, UINT64 ControlRegister, UINT64 MaskRegister)
Clear events of !crwrite.
Definition ProtectedHv.c:722
VOID ProtectedHvDisableMovDebugRegsExitingForDisablingDrCommands(VIRTUAL_MACHINE_STATE *VCpu)
Clear events of !dr.
Definition ProtectedHv.c:708
NTSTATUS VmcallTest(_In_ UINT64 Param1, _In_ UINT64 Param2, _In_ UINT64 Param3)
Test Vmcall (VMCALL_TEST).
Definition Vmcall.c:631
#define VMCALL_SET_VM_ENTRY_LOAD_DEBUG_CONTROLS
VMCALL to set VM-entry LOAD DEBUG CONTROLS.
Definition Vmcall.h:199
#define VMCALL_READ_PHYSICAL_MEMORY
VMCALL to read physical memory.
Definition Vmcall.h:315
#define VMCALL_UNSET_VM_ENTRY_LOAD_DEBUG_CONTROLS
VMCALL to unset VM-entry LOAD DEBUG CONTROLS.
Definition Vmcall.h:207
#define VMCALL_SET_GUEST_IA32_LBR_CTL
VMCALL to set the guest state of IA32_LBR_CTL on VMCS.
Definition Vmcall.h:351
#define VMCALL_WRITE_PHYSICAL_MEM_BYPASS_CACHING_POLICIES
VMCALL to bypass caching policies to write MMIO.
Definition Vmcall.h:309
#define VMCALL_DISABLE_MOV_TO_DEBUG_REGS_EXITING
VMCALL to disable mov to debug registers exiting.
Definition Vmcall.h:148
#define VMCALL_SET_MSR_LBR_SELECT
VMCALL to set MSR_LEGACY_LBR_SELECT using WRMSR.
Definition Vmcall.h:339
#define VMCALL_INVEPT_ALL_CONTEXTS
VMCALL to invalidate EPT (All Contexts).
Definition Vmcall.h:40
#define VMCALL_SET_RDPMC_EXITING
VMCALL to enable rdpmc exiting in primary cpu-based controls.
Definition Vmcall.h:94
#define VMCALL_SET_CLEAR_GUEST_IA32_LBR_CTL
VMCALL to set CLEAR GUEST IA32_LBR_CTL on VM-exit controls.
Definition Vmcall.h:369
#define VMCALL_SET_VM_EXIT_SAVE_DEBUG_CONTROLS
VMCALL to set VM-exit SAVE DEBUG CONTROLS.
Definition Vmcall.h:215
#define VMCALL_RESET_MSR_BITMAP_WRITE
VMCALL to reset MSR Bitmap Write.
Definition Vmcall.h:160
#define VMCALL_DISABLE_DIRTY_LOGGING_MECHANISM
VMCALL to disable dirty logging (PML) mechanism.
Definition Vmcall.h:279
#define VMCALL_CHANGE_PAGE_ATTRIB
VMCALL to Hook Change the attribute bits of the EPT Table.
Definition Vmcall.h:34
#define VMCALL_RESET_EXCEPTION_BITMAP_ONLY_ON_CLEARING_EXCEPTION_EVENTS
VMCALL to reset exception bitmap on VMCS.
Definition Vmcall.h:167
#define VMCALL_GET_VMCS_DEBUGCTL
VMCALL to get IA32_DEBUGCTL on VMCS.
Definition Vmcall.h:327
#define VMCALL_RESET_MSR_BITMAP_READ
VMCALL to reset MSR Bitmap Read.
Definition Vmcall.h:154
#define VMCALL_INVEPT_SINGLE_CONTEXT
VMCALL to invalidate EPT (A Single Context).
Definition Vmcall.h:46
#define VMCALL_UNSET_EXCEPTION_BITMAP
VMCALL to unset exception bitmap on VMCS.
Definition Vmcall.h:191
#define VMCALL_SET_VM_EXIT_ON_NMIS
VMCALL to cause vm-exit on NMIs.
Definition Vmcall.h:229
#define VMCALL_VMXOFF
VMCALL to Call VMXOFF to turn off the hypervisor.
Definition Vmcall.h:28
#define VMCALL_SET_VMCS_DEBUGCTL
VMCALL to set IA32_DEBUGCTL on VMCS.
Definition Vmcall.h:333
#define VMCALL_CHANGE_MSR_BITMAP_WRITE
VMCALL to change MSR Bitmap Write.
Definition Vmcall.h:82
#define VMCALL_ENABLE_DIRTY_LOGGING_MECHANISM
VMCALL to enable dirty logging (PML) mechanism.
Definition Vmcall.h:273
#define VMCALL_TEST
VMCALL to test hypervisor.
Definition Vmcall.h:22
#define VMCALL_UNSET_VM_ENTRY_LOAD_GUEST_IA32_LBR_CTL
VMCALL to unset LOAD GUEST IA32_LBR_CTL on VM-entry controls.
Definition Vmcall.h:363
#define VMCALL_ENABLE_MOV_TO_CR3_EXITING
VMCALL to enable cr3 exiting.
Definition Vmcall.h:179
#define VMCALL_DISABLE_MOV_TO_CONTROL_REGS_EXITING
VMCALL to disable mov to CR exiting.
Definition Vmcall.h:260
#define VMCALL_SET_RDTSC_EXITING
VMCALL to enable rdtsc/rdtscp exiting in primary cpu-based controls.
Definition Vmcall.h:88
#define VMCALL_CHANGE_IO_BITMAP
VMCALL to change I/O Bitmaps (A & B).
Definition Vmcall.h:118
#define VMCALL_UNSET_VM_EXIT_ON_NMIS
VMCALL to not cause vm-exit on NMIs.
Definition Vmcall.h:235
#define VMCALL_GET_GUEST_IA32_LBR_CTL
VMCALL to get the guest state of IA32_LBR_CTL on VMCS.
Definition Vmcall.h:345
#define VMCALL_SET_EXCEPTION_BITMAP
VMCALL to set exception bitmap on VMCS.
Definition Vmcall.h:100
#define VMCALL_UNHOOK_ALL_PAGES
VMCALL to remove a all physical addresses from hook list.
Definition Vmcall.h:52
#define VMCALL_SET_HIDDEN_CC_BREAKPOINT
VMCALL to put hidden breakpoints (using EPT).
Definition Vmcall.h:124
#define VMCALL_READ_PHYSICAL_MEM_BYPASS_CACHING_POLICIES
VMCALL to bypass caching policies to read MMIO.
Definition Vmcall.h:303
#define VMCALL_RESTORE_TO_NORMAL_EPTP
VMCALL to restore EPTP to normal EPTP.
Definition Vmcall.h:291
#define VMCALL_DISABLE_OR_ENABLE_MBEC
VMCALL to enable/disable MBEC.
Definition Vmcall.h:297
#define VMCALL_ENABLE_SYSCALL_HOOK_EFER
VMCALL to enable syscall hook using EFER SCE bit.
Definition Vmcall.h:64
#define VMCALL_UNSET_VM_EXIT_SAVE_DEBUG_CONTROLS
VMCALL to unset VM-exit SAVE DEBUG CONTROLS.
Definition Vmcall.h:223
#define VMCALL_ENABLE_MOV_TO_DEBUG_REGS_EXITING
VMCALL to enable mov to debug registers exiting.
Definition Vmcall.h:106
#define VMCALL_UNSET_RDTSC_EXITING
VMCALL to disable rdtsc/rdtscp exiting in primary cpu-based controls.
Definition Vmcall.h:130
#define VMCALL_UNSET_RDPMC_EXITING
VMCALL to disable rdpmc exiting in primary cpu-based controls.
Definition Vmcall.h:142
#define VMCALL_ENABLE_EXTERNAL_INTERRUPT_EXITING
VMCALL to enable external interrupt exiting.
Definition Vmcall.h:112
#define VMCALL_DISABLE_SYSCALL_HOOK_EFER
VMCALL to disable syscall hook using EFER SCE bit.
Definition Vmcall.h:70
#define VMCALL_CHANGE_TO_MBEC_SUPPORTED_EPTP
VMCALL to change EPTP to an MBEC-supported EPTP.
Definition Vmcall.h:285
#define VMCALL_DISABLE_MOV_TO_CR_EXITING_ONLY_FOR_CR_EVENTS
VMCALL to clear mov 2 cr exiting bit ONLY in the case of disabling the events for !...
Definition Vmcall.h:267
#define VMCALL_ENABLE_MOV_TO_CONTROL_REGS_EXITING
VMCALL to enable mov to CR exiting.
Definition Vmcall.h:254
#define VMCALL_DISABLE_RDTSC_EXITING_ONLY_FOR_TSC_EVENTS
VMCALL to clear rdtsc exiting bit ONLY in the case of disabling the events for !tsc command.
Definition Vmcall.h:242
#define VMCALL_SET_VM_ENTRY_LOAD_GUEST_IA32_LBR_CTL
VMCALL to set LOAD GUEST IA32_LBR_CTL on VM-entry controls.
Definition Vmcall.h:357
#define VMCALL_DISABLE_EXTERNAL_INTERRUPT_EXITING_ONLY_TO_CLEAR_INTERRUPT_COMMANDS
VMCALL to disable external interrupt exiting only to clear !interrupt commands.
Definition Vmcall.h:136
#define VMCALL_RESET_IO_BITMAP
VMCALL to reset I/O Bitmaps (A & B).
Definition Vmcall.h:173
#define VMCALL_UNHOOK_SINGLE_PAGE
VMCALL to restore a single EPT entry and invalidate EPT cache.
Definition Vmcall.h:58
#define VMCALL_WRITE_PHYSICAL_MEMORY
VMCALL to write physical memory.
Definition Vmcall.h:321
#define VMCALL_DISABLE_MOV_TO_HW_DR_EXITING_ONLY_FOR_DR_EVENTS
VMCALL to clear mov 2 hw dr exiting bit ONLY in the case of disabling the events for !...
Definition Vmcall.h:249
#define VMCALL_UNSET_CLEAR_GUEST_IA32_LBR_CTL
VMCALL to unset CLEAR GUEST IA32_LBR_CTL on VM-exit controls.
Definition Vmcall.h:375
#define VMCALL_DISABLE_MOV_TO_CR3_EXITING
VMCALL to disable cr3 exiting.
Definition Vmcall.h:185
#define VMCALL_CHANGE_MSR_BITMAP_READ
VMCALL to change MSR Bitmap Read.
Definition Vmcall.h:76
VOID VmxPerformVmxoff(VIRTUAL_MACHINE_STATE *VCpu)
Prepare and execute Vmxoff instruction.
Definition Vmx.c:991
#define STATUS_UNSUCCESSFUL
Definition Windows.h:172
void * PVOID
Definition BasicTypes.h:56
struct _CR3_TYPE CR3_TYPE
CR3 Structure.
unsigned int UINT32
Definition BasicTypes.h:54
#define TOP_LEVEL_DRIVERS_VMCALL_ENDING_NUMBER
The start number of VMCALL number allowed to be used by top-level drivers.
Definition Constants.h:356
#define TOP_LEVEL_DRIVERS_VMCALL_STARTING_NUMBER
The start number of VMCALL number allowed to be used by top-level drivers.
Definition Constants.h:349
#define LogError(format,...)
Log in the case of error.
Definition HyperDbgHyperLogIntrinsics.h:113
IMPORT_EXPORT_VMM BOOLEAN WritePhysicalMemoryUsingMapIoSpace(PVOID PhysicalAddress, PVOID Buffer, SIZE_T BufferSize)
Write physical memory to the physical address (used in VMI mode).
Definition MemoryManager.c:53
IMPORT_EXPORT_VMM BOOLEAN MemoryMapperWriteMemorySafeByPhysicalAddress(_Inout_ UINT64 DestinationPa, _In_ UINT64 Source, _In_ SIZE_T SizeToWrite)
IMPORT_EXPORT_VMM BOOLEAN ReadPhysicalMemoryUsingMapIoSpace(PVOID PhysicalAddress, PVOID Buffer, SIZE_T BufferSize)
Read physical memory from the physical address (used in VMI mode).
Definition MemoryManager.c:24
IMPORT_EXPORT_VMM BOOLEAN CheckAddressPhysical(UINT64 PAddr)
Checks if the physical address is correct or not based on physical address width.
Definition AddressCheck.c:120
IMPORT_EXPORT_VMM BOOLEAN MemoryMapperReadMemorySafeByPhysicalAddress(_In_ UINT64 PaAddressToRead, _Inout_ UINT64 BufferToSaveMemory, _In_ SIZE_T SizeToRead)
UINT32 CoreId
Definition State.h:328