HyperDbg Debugger
Loading...
Searching...
No Matches
State.h
Go to the documentation of this file.
1
12#pragma once
13
15// typedefs //
17
20typedef EPT_PDPTE_1GB EPT_PML3_ENTRY, *PEPT_PML3_ENTRY;
21typedef EPT_PDE_2MB EPT_PML2_ENTRY, *PEPT_PML2_ENTRY;
24
26// Constants //
28
33#define PENDING_INTERRUPTS_BUFFER_CAPACITY 64
34
39#define MaximumHiddenBreakpointsOnPage 40
40
42// Enums //
44
58
70
72// Memory Layout //
74
79#define VMM_EPT_PML4E_COUNT 512
80
85#define VMM_EPT_PML3E_COUNT 512
86
92#define VMM_EPT_PML2E_COUNT 512
93
99#define VMM_EPT_PML1E_COUNT 512
100
143
145// Structure //
147
161
166typedef struct _VMX_VMXOFF_STATE
167{
168 BOOLEAN IsVmxoffExecuted; // Shows whether the VMXOFF executed or not
169 UINT64 GuestRip; // Rip address of guest to return
170 UINT64 GuestRsp; // Rsp address of guest to return
171
173
295
305
311{
312 BOOLEAN IsOnVmxRootMode; // Detects whether the current logical core is on Executing on VMX Root Mode
313 BOOLEAN IncrementRip; // Checks whether it has to redo the previous instruction or not (it used mainly in Ept routines)
314 BOOLEAN HasLaunched; // Indicate whether the core is virtualized or not
315 BOOLEAN IgnoreMtfUnset; // Indicate whether the core should ignore unsetting the MTF or not
316 BOOLEAN WaitForImmediateVmexit; // Whether the current core is waiting for an immediate vm-exit or not
317 BOOLEAN EnableExternalInterruptsOnContinue; // Whether to enable external interrupts on the continue or not
318 BOOLEAN EnableExternalInterruptsOnContinueMtf; // Whether to enable external interrupts on the continue state of MTF or not
319 BOOLEAN InstrumentationStepInMtf; // Instrumentation step in MTF or not (used for single stepping with MTF)
320 BOOLEAN IgnoreOneMtf; // Ignore (mark as handled) for one MTF
321 BOOLEAN NotNormalEptp; // Indicate that the target processor is on the normal EPTP or not
322 BOOLEAN MbecEnabled; // Indicate that the target processor is on MBEC-enabled mode or not
323 PUINT64 PmlBufferAddress; // Address of buffer used for dirty logging
324 BOOLEAN Test; // Used for test purposes
325 UINT64 TestNumber; // Used for test purposes (Number)
326 GUEST_REGS * Regs; // The virtual processor's general-purpose registers
327 GUEST_XMM_REGS * XmmRegs; // The virtual processor's XMM registers
328 UINT32 CoreId; // The core's unique identifier
329 UINT32 ExitReason; // The core's exit reason
330 UINT32 ExitQualification; // The core's exit qualification
331 UINT64 LastVmexitRip; // RIP in the current VM-exit
332 UINT64 VmxonRegionPhysicalAddress; // Vmxon region physical address
333 UINT64 VmxonRegionVirtualAddress; // VMXON region virtual address
334 UINT64 VmcsRegionPhysicalAddress; // VMCS region physical address
335 UINT64 VmcsRegionVirtualAddress; // VMCS region virtual address
336 UINT64 VmmStack; // Stack for VMM in VM-Exit State
337 UINT64 MsrBitmapVirtualAddress; // Msr Bitmap Virtual Address
338 UINT64 MsrBitmapPhysicalAddress; // Msr Bitmap Physical Address
339 UINT64 IoBitmapVirtualAddressA; // I/O Bitmap Virtual Address (A)
340 UINT64 IoBitmapPhysicalAddressA; // I/O Bitmap Physical Address (A)
341 UINT64 IoBitmapVirtualAddressB; // I/O Bitmap Virtual Address (B)
342 UINT64 IoBitmapPhysicalAddressB; // I/O Bitmap Physical Address (B)
343 UINT32 QueuedNmi; // Queued NMIs
344 UINT32 PendingExternalInterrupts[PENDING_INTERRUPTS_BUFFER_CAPACITY]; // This list holds a buffer for external-interrupts that are in pending state due to the external-interrupt
345 // blocking and waits for interrupt-window exiting
346 // From hvpp :
347 // Pending interrupt queue (FIFO).
348 // Make storage for up-to 64 pending interrupts.
349 // In practice I haven't seen more than 2 pending interrupts.
350 VMX_VMXOFF_STATE VmxoffState; // Shows the vmxoff state of the guest
351 NMI_BROADCASTING_STATE NmiBroadcastingState; // Shows the state of NMI broadcasting
352 VM_EXIT_TRANSPARENCY TransparencyState; // The state of the debugger in transparent-mode
353 PEPT_HOOKED_PAGE_DETAIL MtfEptHookRestorePoint; // It shows the detail of the hooked paged that should be restore in MTF vm-exit
354 UINT8 LastExceptionOccurredInHost; // The vector of last exception occurred in host
355 UINT64 HostIdt; // host Interrupt Descriptor Table (actual type is SEGMENT_DESCRIPTOR_INTERRUPT_GATE_64*)
356 UINT64 HostGdt; // host Global Descriptor Table (actual type is SEGMENT_DESCRIPTOR_32* or SEGMENT_DESCRIPTOR_64*)
357 UINT64 HostTss; // host Task State Segment (actual type is TASK_STATE_SEGMENT_64*)
358 UINT64 HostInterruptStack; // host interrupt RSP
359
360 //
361 // EPT Descriptors
362 //
363 EPT_POINTER EptPointer; // Extended-Page-Table Pointer
364 PVMM_EPT_PAGE_TABLE EptPageTable; // Details of core-specific page-table
365
UCHAR BOOLEAN
Definition BasicTypes.h:35
unsigned char UINT8
Definition BasicTypes.h:52
unsigned int UINT32
Definition BasicTypes.h:54
char CHAR
Definition BasicTypes.h:33
struct _EPT_HOOKS_CONTEXT EPT_HOOKS_CONTEXT
Temporary $context used in some EPT hook commands.
EPT_PTE * PEPT_PML1_ENTRY
Definition State.h:23
EPT_PDPTE * PEPT_PML3_POINTER
Definition State.h:19
struct _NMI_BROADCASTING_STATE * PNMI_BROADCASTING_STATE
#define MaximumHiddenBreakpointsOnPage
Maximum number of hidden breakpoints in a page.
Definition State.h:39
enum _NMI_BROADCAST_ACTION_TYPE NMI_BROADCAST_ACTION_TYPE
Types of actions for NMI broadcasting.
EPT_PDE_2MB * PEPT_PML2_ENTRY
Definition State.h:21
_EPT_HOOKED_LAST_VIOLATION
Types of last violation happened to EPT hook.
Definition State.h:64
@ EPT_HOOKED_LAST_VIOLATION_READ
Definition State.h:65
@ EPT_HOOKED_LAST_VIOLATION_EXEC
Definition State.h:67
@ EPT_HOOKED_LAST_VIOLATION_WRITE
Definition State.h:66
struct _EPT_HOOKED_PAGE_DETAIL EPT_HOOKED_PAGE_DETAIL
Structure to save the state of each hooked pages.
struct _VMM_EPT_PAGE_TABLE VMM_EPT_PAGE_TABLE
Structure for saving EPT Table.
#define VMM_EPT_PML4E_COUNT
The number of 512GB PML4 entries in the page table.
Definition State.h:79
struct _EPT_HOOKED_PAGE_DETAIL * PEPT_HOOKED_PAGE_DETAIL
struct _VMX_VMXOFF_STATE * PVMX_VMXOFF_STATE
#define VMM_EPT_PML3E_COUNT
The number of 1GB PDPT entries in the page table per 512GB PML4 entry.
Definition State.h:85
EPT_PML4E EPT_PML4_POINTER
Definition State.h:18
#define PENDING_INTERRUPTS_BUFFER_CAPACITY
Pending External Interrupts Buffer Capacity.
Definition State.h:33
#define VMM_EPT_PML2E_COUNT
Then number of 2MB Page Directory entries in the page table per 1GB PML3 entry.
Definition State.h:92
EPT_PTE EPT_PML1_ENTRY
Definition State.h:23
_NMI_BROADCAST_ACTION_TYPE
Types of actions for NMI broadcasting.
Definition State.h:50
@ NMI_BROADCAST_ACTION_NONE
Definition State.h:51
@ NMI_BROADCAST_ACTION_REQUEST
Definition State.h:53
@ NMI_BROADCAST_ACTION_INVALIDATE_EPT_CACHE_SINGLE_CONTEXT
Definition State.h:54
@ NMI_BROADCAST_ACTION_TEST
Definition State.h:52
@ NMI_BROADCAST_ACTION_INVALIDATE_EPT_CACHE_ALL_CONTEXTS
Definition State.h:55
struct _VMM_EPT_PAGE_TABLE * PVMM_EPT_PAGE_TABLE
EPT_PDE EPT_PML2_POINTER
Definition State.h:22
EPT_PDPTE EPT_PML3_POINTER
Definition State.h:19
struct _NMI_BROADCASTING_STATE NMI_BROADCASTING_STATE
The status of NMI broadcasting in VMX.
EPT_PDPTE_1GB EPT_PML3_ENTRY
Definition State.h:20
struct _VM_EXIT_TRANSPARENCY * PVM_EXIT_TRANSPARENCY
EPT_PDE_2MB EPT_PML2_ENTRY
Definition State.h:21
struct _VMX_VMXOFF_STATE VMX_VMXOFF_STATE
Save the state of core in the case of VMXOFF.
EPT_PML4E * PEPT_PML4_POINTER
Definition State.h:18
struct _VIRTUAL_MACHINE_STATE VIRTUAL_MACHINE_STATE
The status of each core after and before VMX.
EPT_PDE * PEPT_PML2_POINTER
Definition State.h:22
enum _EPT_HOOKED_LAST_VIOLATION EPT_HOOKED_LAST_VIOLATION
Types of last violation happened to EPT hook.
struct _VIRTUAL_MACHINE_STATE * PVIRTUAL_MACHINE_STATE
EPT_PDPTE_1GB * PEPT_PML3_ENTRY
Definition State.h:20
struct _VM_EXIT_TRANSPARENCY VM_EXIT_TRANSPARENCY
The status of transparency of each core after and before VMX.
#define PAGE_SIZE
Size of each page (4096 bytes).
Definition common.h:80
Structure to save the state of each hooked pages.
Definition State.h:179
UINT64 AddressOfEptHook2sDetourListEntry
The virtual address of it's entry on g_EptHook2sDetourListHead this way we can de-allocate the list w...
Definition State.h:197
SIZE_T PhysicalBaseAddressOfFakePageContents
The base address of the page with fake contents. Used to swap page with fake contents when a hook is ...
Definition State.h:224
UINT64 VirtualAddress
The virtual address from the caller perspective view (cr3).
Definition State.h:191
BOOLEAN IsExecutionHook
This field shows whether the hook contains a hidden hook for execution or not.
Definition State.h:245
LIST_ENTRY PageHookList
Linked list entries for each page hook.
Definition State.h:186
CHAR FakePageContents[PAGE_SIZE]
Definition State.h:181
EPT_HOOKS_CONTEXT LastContextState
Temporary context for the post event monitors It shows the context of the last address that triggered...
Definition State.h:263
PCHAR Trampoline
The buffer of the trampoline function which is used in the inline hook.
Definition State.h:240
EPT_PML1_ENTRY ChangedEntry
The original page entry. Will be copied back when the hook is remove from the page.
Definition State.h:235
BOOLEAN IsMmioShadowing
This field shows whether the hook is for MMIO shadowing or not.
Definition State.h:256
BOOLEAN IsHiddenBreakpoint
If TRUE shows that this is the information about a hidden breakpoint command (not a monitor or hidden...
Definition State.h:251
CHAR PreviousBytesOnBreakpointAddresses[MaximumHiddenBreakpointsOnPage]
Character that was previously used in BreakpointAddresses this is only used in hidden breakpoints (no...
Definition State.h:286
SIZE_T EndOfTargetPhysicalAddress
End address of the target physical address.
Definition State.h:213
SIZE_T StartOfTargetPhysicalAddress
Start address of the target physical address.
Definition State.h:208
UINT64 BreakpointAddresses[MaximumHiddenBreakpointsOnPage]
Address of hooked pages (multiple breakpoints on a single page) this is only used in hidden breakpoin...
Definition State.h:280
UINT64 HookingTag
Tag used for notifying the caller.
Definition State.h:218
EPT_PML1_ENTRY OriginalEntry
The original page entry. Will be copied back when the hook is removed from the page.
Definition State.h:230
BOOLEAN IsPostEventTriggerAllowed
This field shows whether the hook should call the post event trigger after restoring the state or not...
Definition State.h:269
SIZE_T PhysicalBaseAddress
The base address of the page. Used to find this structure in the list of page hooks when a hook is hi...
Definition State.h:203
UINT64 CountOfBreakpoints
Count of breakpoints (multiple breakpoints on a single page) this is only used in hidden breakpoints ...
Definition State.h:292
EPT_HOOKED_LAST_VIOLATION LastViolation
This field shows the last violation happened to this EPT hook.
Definition State.h:274
The status of NMI broadcasting in VMX.
Definition State.h:301
volatile NMI_BROADCAST_ACTION_TYPE NmiBroadcastAction
Definition State.h:302
The status of each core after and before VMX.
Definition State.h:311
UINT64 MsrBitmapPhysicalAddress
Definition State.h:338
UINT32 ExitQualification
Definition State.h:330
PVMM_EPT_PAGE_TABLE EptPageTable
Definition State.h:364
UINT64 VmxonRegionVirtualAddress
Definition State.h:333
UINT64 HostInterruptStack
Definition State.h:358
BOOLEAN NotNormalEptp
Definition State.h:321
NMI_BROADCASTING_STATE NmiBroadcastingState
Definition State.h:351
UINT64 TestNumber
Definition State.h:325
UINT64 HostGdt
Definition State.h:356
UINT64 IoBitmapVirtualAddressB
Definition State.h:341
BOOLEAN IgnoreMtfUnset
Definition State.h:315
EPT_POINTER EptPointer
Definition State.h:363
GUEST_XMM_REGS * XmmRegs
Definition State.h:327
BOOLEAN EnableExternalInterruptsOnContinueMtf
Definition State.h:318
BOOLEAN MbecEnabled
Definition State.h:322
UINT64 IoBitmapPhysicalAddressA
Definition State.h:340
UINT32 PendingExternalInterrupts[PENDING_INTERRUPTS_BUFFER_CAPACITY]
Definition State.h:344
PUINT64 PmlBufferAddress
Definition State.h:323
UINT64 VmcsRegionPhysicalAddress
Definition State.h:334
UINT64 MsrBitmapVirtualAddress
Definition State.h:337
BOOLEAN IgnoreOneMtf
Definition State.h:320
UINT64 VmmStack
Definition State.h:336
UINT32 QueuedNmi
Definition State.h:343
BOOLEAN WaitForImmediateVmexit
Definition State.h:316
BOOLEAN IncrementRip
Definition State.h:313
UINT8 LastExceptionOccurredInHost
Definition State.h:354
PEPT_HOOKED_PAGE_DETAIL MtfEptHookRestorePoint
Definition State.h:353
UINT64 HostTss
Definition State.h:357
BOOLEAN HasLaunched
Definition State.h:314
GUEST_REGS * Regs
Definition State.h:326
UINT64 HostIdt
Definition State.h:355
UINT32 ExitReason
Definition State.h:329
VMX_VMXOFF_STATE VmxoffState
Definition State.h:350
BOOLEAN IsOnVmxRootMode
Definition State.h:312
BOOLEAN Test
Definition State.h:324
UINT32 CoreId
Definition State.h:328
BOOLEAN InstrumentationStepInMtf
Definition State.h:319
UINT64 IoBitmapPhysicalAddressB
Definition State.h:342
UINT64 IoBitmapVirtualAddressA
Definition State.h:339
BOOLEAN EnableExternalInterruptsOnContinue
Definition State.h:317
VM_EXIT_TRANSPARENCY TransparencyState
Definition State.h:352
UINT64 LastVmexitRip
Definition State.h:331
UINT64 VmcsRegionVirtualAddress
Definition State.h:335
UINT64 VmxonRegionPhysicalAddress
Definition State.h:332
The status of transparency of each core after and before VMX.
Definition State.h:153
UINT64 RevealedTimeStampCounterByRdtsc
Definition State.h:157
UINT64 PreviousTimeStampCounter
Definition State.h:154
HANDLE ThreadId
Definition State.h:156
BOOLEAN CpuidAfterRdtscDetected
Definition State.h:158
Structure for saving EPT Table.
Definition State.h:106
EPT_PML4_POINTER PML4[VMM_EPT_PML4E_COUNT]
28.2.2 Describes 512 contiguous 512GB memory regions each with 512 1GB regions.
Definition State.h:111
EPT_PML3_POINTER PML3[VMM_EPT_PML3E_COUNT]
Describes exactly 512 contiguous 1GB memory regions within a our singular 512GB PML4 region.
Definition State.h:125
LIST_ENTRY DynamicSplitList
Tracks dynamic 2MB->4KB splits for this EPT table. NOTE: Each item stores a direct VA to the split PM...
Definition State.h:140
EPT_PML2_ENTRY PML2[VMM_EPT_PML3E_COUNT][VMM_EPT_PML2E_COUNT]
For each 1GB PML3 entry, create 512 2MB entries to map identity. NOTE: We are using 2MB pages as the ...
Definition State.h:133
EPT_PML3_ENTRY PML3_RSVD[VMM_EPT_PML4E_COUNT - 1][VMM_EPT_PML3E_COUNT]
Describes exactly 512 contiguous 1GB memory regions within a our singular 512GB PML4 region (This ent...
Definition State.h:119
Save the state of core in the case of VMXOFF.
Definition State.h:167
UINT64 GuestRip
Definition State.h:169
UINT64 GuestRsp
Definition State.h:170
BOOLEAN IsVmxoffExecuted
Definition State.h:168
Definition BasicTypes.h:136
Definition BasicTypes.h:174