HyperPlatform Programmer's Reference
|
Declares interfaces to utility functions. More...
#include "ia32_type.h"
Go to the source code of this file.
Classes | |
struct | PhysicalMemoryRun |
Represents ranges of addresses. More... | |
struct | PhysicalMemoryDescriptor |
Represents a physical memory ranges of the system. More... | |
Enumerations | |
enum | VmxStatus : unsigned __int8 { VmxStatus::kOk = 0, VmxStatus::kErrorWithStatus = 1, VmxStatus::kErrorWithoutStatus = 2 } |
Indicates a result of VMX-instructions. More... | |
enum | HypercallNumber : unsigned __int32 { HypercallNumber::kTerminateVmm, HypercallNumber::kPingVmm, HypercallNumber::kGetSharedProcessorData } |
Available command numbers for VMCALL. More... | |
Functions | |
constexpr VmxStatus | operator|= (_In_ VmxStatus lhs, _In_ VmxStatus rhs) |
Provides |= operator for VmxStatus. More... | |
NTSTATUS | UtilInitialization (_In_ PDRIVER_OBJECT driver_object) |
Makes the Util functions ready for use. More... | |
void | UtilTermination () |
Frees all resources allocated for the sake of the Util functions. More... | |
void * | UtilPcToFileHeader (_In_ void *address) |
Returns a module base address of address. More... | |
const PhysicalMemoryDescriptor * | UtilGetPhysicalMemoryRanges () |
Returns ranges of physical memory on the system. More... | |
NTSTATUS | UtilForEachProcessor (_In_ NTSTATUS(*callback_routine)(void *), _In_opt_ void *context) |
Executes callback_routine on each processor. More... | |
NTSTATUS | UtilForEachProcessorDpc (_In_ PKDEFERRED_ROUTINE deferred_routine, _In_opt_ void *context) |
Queues deferred_routine on all processors. More... | |
NTSTATUS | UtilSleep (_In_ LONG millisecond) |
Suspends the execution of the current thread. More... | |
void * | UtilMemMem (_In_ const void *search_base, _In_ SIZE_T search_size, _In_ const void *pattern, _In_ SIZE_T pattern_size) |
Searches a byte pattern from a given address range. More... | |
void * | UtilGetSystemProcAddress (_In_ const wchar_t *proc_name) |
Get an address of an exported symbol by the kernel or HAL. More... | |
bool | UtilIsX86Pae () |
Checks if the system is a PAE-enabled x86 system. More... | |
bool | UtilIsAccessibleAddress (_In_ void *address) |
Checks is the address is present on physical memory. More... | |
ULONG64 | UtilPaFromVa (_In_ void *va) |
VA -> PA. More... | |
PFN_NUMBER | UtilPfnFromVa (_In_ void *va) |
VA -> PFN. More... | |
PFN_NUMBER | UtilPfnFromPa (_In_ ULONG64 pa) |
PA -> PFN. More... | |
void * | UtilVaFromPa (_In_ ULONG64 pa) |
PA -> VA. More... | |
ULONG64 | UtilPaFromPfn (_In_ PFN_NUMBER pfn) |
PNF -> PA. More... | |
void * | UtilVaFromPfn (_In_ PFN_NUMBER pfn) |
PNF -> VA. More... | |
void * | UtilAllocateContiguousMemory (_In_ SIZE_T number_of_bytes) |
Allocates continuous physical memory. More... | |
void | UtilFreeContiguousMemory (_In_ void *base_address) |
Frees an address allocated by UtilAllocateContiguousMemory() More... | |
NTSTATUS | UtilVmCall (_In_ HypercallNumber hypercall_number, _In_opt_ void *context) |
Executes VMCALL. More... | |
void | UtilDumpGpRegisters (_In_ const AllRegisters *all_regs, _In_ ULONG_PTR stack_pointer) |
Debug prints registers. More... | |
ULONG_PTR | UtilVmRead (_In_ VmcsField field) |
Reads natural-width VMCS. More... | |
ULONG64 | UtilVmRead64 (_In_ VmcsField field) |
Reads 64bit-width VMCS. More... | |
VmxStatus | UtilVmWrite (_In_ VmcsField field, _In_ ULONG_PTR field_value) |
Writes natural-width VMCS. More... | |
VmxStatus | UtilVmWrite64 (_In_ VmcsField field, _In_ ULONG64 field_value) |
Writes 64bit-width VMCS. More... | |
ULONG_PTR | UtilReadMsr (_In_ Msr msr) |
Reads natural-width MSR. More... | |
ULONG64 | UtilReadMsr64 (_In_ Msr msr) |
Reads 64bit-width MSR. More... | |
void | UtilWriteMsr (_In_ Msr msr, _In_ ULONG_PTR value) |
Writes natural-width MSR. More... | |
void | UtilWriteMsr64 (_In_ Msr msr, _In_ ULONG64 value) |
Writes 64bit-width MSR. More... | |
VmxStatus | UtilInveptGlobal () |
Executes the INVEPT instruction and invalidates EPT entry cache. More... | |
VmxStatus | UtilInvvpidIndividualAddress (_In_ USHORT vpid, _In_ void *address) |
Executes the INVVPID instruction (type 0) More... | |
VmxStatus | UtilInvvpidSingleContext (_In_ USHORT vpid) |
Executes the INVVPID instruction (type 1) More... | |
VmxStatus | UtilInvvpidAllContext () |
Executes the INVVPID instruction (type 2) More... | |
VmxStatus | UtilInvvpidSingleContextExceptGlobal (_In_ USHORT vpid) |
Executes the INVVPID instruction (type 3) More... | |
void | UtilLoadPdptes (_In_ ULONG_PTR cr3_value) |
Loads the PDPTE registers from CR3 to VMCS. More... | |
NTSTATUS | UtilForceCopyMemory (_In_ void *destination, _In_ const void *source, _In_ SIZE_T length) |
Does RtlCopyMemory safely even if destination is a read only region. More... | |
template<typename T > | |
constexpr bool | UtilIsInBounds (_In_ const T &value, _In_ const T &min, _In_ const T &max) |
Tests if value is in between min and max. More... | |
Declares interfaces to utility functions.
Definition in file util.h.
|
strong |
|
strong |
void* UtilAllocateContiguousMemory | ( | _In_ SIZE_T | number_of_bytes | ) |
Allocates continuous physical memory.
number_of_bytes | A size to allocate |
A returned value must be freed with UtilFreeContiguousMemory().
void UtilDumpGpRegisters | ( | _In_ const AllRegisters * | all_regs, |
_In_ ULONG_PTR | stack_pointer | ||
) |
Debug prints registers.
all_regs | Registers to print out |
stack_pointer | A stack pointer before calling this function |
NTSTATUS UtilForceCopyMemory | ( | _In_ void * | destination, |
_In_ const void * | source, | ||
_In_ SIZE_T | length | ||
) |
Does RtlCopyMemory safely even if destination is a read only region.
destination | A destination address |
source | A source address |
length | A size to copy in bytes |
NTSTATUS UtilForEachProcessor | ( | _In_ NTSTATUS(*)(void *) | callback_routine, |
_In_opt_ void * | context | ||
) |
Executes callback_routine on each processor.
callback_routine | A function to execute |
context | An arbitrary parameter for callback_routine |
NTSTATUS UtilForEachProcessorDpc | ( | _In_ PKDEFERRED_ROUTINE | deferred_routine, |
_In_opt_ void * | context | ||
) |
Queues deferred_routine on all processors.
deferred_routine | A DPC routine to be queued |
context | An arbitrary parameter for deferred_routine |
deferred_routine must free the pointer to a DPC structure like this: ExFreePoolWithTag(dpc, kHyperPlatformCommonPoolTag).
void UtilFreeContiguousMemory | ( | _In_ void * | base_address | ) |
Frees an address allocated by UtilAllocateContiguousMemory()
base_address | A return value of UtilAllocateContiguousMemory() to free |
const PhysicalMemoryDescriptor* UtilGetPhysicalMemoryRanges | ( | ) |
void* UtilGetSystemProcAddress | ( | _In_ const wchar_t * | proc_name | ) |
Get an address of an exported symbol by the kernel or HAL.
proc_name | A name of a symbol to locate an address |
NTSTATUS UtilInitialization | ( | _In_ PDRIVER_OBJECT | driver_object | ) |
Makes the Util functions ready for use.
driver_object | The current driver's driver object |
VmxStatus UtilInveptGlobal | ( | ) |
VmxStatus UtilInvvpidAllContext | ( | ) |
VmxStatus UtilInvvpidIndividualAddress | ( | _In_ USHORT | vpid, |
_In_ void * | address | ||
) |
Executes the INVVPID instruction (type 0)
VmxStatus UtilInvvpidSingleContext | ( | _In_ USHORT | vpid | ) |
Executes the INVVPID instruction (type 1)
VmxStatus UtilInvvpidSingleContextExceptGlobal | ( | _In_ USHORT | vpid | ) |
Executes the INVVPID instruction (type 3)
bool UtilIsAccessibleAddress | ( | _In_ void * | address | ) |
Checks is the address is present on physical memory.
address | A virtual address to test |
constexpr bool UtilIsInBounds | ( | _In_ const T & | value, |
_In_ const T & | min, | ||
_In_ const T & | max | ||
) |
bool UtilIsX86Pae | ( | ) |
void UtilLoadPdptes | ( | _In_ ULONG_PTR | cr3_value | ) |
Loads the PDPTE registers from CR3 to VMCS.
cr3_value | CR3 value to retrieve PDPTEs |
void* UtilMemMem | ( | _In_ const void * | search_base, |
_In_ SIZE_T | search_size, | ||
_In_ const void * | pattern, | ||
_In_ SIZE_T | pattern_size | ||
) |
Searches a byte pattern from a given address range.
search_base | An address to start search |
search_size | A length to search in bytes |
pattern | A byte pattern to search |
pattern_size | A size of pattern |
ULONG64 UtilPaFromPfn | ( | _In_ PFN_NUMBER | pfn | ) |
PNF -> PA.
pfn | A page frame number to get its physical address |
ULONG64 UtilPaFromVa | ( | _In_ void * | va | ) |
VA -> PA.
va | A virtual address to get its physical address |
void* UtilPcToFileHeader | ( | _In_ void * | address | ) |
Returns a module base address of address.
address | An address to get a base address |
PFN_NUMBER UtilPfnFromPa | ( | _In_ ULONG64 | pa | ) |
PA -> PFN.
pa | A physical address to get its page frame number |
PFN_NUMBER UtilPfnFromVa | ( | _In_ void * | va | ) |
VA -> PFN.
va | A virtual address to get its physical address |
ULONG_PTR UtilReadMsr | ( | _In_ Msr | msr | ) |
Reads natural-width MSR.
msr | MSR to read |
ULONG64 UtilReadMsr64 | ( | _In_ Msr | msr | ) |
Reads 64bit-width MSR.
msr | MSR to read |
NTSTATUS UtilSleep | ( | _In_ LONG | millisecond | ) |
Suspends the execution of the current thread.
millisecond | Time to suspend in milliseconds |
void UtilTermination | ( | ) |
void* UtilVaFromPa | ( | _In_ ULONG64 | pa | ) |
PA -> VA.
pa | A physical address to get its virtual address |
void* UtilVaFromPfn | ( | _In_ PFN_NUMBER | pfn | ) |
PNF -> VA.
pfn | A page frame number to get its virtual address |
NTSTATUS UtilVmCall | ( | _In_ HypercallNumber | hypercall_number, |
_In_opt_ void * | context | ||
) |
Executes VMCALL.
hypercall_number | A command number |
context | An arbitrary parameter |
ULONG_PTR UtilVmRead | ( | _In_ VmcsField | field | ) |
Reads natural-width VMCS.
field | VMCS-field to read |
ULONG64 UtilVmRead64 | ( | _In_ VmcsField | field | ) |
Reads 64bit-width VMCS.
field | VMCS-field to read |
Writes natural-width VMCS.
field | VMCS-field to write |
field_value | A value to write |
Writes 64bit-width VMCS.
field | VMCS-field to write |
field_value | A value to write |
void UtilWriteMsr | ( | _In_ Msr | msr, |
_In_ ULONG_PTR | value | ||
) |
Writes natural-width MSR.
msr | MSR to write |
value | A value to write |
void UtilWriteMsr64 | ( | _In_ Msr | msr, |
_In_ ULONG64 | value | ||
) |
Writes 64bit-width MSR.
msr | MSR to write |
value | A value to write |