8 #ifndef HYPERPLATFORM_ASM_H_ 9 #define HYPERPLATFORM_ASM_H_ 39 _In_
void (*vm_initialization_routine)(_In_ ULONG_PTR, _In_ ULONG_PTR,
41 _In_opt_
void *context);
50 unsigned char __stdcall
AsmVmxCall(_In_ ULONG_PTR hypercall_number,
51 _In_opt_
void *context);
67 void __stdcall
AsmWriteTR(_In_ USHORT task_register);
75 void __stdcall
AsmWriteES(_In_ USHORT segment_selector);
83 void __stdcall
AsmWriteCS(_In_ USHORT segment_selector);
91 void __stdcall
AsmWriteSS(_In_ USHORT segment_selector);
99 void __stdcall
AsmWriteDS(_In_ USHORT segment_selector);
107 void __stdcall
AsmWriteFS(_In_ USHORT segment_selector);
115 void __stdcall
AsmWriteGS(_In_ USHORT segment_selector);
131 void __stdcall
AsmWriteCR2(_In_ ULONG_PTR cr2_value);
175 inline unsigned char __vmx_on(
176 _In_
unsigned __int64 *vms_support_physical_address) {
178 PHYSICAL_ADDRESS physical_address = {};
179 physical_address.QuadPart = *vms_support_physical_address;
181 push physical_address.HighPart
182 push physical_address.LowPart
208 inline unsigned char __vmx_vmclear(
209 _In_
unsigned __int64 *vmcs_physical_address) {
211 PHYSICAL_ADDRESS physical_address = {};
212 physical_address.QuadPart = *vmcs_physical_address;
214 push physical_address.HighPart
215 push physical_address.LowPart
239 inline unsigned char __vmx_vmlaunch() {
262 inline unsigned char __vmx_vmptrld(
263 _In_
unsigned __int64 *vmcs_physical_address) {
265 PHYSICAL_ADDRESS physical_address = {};
266 physical_address.QuadPart = *vmcs_physical_address;
268 push physical_address.HighPart
269 push physical_address.LowPart
295 inline unsigned char __vmx_vmread(_In_
size_t field,
296 _Out_
size_t *field_value) {
326 inline unsigned char __vmx_vmwrite(_In_
size_t field, _In_
size_t field_value) {
357 #endif // HYPERPLATFORM_ASM_H_ void __stdcall AsmWriteCS(_In_ USHORT segment_selector)
Writes to CS.
void __stdcall AsmWriteFS(_In_ USHORT segment_selector)
Writes to FS.
USHORT __stdcall AsmReadGS()
Reads GS.
USHORT __stdcall AsmReadCS()
Reads CS.
USHORT __stdcall AsmReadTR()
Reads STR.
USHORT __stdcall AsmReadDS()
Reads DS.
ULONG_PTR cf
[0] Carry flag
InvVpidType
See: INVVPID Descriptor.
void __stdcall AsmWriteGDT(_In_ const Gdtr *gdtr)
Writes to GDT.
USHORT __stdcall AsmReadES()
Reads ES.
void __sgdt(_Out_ void *gdtr)
Writes to GDT.
void __stdcall AsmReadGDT(_Out_ Gdtr *gdtr)
Reads SGDT.
InvEptType
See: INVEPT Descriptor.
bool __stdcall AsmInitializeVm(_In_ void(*vm_initialization_routine)(_In_ ULONG_PTR, _In_ ULONG_PTR, _In_opt_ void *), _In_opt_ void *context)
A wrapper for vm_initialization_routine.
struct FlagRegister::@1 fields
USHORT __stdcall AsmReadLDTR()
Reads SLDT.
unsigned char __stdcall AsmVmxCall(_In_ ULONG_PTR hypercall_number, _In_opt_ void *context)
Executes VMCALL with the given hypercall number and a context.
USHORT __stdcall AsmReadSS()
Reads SS.
void __stdcall AsmWriteTR(_In_ USHORT task_register)
Writes to TR.
unsigned char __stdcall AsmInvept(_In_ InvEptType invept_type, _In_ const InvEptDescriptor *invept_descriptor)
Invalidates translations derived from EPT.
See: SYSTEM FLAGS AND FIELDS IN THE EFLAGS REGISTER.
ULONG_PTR zf
[6] Zero flag
USHORT __stdcall AsmReadFS()
Reads FS.
void __stdcall AsmWriteGS(_In_ USHORT segment_selector)
Writes to GS.
ULONG_PTR __stdcall AsmLoadAccessRightsByte(_In_ ULONG_PTR segment_selector)
Loads access rights byte.
void __stdcall AsmWriteSS(_In_ USHORT segment_selector)
Writes to SS.
Defines constants and structures defined by the x86-64 architecture.
unsigned char __stdcall AsmInvvpid(_In_ InvVpidType invvpid_type, _In_ const InvVpidDescriptor *invvpid_descriptor)
Invalidate translations based on VPID.
void __stdcall AsmVmmEntryPoint()
An entry point of VMM where gets called whenever VM-exit occurred.
void __stdcall AsmWriteCR2(_In_ ULONG_PTR cr2_value)
Writes to CR2.
void __lgdt(_In_ void *gdtr)
Reads SGDT.
See: MEMORY-MANAGEMENT REGISTERS.
void __stdcall AsmInvalidateInternalCaches()
Invalidates internal caches.
void __stdcall AsmWriteES(_In_ USHORT segment_selector)
Writes to ES.
void __stdcall AsmWriteDS(_In_ USHORT segment_selector)
Writes to DS.