HyperDbg Debugger
|
Contains the headers relating to EPT structures, MTRR and all basic Hooking structures. More...
Go to the source code of this file.
Classes | |
struct | _MTRR_RANGE_DESCRIPTOR |
MTRR Descriptor. More... | |
union | _IA32_MTRR_FIXED_RANGE_TYPE |
Fixed range MTRR. More... | |
struct | _EPT_STATE |
Main structure for saving the state of EPT among the project. More... | |
struct | _VMM_EPT_DYNAMIC_SPLIT |
Split 2MB granularity to 4 KB granularity. More... | |
Macros | |
#define | PAGE_ATTRIB_READ 0x2 |
Page attributes for internal use. | |
#define | PAGE_ATTRIB_WRITE 0x4 |
#define | PAGE_ATTRIB_EXEC 0x8 |
#define | PAGE_ATTRIB_EXEC_HIDDEN_HOOK 0x10 |
#define | SIZE_2_MB ((SIZE_T)(512 * PAGE_SIZE)) |
Integer 2MB. | |
#define | ADDRMASK_EPT_PML1_OFFSET(_VAR_) ((_VAR_) & 0xFFFULL) |
Offset into the 1st paging structure (4096 byte) | |
#define | ADDRMASK_EPT_PML1_INDEX(_VAR_) (((_VAR_) & 0x1FF000ULL) >> 12) |
Index of the 1st paging structure (4096 byte) | |
#define | ADDRMASK_EPT_PML2_INDEX(_VAR_) (((_VAR_) & 0x3FE00000ULL) >> 21) |
Index of the 2nd paging structure (2MB) | |
#define | ADDRMASK_EPT_PML3_INDEX(_VAR_) (((_VAR_) & 0x7FC0000000ULL) >> 30) |
Index of the 3rd paging structure (1GB) | |
#define | ADDRMASK_EPT_PML4_INDEX(_VAR_) (((_VAR_) & 0xFF8000000000ULL) >> 39) |
Index of the 4th paging structure (512GB) | |
#define | MAX_VARIABLE_RANGE_MTRRS 255 |
Architecturally defined number of variable range MTRRs. | |
#define | NUM_FIXED_RANGE_MTRRS ((1 + 2 + 8) * RTL_NUMBER_OF_FIELD(IA32_MTRR_FIXED_RANGE_TYPE, s.Types)) |
Architecturally defined number of fixed range MTRRs. 1 register for 64k, 2 registers for 16k, 8 registers for 4k, and each register has 8 ranges as per "Fixed Range MTRRs" states. | |
#define | NUM_MTRR_ENTRIES (MAX_VARIABLE_RANGE_MTRRS + NUM_FIXED_RANGE_MTRRS) |
Total number of MTRR descriptors to store. | |
Typedefs | |
typedef struct _MTRR_RANGE_DESCRIPTOR | MTRR_RANGE_DESCRIPTOR |
MTRR Descriptor. | |
typedef struct _MTRR_RANGE_DESCRIPTOR * | PMTRR_RANGE_DESCRIPTOR |
typedef union _IA32_MTRR_FIXED_RANGE_TYPE | IA32_MTRR_FIXED_RANGE_TYPE |
Fixed range MTRR. | |
typedef struct _EPT_STATE | EPT_STATE |
Main structure for saving the state of EPT among the project. | |
typedef struct _EPT_STATE * | PEPT_STATE |
typedef struct _VMM_EPT_DYNAMIC_SPLIT | VMM_EPT_DYNAMIC_SPLIT |
Split 2MB granularity to 4 KB granularity. | |
typedef struct _VMM_EPT_DYNAMIC_SPLIT * | PVMM_EPT_DYNAMIC_SPLIT |
Functions | |
BOOLEAN | EptSetupPML2Entry (PVMM_EPT_PAGE_TABLE EptPageTable, PEPT_PML2_ENTRY NewEntry, SIZE_T PageFrameNumber) |
Set up PML2 Entries. | |
BOOLEAN | EptHandlePageHookExit (_Inout_ VIRTUAL_MACHINE_STATE *VCpu, _In_ VMX_EXIT_QUALIFICATION_EPT_VIOLATION ViolationQualification, _In_ UINT64 GuestPhysicalAddr) |
BOOLEAN | EptCheckFeatures (VOID) |
Check for EPT Features. | |
BOOLEAN | EptBuildMtrrMap (VOID) |
Build MTRR Map. | |
PVMM_EPT_PAGE_TABLE | EptAllocateAndCreateIdentityPageTable (VOID) |
Allocates page maps and create identity page table. | |
BOOLEAN | EptSplitLargePage (PVMM_EPT_PAGE_TABLE EptPageTable, PVOID PreAllocatedBuffer, SIZE_T PhysicalAddress) |
Convert 2MB pages to 4KB pages. | |
PEPT_PML2_ENTRY | EptGetPml2Entry (PVMM_EPT_PAGE_TABLE EptPageTable, SIZE_T PhysicalAddress) |
Split 2MB (LargePage) into 4kb pages. | |
BOOLEAN | EptLogicalProcessorInitialize (VOID) |
Initialize EPT Table based on Processor Index. | |
BOOLEAN | EptHandleEptViolation (VIRTUAL_MACHINE_STATE *VCpu) |
Handle EPT Violation. | |
PEPT_PML1_ENTRY | EptGetPml1Entry (PVMM_EPT_PAGE_TABLE EptPageTable, SIZE_T PhysicalAddress) |
Get the PML1 Entry of a special address. | |
PVOID | EptGetPml1OrPml2Entry (PVMM_EPT_PAGE_TABLE EptPageTable, SIZE_T PhysicalAddress, BOOLEAN *IsLargePage) |
Get the PML1 entry for this physical address if the large page is available then large page of Pml2 is returned. | |
VOID | EptHandleMisconfiguration (VOID) |
Handle Ept Misconfigurations. | |
VOID | EptSetPML1AndInvalidateTLB (_Inout_ VIRTUAL_MACHINE_STATE *VCpu, _Out_ PEPT_PML1_ENTRY EntryAddress, _In_ EPT_PML1_ENTRY EntryValue, _In_ _Strict_type_match_ INVEPT_TYPE InvalidationType) |
This function set the specific PML1 entry in a spinlock protected area then invalidate the TLB , this function should be called from vmx root-mode. | |
BOOLEAN | EptCheckAndHandleBreakpoint (VIRTUAL_MACHINE_STATE *VCpu) |
Check if the breakpoint vm-exit relates to EPT hook or not. | |
Contains the headers relating to EPT structures, MTRR and all basic Hooking structures.
#define ADDRMASK_EPT_PML1_INDEX | ( | _VAR_ | ) | (((_VAR_) & 0x1FF000ULL) >> 12) |
Index of the 1st paging structure (4096 byte)
#define ADDRMASK_EPT_PML1_OFFSET | ( | _VAR_ | ) | ((_VAR_) & 0xFFFULL) |
Offset into the 1st paging structure (4096 byte)
#define ADDRMASK_EPT_PML2_INDEX | ( | _VAR_ | ) | (((_VAR_) & 0x3FE00000ULL) >> 21) |
Index of the 2nd paging structure (2MB)
#define ADDRMASK_EPT_PML3_INDEX | ( | _VAR_ | ) | (((_VAR_) & 0x7FC0000000ULL) >> 30) |
Index of the 3rd paging structure (1GB)
#define ADDRMASK_EPT_PML4_INDEX | ( | _VAR_ | ) | (((_VAR_) & 0xFF8000000000ULL) >> 39) |
Index of the 4th paging structure (512GB)
#define MAX_VARIABLE_RANGE_MTRRS 255 |
Architecturally defined number of variable range MTRRs.
#define NUM_FIXED_RANGE_MTRRS ((1 + 2 + 8) * RTL_NUMBER_OF_FIELD(IA32_MTRR_FIXED_RANGE_TYPE, s.Types)) |
Architecturally defined number of fixed range MTRRs. 1 register for 64k, 2 registers for 16k, 8 registers for 4k, and each register has 8 ranges as per "Fixed Range MTRRs" states.
#define NUM_MTRR_ENTRIES (MAX_VARIABLE_RANGE_MTRRS + NUM_FIXED_RANGE_MTRRS) |
Total number of MTRR descriptors to store.
#define PAGE_ATTRIB_EXEC 0x8 |
#define PAGE_ATTRIB_EXEC_HIDDEN_HOOK 0x10 |
#define PAGE_ATTRIB_READ 0x2 |
Page attributes for internal use.
#define PAGE_ATTRIB_WRITE 0x4 |
#define SIZE_2_MB ((SIZE_T)(512 * PAGE_SIZE)) |
Integer 2MB.
typedef struct _EPT_STATE EPT_STATE |
Main structure for saving the state of EPT among the project.
typedef union _IA32_MTRR_FIXED_RANGE_TYPE IA32_MTRR_FIXED_RANGE_TYPE |
Fixed range MTRR.
typedef struct _MTRR_RANGE_DESCRIPTOR MTRR_RANGE_DESCRIPTOR |
MTRR Descriptor.
typedef struct _EPT_STATE * PEPT_STATE |
typedef struct _MTRR_RANGE_DESCRIPTOR * PMTRR_RANGE_DESCRIPTOR |
typedef struct _VMM_EPT_DYNAMIC_SPLIT * PVMM_EPT_DYNAMIC_SPLIT |
typedef struct _VMM_EPT_DYNAMIC_SPLIT VMM_EPT_DYNAMIC_SPLIT |
Split 2MB granularity to 4 KB granularity.
PVMM_EPT_PAGE_TABLE EptAllocateAndCreateIdentityPageTable | ( | VOID | ) |
Allocates page maps and create identity page table.
Build MTRR Map.
Build MTRR Map.
BOOLEAN EptCheckAndHandleBreakpoint | ( | VIRTUAL_MACHINE_STATE * | VCpu | ) |
Check if the breakpoint vm-exit relates to EPT hook or not.
VCpu | The virtual processor's state |
Check for EPT Features.
Check for EPT Features.
PEPT_PML1_ENTRY EptGetPml1Entry | ( | PVMM_EPT_PAGE_TABLE | EptPageTable, |
SIZE_T | PhysicalAddress ) |
Get the PML1 Entry of a special address.
EptPageTable | |
PhysicalAddress |
Get the PML1 Entry of a special address.
EptPageTable | The EPT Page Table |
PhysicalAddress | Physical address that we want to get its PML1 |
PVOID EptGetPml1OrPml2Entry | ( | PVMM_EPT_PAGE_TABLE | EptPageTable, |
SIZE_T | PhysicalAddress, | ||
BOOLEAN * | IsLargePage ) |
Get the PML1 entry for this physical address if the large page is available then large page of Pml2 is returned.
EptPageTable | The EPT Page Table |
PhysicalAddress | Physical address that we want to get its PML1 |
IsLargePage | Shows whether it's a large page or not |
EptPageTable | The EPT Page Table |
PhysicalAddress | Physical address that we want to get its PML1 |
IsLargePage | Shows whether it's a large page or not |
PEPT_PML2_ENTRY EptGetPml2Entry | ( | PVMM_EPT_PAGE_TABLE | EptPageTable, |
SIZE_T | PhysicalAddress ) |
Split 2MB (LargePage) into 4kb pages.
EptPageTable | The EPT Page Table |
PreAllocatedBuffer | The address of pre-allocated buffer |
PhysicalAddress | Physical address of where we want to split |
Split 2MB (LargePage) into 4kb pages.
EptPageTable | The EPT Page Table |
PhysicalAddress | Physical Address that we want to get its PML2 |
BOOLEAN EptHandleEptViolation | ( | VIRTUAL_MACHINE_STATE * | VCpu | ) |
Handle EPT Violation.
VCpu | The virtual processor's state |
Handle EPT Violation.
Violations are thrown whenever an operation is performed on an EPT entry that does not provide permissions to access that page
VCpu | The virtual processor's state |
Handle Ept Misconfigurations.
Handle Ept Misconfigurations.
GuestAddress |
BOOLEAN EptHandlePageHookExit | ( | _Inout_ VIRTUAL_MACHINE_STATE * | VCpu, |
_In_ VMX_EXIT_QUALIFICATION_EPT_VIOLATION | ViolationQualification, | ||
_In_ UINT64 | GuestPhysicalAddr ) |
Initialize EPT Table based on Processor Index.
Initialize EPT Table based on Processor Index.
Creates an identity mapped page table and sets up an EPTP to be applied to the VMCS later
VOID EptSetPML1AndInvalidateTLB | ( | _Inout_ VIRTUAL_MACHINE_STATE * | VCpu, |
_Out_ PEPT_PML1_ENTRY | EntryAddress, | ||
_In_ EPT_PML1_ENTRY | EntryValue, | ||
_In_ _Strict_type_match_ INVEPT_TYPE | InvalidationType ) |
This function set the specific PML1 entry in a spinlock protected area then invalidate the TLB , this function should be called from vmx root-mode.
EntryAddress | |
EntryValue | |
InvalidationType |
BOOLEAN EptSetupPML2Entry | ( | PVMM_EPT_PAGE_TABLE | EptPageTable, |
PEPT_PML2_ENTRY | NewEntry, | ||
SIZE_T | PageFrameNumber ) |
Set up PML2 Entries.
EptPageTable | |
NewEntry | The PML2 Entry |
PageFrameNumber | PFN (Physical Address) |
BOOLEAN EptSplitLargePage | ( | PVMM_EPT_PAGE_TABLE | EptPageTable, |
PVOID | PreAllocatedBuffer, | ||
SIZE_T | PhysicalAddress ) |
Convert 2MB pages to 4KB pages.
EptPageTable | |
PreAllocatedBuffer | |
PhysicalAddress |
Convert 2MB pages to 4KB pages.
EptPageTable | The EPT Page Table |
PreAllocatedBuffer | The address of pre-allocated buffer |
PhysicalAddress | Physical address of where we want to split |