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

Header for Handlers of Guest's IDT Emulator. More...

Go to the source code of this file.

Classes

struct  _SIDT_ENTRY
struct  _KIDT_ENTRY
struct  _INTERRUPT_TRAP_FRAME
 Trap frame for interrupts. More...
struct  _HOST_EXCEPTION_INFO
 Filled out when a host exception occurs. More...

Macros

#define USE_DEFAULT_OS_IDT_AS_HOST_IDT   FALSE
 Whether the hypervisor should use the default OS's IDT as the host IDT in VMCS or not.
#define HOST_IDT_DESCRIPTOR_COUNT   256
 Maximum number of interrupt entries in IDT.

Typedefs

typedef struct _SIDT_ENTRY SIDT_ENTRY
typedef struct _SIDT_ENTRYPSIDT_ENTRY
typedef struct _KIDT_ENTRY KIDT_ENTRY
typedef struct _KIDT_ENTRYPKIDT_ENTRY
typedef struct _INTERRUPT_TRAP_FRAME INTERRUPT_TRAP_FRAME
 Trap frame for interrupts.
typedef struct _INTERRUPT_TRAP_FRAMEPINTERRUPT_TRAP_FRAME
typedef struct _HOST_EXCEPTION_INFO HOST_EXCEPTION_INFO
 Filled out when a host exception occurs.
typedef struct _HOST_EXCEPTION_INFOPHOST_EXCEPTION_INFO

Functions

VOID IdtEmulationPrepareHostIdt (_Inout_ VIRTUAL_MACHINE_STATE *VCpu)
 Prepare Host IDT.
VOID IdtEmulationHandleExceptionAndNmi (_Inout_ VIRTUAL_MACHINE_STATE *VCpu, _In_ VMEXIT_INTERRUPT_INFORMATION InterruptExit)
 Handle NMI and exception vm-exits.
VOID IdtEmulationHandleExternalInterrupt (_Inout_ VIRTUAL_MACHINE_STATE *VCpu, _In_ VMEXIT_INTERRUPT_INFORMATION InterruptExit)
 external-interrupt vm-exit handler
VOID IdtEmulationHandleNmiWindowExiting (_Inout_ VIRTUAL_MACHINE_STATE *VCpu)
 Handle NMI-window exitings.
VOID IdtEmulationHandleInterruptWindowExiting (_Inout_ VIRTUAL_MACHINE_STATE *VCpu)
 Handle interrupt-window exitings.
VOID IdtEmulationQueryIdtEntriesRequest (PINTERRUPT_DESCRIPTOR_TABLE_ENTRIES_PACKETS IdtQueryRequest, BOOLEAN ReadFromVmxRoot)
 Perform query for IDT entries.

Detailed Description

Header for Handlers of Guest's IDT Emulator.

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

Macro Definition Documentation

◆ HOST_IDT_DESCRIPTOR_COUNT

#define HOST_IDT_DESCRIPTOR_COUNT   256

Maximum number of interrupt entries in IDT.

◆ USE_DEFAULT_OS_IDT_AS_HOST_IDT

#define USE_DEFAULT_OS_IDT_AS_HOST_IDT   FALSE

Whether the hypervisor should use the default OS's IDT as the host IDT in VMCS or not.

Typedef Documentation

◆ HOST_EXCEPTION_INFO

Filled out when a host exception occurs.

◆ INTERRUPT_TRAP_FRAME

Trap frame for interrupts.

◆ KIDT_ENTRY

typedef struct _KIDT_ENTRY KIDT_ENTRY

◆ PHOST_EXCEPTION_INFO

◆ PINTERRUPT_TRAP_FRAME

◆ PKIDT_ENTRY

typedef struct _KIDT_ENTRY * PKIDT_ENTRY

◆ PSIDT_ENTRY

typedef struct _SIDT_ENTRY * PSIDT_ENTRY

◆ SIDT_ENTRY

typedef struct _SIDT_ENTRY SIDT_ENTRY

Function Documentation

◆ IdtEmulationHandleExceptionAndNmi()

VOID IdtEmulationHandleExceptionAndNmi ( _Inout_ VIRTUAL_MACHINE_STATE * VCpu,
_In_ VMEXIT_INTERRUPT_INFORMATION InterruptExit )

Handle NMI and exception vm-exits.

Parameters
VCpuThe virtual processor's state
InterruptExitinterrupt exit information
Returns
VOID
338{
339 //
340 // Exception or non-maskable interrupt (NMI). Either:
341 // 1: Guest software caused an exception and the bit in the exception bitmap associated with exception's vector was set to 1
342 // 2: An NMI was delivered to the logical processor and the "NMI exiting" VM-execution control was 1.
343 //
344 // VMCS_VMEXIT_INTERRUPTION_INFORMATION shows the exit information about event that occurred and causes this exit
345 // Don't forget to read VMCS_VMEXIT_INTERRUPTION_ERROR_CODE in the case of re-injectiong event
346 //
347
348 switch (InterruptExit.Vector)
349 {
351
352 //
353 // Handle software breakpoints
354 //
355 {
356 UINT64 GuestRip = NULL64_ZERO;
357 BYTE TargetMem = NULL_ZERO;
358
359 VmxVmread64P(VMCS_GUEST_RIP, &GuestRip);
360
361 MemoryMapperReadMemorySafe(GuestRip, &TargetMem, sizeof(BYTE));
362
363 if (!EptCheckAndHandleBreakpoint(VCpu) || TargetMem == 0xcc)
364 {
366 {
367 //
368 // Don't increment rip
369 //
371
372 //
373 // Kernel debugger (debugger-mode) is not attached, re-inject the breakpoint
374 //
376 }
377 }
378 }
379
380 break;
381
383
384 //
385 // Handle the #UD, checking if this exception was intentional.
386 //
387 if (!SyscallHookHandleUD(VCpu))
388 {
389 //
390 // If this #UD was found to be unintentional, inject a #UD interruption into the guest.
391 //
393 }
394
395 break;
396
398
399 //
400 // Handle page-faults (#PFs)
401 //
402 IdtEmulationHandlePageFaults(VCpu, InterruptExit);
403
404 break;
405
407
408 //
409 // Check if syscall callback is enabled and if so, then we need to
410 // check whether the this trap flag is set because of intercepting
411 // the result of a system-call or not
412 //
415 HANDLE_TO_UINT32(PsGetCurrentProcessId()),
416 HANDLE_TO_UINT32(PsGetCurrentThreadId())))
417 {
418 //
419 // Being here means that this #DB was caused by a trap flag of
420 // the system-call in the syscall callback, so no need to further handle
421 // it (nothing to do)
422 //
423 }
425 {
426 //
427 // It's not because of thread change detection, so re-inject it
428 //
429 EventInjectInterruptOrException(InterruptExit);
430 }
431
432 break;
433
435
436 if (VCpu->EnableExternalInterruptsOnContinue ||
437 VCpu->EnableExternalInterruptsOnContinueMtf ||
438 VCpu->InstrumentationStepInMtf)
439 {
440 //
441 // Ignore the nmi
442 //
443 }
444 else
445 {
446 //
447 // Re-inject the interrupt/exception because it doesn't relate to us
448 //
449 EventInjectInterruptOrException(InterruptExit);
450 }
451
452 break;
453
454 default:
455
456 //
457 // Re-inject the interrupt/exception, nothing special to handle
458 //
459 EventInjectInterruptOrException(InterruptExit);
460
461 break;
462 }
463}
BOOLEAN DebuggingCallbackHandleDebugBreakpointException(UINT32 CoreId)
routine callback to handle debug breakpoint exception
Definition Callback.c:252
BOOLEAN DebuggingCallbackHandleBreakpointException(UINT32 CoreId)
routine callback to handle breakpoint exception
Definition Callback.c:231
_Use_decl_annotations_ BOOLEAN SyscallHookHandleUD(VIRTUAL_MACHINE_STATE *VCpu)
Detect whether the UD was because of Syscall or Sysret or not.
Definition EferHook.c:267
BOOLEAN EptCheckAndHandleBreakpoint(VIRTUAL_MACHINE_STATE *VCpu)
Check if the breakpoint vm-exit relates to EPT hook or not.
Definition Ept.c:1317
VOID EventInjectInterruptOrException(_In_ VMEXIT_INTERRUPT_INFORMATION InterruptExit)
re-inject interrupt or exception to the guest
Definition Events.c:155
VOID EventInjectUndefinedOpcode(VIRTUAL_MACHINE_STATE *VCpu)
Inject UD to the guest (Invalid Opcode - Undefined Opcode).
Definition Events.c:79
VOID EventInjectBreakpoint()
Inject BP to the guest (Event Injection).
Definition Events.c:46
VOID HvSuppressRipIncrement(VIRTUAL_MACHINE_STATE *VCpu)
Suppress the incrementation of RIP.
Definition Hv.c:320
VOID IdtEmulationHandlePageFaults(_Inout_ VIRTUAL_MACHINE_STATE *VCpu, _In_ VMEXIT_INTERRUPT_INFORMATION InterruptExit)
Handle Page-fault exception bitmap VM-exits.
Definition IdtEmulation.c:296
#define HANDLE_TO_UINT32(_var)
Definition MetaMacros.h:39
UCHAR VmxVmread64P(size_t Field, UINT64 *FieldValue)
VMX VMREAD instruction (64-bit, pointer variant).
Definition PlatformIntrinsicsVmx.c:207
BOOLEAN SyscallCallbackCheckAndHandleAfterSyscallTrapFlags(VIRTUAL_MACHINE_STATE *VCpu, UINT32 ProcessId, UINT32 ThreadId)
Handle the trap flags as the result of interception of the return of the system-call.
Definition SyscallCallback.c:285
#define NULL_ZERO
Definition BasicTypes.h:110
unsigned char BYTE
Definition BasicTypes.h:40
#define NULL64_ZERO
Definition BasicTypes.h:111
@ EXCEPTION_VECTOR_UNDEFINED_OPCODE
Definition Events.h:30
@ EXCEPTION_VECTOR_NMI
Definition Events.h:26
@ EXCEPTION_VECTOR_DEBUG_BREAKPOINT
Definition Events.h:25
@ EXCEPTION_VECTOR_PAGE_FAULT
Definition Events.h:38
@ EXCEPTION_VECTOR_BREAKPOINT
Definition Events.h:27
IMPORT_EXPORT_VMM BOOLEAN MemoryMapperReadMemorySafe(_In_ UINT64 VaAddressToRead, _Inout_ PVOID BufferToSaveMemory, _In_ SIZE_T SizeToRead)
BOOLEAN g_SyscallCallbackStatus
Shows whether the syscall callback is enabled or not.
Definition GlobalVariables.h:118

◆ IdtEmulationHandleExternalInterrupt()

VOID IdtEmulationHandleExternalInterrupt ( _Inout_ VIRTUAL_MACHINE_STATE * VCpu,
_In_ VMEXIT_INTERRUPT_INFORMATION InterruptExit )

external-interrupt vm-exit handler

Parameters
VCpuThe virtual processor's state
InterruptExitinterrupt info from vm-exit
Returns
VOID
514{
515 BOOLEAN Interruptible = TRUE;
516 VMX_INTERRUPTIBILITY_STATE InterruptibilityState = {0};
517 RFLAGS GuestRflags = {0};
518
519 //
520 // In order to enable External Interrupt Exiting we have to set
521 // IA32_VMX_PINBASED_CTLS_EXTERNAL_INTERRUPT_EXITING_FLAG in vmx
522 // pin-based controls (PIN_BASED_VM_EXEC_CONTROL) and also
523 // we should enable IA32_VMX_EXIT_CTLS_ACKNOWLEDGE_INTERRUPT_ON_EXIT_FLAG
524 // on vmx vm-exit controls (VMCS_CTRL_VMEXIT_CONTROLS), also this function
525 // might not always be successful if the guest is not in the interruptible
526 // state so it wait for and interrupt-window exiting to re-inject
527 // the interrupt into the guest
528 //
529 if (VCpu->EnableExternalInterruptsOnContinue ||
530 VCpu->EnableExternalInterruptsOnContinueMtf)
531 {
532 //
533 // Ignore the interrupt as it's suppressed because of instrumentation step-in
534 //
535
536 //
537 // During developing HyperDbg, we realized that if we just ignore the interrupts completely
538 // while we are waiting on 'i' instrumentation step-in command, then the serial device becomes
539 // unresponsive, to solve this issue we hold the details of interrupts so we can re-inject
540 // and process them when we decide to continue the debuggee (guest interrupt windows is open)
541 // this way, the serial device works normally and won't become unresponsive
542 //
544
545 //
546 // avoid incrementing rip
547 //
549 }
550
551 else if (InterruptExit.Valid && InterruptExit.InterruptionType == INTERRUPT_TYPE_EXTERNAL_INTERRUPT)
552 {
553 VmxVmread64P(VMCS_GUEST_RFLAGS, &GuestRflags.AsUInt);
554 VmxVmread32P(VMCS_GUEST_INTERRUPTIBILITY_STATE, &InterruptibilityState.AsUInt);
555
556 //
557 // External interrupts cannot be injected into the
558 // guest if guest isn't interruptible (e.g.: guest
559 // is blocked by "mov ss", or EFLAGS.IF == 0).
560 //
561 Interruptible = GuestRflags.InterruptEnableFlag && !InterruptibilityState.BlockingByMovSs;
562
563 if (Interruptible)
564 {
565 //
566 // Re-inject the interrupt/exception
567 //
568 EventInjectInterruptOrException(InterruptExit);
569 }
570 else
571 {
572 //
573 // We can't inject interrupt because the guest's state is not interruptible
574 // we have to queue it an re-inject it when the interrupt window is opened!
575 //
577
578 //
579 // Enable Interrupt-window exiting.
580 //
582 }
583
584 //
585 // avoid incrementing rip
586 //
588 }
589 else
590 {
591 Interruptible = FALSE;
592
593 LogError("Err, why we are here? it's a vm-exit due to the external"
594 "interrupt and its type is not external interrupt? weird!");
595 }
596}
VOID HvSetInterruptWindowExiting(BOOLEAN Set)
Set Interrupt-window exiting.
Definition Hv.c:650
BOOLEAN IdtEmulationInjectInterruptWhenInterruptWindowIsOpen(_Inout_ VIRTUAL_MACHINE_STATE *VCpu, _In_ VMEXIT_INTERRUPT_INFORMATION InterruptExit)
if the guest is not interruptible, then we save the details of each interrupt so we can re-inject the...
Definition IdtEmulation.c:475
UCHAR VmxVmread32P(size_t Field, UINT32 *FieldValue)
VMX VMREAD instruction (32-bit, pointer variant).
Definition PlatformIntrinsicsVmx.c:227
UCHAR BOOLEAN
Definition BasicTypes.h:35
#define TRUE
Definition BasicTypes.h:114
#define FALSE
Definition BasicTypes.h:113
#define LogError(format,...)
Log in the case of error.
Definition HyperDbgHyperLogIntrinsics.h:113
@ INTERRUPT_TYPE_EXTERNAL_INTERRUPT
Definition Events.h:50

◆ IdtEmulationHandleInterruptWindowExiting()

VOID IdtEmulationHandleInterruptWindowExiting ( _Inout_ VIRTUAL_MACHINE_STATE * VCpu)

Handle interrupt-window exitings.

Parameters
VCpuThe virtual processor's state
Returns
VOID
663{
664 VMEXIT_INTERRUPT_INFORMATION InterruptExit = {0};
665 BOOLEAN InjectPageFault = FALSE;
666
667 //
668 // Check if page-fault needs to be injected or not
669 //
671 {
673 }
674
675 //
676 // Check if another interrupt (page-fault) needed to injected or not
677 //
678 if (!InjectPageFault)
679 {
680 for (SIZE_T i = 0; i < PENDING_INTERRUPTS_BUFFER_CAPACITY; i++)
681 {
682 //
683 // Find an empty space
684 //
685 if (VCpu->PendingExternalInterrupts[i] != NULL_ZERO)
686 {
687 //
688 // Save it for re-injection (interrupt-window exiting)
689 //
690 InterruptExit.AsUInt = VCpu->PendingExternalInterrupts[i];
691
692 //
693 // Free the entry
694 //
695 VCpu->PendingExternalInterrupts[i] = NULL_ZERO;
696 break;
697 }
698 }
699
700 if (InterruptExit.AsUInt == 0)
701 {
702 //
703 // Nothing left in pending state, let's disable the interrupt window exiting
704 //
706 }
707 else
708 {
709 //
710 // Inject the interrupt/exception
711 //
712
713 EventInjectInterruptOrException(InterruptExit);
714 }
715 }
716
717 //
718 // avoid incrementing rip
719 //
721}
BOOLEAN IdtEmulationInjectPageFaultWhenInterruptWindowsIsOpen(_Inout_ VIRTUAL_MACHINE_STATE *VCpu)
Injects a page-fault when interrupt window is open.
Definition IdtEmulation.c:625
#define PENDING_INTERRUPTS_BUFFER_CAPACITY
Pending External Interrupts Buffer Capacity.
Definition State.h:33
BOOLEAN g_WaitingForInterruptWindowToInjectPageFault
Shows whether the VMM is waiting to inject a page-fault or not.
Definition GlobalVariables.h:192

◆ IdtEmulationHandleNmiWindowExiting()

VOID IdtEmulationHandleNmiWindowExiting ( _Inout_ VIRTUAL_MACHINE_STATE * VCpu)

Handle NMI-window exitings.

Parameters
VCpuThe virtual processor's state
Returns
VOID
606{
607 //
608 // Inject the NMI into the guest
609 //
610 EventInjectNmi(VCpu);
611
612 //
613 // Disable NMI-window exiting since we have no more NMIs to inject
614 //
616}
VOID EventInjectNmi(VIRTUAL_MACHINE_STATE *VCpu)
Inject NMI to the guest (Event Injection).
Definition Events.c:96
VOID HvSetNmiWindowExiting(BOOLEAN Set)
Set NMI-window exiting.
Definition Hv.c:758

◆ IdtEmulationPrepareHostIdt()

VOID IdtEmulationPrepareHostIdt ( _Inout_ VIRTUAL_MACHINE_STATE * VCpu)

Prepare Host IDT.

Parameters
VCpuThe virtual processor's state
Returns
VOID
118{
119 SEGMENT_DESCRIPTOR_INTERRUPT_GATE_64 * VmxHostIdt = (SEGMENT_DESCRIPTOR_INTERRUPT_GATE_64 *)VCpu->HostIdt;
120 SEGMENT_DESCRIPTOR_INTERRUPT_GATE_64 * WindowsIdt = (SEGMENT_DESCRIPTOR_INTERRUPT_GATE_64 *)AsmGetIdtBase();
121
122 //
123 // Zero the memory
124 //
125 RtlZeroMemory(VmxHostIdt, HOST_IDT_DESCRIPTOR_COUNT * sizeof(SEGMENT_DESCRIPTOR_INTERRUPT_GATE_64));
126
127 //
128 // Copy OS interrupt (IDT) entries
129 //
130 RtlCopyBytes(VmxHostIdt,
131 WindowsIdt,
132 HOST_IDT_DESCRIPTOR_COUNT * sizeof(SEGMENT_DESCRIPTOR_INTERRUPT_GATE_64));
133
134 /*
135 for (SIZE_T i = 0; i < HOST_IDT_DESCRIPTOR_COUNT; i++)
136 {
137 SEGMENT_DESCRIPTOR_INTERRUPT_GATE_64 CurrentEntry = WindowsIdt[i];
138
139 UINT64 Offset = 0;
140 Offset |= ((UINT64)CurrentEntry.OffsetLow) << 0;
141 Offset |= ((UINT64)CurrentEntry.OffsetMiddle) << 16;
142 Offset |= ((UINT64)CurrentEntry.OffsetHigh) << 32;
143
144 // LogInfo("IDT Entry [%d] at: %llx", i, Offset);
145
146 IdtEmulationCreateInterruptGate((PVOID)Offset, &VmxHostIdt[i]);
147 }
148 */
149
150 //
151 // Function related to handling host IDT are a modified version of the following project:
152 // https://github.com/jonomango/hv/blob/main/hv
153 //
154
155 //
156 // Add customize interrupt handlers
157 //
159 // IdtEmulationCreateInterruptGate((PVOID)InterruptHandler1, &VmxHostIdt[EXCEPTION_VECTOR_DEBUG_BREAKPOINT]); // #DB
161 // IdtEmulationCreateInterruptGate((PVOID)InterruptHandler3, &VmxHostIdt[EXCEPTION_VECTOR_BREAKPOINT]); // #BP
171 // IdtEmulationCreateInterruptGate((PVOID)InterruptHandler14, &VmxHostIdt[EXCEPTION_VECTOR_PAGE_FAULT]); // #PF
178}
VOID IdtEmulationCreateInterruptGate(PVOID Handler, SEGMENT_DESCRIPTOR_INTERRUPT_GATE_64 *Entry)
Create an interrupt gate that points to the supplied interrupt handler.
Definition IdtEmulation.c:73
#define HOST_IDT_DESCRIPTOR_COUNT
Maximum number of interrupt entries in IDT.
Definition IdtEmulation.h:29
VOID InterruptHandler17()
The 17th entry in IDT.
VOID InterruptHandler13()
The 13th entry in IDT.
VOID InterruptHandler11()
The 11th entry in IDT.
UINT64 AsmGetIdtBase()
Get IDT base.
VOID InterruptHandler2()
The 2nd entry in IDT.
VOID InterruptHandler12()
The 12th entry in IDT.
VOID InterruptHandler19()
The 19th entry in IDT.
VOID InterruptHandler8()
The 8th entry in IDT.
VOID InterruptHandler18()
The 18th entry in IDT.
VOID InterruptHandler20()
The 20th entry in IDT.
VOID InterruptHandler30()
The 30th entry in IDT.
VOID InterruptHandler7()
The 7th entry in IDT.
VOID InterruptHandler5()
The 5th entry in IDT.
VOID InterruptHandler0()
The 0th entry in IDT.
VOID InterruptHandler10()
The 10th entry in IDT.
VOID InterruptHandler16()
The 16th entry in IDT.
VOID InterruptHandler6()
The 6th entry in IDT.
VOID InterruptHandler4()
The 4th entry in IDT.
void * PVOID
Definition BasicTypes.h:56
@ EXCEPTION_VECTOR_RESERVED11
Definition Events.h:54
@ EXCEPTION_VECTOR_GENERAL_PROTECTION_FAULT
Definition Events.h:37
@ EXCEPTION_VECTOR_MATH_FAULT
Definition Events.h:40
@ EXCEPTION_VECTOR_STACK_SEGMENT_FAULT
Definition Events.h:36
@ EXCEPTION_VECTOR_INVALID_TASK_SEGMENT_SELECTOR
Definition Events.h:34
@ EXCEPTION_VECTOR_DIVIDE_ERROR
Definition Events.h:24
@ EXCEPTION_VECTOR_ALIGNMENT_CHECK
Definition Events.h:41
@ EXCEPTION_VECTOR_MACHINE_CHECK
Definition Events.h:42
@ EXCEPTION_VECTOR_SIMD_FLOATING_POINT_NUMERIC_ERROR
Definition Events.h:43
@ EXCEPTION_VECTOR_NO_MATH_COPROCESSOR
Definition Events.h:31
@ EXCEPTION_VECTOR_VIRTUAL_EXCEPTION
Definition Events.h:44
@ EXCEPTION_VECTOR_BOUND_RANGE_EXCEEDED
Definition Events.h:29
@ EXCEPTION_VECTOR_OVERFLOW
Definition Events.h:28
@ EXCEPTION_VECTOR_SEGMENT_NOT_PRESENT
Definition Events.h:35
@ EXCEPTION_VECTOR_DOUBLE_FAULT
Definition Events.h:32

◆ IdtEmulationQueryIdtEntriesRequest()

VOID IdtEmulationQueryIdtEntriesRequest ( PINTERRUPT_DESCRIPTOR_TABLE_ENTRIES_PACKETS IdtQueryRequest,
BOOLEAN ReadFromVmxRoot )

Perform query for IDT entries.

Parameters
IdtQueryRequest
ReadFromVmxRoot
Returns
VOID
25{
26 SIDT_ENTRY IdtrReg;
27 KIDT_ENTRY * IdtEntries;
28
29 //
30 // Read IDTR register
31 //
32
33 if (!ReadFromVmxRoot)
34 {
35 //
36 // Since it's not in VMX Root, we can directly read the IDTR register
37 //
38 CpuSidt(&IdtrReg);
39
40 //
41 // Get the IDT base address
42 //
43 IdtEntries = (KIDT_ENTRY *)IdtrReg.IdtBase;
44 }
45 else
46 {
47 //
48 // Since it's in VMX Root, we need to read the IDTR register from the VMCS
49 //
50 IdtEntries = (KIDT_ENTRY *)GetGuestIdtr();
51 }
52
53 //
54 // Gather a list of IDT entries
55 //
56 for (UINT32 i = 0; i < MAX_NUMBER_OF_IDT_ENTRIES; i++)
57 {
58 IdtQueryRequest->IdtEntry[i] = (UINT64)((UINT64)IdtEntries[i].HighestPart << 32) |
59 ((UINT64)IdtEntries[i].HighPart << 16) |
60 (UINT64)IdtEntries[i].LowPart;
61 }
62}
struct _KIDT_ENTRY KIDT_ENTRY
struct _SIDT_ENTRY SIDT_ENTRY
VOID CpuSidt(VOID *Idtr)
Store Interrupt Descriptor Table Register.
Definition PlatformIntrinsics.c:419
unsigned int UINT32
Definition BasicTypes.h:54
#define MAX_NUMBER_OF_IDT_ENTRIES
Maximum number of IDT entries.
Definition RequestStructures.h:1457
IMPORT_EXPORT_VMM UINT64 GetGuestIdtr()
Get the Guest Idtr.
Definition ManageRegs.c:304
UINT64 IdtEntry[MAX_NUMBER_OF_IDT_ENTRIES]
Definition RequestStructures.h:1466
ULONG LowPart
Definition IdtEmulation.h:45
ULONG HighPart
Definition IdtEmulation.h:54
ULONG_PTR IdtBase
Definition IdtEmulation.h:40