HyperDbg Debugger
|
The implementation of functions relating to the Extended Page Table (a.k.a. EPT) More...
#include "pch.h"
Functions | |
BOOLEAN | EptCheckFeatures (VOID) |
Check whether EPT features are present or not. | |
UINT8 | EptGetMemoryType (SIZE_T PageFrameNumber, BOOLEAN IsLargePage) |
Check whether EPT features are present or not. | |
BOOLEAN | EptBuildMtrrMap (VOID) |
Build MTRR Map of current physical addresses. | |
PEPT_PML1_ENTRY | EptGetPml1Entry (PVMM_EPT_PAGE_TABLE EptPageTable, SIZE_T PhysicalAddress) |
Get the PML1 entry for this physical address if the page is split. | |
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. | |
PEPT_PML2_ENTRY | EptGetPml2Entry (PVMM_EPT_PAGE_TABLE EptPageTable, SIZE_T PhysicalAddress) |
Get the PML2 entry for this physical address. | |
BOOLEAN | EptSplitLargePage (PVMM_EPT_PAGE_TABLE EptPageTable, PVOID PreAllocatedBuffer, SIZE_T PhysicalAddress) |
Split 2MB (LargePage) into 4kb pages. | |
BOOLEAN | EptIsValidForLargePage (SIZE_T PageFrameNumber) |
Check if potential large page doesn't land on two or more different cache memory types. | |
BOOLEAN | EptSetupPML2Entry (PVMM_EPT_PAGE_TABLE EptPageTable, PEPT_PML2_ENTRY NewEntry, SIZE_T PageFrameNumber) |
Set up PML2 Entries. | |
PVMM_EPT_PAGE_TABLE | EptAllocateAndCreateIdentityPageTable (VOID) |
Allocates page maps and create identity page table. | |
BOOLEAN | EptLogicalProcessorInitialize (VOID) |
Initialize EPT for an individual logical processor. | |
_Use_decl_annotations_ BOOLEAN | EptHandlePageHookExit (VIRTUAL_MACHINE_STATE *VCpu, VMX_EXIT_QUALIFICATION_EPT_VIOLATION ViolationQualification, UINT64 GuestPhysicalAddr) |
Check if this exit is due to a violation caused by a currently hooked page. | |
BOOLEAN | EptHandleEptViolation (VIRTUAL_MACHINE_STATE *VCpu) |
Handle VM exits for EPT violations. | |
VOID | EptHandleMisconfiguration (VOID) |
Handle vm-exits for EPT Misconfiguration. | |
_Use_decl_annotations_ VOID | EptSetPML1AndInvalidateTLB (VIRTUAL_MACHINE_STATE *VCpu, PEPT_PML1_ENTRY EntryAddress, EPT_PML1_ENTRY EntryValue, INVEPT_TYPE InvalidationType) |
This function set the specific PML1 entry in a spinlock protected area then invalidate the TLB. | |
BOOLEAN | EptCheckAndHandleEptHookBreakpoints (VIRTUAL_MACHINE_STATE *VCpu, UINT64 GuestRip) |
Perform checking and handling if the breakpoint vm-exit relates to EPT hook or not. | |
BOOLEAN | EptCheckAndHandleBreakpoint (VIRTUAL_MACHINE_STATE *VCpu) |
Check if the breakpoint vm-exit relates to EPT hook or not. | |
The implementation of functions relating to the Extended Page Table (a.k.a. EPT)
Some of the codes are re-used from Gbps/gbhv (https://github.com/Gbps/gbhv)
PVMM_EPT_PAGE_TABLE EptAllocateAndCreateIdentityPageTable | ( | VOID | ) |
Allocates page maps and create identity page table.
Build MTRR Map of current physical addresses.
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 |
BOOLEAN EptCheckAndHandleEptHookBreakpoints | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
UINT64 | GuestRip ) |
Perform checking and handling if the breakpoint vm-exit relates to EPT hook or not.
VCpu | The virtual processor's state |
GuestRip |
Check whether EPT features are present or not.
Check for EPT Features.
Check whether EPT features are present or not.
PageFrameNumber | |
IsLargePage |
PEPT_PML1_ENTRY EptGetPml1Entry | ( | PVMM_EPT_PAGE_TABLE | EptPageTable, |
SIZE_T | PhysicalAddress ) |
Get the PML1 entry for this physical address if the page is split.
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 |
PEPT_PML2_ENTRY EptGetPml2Entry | ( | PVMM_EPT_PAGE_TABLE | EptPageTable, |
SIZE_T | PhysicalAddress ) |
Get the PML2 entry for this physical address.
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 VM exits for EPT violations.
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 vm-exits for EPT Misconfiguration.
Handle Ept Misconfigurations.
GuestAddress |
_Use_decl_annotations_ BOOLEAN EptHandlePageHookExit | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
VMX_EXIT_QUALIFICATION_EPT_VIOLATION | ViolationQualification, | ||
UINT64 | GuestPhysicalAddr ) |
Check if this exit is due to a violation caused by a currently hooked page.
If the memory access attempt was RW and the page was marked executable, the page is swapped with the original page.
If the memory access attempt was execute and the page was marked not executable, the page is swapped with the hooked page.
VCpu | The virtual processor's state * |
ViolationQualification | The violation qualification in vm-exit |
GuestPhysicalAddr | The GUEST_PHYSICAL_ADDRESS that caused this EPT violation |
BOOLEAN EptIsValidForLargePage | ( | SIZE_T | PageFrameNumber | ) |
Check if potential large page doesn't land on two or more different cache memory types.
PageFrameNumber | PFN (Physical Address) |
Initialize EPT for an individual logical processor.
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
_Use_decl_annotations_ VOID EptSetPML1AndInvalidateTLB | ( | VIRTUAL_MACHINE_STATE * | VCpu, |
PEPT_PML1_ENTRY | EntryAddress, | ||
EPT_PML1_ENTRY | EntryValue, | ||
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
VCpu | The virtual processor's state |
EntryAddress | PML1 entry information (the target address) |
EntryValue | The value of pm1's entry (the value that should be replaced) |
InvalidationType | type of invalidation |
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 ) |
Split 2MB (LargePage) into 4kb pages.
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 |