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_PDE_2MB EPT_PML2_ENTRY, *PEPT_PML2_ENTRY;
23
25// Constants //
27
32#define PENDING_INTERRUPTS_BUFFER_CAPACITY 64
33
38#define MaximumHiddenBreakpointsOnPage 40
39
41// Enums //
43
57
69
71// Memory Layout //
73
78#define VMM_EPT_PML4E_COUNT 512
79
84#define VMM_EPT_PML3E_COUNT 512
85
91#define VMM_EPT_PML2E_COUNT 512
92
98#define VMM_EPT_PML1E_COUNT 512
99
127
129// Structure //
131
145
150typedef struct _VMX_VMXOFF_STATE
151{
152 BOOLEAN IsVmxoffExecuted; // Shows whether the VMXOFF executed or not
153 UINT64 GuestRip; // Rip address of guest to return
154 UINT64 GuestRsp; // Rsp address of guest to return
155
157
163{
164 DECLSPEC_ALIGN(PAGE_SIZE)
165 CHAR FakePageContents[PAGE_SIZE];
166
170 LIST_ENTRY PageHookList;
171
175 UINT64 VirtualAddress;
176
181 UINT64 AddressOfEptHook2sDetourListEntry;
182
187 SIZE_T PhysicalBaseAddress;
188
192 SIZE_T StartOfTargetPhysicalAddress;
193
197 SIZE_T EndOfTargetPhysicalAddress;
198
202 UINT64 HookingTag;
203
208 SIZE_T PhysicalBaseAddressOfFakePageContents;
209
214 EPT_PML1_ENTRY OriginalEntry;
215
219 EPT_PML1_ENTRY ChangedEntry;
220
224 PCHAR Trampoline;
225
229 BOOLEAN IsExecutionHook;
230
235 BOOLEAN IsHiddenBreakpoint;
236
242 EPT_HOOKS_CONTEXT LastContextState;
243
248 BOOLEAN IsPostEventTriggerAllowed;
249
254
260
265 CHAR PreviousBytesOnBreakpointAddresses[MaximumHiddenBreakpointsOnPage];
266
271 UINT64 CountOfBreakpoints;
272
274
284
290{
291 BOOLEAN IsOnVmxRootMode; // Detects whether the current logical core is on Executing on VMX Root Mode
292 BOOLEAN IncrementRip; // Checks whether it has to redo the previous instruction or not (it used mainly in Ept routines)
293 BOOLEAN HasLaunched; // Indicate whether the core is virtualized or not
294 BOOLEAN IgnoreMtfUnset; // Indicate whether the core should ignore unsetting the MTF or not
295 BOOLEAN WaitForImmediateVmexit; // Whether the current core is waiting for an immediate vm-exit or not
296 BOOLEAN EnableExternalInterruptsOnContinue; // Whether to enable external interrupts on the continue or not
297 BOOLEAN EnableExternalInterruptsOnContinueMtf; // Whether to enable external interrupts on the continue state of MTF or not
298 BOOLEAN RegisterBreakOnMtf; // Registered Break in the case of MTFs (used in instrumentation step-in)
299 BOOLEAN IgnoreOneMtf; // Ignore (mark as handled) for one MTF
300 BOOLEAN NotNormalEptp; // Indicate that the target processor is on the normal EPTP or not
301 BOOLEAN MbecEnabled; // Indicate that the target processor is on MBEC-enabled mode or not
302 PUINT64 PmlBufferAddress; // Address of buffer used for dirty logging
303 BOOLEAN Test; // Used for test purposes
304 UINT64 TestNumber; // Used for test purposes (Number)
305 GUEST_REGS * Regs; // The virtual processor's general-purpose registers
306 UINT32 CoreId; // The core's unique identifier
307 UINT32 ExitReason; // The core's exit reason
308 UINT32 ExitQualification; // The core's exit qualification
309 UINT64 LastVmexitRip; // RIP in the current VM-exit
310 UINT64 VmxonRegionPhysicalAddress; // Vmxon region physical address
311 UINT64 VmxonRegionVirtualAddress; // VMXON region virtual address
312 UINT64 VmcsRegionPhysicalAddress; // VMCS region physical address
313 UINT64 VmcsRegionVirtualAddress; // VMCS region virtual address
314 UINT64 VmmStack; // Stack for VMM in VM-Exit State
315 UINT64 MsrBitmapVirtualAddress; // Msr Bitmap Virtual Address
316 UINT64 MsrBitmapPhysicalAddress; // Msr Bitmap Physical Address
317 UINT64 IoBitmapVirtualAddressA; // I/O Bitmap Virtual Address (A)
318 UINT64 IoBitmapPhysicalAddressA; // I/O Bitmap Physical Address (A)
319 UINT64 IoBitmapVirtualAddressB; // I/O Bitmap Virtual Address (B)
320 UINT64 IoBitmapPhysicalAddressB; // I/O Bitmap Physical Address (B)
321 UINT32 QueuedNmi; // Queued NMIs
322 UINT32 PendingExternalInterrupts[PENDING_INTERRUPTS_BUFFER_CAPACITY]; // This list holds a buffer for external-interrupts that are in pending state due to the external-interrupt
323 // blocking and waits for interrupt-window exiting
324 // From hvpp :
325 // Pending interrupt queue (FIFO).
326 // Make storage for up-to 64 pending interrupts.
327 // In practice I haven't seen more than 2 pending interrupts.
328 VMX_VMXOFF_STATE VmxoffState; // Shows the vmxoff state of the guest
329 NMI_BROADCASTING_STATE NmiBroadcastingState; // Shows the state of NMI broadcasting
330 VM_EXIT_TRANSPARENCY TransparencyState; // The state of the debugger in transparent-mode
331 PEPT_HOOKED_PAGE_DETAIL MtfEptHookRestorePoint; // It shows the detail of the hooked paged that should be restore in MTF vm-exit
332 UINT8 LastExceptionOccuredInHost; // The vector of last exception occured in host
333 UINT64 HostIdt; // host Interrupt Descriptor Table (actual type is SEGMENT_DESCRIPTOR_INTERRUPT_GATE_64*)
334 UINT64 HostGdt; // host Global Descriptor Table (actual type is SEGMENT_DESCRIPTOR_32* or SEGMENT_DESCRIPTOR_64*)
335 UINT64 HostTss; // host Task State Segment (actual type is TASK_STATE_SEGMENT_64*)
336 UINT64 HostInterruptStack; // host interrupt RSP
337
338 //
339 // EPT Descriptors
340 //
341 EPT_POINTER EptPointer; // Extended-Page-Table Pointer
342 PVMM_EPT_PAGE_TABLE EptPageTable; // Details of core-specific page-table
343
UCHAR BOOLEAN
Definition BasicTypes.h:39
unsigned __int64 UINT64
Definition BasicTypes.h:21
unsigned char UINT8
Definition BasicTypes.h:46
unsigned __int64 * PUINT64
Definition BasicTypes.h:21
unsigned int UINT32
Definition BasicTypes.h:48
char CHAR
Definition BasicTypes.h:31
EPT_PTE * PEPT_PML1_ENTRY
Definition State.h:22
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:38
enum _NMI_BROADCAST_ACTION_TYPE NMI_BROADCAST_ACTION_TYPE
Types of actions for NMI broadcasting.
EPT_PDE_2MB * PEPT_PML2_ENTRY
Definition State.h:20
_EPT_HOOKED_LAST_VIOLATION
Types of last violation happened to EPT hook.
Definition State.h:63
@ EPT_HOOKED_LAST_VIOLATION_READ
Definition State.h:64
@ EPT_HOOKED_LAST_VIOLATION_EXEC
Definition State.h:66
@ EPT_HOOKED_LAST_VIOLATION_WRITE
Definition State.h:65
#define VMM_EPT_PML4E_COUNT
The number of 512GB PML4 entries in the page table.
Definition State.h:78
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:84
EPT_PML4E EPT_PML4_POINTER
Definition State.h:18
#define PENDING_INTERRUPTS_BUFFER_CAPACITY
Pending External Interrupts Buffer Capacity.
Definition State.h:32
#define VMM_EPT_PML2E_COUNT
Then number of 2MB Page Directory entries in the page table per 1GB PML3 entry.
Definition State.h:91
EPT_PTE EPT_PML1_ENTRY
Definition State.h:22
_NMI_BROADCAST_ACTION_TYPE
Types of actions for NMI broadcasting.
Definition State.h:49
@ NMI_BROADCAST_ACTION_NONE
Definition State.h:50
@ NMI_BROADCAST_ACTION_REQUEST
Definition State.h:52
@ NMI_BROADCAST_ACTION_INVALIDATE_EPT_CACHE_SINGLE_CONTEXT
Definition State.h:53
@ NMI_BROADCAST_ACTION_TEST
Definition State.h:51
@ NMI_BROADCAST_ACTION_INVALIDATE_EPT_CACHE_ALL_CONTEXTS
Definition State.h:54
EPT_PDE EPT_PML2_POINTER
Definition State.h:21
EPT_PDPTE EPT_PML3_POINTER
Definition State.h:19
struct _NMI_BROADCASTING_STATE NMI_BROADCASTING_STATE
The status of NMI broadcasting in VMX.
struct _VM_EXIT_TRANSPARENCY * PVM_EXIT_TRANSPARENCY
EPT_PDE_2MB EPT_PML2_ENTRY
Definition State.h:20
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:21
enum _EPT_HOOKED_LAST_VIOLATION EPT_HOOKED_LAST_VIOLATION
Types of last violation happened to EPT hook.
struct _VIRTUAL_MACHINE_STATE * PVIRTUAL_MACHINE_STATE
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:69
Structure to save the state of each hooked pages.
Definition State.h:163
Temporary $context used in some EPT hook commands.
Definition DataTypes.h:320
The status of NMI broadcasting in VMX.
Definition State.h:280
volatile NMI_BROADCAST_ACTION_TYPE NmiBroadcastAction
Definition State.h:281
The status of each core after and before VMX.
Definition State.h:290
UINT64 MsrBitmapPhysicalAddress
Definition State.h:316
UINT32 ExitQualification
Definition State.h:308
PVMM_EPT_PAGE_TABLE EptPageTable
Definition State.h:342
UINT64 VmxonRegionVirtualAddress
Definition State.h:311
UINT64 HostInterruptStack
Definition State.h:336
BOOLEAN NotNormalEptp
Definition State.h:300
NMI_BROADCASTING_STATE NmiBroadcastingState
Definition State.h:329
UINT64 TestNumber
Definition State.h:304
UINT8 LastExceptionOccuredInHost
Definition State.h:332
UINT64 HostGdt
Definition State.h:334
UINT64 IoBitmapVirtualAddressB
Definition State.h:319
BOOLEAN IgnoreMtfUnset
Definition State.h:294
EPT_POINTER EptPointer
Definition State.h:341
BOOLEAN EnableExternalInterruptsOnContinueMtf
Definition State.h:297
BOOLEAN MbecEnabled
Definition State.h:301
UINT64 IoBitmapPhysicalAddressA
Definition State.h:318
PUINT64 PmlBufferAddress
Definition State.h:302
UINT64 VmcsRegionPhysicalAddress
Definition State.h:312
UINT64 MsrBitmapVirtualAddress
Definition State.h:315
BOOLEAN IgnoreOneMtf
Definition State.h:299
UINT64 VmmStack
Definition State.h:314
UINT32 QueuedNmi
Definition State.h:321
BOOLEAN WaitForImmediateVmexit
Definition State.h:295
BOOLEAN IncrementRip
Definition State.h:292
PEPT_HOOKED_PAGE_DETAIL MtfEptHookRestorePoint
Definition State.h:331
UINT64 HostTss
Definition State.h:335
BOOLEAN HasLaunched
Definition State.h:293
GUEST_REGS * Regs
Definition State.h:305
UINT64 HostIdt
Definition State.h:333
UINT32 ExitReason
Definition State.h:307
VMX_VMXOFF_STATE VmxoffState
Definition State.h:328
BOOLEAN IsOnVmxRootMode
Definition State.h:291
BOOLEAN RegisterBreakOnMtf
Definition State.h:298
BOOLEAN Test
Definition State.h:303
UINT32 CoreId
Definition State.h:306
UINT64 IoBitmapPhysicalAddressB
Definition State.h:320
UINT64 IoBitmapVirtualAddressA
Definition State.h:317
BOOLEAN EnableExternalInterruptsOnContinue
Definition State.h:296
VM_EXIT_TRANSPARENCY TransparencyState
Definition State.h:330
UINT64 LastVmexitRip
Definition State.h:309
UINT64 VmcsRegionVirtualAddress
Definition State.h:313
UINT64 VmxonRegionPhysicalAddress
Definition State.h:310
The status of transparency of each core after and before VMX.
Definition State.h:137
UINT64 RevealedTimeStampCounterByRdtsc
Definition State.h:141
UINT64 PreviousTimeStampCounter
Definition State.h:138
HANDLE ThreadId
Definition State.h:140
BOOLEAN CpuidAfterRdtscDetected
Definition State.h:142
Structure for saving EPT Table.
Definition State.h:105
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:110
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:116
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:124
Save the state of core in the case of VMXOFF.
Definition State.h:151
UINT64 GuestRip
Definition State.h:153
UINT64 GuestRsp
Definition State.h:154
BOOLEAN IsVmxoffExecuted
Definition State.h:152
Definition BasicTypes.h:70