Add files via upload
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#include <ntifs.h>
|
||||
#include "VTUtils.h"
|
||||
#include "Vmx.h"
|
||||
#include "VTHandler.h"
|
||||
|
||||
VOID DriverUnload(PDRIVER_OBJECT pDriver)
|
||||
{
|
||||
VmxDisableOff(TRUE);
|
||||
UNREFERENCED_PARAMETER(pDriver);
|
||||
}
|
||||
|
||||
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriver, PUNICODE_STRING pReg)
|
||||
{
|
||||
BOOLEAN intelCpu;
|
||||
BOOLEAN cpuidVmx;
|
||||
BOOLEAN biosVmx;
|
||||
BOOLEAN vmxEnabled;
|
||||
|
||||
UNREFERENCED_PARAMETER(pReg);
|
||||
|
||||
intelCpu = VMXIsIntelCpu();
|
||||
cpuidVmx = intelCpu && VMXIsCpuidVT();
|
||||
biosVmx = cpuidVmx && VMXIsBiosVT();
|
||||
vmxEnabled = cpuidVmx && VMXIsEnabled();
|
||||
|
||||
DbgPrintEx(77, 0, "[vt_detect] Result: Intel=%s, VMX=%s, BIOS=%s, VMXE=%s\r\n",
|
||||
intelCpu ? "TRUE" : "FALSE",
|
||||
cpuidVmx ? "TRUE" : "FALSE",
|
||||
biosVmx ? "TRUE" : "FALSE",
|
||||
vmxEnabled ? "TRUE" : "FALSE");
|
||||
|
||||
if (intelCpu && cpuidVmx && biosVmx)
|
||||
{
|
||||
DbgPrintEx(77, 0, "[db]:Support VT\r\n");
|
||||
|
||||
if (VmxInit((ULONG64)(ULONG_PTR)AsmVmxExitHandler))
|
||||
{
|
||||
VMXGetCurrentVCpu()->isStartSuccess = TRUE;
|
||||
DbgPrintEx(77, 0, "[db]:VMXON success\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgPrintEx(77, 0, "[db]:VMXON failed\r\n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
DbgPrintEx(77, 0, "[db]:Unsupport VT\r\n");
|
||||
}
|
||||
|
||||
pDriver->DriverUnload = DriverUnload;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
+344
@@ -0,0 +1,344 @@
|
||||
#include "VTHandler.h"
|
||||
#include "vtdef.h"
|
||||
#include "VTUtils.h"
|
||||
#include "vmxs.h"
|
||||
#include "Vmx.h"
|
||||
|
||||
#define REG_MAKE(HH,CC) ((CC<<32) | (HH & 0xffffffff))
|
||||
|
||||
VOID VmxHandlerCpuid(PGUEST_CONTEXT context)
|
||||
{
|
||||
ULONG64 functionNumber = context->mRax;
|
||||
ULONG64 leaf = context->mRcx;
|
||||
|
||||
if (functionNumber == 0x12345678)
|
||||
{
|
||||
context->mRax = 0x11111111;
|
||||
context->mRbx = 0x22222222;
|
||||
context->mRcx = 0x33333333;
|
||||
context->mRdx = 0x44444444;
|
||||
|
||||
//VmxSetMTF(TRUE);
|
||||
//VMXExitIntEvent eventInfo = {0};
|
||||
//eventInfo.vaild = 1;
|
||||
//eventInfo.vector = 0;
|
||||
//eventInfo.type = 7;
|
||||
//
|
||||
//__vmx_vmwrite(VM_ENTRY_INTR_INFO_FIELD, *(PULONG64)&eventInfo);
|
||||
//__vmx_vmwrite(VM_ENTRY_INSTRUCTION_LEN, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
int cpuinfo[4] = { 0 };
|
||||
__cpuidex(cpuinfo, (int)functionNumber, (int)leaf);
|
||||
|
||||
context->mRax = cpuinfo[0];
|
||||
context->mRbx = cpuinfo[1];
|
||||
context->mRcx = cpuinfo[2];
|
||||
context->mRdx = cpuinfo[3];
|
||||
}
|
||||
}
|
||||
VOID VmxHandlerInvpcid(PGUEST_CONTEXT context)
|
||||
{
|
||||
ULONG64 guestRsp = VmxReadField(GUEST_RSP);
|
||||
ULONG64 qualification = VmxReadField(EXIT_QUALIFICATION);
|
||||
ULONG64 info = VmxReadField(VMX_INSTRUCTION_INFO);
|
||||
PINVPCID pcidinfo = (PINVPCID)&info;
|
||||
|
||||
PULONG64 regs = (PLONG64)context;
|
||||
|
||||
ULONG64 optIndex = pcidinfo->regOpt;
|
||||
|
||||
//invcpid rsp, dword ptr ds : [rax + rsi*scale + 0xc];
|
||||
|
||||
ULONG64 base = 0;
|
||||
ULONG64 index = 0;
|
||||
|
||||
if (!pcidinfo->baseInvaild)
|
||||
{
|
||||
if (pcidinfo->base == 4)
|
||||
{
|
||||
base = guestRsp;
|
||||
}
|
||||
else
|
||||
{
|
||||
base = regs[pcidinfo->base];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!pcidinfo->indexInvaild)
|
||||
{
|
||||
if (pcidinfo->index == 4)
|
||||
{
|
||||
index = guestRsp;
|
||||
}
|
||||
else
|
||||
{
|
||||
index = regs[pcidinfo->index];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (pcidinfo->scale)
|
||||
{
|
||||
index = index * (1ULL << pcidinfo->scale);
|
||||
}
|
||||
|
||||
base = base + index + qualification;
|
||||
|
||||
//ULONG64 value = 0;
|
||||
//
|
||||
//if (pcidinfo->addrssSize == 0)
|
||||
//{
|
||||
// value = *(PUSHORT)base;
|
||||
//}
|
||||
//else if (pcidinfo->addrssSize == 1)
|
||||
//{
|
||||
// value = *(PULONG)base;
|
||||
//}
|
||||
//else if (pcidinfo->addrssSize == 2)
|
||||
//{
|
||||
// value = *(PULONG64)base;
|
||||
//}
|
||||
|
||||
if (optIndex == 4)
|
||||
{
|
||||
_invpcid((ULONG)guestRsp, (PVOID)(ULONG_PTR)base);
|
||||
}
|
||||
else
|
||||
{
|
||||
_invpcid((ULONG)regs[optIndex], (PVOID)(ULONG_PTR)base);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
VOID VmxHandlerException(PGUEST_CONTEXT context)
|
||||
{
|
||||
ULONG64 guestRip = VmxReadField(GUEST_RIP);
|
||||
ULONG64 guestRsp = VmxReadField(GUEST_RSP);
|
||||
ULONG64 codelen = VmxReadField(VM_EXIT_INSTRUCTION_LEN);
|
||||
|
||||
ULONG64 info = VmxReadField(VM_EXIT_INTR_INFO);
|
||||
ULONG64 error = VmxReadField(VM_EXIT_INTR_ERROR_CODE);
|
||||
|
||||
PVMXExitIntEvent eventInfo = (PVMXExitIntEvent)&info;
|
||||
|
||||
if (!eventInfo->vaild)
|
||||
{
|
||||
__vmx_vmwrite(GUEST_RIP, guestRip + codelen);
|
||||
__vmx_vmwrite(GUEST_RSP, guestRsp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (eventInfo->errorCode)
|
||||
{
|
||||
__vmx_vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, error);
|
||||
}
|
||||
|
||||
|
||||
switch (eventInfo->type)
|
||||
{
|
||||
case EXCEPTION_W_INT:
|
||||
break;
|
||||
case EXCEPTION_NMI_INT:
|
||||
break;
|
||||
case EXCEPTION_HARDWARE:
|
||||
{
|
||||
if (eventInfo->vector == 0xe)
|
||||
{
|
||||
ULONG64 liner = VmxReadField(GUEST_LINEAR_ADDRESS);
|
||||
ULONG64 expcetionAddress = VmxReadField(EXIT_QUALIFICATION);
|
||||
AsmWriteCr2(expcetionAddress);
|
||||
DbgPrintEx(77, 0, "[db]:page fault ouccur \r\n");
|
||||
|
||||
__vmx_vmwrite(VM_ENTRY_INTR_INFO_FIELD, info);
|
||||
__vmx_vmwrite(VM_ENTRY_INSTRUCTION_LEN, codelen);
|
||||
|
||||
codelen = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EXCEPTION_SOFT:
|
||||
{
|
||||
if (eventInfo->vector == 3)
|
||||
{
|
||||
DbgPrintEx(77, 0, "[db]:int 3 \r\n");
|
||||
//eventInfo->vector = 0x1d;
|
||||
__vmx_vmwrite(VM_ENTRY_INTR_INFO_FIELD, info);
|
||||
__vmx_vmwrite(VM_ENTRY_INSTRUCTION_LEN, codelen);
|
||||
codelen = 0;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
__vmx_vmwrite(GUEST_RIP, guestRip + codelen);
|
||||
__vmx_vmwrite(GUEST_RSP, guestRsp);
|
||||
return;
|
||||
}
|
||||
VOID VmxHandlerMTF(PGUEST_CONTEXT context)
|
||||
{
|
||||
__debugbreak();
|
||||
ULONG64 guestRip = VmxReadField(GUEST_RIP);
|
||||
ULONG64 guestRsp = VmxReadField(GUEST_RSP);
|
||||
ULONG64 codelen = VmxReadField(VM_EXIT_INSTRUCTION_LEN);
|
||||
VmxSetMTF(FALSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
EXTERN_C ULONG VmxExitHandler(PGUEST_CONTEXT context) {
|
||||
ULONG reason = (ULONG)(VmxReadField(VM_EXIT_REASON) & 0xFFFF);
|
||||
ULONG64 guestRip = VmxReadField(GUEST_RIP);
|
||||
ULONG64 guestRsp = VmxReadField(GUEST_RSP);
|
||||
ULONG64 codelen = VmxReadField(VM_EXIT_INSTRUCTION_LEN);
|
||||
|
||||
|
||||
switch (reason)
|
||||
{
|
||||
|
||||
|
||||
case EXIT_REASON_MTF:
|
||||
{
|
||||
VmxHandlerMTF(context);
|
||||
codelen = 0;
|
||||
}break;
|
||||
case EXIT_REASON_EXCEPTION_NMI:
|
||||
{
|
||||
VmxHandlerException(context);
|
||||
return 0;
|
||||
}break;
|
||||
case EXIT_REASON_CPUID:
|
||||
{
|
||||
VmxHandlerCpuid(context);
|
||||
}break;
|
||||
case EXIT_REASON_VMCALL:
|
||||
{
|
||||
if (context->mRax == 'exit')
|
||||
{
|
||||
|
||||
GdtTable gdtTable = { 0 };
|
||||
GdtTable idtTable = { 0 };
|
||||
gdtTable.Base = VmxReadField(GUEST_GDTR_BASE);
|
||||
gdtTable.limit = VmxReadField(GUEST_GDTR_LIMIT);
|
||||
idtTable.Base = VmxReadField(GUEST_IDTR_BASE);
|
||||
idtTable.limit = VmxReadField(GUEST_IDTR_LIMIT);
|
||||
ULONG64 eflgs = VmxReadField(GUEST_RFLAGS);
|
||||
VmxExitRip = guestRip + codelen;
|
||||
VmxExitRsp = guestRsp;
|
||||
__vmx_off();
|
||||
|
||||
__lidt(&idtTable);
|
||||
AsmLgdt(&gdtTable);
|
||||
__writeeflags(eflgs);
|
||||
//��ԭRIP��RSP
|
||||
|
||||
PVCPU vcpu = VMXGetCurrentVCpu();
|
||||
vcpu->isStartSuccess = FALSE;
|
||||
//if (vmxCpu->cpuNumber == 0)
|
||||
//{
|
||||
// DbgBreakPoint();
|
||||
//}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ULONG64 flags = VmxReadField(GUEST_RFLAGS);
|
||||
flags |= 0x41;
|
||||
__vmx_vmwrite(GUEST_RFLAGS, flags);
|
||||
}
|
||||
|
||||
}break;
|
||||
|
||||
case EXIT_REASON_VMCLEAR:
|
||||
case EXIT_REASON_VMLAUNCH:
|
||||
case EXIT_REASON_VMPTRLD:
|
||||
case EXIT_REASON_VMPTRST:
|
||||
case EXIT_REASON_VMREAD:
|
||||
case EXIT_REASON_VMRESUME:
|
||||
case EXIT_REASON_VMWRITE:
|
||||
case EXIT_REASON_VMXOFF:
|
||||
case EXIT_REASON_VMXON:
|
||||
{
|
||||
ULONG64 flags = VmxReadField(GUEST_RFLAGS);
|
||||
flags |= 0x41;
|
||||
__vmx_vmwrite(GUEST_RFLAGS, flags);
|
||||
|
||||
}break;
|
||||
case EXIT_REASON_INVD:
|
||||
{
|
||||
AsmInvd();
|
||||
}break;
|
||||
case EXIT_REASON_XSETBV:
|
||||
{
|
||||
DbgPrintEx(77, 0, "[db]:XSETBV\r\n");
|
||||
ULONG64 value = REG_MAKE(context->mRax, context->mRdx);
|
||||
_xsetbv(context->mRcx, value);
|
||||
}break;
|
||||
case EXIT_REASON_MSR_READ:
|
||||
{
|
||||
DbgPrintEx(77, 0, "[db]:msr index = %ll\r\n", context->mRcx);
|
||||
ULONG64 value = __readmsr(context->mRcx);
|
||||
context->mRax = value & 0xffffffff;
|
||||
context->mRdx = (value >> 32) & 0xffffffff;
|
||||
}break;
|
||||
case EXIT_REASON_MSR_WRITE:
|
||||
{
|
||||
ULONG msr = (ULONG)context->mRcx;
|
||||
ULONG64 value =
|
||||
((context->mRdx & 0xffffffffULL) << 32) |
|
||||
(context->mRax & 0xffffffffULL);
|
||||
|
||||
DbgPrintEx(77, 0,
|
||||
"[db]:WRMSR index=0x%08X value=0x%I64X\r\n",
|
||||
msr,
|
||||
value);
|
||||
|
||||
__writemsr(msr, value);
|
||||
}break;
|
||||
case EXIT_REASON_RDTSCP:
|
||||
{
|
||||
DbgPrintEx(77, 0, "[db]:RDTSCP\r\n");
|
||||
int x = 0;
|
||||
LARGE_INTEGER inTime = { 0 };
|
||||
inTime.QuadPart = __rdtscp(&x);
|
||||
|
||||
context->mRax = inTime.LowPart;
|
||||
context->mRdx = inTime.HighPart;
|
||||
context->mRcx = x;
|
||||
|
||||
}break;
|
||||
case EXIT_REASON_INVPCID:
|
||||
{
|
||||
|
||||
DbgPrintEx(77, 0, "[db]:INVPCID\r\n");
|
||||
|
||||
VmxHandlerInvpcid(context);
|
||||
|
||||
|
||||
|
||||
}break;
|
||||
|
||||
}
|
||||
|
||||
__vmx_vmwrite(GUEST_RIP, guestRip + codelen);
|
||||
__vmx_vmwrite(GUEST_RSP, guestRsp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
EXTERN_C void MyOpenProcess(PGUEST_CONTEXT context) {
|
||||
|
||||
}
|
||||
|
||||
EXTERN_C void JmpOpenProcessRet(PGUEST_CONTEXT context) {
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
#include <ntifs.h>
|
||||
|
||||
#define EXCEPTION_W_INT 0
|
||||
#define EXCEPTION_NMI_INT 2
|
||||
#define EXCEPTION_HARDWARE 3
|
||||
#define EXCEPTION_SOFT 6
|
||||
typedef struct _GUEST_CONTEXT
|
||||
{
|
||||
ULONG64 mRax;
|
||||
ULONG64 mRcx;
|
||||
ULONG64 mRdx;
|
||||
ULONG64 mRbx;
|
||||
ULONG64 mRsp;
|
||||
ULONG64 mRbp;
|
||||
ULONG64 mRsi;
|
||||
ULONG64 mRdi;
|
||||
ULONG64 mR8;
|
||||
ULONG64 mR9;
|
||||
ULONG64 mR10;
|
||||
ULONG64 mR11;
|
||||
ULONG64 mR12;
|
||||
ULONG64 mR13;
|
||||
ULONG64 mR14;
|
||||
ULONG64 mR15;
|
||||
}GUEST_CONTEXT, * PGUEST_CONTEXT;
|
||||
|
||||
typedef struct _INVPCID
|
||||
{
|
||||
ULONG64 scale : 2;
|
||||
ULONG64 und : 5;
|
||||
ULONG64 addrssSize : 3;
|
||||
ULONG64 rev1 : 1;
|
||||
ULONG64 und2 : 4;
|
||||
ULONG64 segement : 3;
|
||||
ULONG64 index : 4;
|
||||
ULONG64 indexInvaild : 1;
|
||||
ULONG64 base : 4;
|
||||
ULONG64 baseInvaild : 1;
|
||||
ULONG64 regOpt : 4;
|
||||
ULONG64 un3 : 32;
|
||||
}INVPCID, * PINVPCID;
|
||||
|
||||
typedef struct _VMXExitIntEvent
|
||||
{
|
||||
ULONG64 vector : 8;
|
||||
ULONG64 type : 3;
|
||||
ULONG64 errorCode : 1;
|
||||
ULONG64 NMIUNBlocking : 1;
|
||||
ULONG64 reun : 18;
|
||||
ULONG64 vaild : 1;
|
||||
ULONG64 reun2 : 32;
|
||||
}VMXExitIntEvent, * PVMXExitIntEvent;
|
||||
|
||||
|
||||
|
||||
|
||||
EXTERN_C ULONG VmxExitHandler(PGUEST_CONTEXT context);
|
||||
@@ -0,0 +1,196 @@
|
||||
#include "VTUtils.h"
|
||||
#include "vtdef.h"
|
||||
#include <intrin.h>
|
||||
|
||||
BOOLEAN VMXIsIntelCpu()
|
||||
{
|
||||
int ids[4] = { 0 };
|
||||
char vendor[13];
|
||||
|
||||
__cpuidex(ids, 0, 0);
|
||||
RtlCopyMemory(vendor, &ids[1], sizeof(ULONG));
|
||||
RtlCopyMemory(vendor + 4, &ids[3], sizeof(ULONG));
|
||||
RtlCopyMemory(vendor + 8, &ids[2], sizeof(ULONG));
|
||||
vendor[12] = '\0';
|
||||
|
||||
BOOLEAN intel = RtlCompareMemory(vendor, "GenuineIntel", 12) == 12;
|
||||
DbgPrintEx(77, 0, "[vt_detect] CPU vendor=%s, Intel=%s\r\n",
|
||||
vendor, intel ? "TRUE" : "FALSE");
|
||||
|
||||
return intel;
|
||||
}
|
||||
|
||||
BOOLEAN VMXIsCpuidVT()
|
||||
{
|
||||
int ids[4] = { 0 };
|
||||
|
||||
__cpuidex(ids, 1, 0);
|
||||
|
||||
BOOLEAN supported = (ids[2] & (1u << 5)) != 0;
|
||||
DbgPrintEx(77, 0, "[vt_detect] CPUID.1: ECX=0x%08X, VMX=%s\r\n",
|
||||
(unsigned int)ids[2], supported ? "TRUE" : "FALSE");
|
||||
|
||||
return supported;
|
||||
}
|
||||
|
||||
BOOLEAN VMXIsBiosVT()
|
||||
{
|
||||
ULONG64 featureControl = __readmsr(IA32_FEATURE_CONTROL);
|
||||
BOOLEAN locked = (featureControl & IA32_FEATURE_CONTROL_LOCKED) != 0;
|
||||
BOOLEAN vmxonEnabled = (featureControl & IA32_FEATURE_CONTROL_VMXON) != 0;
|
||||
|
||||
DbgPrintEx(77, 0, "[vt_detect] IA32_FEATURE_CONTROL=0x%I64X, LOCKED=%s, VMXON=%s\r\n",
|
||||
featureControl, locked ? "TRUE" : "FALSE", vmxonEnabled ? "TRUE" : "FALSE");
|
||||
|
||||
return locked && vmxonEnabled;
|
||||
}
|
||||
|
||||
BOOLEAN VMXIsEnabled()
|
||||
{
|
||||
ULONG64 cr4 = __readcr4();
|
||||
BOOLEAN enabled = (cr4 & (1ULL << 13)) != 0;
|
||||
|
||||
DbgPrintEx(77, 0, "[vt_detect] CR4=0x%I64X, VMXE=%s\r\n",
|
||||
cr4, enabled ? "TRUE" : "FALSE");
|
||||
|
||||
return enabled;
|
||||
}
|
||||
|
||||
|
||||
VCPU vcpus[128] = { 0 };
|
||||
|
||||
PVCPU VMXGetCurrentVCpu()
|
||||
{
|
||||
ULONG number = KeGetCurrentProcessorNumberEx(NULL);
|
||||
return &vcpus[number];
|
||||
}
|
||||
|
||||
PVCPU VMXGetVCpuByCpuNumber(ULONG number)
|
||||
{
|
||||
|
||||
return &vcpus[number];
|
||||
}
|
||||
|
||||
ULONG64 VmxAdjustMsrValue(ULONG64 Value, ULONG64 msr)
|
||||
{
|
||||
ULONG64 msrValue = __readmsr((ULONG)msr);
|
||||
ULONG64 mustBeOne = (ULONG)(msrValue & 0xffffffffULL);
|
||||
ULONG64 allowedBits = (ULONG)(msrValue >> 32);
|
||||
|
||||
Value |= mustBeOne;
|
||||
Value &= allowedBits;
|
||||
|
||||
return Value;
|
||||
}
|
||||
|
||||
BOOLEAN VmxIsControlTrue()
|
||||
{
|
||||
ULONG64 basic = __readmsr(IA32_VMX_BASIC);
|
||||
return ((basic >> 55) & 1);
|
||||
}
|
||||
|
||||
ULONG64 VmxReadField(ULONG64 idField)
|
||||
{
|
||||
ULONG64 value = 0;
|
||||
__vmx_vmread(idField, &value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
BOOLEAN VmxSetReadMsrBitMap(PUCHAR bitMap, ULONG64 msr, BOOLEAN isEnable)
|
||||
{
|
||||
|
||||
|
||||
if (msr >= 0xc0000000)
|
||||
{
|
||||
bitMap += 1024;
|
||||
msr -= 0xc0000000;
|
||||
}
|
||||
|
||||
PUCHAR temp = 0;
|
||||
ULONG64 byteOffset = 0;
|
||||
ULONG64 mod = 0;
|
||||
if (msr != 0)
|
||||
{
|
||||
byteOffset = msr / 8;
|
||||
mod = msr % 8;
|
||||
temp = (bitMap + byteOffset);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = bitMap;
|
||||
}
|
||||
|
||||
if (isEnable)
|
||||
{
|
||||
*temp |= 1 << mod;
|
||||
}
|
||||
else
|
||||
{
|
||||
*temp &= ~(1 << mod);
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
BOOLEAN VmxSetWriteMsrBitMap(PUCHAR bitMap, ULONG64 msr, BOOLEAN isEnable)
|
||||
{
|
||||
bitMap += 2048;
|
||||
|
||||
if (msr >= 0xc0000000)
|
||||
{
|
||||
bitMap += 1024;
|
||||
msr -= 0xc0000000;
|
||||
}
|
||||
|
||||
PUCHAR temp = 0;
|
||||
ULONG64 byteOffset = 0;
|
||||
ULONG64 mod = 0;
|
||||
if (msr != 0)
|
||||
{
|
||||
byteOffset = msr / 8;
|
||||
mod = msr % 8;
|
||||
temp = (bitMap + byteOffset);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = bitMap;
|
||||
}
|
||||
|
||||
if (isEnable)
|
||||
{
|
||||
*temp |= 1 << mod;
|
||||
}
|
||||
else
|
||||
{
|
||||
*temp &= ~(1 << mod);
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID VmxSetMTF(BOOLEAN isOpen)
|
||||
{
|
||||
ULONG64 Proccontorlmsr = VmxIsControlTrue() ? IA32_MSR_VMX_TRUE_PROCBASED_CTLS : IA32_MSR_VMX_PROCBASED_CTLS;
|
||||
|
||||
ULONG64 mark = VmxReadField(CPU_BASED_VM_EXEC_CONTROL);
|
||||
|
||||
if (isOpen)
|
||||
{
|
||||
mark |= CPU_BASED_MONITOR_TRAP_FLAG;
|
||||
}
|
||||
else
|
||||
{
|
||||
mark &= (~CPU_BASED_MONITOR_TRAP_FLAG);
|
||||
}
|
||||
|
||||
ULONG64 msrValue = VmxAdjustMsrValue(mark, Proccontorlmsr);
|
||||
|
||||
__vmx_vmwrite(CPU_BASED_VM_EXEC_CONTROL, msrValue);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#pragma once
|
||||
|
||||
#include "vtdef.h"
|
||||
|
||||
typedef struct _VCPU
|
||||
{
|
||||
ULONG cpuNumber;
|
||||
BOOLEAN isStartSuccess;
|
||||
PVOID VmxOnMemory;
|
||||
PHYSICAL_ADDRESS VmxOnPhy;
|
||||
|
||||
PVOID VmcsMemory;
|
||||
PHYSICAL_ADDRESS VmcsPhy;
|
||||
|
||||
PUCHAR VmxHostStackTop; //ջ��
|
||||
PUCHAR VmxHostStackBase; //ջ��
|
||||
|
||||
PVOID VmMsrBitMap;
|
||||
PHYSICAL_ADDRESS VmMsrBitMapPhy;
|
||||
|
||||
} VCPU, * PVCPU;
|
||||
|
||||
//typedef struct _VCPU
|
||||
//{
|
||||
// ULONG cpuNumber;
|
||||
// ULONG isStartSuccess;
|
||||
// PVOID VmxOnMemory;
|
||||
// PHYSICAL_ADDRESS VmxOnPhy;
|
||||
//
|
||||
// PVOID VmcsMemory;
|
||||
// PHYSICAL_ADDRESS VmcsPhy;
|
||||
//
|
||||
// PVOID VmxHostStackTop; //Õ»¶¥
|
||||
// PVOID VmxHostStackBase; //Õ»µ×
|
||||
//
|
||||
// PVOID VmMsrBitMap;
|
||||
// PHYSICAL_ADDRESS VmMsrBitMapPhy;
|
||||
//
|
||||
//
|
||||
//}VCPU, * PVCPU;
|
||||
|
||||
BOOLEAN VMXIsIntelCpu();
|
||||
|
||||
BOOLEAN VMXIsCpuidVT();
|
||||
|
||||
BOOLEAN VMXIsBiosVT();
|
||||
|
||||
BOOLEAN VMXIsEnabled();
|
||||
|
||||
PVCPU VMXGetCurrentVCpu();
|
||||
|
||||
PVCPU VMXGetVCpuByCpuNumber(ULONG number);
|
||||
|
||||
ULONG64 VmxAdjustMsrValue(ULONG64 Value, ULONG64 msr);
|
||||
|
||||
BOOLEAN VmxIsControlTrue();
|
||||
|
||||
ULONG64 VmxReadField(ULONG64 idField);
|
||||
|
||||
BOOLEAN VmxSetReadMsrBitMap(PUCHAR bitMap, ULONG64 msr, BOOLEAN isEnable);
|
||||
|
||||
BOOLEAN VmxSetWriteMsrBitMap(PUCHAR bitMap, ULONG64 msr, BOOLEAN isEnable);
|
||||
|
||||
VOID VmxSetMTF(BOOLEAN isOpen);
|
||||
@@ -0,0 +1,452 @@
|
||||
#include "Vmx.h"
|
||||
#include <ntifs.h>
|
||||
|
||||
volatile ULONG64 VmxExitRip = 0;
|
||||
volatile ULONG64 VmxExitRsp = 0;
|
||||
|
||||
VOID VmxFreeMemory() {
|
||||
PVCPU vcpu = VMXGetCurrentVCpu();
|
||||
if (vcpu->VmxOnMemory)
|
||||
{
|
||||
MmFreeContiguousMemorySpecifyCache(vcpu->VmxOnMemory,PAGE_SIZE,MmCached);
|
||||
|
||||
vcpu->VmxOnMemory = NULL;
|
||||
vcpu->VmxOnPhy.QuadPart = 0;
|
||||
}
|
||||
|
||||
if (vcpu->VmxHostStackTop)
|
||||
{
|
||||
MmFreeContiguousMemorySpecifyCache(vcpu->VmxHostStackTop, PAGE_SIZE * 8, MmCached);
|
||||
vcpu->VmxHostStackTop = NULL;
|
||||
|
||||
}
|
||||
|
||||
if (vcpu->VmcsMemory)
|
||||
{
|
||||
MmFreeContiguousMemorySpecifyCache(vcpu->VmcsMemory, PAGE_SIZE, MmCached);
|
||||
vcpu->VmcsMemory = NULL;
|
||||
}
|
||||
|
||||
if (vcpu->VmMsrBitMap)
|
||||
{
|
||||
MmFreeContiguousMemorySpecifyCache(vcpu->VmMsrBitMap, PAGE_SIZE, MmCached);
|
||||
vcpu->VmMsrBitMap = NULL;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
VOID VmxDisableOff(BOOLEAN is_vt)
|
||||
{
|
||||
PVCPU vcpu = VMXGetCurrentVCpu();
|
||||
if (vcpu == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_vt) {
|
||||
AsmVmCall(0x65786974UL);
|
||||
|
||||
VmxFreeMemory();
|
||||
DbgPrintEx(77, 0, "[vmx] VMX shutdown complete\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (vcpu->isStartSuccess)
|
||||
{
|
||||
__vmx_off();
|
||||
vcpu->isStartSuccess = FALSE;
|
||||
|
||||
// Restore CR0 and CR4 after leaving VMX operation.
|
||||
ULONG64 cr0 = __readcr0();
|
||||
ULONG64 cr4 = __readcr4();
|
||||
ULONG64 cr0Fixed0 = __readmsr(IA32_VMX_CR0_FIXED0);
|
||||
ULONG64 cr0Fixed1 = __readmsr(IA32_VMX_CR0_FIXED1);
|
||||
ULONG64 cr4Fixed0 = __readmsr(IA32_VMX_CR4_FIXED0);
|
||||
ULONG64 cr4Fixed1 = __readmsr(IA32_VMX_CR4_FIXED1);
|
||||
|
||||
cr0 = (cr0 | cr0Fixed0) & cr0Fixed1;
|
||||
cr4 = ((cr4 & ~(1ULL << 13)) | cr4Fixed0) & cr4Fixed1;
|
||||
|
||||
__writecr0(cr0);
|
||||
__writecr4(cr4);
|
||||
}
|
||||
|
||||
VmxFreeMemory();
|
||||
|
||||
}
|
||||
|
||||
BOOLEAN VmxInitVmOn()
|
||||
{
|
||||
|
||||
// Apply the VMX fixed-bit requirements.
|
||||
ULONG64 mcr4 = __readcr4();
|
||||
ULONG64 mcr0 = __readcr0();
|
||||
|
||||
ULONG64 vcr00 = __readmsr(IA32_VMX_CR0_FIXED0);
|
||||
ULONG64 vcr01 = __readmsr(IA32_VMX_CR0_FIXED1);
|
||||
ULONG64 vcr40 = __readmsr(IA32_VMX_CR4_FIXED0);
|
||||
ULONG64 vcr41 = __readmsr(IA32_VMX_CR4_FIXED1);
|
||||
|
||||
mcr4 = (mcr4 | vcr40) & vcr41;
|
||||
|
||||
__writecr4(mcr4);
|
||||
|
||||
mcr0 = (mcr0 | vcr00) & vcr01;
|
||||
|
||||
__writecr0(mcr0);
|
||||
|
||||
// Initialize the current processor state.
|
||||
PVCPU vcpu = VMXGetCurrentVCpu();
|
||||
|
||||
vcpu->isStartSuccess = FALSE;
|
||||
vcpu->cpuNumber = KeGetCurrentProcessorNumberEx(NULL);
|
||||
|
||||
PHYSICAL_ADDRESS phylow = { 0 };
|
||||
PHYSICAL_ADDRESS phyhigh = { MAXULONG64 };
|
||||
|
||||
vcpu->VmxOnMemory = MmAllocateContiguousMemorySpecifyCache(PAGE_SIZE, phylow, phyhigh, phylow, MmCached);
|
||||
|
||||
if (vcpu->VmxOnMemory == NULL)
|
||||
{
|
||||
DbgPrintEx(77, 0, "[db]:unable to allocate VMXON memory\r\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memset(vcpu->VmxOnMemory, 0, PAGE_SIZE);
|
||||
|
||||
vcpu->VmxOnPhy = MmGetPhysicalAddress(vcpu->VmxOnMemory);
|
||||
|
||||
// Prepare and execute VMXON.
|
||||
ULONG64 basic = __readmsr(IA32_VMX_BASIC);
|
||||
|
||||
*(PULONG)vcpu->VmxOnMemory = (ULONG)basic;
|
||||
|
||||
ULONG64 vmxonPhysicalAddress = (ULONG64)vcpu->VmxOnPhy.QuadPart;
|
||||
int error = __vmx_on(&vmxonPhysicalAddress);
|
||||
|
||||
if (error)
|
||||
{
|
||||
DbgPrintEx(77, 0, "[db]:vmxon ins error = %d\r\n", error);
|
||||
VmxDisableOff(FALSE);
|
||||
}
|
||||
|
||||
vcpu->isStartSuccess = TRUE;
|
||||
return error == 0;
|
||||
}
|
||||
|
||||
void FullGdtDataItem(int index, short selector)
|
||||
{
|
||||
GdtTable gdtTable = { 0 };
|
||||
AsmGetGdtTable(&gdtTable);
|
||||
//00cf9300`0000ffff
|
||||
|
||||
USHORT select = selector;
|
||||
selector &= 0xFFF8;
|
||||
|
||||
ULONG64 limit = __segmentlimit(selector);
|
||||
PULONG item = (PULONG)(gdtTable.Base + selector);
|
||||
|
||||
LARGE_INTEGER itemBase = { 0 };
|
||||
itemBase.LowPart = (*item & 0xFFFF0000) >> 16;
|
||||
item += 1;
|
||||
itemBase.LowPart |= (*item & 0xFF000000) | ((*item & 0xFF) << 16);
|
||||
|
||||
//����
|
||||
ULONG attr = (*item & 0x00F0FF00) >> 8;
|
||||
|
||||
|
||||
|
||||
if (selector == 0)
|
||||
{
|
||||
attr |= 1 << 16;
|
||||
}
|
||||
|
||||
__vmx_vmwrite(GUEST_ES_BASE + index * 2, itemBase.QuadPart);
|
||||
__vmx_vmwrite(GUEST_ES_LIMIT + index * 2, limit);
|
||||
__vmx_vmwrite(GUEST_ES_AR_BYTES + index * 2, attr);
|
||||
__vmx_vmwrite(GUEST_ES_SELECTOR + index * 2, select);
|
||||
|
||||
}
|
||||
|
||||
VOID VmxInitGuest(ULONG64 guestRip, ULONG64 GuestRsp)
|
||||
{
|
||||
PVCPU vcpu = VMXGetCurrentVCpu();
|
||||
|
||||
FullGdtDataItem(0, AsmReadES());
|
||||
FullGdtDataItem(1, AsmReadCS());
|
||||
FullGdtDataItem(2, AsmReadSS());
|
||||
FullGdtDataItem(3, AsmReadDS());
|
||||
FullGdtDataItem(4, AsmReadFS());
|
||||
FullGdtDataItem(5, AsmReadGS());
|
||||
FullGdtDataItem(6, AsmReadLDTR());
|
||||
|
||||
GdtTable gdtTable = { 0 };
|
||||
AsmGetGdtTable(&gdtTable);
|
||||
|
||||
|
||||
ULONG trSelector = AsmReadTR();
|
||||
|
||||
trSelector &= 0xFFF8;
|
||||
ULONG64 trlimit = __segmentlimit(trSelector);
|
||||
|
||||
LARGE_INTEGER trBase = { 0 };
|
||||
|
||||
PULONG trItem = (PULONG)(gdtTable.Base + trSelector);
|
||||
|
||||
|
||||
//��TR
|
||||
trBase.LowPart = ((trItem[0] >> 16) & 0xFFFF) | ((trItem[1] & 0xFF) << 16) | ((trItem[1] & 0xFF000000));
|
||||
trBase.HighPart = trItem[2];
|
||||
|
||||
//����
|
||||
ULONG attr = (trItem[1] & 0x00F0FF00) >> 8;
|
||||
__vmx_vmwrite(GUEST_TR_BASE, trBase.QuadPart);
|
||||
__vmx_vmwrite(GUEST_TR_LIMIT, trlimit);
|
||||
__vmx_vmwrite(GUEST_TR_AR_BYTES, attr);
|
||||
__vmx_vmwrite(GUEST_TR_SELECTOR, trSelector);
|
||||
|
||||
__vmx_vmwrite(GUEST_IA32_DEBUGCTL, __readmsr(IA32_MSR_DEBUGCTL));
|
||||
__vmx_vmwrite(GUEST_IA32_PAT, __readmsr(IA32_MSR_PAT));
|
||||
__vmx_vmwrite(GUEST_IA32_EFER, __readmsr(IA32_MSR_EFER));
|
||||
|
||||
__vmx_vmwrite(GUEST_FS_BASE, __readmsr(IA32_FS_BASE));
|
||||
__vmx_vmwrite(GUEST_GS_BASE, __readmsr(IA32_GS_BASE));
|
||||
|
||||
__vmx_vmwrite(GUEST_SYSENTER_CS, __readmsr(0x174));
|
||||
__vmx_vmwrite(GUEST_SYSENTER_ESP, __readmsr(0x175));
|
||||
__vmx_vmwrite(GUEST_SYSENTER_EIP, __readmsr(0x176));
|
||||
|
||||
|
||||
__vmx_vmwrite(GUEST_GDTR_BASE, gdtTable.Base);
|
||||
__vmx_vmwrite(GUEST_GDTR_LIMIT, gdtTable.limit);
|
||||
|
||||
//�����������һ�εķ��ص�ַ���ջ
|
||||
__vmx_vmwrite(GUEST_RSP, GuestRsp);
|
||||
__vmx_vmwrite(GUEST_RIP, guestRip);
|
||||
|
||||
GdtTable idtTable = { 0 };
|
||||
__sidt(&idtTable);
|
||||
__vmx_vmwrite(GUEST_IDTR_BASE, idtTable.Base);
|
||||
__vmx_vmwrite(GUEST_IDTR_LIMIT, idtTable.limit);
|
||||
|
||||
__vmx_vmwrite(GUEST_CR0, __readcr0());
|
||||
__vmx_vmwrite(GUEST_CR4, __readcr4());
|
||||
__vmx_vmwrite(GUEST_CR3, __readcr3());
|
||||
__vmx_vmwrite(GUEST_RFLAGS, __readeflags());
|
||||
__vmx_vmwrite(GUEST_DR7, __readdr(7));
|
||||
|
||||
__vmx_vmwrite(VMCS_LINK_POINTER, (ULONG64)-1);
|
||||
|
||||
}
|
||||
|
||||
VOID VmxInitHost(ULONG64 HostRIP)
|
||||
{
|
||||
PVCPU vcpu = VMXGetCurrentVCpu();
|
||||
|
||||
|
||||
|
||||
GdtTable gdtTable = { 0 };
|
||||
AsmGetGdtTable(&gdtTable);
|
||||
|
||||
|
||||
ULONG trSelector = AsmReadTR();
|
||||
|
||||
trSelector &= 0xFFF8;
|
||||
|
||||
LARGE_INTEGER trBase = { 0 };
|
||||
|
||||
PULONG trItem = (PULONG)(gdtTable.Base + trSelector);
|
||||
|
||||
|
||||
//��TR
|
||||
trBase.LowPart = ((trItem[0] >> 16) & 0xFFFF) | ((trItem[1] & 0xFF) << 16) | ((trItem[1] & 0xFF000000));
|
||||
trBase.HighPart = trItem[2];
|
||||
|
||||
//����
|
||||
__vmx_vmwrite(HOST_TR_BASE, trBase.QuadPart);
|
||||
__vmx_vmwrite(HOST_TR_SELECTOR, trSelector);
|
||||
|
||||
__vmx_vmwrite(HOST_ES_SELECTOR, AsmReadES() & 0xfff8);
|
||||
__vmx_vmwrite(HOST_CS_SELECTOR, AsmReadCS() & 0xfff8);
|
||||
__vmx_vmwrite(HOST_SS_SELECTOR, AsmReadSS() & 0xfff8);
|
||||
__vmx_vmwrite(HOST_DS_SELECTOR, AsmReadDS() & 0xfff8);
|
||||
__vmx_vmwrite(HOST_FS_SELECTOR, AsmReadFS() & 0xfff8);
|
||||
__vmx_vmwrite(HOST_GS_SELECTOR, AsmReadGS() & 0xfff8);
|
||||
|
||||
|
||||
|
||||
__vmx_vmwrite(HOST_CR0, __readcr0());
|
||||
__vmx_vmwrite(HOST_CR4, __readcr4());
|
||||
__vmx_vmwrite(HOST_CR3, __readcr3());
|
||||
__vmx_vmwrite(HOST_RSP, (ULONG64)vcpu->VmxHostStackBase);
|
||||
__vmx_vmwrite(HOST_RIP, HostRIP);
|
||||
|
||||
|
||||
__vmx_vmwrite(HOST_IA32_PAT, __readmsr(IA32_MSR_PAT));
|
||||
__vmx_vmwrite(HOST_IA32_EFER, __readmsr(IA32_MSR_EFER));
|
||||
//__vmx_vmwrite(HOST_IA32_PERF_GLOBAL_CTRL, __readmsr(IA32_PERF_GLOBAL_CTRL));
|
||||
|
||||
__vmx_vmwrite(HOST_FS_BASE, __readmsr(IA32_FS_BASE));
|
||||
__vmx_vmwrite(HOST_GS_BASE, __readmsr(IA32_GS_BASE));
|
||||
|
||||
__vmx_vmwrite(HOST_IA32_SYSENTER_CS, __readmsr(0x174));
|
||||
__vmx_vmwrite(HOST_IA32_SYSENTER_ESP, __readmsr(0x175));
|
||||
__vmx_vmwrite(HOST_IA32_SYSENTER_EIP, __readmsr(0x176));
|
||||
|
||||
|
||||
//IDT GDT
|
||||
|
||||
GdtTable idtTable;
|
||||
__sidt(&idtTable);
|
||||
|
||||
__vmx_vmwrite(HOST_GDTR_BASE, gdtTable.Base);
|
||||
__vmx_vmwrite(HOST_IDTR_BASE, idtTable.Base);
|
||||
}
|
||||
|
||||
VOID VmxInitEntry()
|
||||
{
|
||||
ULONG64 contorlmsr = VmxIsControlTrue() ? IA32_MSR_VMX_TRUE_ENTRY_CTLS : IA32_VMX_ENTRY_CTLS;
|
||||
|
||||
ULONG mark = VM_ENTRY_IA32E_MODE_GUEST;
|
||||
ULONG64 msrValue = VmxAdjustMsrValue(mark, contorlmsr);
|
||||
__vmx_vmwrite(VM_ENTRY_CONTROLS, msrValue);
|
||||
__vmx_vmwrite(VM_ENTRY_MSR_LOAD_COUNT, 0);
|
||||
__vmx_vmwrite(VM_ENTRY_INTR_INFO_FIELD, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
VOID VmxInitExit()
|
||||
{
|
||||
ULONG64 contorlmsr = VmxIsControlTrue() ? IA32_MSR_VMX_TRUE_EXIT_CTLS : IA32_MSR_VMX_EXIT_CTLS;
|
||||
|
||||
ULONG mark = 0x200 | 0x8000;
|
||||
ULONG64 value = VmxAdjustMsrValue(mark, contorlmsr);
|
||||
__vmx_vmwrite(VM_EXIT_CONTROLS, value);
|
||||
__vmx_vmwrite(VM_EXIT_MSR_LOAD_COUNT, 0);
|
||||
__vmx_vmwrite(VM_EXIT_INTR_INFO, 0);
|
||||
}
|
||||
|
||||
VOID VmxInitControl() {
|
||||
PVCPU vcpu = VMXGetCurrentVCpu();
|
||||
|
||||
ULONG64 contorlmsr = VmxIsControlTrue() ? IA32_MSR_VMX_TRUE_PINBASED_CTLS : IA32_MSR_VMX_PINBASED_CTLS;
|
||||
ULONG mark = 0;
|
||||
ULONG64 msrValue = VmxAdjustMsrValue(mark, contorlmsr);
|
||||
__vmx_vmwrite(PIN_BASED_VM_EXEC_CONTROL, msrValue);
|
||||
|
||||
|
||||
ULONG64 Proccontorlmsr = VmxIsControlTrue() ? IA32_MSR_VMX_TRUE_PROCBASED_CTLS : IA32_MSR_VMX_PROCBASED_CTLS;
|
||||
mark = CPU_BASED_ACTIVATE_MSR_BITMAP | CPU_BASED_ACTIVATE_SECONDARY_CONTROLS;
|
||||
msrValue = VmxAdjustMsrValue(mark, Proccontorlmsr);
|
||||
__vmx_vmwrite(CPU_BASED_VM_EXEC_CONTROL, msrValue);
|
||||
|
||||
|
||||
VmxSetReadMsrBitMap(vcpu->VmMsrBitMap, 0xc0000082, TRUE);
|
||||
__vmx_vmwrite(MSR_BITMAP, vcpu->VmMsrBitMapPhy.QuadPart);
|
||||
|
||||
|
||||
|
||||
mark = SECONDARY_EXEC_XSAVES | SECONDARY_EXEC_ENABLE_RDTSCP | SECONDARY_EXEC_ENABLE_INVPCID;
|
||||
msrValue = VmxAdjustMsrValue(mark, IA32_MSR_VMX_PROCBASED_CTLS2);
|
||||
__vmx_vmwrite(SECONDARY_VM_EXEC_CONTROL, msrValue);
|
||||
|
||||
|
||||
/*mark = 1 << 3;
|
||||
__vmx_vmwrite(EXCEPTION_BITMAP, mark);*/
|
||||
|
||||
mark = 1 << 14;
|
||||
|
||||
|
||||
__vmx_vmwrite(EXCEPTION_BITMAP, mark);
|
||||
__vmx_vmwrite(PAGE_FAULT_ERROR_CODE_MASK, 3);
|
||||
__vmx_vmwrite(PAGE_FAULT_ERROR_CODE_MATCH, 3);
|
||||
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN VmxInitVmcs(ULONG64 hostRip, PULONG64 guestRip)
|
||||
{
|
||||
PULONG64 pguestRsp = guestRip;
|
||||
PVCPU vcpu = VMXGetCurrentVCpu();
|
||||
|
||||
|
||||
PHYSICAL_ADDRESS phylow = { 0 };
|
||||
PHYSICAL_ADDRESS phyhigh = { MAXULONG64 };
|
||||
|
||||
|
||||
vcpu->VmcsMemory= MmAllocateContiguousMemorySpecifyCache(PAGE_SIZE, phylow, phyhigh, phylow, MmCached);
|
||||
memset(vcpu->VmcsMemory, 0, PAGE_SIZE);
|
||||
vcpu->VmcsPhy = MmGetPhysicalAddress(vcpu->VmcsMemory);
|
||||
|
||||
vcpu->VmMsrBitMap = MmAllocateContiguousMemorySpecifyCache(PAGE_SIZE, phylow, phyhigh, phylow, MmCached);
|
||||
memset(vcpu->VmMsrBitMap, 0, PAGE_SIZE);
|
||||
vcpu->VmMsrBitMapPhy = MmGetPhysicalAddress(vcpu->VmMsrBitMap);
|
||||
|
||||
vcpu->VmxHostStackTop = MmAllocateContiguousMemorySpecifyCache(PAGE_SIZE * 8, phylow, phyhigh, phylow, MmCached);
|
||||
memset(vcpu->VmxHostStackTop, 0, 8 * PAGE_SIZE);
|
||||
vcpu->VmxHostStackBase = vcpu->VmxHostStackTop + (7 * PAGE_SIZE);
|
||||
|
||||
|
||||
|
||||
ULONG64 basic = __readmsr(IA32_VMX_BASIC);
|
||||
|
||||
*(PULONG)vcpu->VmcsMemory = (ULONG)basic;
|
||||
|
||||
int error = __vmx_vmclear(&vcpu->VmcsPhy.QuadPart);
|
||||
if (error)
|
||||
{
|
||||
DbgPrintEx(77, 0, "[db]:__vmx_vmclear ins error = %d\r\n", error);
|
||||
VmxDisableOff(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
error = __vmx_vmptrld(&vcpu->VmcsPhy.QuadPart);
|
||||
if (error)
|
||||
{
|
||||
DbgPrintEx(77, 0, "[db]:__vmx_vmptrld ins error = %d\r\n", error);
|
||||
VmxDisableOff(FALSE);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
VmxInitGuest(*pguestRsp, pguestRsp + 1);
|
||||
VmxInitHost(hostRip);
|
||||
VmxInitEntry();
|
||||
VmxInitExit();
|
||||
VmxInitControl();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOLEAN VmxInit(ULONG64 hostRip)
|
||||
{
|
||||
|
||||
|
||||
PULONG64 ReturnAddr = _AddressOfReturnAddress();
|
||||
BOOLEAN isSuccess = VmxInitVmOn();
|
||||
|
||||
if (isSuccess)
|
||||
{
|
||||
isSuccess = VmxInitVmcs(hostRip, ReturnAddr);
|
||||
|
||||
if (!isSuccess)
|
||||
{
|
||||
VmxDisableOff(FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
int error = __vmx_vmlaunch();
|
||||
DbgPrintEx(77, 0, "[db]:__vmx_vmlaunch = %d,error = %llx\r\n", error, VmxReadField(VM_INSTRUCTION_ERROR));
|
||||
if (error)
|
||||
{
|
||||
VmxDisableOff(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isSuccess;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
|
||||
#include "vtdef.h"
|
||||
#include "VTUtils.h"
|
||||
#include <intrin.h>
|
||||
#include "vmxs.h"
|
||||
|
||||
#pragma pack(push,1)
|
||||
typedef struct _GdtTable
|
||||
{
|
||||
USHORT limit;
|
||||
ULONG64 Base;
|
||||
}GdtTable, * PGdtTable;
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
BOOLEAN VmxInit(ULONG64 hostRip);
|
||||
|
||||
extern volatile ULONG64 VmxExitRip;
|
||||
extern volatile ULONG64 VmxExitRsp;
|
||||
|
||||
|
||||
|
||||
|
||||
VOID VmxDisableOff(BOOLEAN is_vt);
|
||||
@@ -0,0 +1,244 @@
|
||||
.code
|
||||
|
||||
extern VmxExitHandler:proc
|
||||
extern VmxExitRip:qword
|
||||
extern VmxExitRsp:qword
|
||||
extern MyOpenProcess:proc
|
||||
extern JmpOpenProcessRet:dq
|
||||
|
||||
AsmGetGdtTable proc
|
||||
sgdt [rcx];
|
||||
ret;
|
||||
AsmGetGdtTable endp;
|
||||
|
||||
|
||||
AsmReadES proc
|
||||
xor eax,eax;
|
||||
mov ax,es;
|
||||
ret;
|
||||
AsmReadES endp
|
||||
|
||||
AsmReadCS proc
|
||||
xor eax,eax;
|
||||
mov ax,cs;
|
||||
ret;
|
||||
AsmReadCS endp
|
||||
|
||||
AsmReadSS proc
|
||||
xor eax,eax;
|
||||
mov ax,ss;
|
||||
ret;
|
||||
AsmReadSS endp
|
||||
|
||||
AsmReadDS proc
|
||||
xor eax,eax;
|
||||
mov ax,ds;
|
||||
ret;
|
||||
AsmReadDS endp
|
||||
|
||||
AsmReadFS proc
|
||||
xor eax,eax;
|
||||
mov ax,fs;
|
||||
ret;
|
||||
AsmReadFS endp
|
||||
|
||||
AsmReadGS proc
|
||||
xor eax,eax;
|
||||
mov ax,gs;
|
||||
ret;
|
||||
AsmReadGS endp
|
||||
|
||||
AsmReadTR proc
|
||||
xor eax,eax;
|
||||
str ax;
|
||||
ret;
|
||||
|
||||
AsmReadTR endp
|
||||
|
||||
AsmReadLDTR proc
|
||||
xor eax,eax;
|
||||
sldt ax
|
||||
ret;
|
||||
AsmReadLDTR endp
|
||||
|
||||
|
||||
AsmVmxExitHandler proc
|
||||
push r15;
|
||||
push r14;
|
||||
push r13;
|
||||
push r12;
|
||||
push r11;
|
||||
push r10;
|
||||
push r9;
|
||||
push r8;
|
||||
push rdi;
|
||||
push rsi;
|
||||
push rbp;
|
||||
push rsp;
|
||||
push rbx;
|
||||
push rdx;
|
||||
push rcx;
|
||||
push rax;
|
||||
|
||||
mov rcx,rsp;
|
||||
sub rsp,0100h
|
||||
call VmxExitHandler
|
||||
add rsp,0100h;
|
||||
test eax,eax
|
||||
jnz VmxExitPath
|
||||
|
||||
mov rax,qword ptr [rsp+00h]
|
||||
mov rcx,qword ptr [rsp+08h]
|
||||
mov rdx,qword ptr [rsp+10h]
|
||||
mov rbx,qword ptr [rsp+18h]
|
||||
mov rbp,qword ptr [rsp+28h]
|
||||
mov rsi,qword ptr [rsp+30h]
|
||||
mov rdi,qword ptr [rsp+38h]
|
||||
mov r8,qword ptr [rsp+40h]
|
||||
mov r9,qword ptr [rsp+48h]
|
||||
mov r10,qword ptr [rsp+50h]
|
||||
mov r11,qword ptr [rsp+58h]
|
||||
mov r12,qword ptr [rsp+60h]
|
||||
mov r13,qword ptr [rsp+68h]
|
||||
mov r14,qword ptr [rsp+70h]
|
||||
mov r15,qword ptr [rsp+78h]
|
||||
mov rsp,qword ptr [rsp+20h]
|
||||
vmresume
|
||||
ret
|
||||
|
||||
VmxExitPath:
|
||||
mov rax,qword ptr [rsp+00h]
|
||||
mov rcx,qword ptr [rsp+08h]
|
||||
mov rdx,qword ptr [rsp+10h]
|
||||
mov rbx,qword ptr [rsp+18h]
|
||||
mov rbp,qword ptr [rsp+28h]
|
||||
mov rsi,qword ptr [rsp+30h]
|
||||
mov rdi,qword ptr [rsp+38h]
|
||||
mov r8,qword ptr [rsp+40h]
|
||||
mov r9,qword ptr [rsp+48h]
|
||||
mov r10,qword ptr [rsp+50h]
|
||||
mov r11,qword ptr [rsp+58h]
|
||||
mov r12,qword ptr [rsp+60h]
|
||||
mov r13,qword ptr [rsp+68h]
|
||||
mov r14,qword ptr [rsp+70h]
|
||||
mov r15,qword ptr [rsp+78h]
|
||||
mov rsp,qword ptr [VmxExitRsp]
|
||||
jmp qword ptr [VmxExitRip]
|
||||
AsmVmxExitHandler endp
|
||||
;
|
||||
;
|
||||
AsmInvd proc
|
||||
invd;
|
||||
ret
|
||||
AsmInvd endp;
|
||||
;
|
||||
AsmVmCall proc
|
||||
mov rax,rcx; //��־
|
||||
vmcall
|
||||
ret;
|
||||
AsmVmCall endp;
|
||||
|
||||
AsmVmCallHook proc
|
||||
mov rax,rcx; //��־
|
||||
mov rcx,rdx;
|
||||
mov rdx,r8;
|
||||
mov r8,r9;
|
||||
mov r9,qword ptr [rsp+028h];
|
||||
vmcall
|
||||
ret;
|
||||
AsmVmCallHook endp;
|
||||
;
|
||||
AsmJmpRet proc
|
||||
mov rsp,rdx;
|
||||
jmp rcx;
|
||||
ret;
|
||||
AsmJmpRet endp;
|
||||
;
|
||||
AsmWriteCr2 proc
|
||||
mov cr2,rcx;
|
||||
ret;
|
||||
AsmWriteCr2 endp;
|
||||
|
||||
AsmLgdt proc
|
||||
lgdt fword ptr [rcx]
|
||||
ret;
|
||||
AsmLgdt endp;
|
||||
|
||||
|
||||
;
|
||||
;AsmInvvpid PROC
|
||||
;
|
||||
; invvpid rcx, oword ptr [rdx]
|
||||
; jz ErrorWithStatus
|
||||
; jc ErrorCodeFailed
|
||||
; xor rax, rax
|
||||
; ret
|
||||
;
|
||||
;ErrorWithStatus:
|
||||
; mov rax, 1
|
||||
; ret
|
||||
;
|
||||
;ErrorCodeFailed:
|
||||
; mov rax, 2
|
||||
; ret
|
||||
;
|
||||
;AsmInvvpid ENDP
|
||||
;
|
||||
;
|
||||
Asminvept proc
|
||||
invept rcx, OWORD PTR [rdx]
|
||||
ret;
|
||||
Asminvept endp
|
||||
|
||||
|
||||
AsmNtOpenProcess proc
|
||||
push r15;
|
||||
push r14;
|
||||
push r13;
|
||||
push r12;
|
||||
push r11;
|
||||
push r10;
|
||||
push r9;
|
||||
push r8;
|
||||
push rdi;
|
||||
push rsi;
|
||||
push rbp;
|
||||
push rsp;
|
||||
push rbx;
|
||||
push rdx;
|
||||
push rcx;
|
||||
push rax;
|
||||
|
||||
mov rcx,rsp;
|
||||
sub rsp,0100h
|
||||
call MyOpenProcess
|
||||
add rsp,0100h;
|
||||
|
||||
pop rax;
|
||||
pop rcx;
|
||||
pop rdx;
|
||||
pop rbx;
|
||||
pop rsp;
|
||||
pop rbp;
|
||||
pop rsi;
|
||||
pop rdi;
|
||||
pop r8;
|
||||
pop r9;
|
||||
pop r10;
|
||||
pop r11;
|
||||
pop r12;
|
||||
pop r13;
|
||||
pop r14;
|
||||
pop r15;
|
||||
|
||||
sub rsp,38h
|
||||
mov rax,qword ptr gs:[188h]
|
||||
;//WIN7
|
||||
;mov r10b,byte ptr [rax+1F6h]
|
||||
mov r10b,byte ptr [rax+232h]
|
||||
jmp qword ptr [JmpOpenProcessRet];
|
||||
|
||||
AsmNtOpenProcess endp
|
||||
;
|
||||
|
||||
end
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include <ntifs.h>
|
||||
|
||||
EXTERN_C VOID AsmGetGdtTable(PVOID tableBaseAddr);
|
||||
EXTERN_C USHORT AsmReadES();
|
||||
EXTERN_C USHORT AsmReadCS();
|
||||
EXTERN_C USHORT AsmReadSS();
|
||||
EXTERN_C USHORT AsmReadDS();
|
||||
EXTERN_C USHORT AsmReadFS();
|
||||
EXTERN_C USHORT AsmReadGS();
|
||||
EXTERN_C USHORT AsmReadTR();
|
||||
EXTERN_C USHORT AsmReadLDTR();
|
||||
|
||||
EXTERN_C void AsmVmxExitHandler();
|
||||
|
||||
EXTERN_C VOID AsmInvd();
|
||||
|
||||
EXTERN_C VOID AsmVmCall(ULONG exitCode);
|
||||
EXTERN_C VOID AsmVmCallHook(ULONG hookTag, ULONG64 cr3, ULONG64 hookGPA, ULONG64 newGPA, PULONG64 retValue);
|
||||
EXTERN_C VOID AsmJmpRet(ULONG64 rip,ULONG64 rsp);
|
||||
EXTERN_C VOID AsmWriteCr2(ULONG64 address);
|
||||
EXTERN_C void Asminvept(ULONG type, ULONG64 eptp);
|
||||
|
||||
EXTERN_C void AsmLgdt(PVOID gdtTable);
|
||||
|
||||
EXTERN_C NTSTATUS AsmNtOpenProcess();
|
||||
|
||||
//EXTERN_C NTSTATUS AsmNtCreateFile();
|
||||
|
||||
/*
|
||||
EXTERN_C unsigned char AsmInvvpid(unsigned long Type, void * Descriptors);
|
||||
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,29 @@
|
||||
;
|
||||
; vt-detect.inf
|
||||
;
|
||||
|
||||
[Version]
|
||||
Signature="$WINDOWS NT$"
|
||||
Class=System
|
||||
ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318}
|
||||
Provider=%ManufacturerName%
|
||||
DriverVer=
|
||||
CatalogFile=vt-detect.cat
|
||||
PnpLockdown=1
|
||||
|
||||
[DestinationDirs]
|
||||
DefaultDestDir = 13
|
||||
|
||||
[SourceDisksNames]
|
||||
1 = %DiskName%,,,""
|
||||
|
||||
[SourceDisksFiles]
|
||||
|
||||
[Manufacturer]
|
||||
%ManufacturerName%=Standard,NT$ARCH$.10.0...16299 ; %13% support introduced in build 16299
|
||||
|
||||
[Standard.NT$ARCH$.10.0...16299]
|
||||
|
||||
[Strings]
|
||||
ManufacturerName="<Your manufacturer name>" ;TODO: Replace with your manufacturer name
|
||||
DiskName="vt-detect Source Disk"
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36511.14 d17.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vt-detect", "vt-detect.vcxproj", "{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
Debug|x64 = Debug|x64
|
||||
Release|ARM64 = Release|ARM64
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}.Debug|ARM64.Deploy.0 = Debug|ARM64
|
||||
{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}.Debug|x64.Build.0 = Debug|x64
|
||||
{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}.Release|ARM64.Deploy.0 = Release|ARM64
|
||||
{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}.Release|x64.ActiveCfg = Release|x64
|
||||
{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}.Release|x64.Build.0 = Release|x64
|
||||
{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}.Release|x64.Deploy.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {1EAFDF53-7FEB-4FC8-95E5-B0F1CAA27DEB}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,122 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|ARM64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{B14AD443-D68A-6E0E-5B5E-6FC849287B5F}</ProjectGuid>
|
||||
<TemplateGuid>{dd38f7fc-d7bd-488b-9242-7d8754cde80d}</TemplateGuid>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform Condition="'$(Platform)' == ''">x64</Platform>
|
||||
<RootNamespace>vt_detect</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
|
||||
<ConfigurationType>Driver</ConfigurationType>
|
||||
<DriverType>WDM</DriverType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
|
||||
<ConfigurationType>Driver</ConfigurationType>
|
||||
<DriverType>WDM</DriverType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
|
||||
<ConfigurationType>Driver</ConfigurationType>
|
||||
<DriverType>WDM</DriverType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
|
||||
<TargetVersion>Windows10</TargetVersion>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
|
||||
<ConfigurationType>Driver</ConfigurationType>
|
||||
<DriverType>WDM</DriverType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
|
||||
<DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<DriverSign>
|
||||
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
|
||||
</DriverSign>
|
||||
<ClCompile>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>NTDDI_VERSION=NTDDI_WIN7;_WIN32_WINNT=0x0601;WINVER=0x0601;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalOptions>%(AdditionalOptions) /osversion:6.1</AdditionalOptions>
|
||||
</Link>
|
||||
<DriverSign>
|
||||
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
|
||||
</DriverSign>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<FilesToPackage Include="$(TargetPath)" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="DriverMain.c" />
|
||||
<ClCompile Include="Vmx.c" />
|
||||
<ClCompile Include="VTHandler.c" />
|
||||
<ClCompile Include="VTUtils.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Vmx.h" />
|
||||
<ClInclude Include="vmxs.h" />
|
||||
<ClInclude Include="vtdef.h" />
|
||||
<ClInclude Include="VTHandler.h" />
|
||||
<ClInclude Include="VTUtils.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<MASM Include="vmxs.asm" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Driver Files">
|
||||
<UniqueIdentifier>{8E41214B-6785-4CFE-B992-037D68949A14}</UniqueIdentifier>
|
||||
<Extensions>inf;inv;inx;mof;mc;</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="DriverMain.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="VTUtils.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Vmx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Vmx.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="vtdef.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="VTUtils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
</Project>
|
||||
@@ -0,0 +1,321 @@
|
||||
#pragma once
|
||||
|
||||
#include <ntifs.h>
|
||||
|
||||
#define IA32_FEATURE_CONTROL 0x3A
|
||||
#define IA32_MSR_DEBUGCTL 0x1D9
|
||||
#define IA32_MSR_PAT 0x277
|
||||
#define IA32_PERF_GLOBAL_CTRL 0x38f
|
||||
|
||||
#define IA32_FEATURE_CONTROL_LOCKED (1ULL << 0)
|
||||
#define IA32_FEATURE_CONTROL_VMXON (1ULL << 2)
|
||||
|
||||
#define VM_ENTRY_IA32E_MODE_GUEST (1u << 9)
|
||||
|
||||
|
||||
#define IA32_MSR_VMX_PINBASED_CTLS 0x481
|
||||
#define IA32_MSR_VMX_PROCBASED_CTLS 0x482
|
||||
#define IA32_MSR_VMX_EXIT_CTLS 0x483
|
||||
#define IA32_VMX_ENTRY_CTLS 0x484
|
||||
|
||||
#define IA32_VMX_BASIC 0x480
|
||||
#define IA32_VMX_CR0_FIXED0 0x486
|
||||
#define IA32_VMX_CR0_FIXED1 0x487
|
||||
#define IA32_VMX_CR4_FIXED0 0x488
|
||||
#define IA32_VMX_CR4_FIXED1 0x489
|
||||
|
||||
#define IA32_MSR_VMX_PROCBASED_CTLS2 0x48B
|
||||
#define IA32_MSR_VMX_EPT_VPID_CAP 0x48C
|
||||
#define IA32_MSR_VMX_TRUE_PINBASED_CTLS 0x48D
|
||||
#define IA32_MSR_VMX_TRUE_PROCBASED_CTLS 0x48E
|
||||
#define IA32_MSR_VMX_TRUE_EXIT_CTLS 0x48F
|
||||
#define IA32_MSR_VMX_TRUE_ENTRY_CTLS 0x490
|
||||
|
||||
#define IA32_FS_BASE 0XC0000100
|
||||
#define IA32_GS_BASE 0XC0000101
|
||||
#define IA32_GS_KERNEL_BASE 0XC0000102
|
||||
#define IA32_MSR_EFER 0xc0000080
|
||||
#define IA32_MSR_SYSENTRY 0xc0000082
|
||||
|
||||
|
||||
//#define VMX_MARK ((ULONG64)X) ((ULONG64)X)
|
||||
|
||||
enum
|
||||
{
|
||||
VIRTUAL_PROCESSOR_ID = 0x00000000,
|
||||
POSTED_INTR_NV = 0x00000002,
|
||||
GUEST_ES_SELECTOR = 0x00000800,
|
||||
GUEST_CS_SELECTOR = 0x00000802,
|
||||
GUEST_SS_SELECTOR = 0x00000804,
|
||||
GUEST_DS_SELECTOR = 0x00000806,
|
||||
GUEST_FS_SELECTOR = 0x00000808,
|
||||
GUEST_GS_SELECTOR = 0x0000080a,
|
||||
GUEST_LDTR_SELECTOR = 0x0000080c,
|
||||
GUEST_TR_SELECTOR = 0x0000080e,
|
||||
GUEST_INTR_STATUS = 0x00000810,
|
||||
HOST_ES_SELECTOR = 0x00000c00,
|
||||
HOST_CS_SELECTOR = 0x00000c02,
|
||||
HOST_SS_SELECTOR = 0x00000c04,
|
||||
HOST_DS_SELECTOR = 0x00000c06,
|
||||
HOST_FS_SELECTOR = 0x00000c08,
|
||||
HOST_GS_SELECTOR = 0x00000c0a,
|
||||
HOST_TR_SELECTOR = 0x00000c0c,
|
||||
IO_BITMAP_A = 0x00002000,
|
||||
IO_BITMAP_A_HIGH = 0x00002001,
|
||||
IO_BITMAP_B = 0x00002002,
|
||||
IO_BITMAP_B_HIGH = 0x00002003,
|
||||
MSR_BITMAP = 0x00002004,
|
||||
MSR_BITMAP_HIGH = 0x00002005,
|
||||
VM_EXIT_MSR_STORE_ADDR = 0x00002006,
|
||||
VM_EXIT_MSR_STORE_ADDR_HIGH = 0x00002007,
|
||||
VM_EXIT_MSR_LOAD_ADDR = 0x00002008,
|
||||
VM_EXIT_MSR_LOAD_ADDR_HIGH = 0x00002009,
|
||||
VM_ENTRY_MSR_LOAD_ADDR = 0x0000200a,
|
||||
VM_ENTRY_MSR_LOAD_ADDR_HIGH = 0x0000200b,
|
||||
TSC_OFFSET = 0x00002010,
|
||||
TSC_OFFSET_HIGH = 0x00002011,
|
||||
VIRTUAL_APIC_PAGE_ADDR = 0x00002012,
|
||||
VIRTUAL_APIC_PAGE_ADDR_HIGH = 0x00002013,
|
||||
APIC_ACCESS_ADDR = 0x00002014,
|
||||
APIC_ACCESS_ADDR_HIGH = 0x00002015,
|
||||
POSTED_INTR_DESC_ADDR = 0x00002016,
|
||||
POSTED_INTR_DESC_ADDR_HIGH = 0x00002017,
|
||||
EPT_POINTER = 0x0000201a,
|
||||
EPT_POINTER_HIGH = 0x0000201b,
|
||||
EOI_EXIT_BITMAP0 = 0x0000201c,
|
||||
EOI_EXIT_BITMAP0_HIGH = 0x0000201d,
|
||||
EOI_EXIT_BITMAP1 = 0x0000201e,
|
||||
EOI_EXIT_BITMAP1_HIGH = 0x0000201f,
|
||||
EOI_EXIT_BITMAP2 = 0x00002020,
|
||||
EOI_EXIT_BITMAP2_HIGH = 0x00002021,
|
||||
EOI_EXIT_BITMAP3 = 0x00002022,
|
||||
EOI_EXIT_BITMAP3_HIGH = 0x00002023,
|
||||
VMREAD_BITMAP = 0x00002026,
|
||||
VMWRITE_BITMAP = 0x00002028,
|
||||
XSS_EXIT_BITMAP = 0x0000202C,
|
||||
XSS_EXIT_BITMAP_HIGH = 0x0000202D,
|
||||
GUEST_PHYSICAL_ADDRESS = 0x00002400,
|
||||
GUEST_PHYSICAL_ADDRESS_HIGH = 0x00002401,
|
||||
VMCS_LINK_POINTER = 0x00002800,
|
||||
VMCS_LINK_POINTER_HIGH = 0x00002801,
|
||||
GUEST_IA32_DEBUGCTL = 0x00002802,
|
||||
GUEST_IA32_DEBUGCTL_HIGH = 0x00002803,
|
||||
GUEST_IA32_PAT = 0x00002804,
|
||||
GUEST_IA32_PAT_HIGH = 0x00002805,
|
||||
GUEST_IA32_EFER = 0x00002806,
|
||||
GUEST_IA32_EFER_HIGH = 0x00002807,
|
||||
GUEST_IA32_PERF_GLOBAL_CTRL = 0x00002808,
|
||||
GUEST_IA32_PERF_GLOBAL_CTRL_HIGH = 0x00002809,
|
||||
GUEST_PDPTR0 = 0x0000280a,
|
||||
GUEST_PDPTR0_HIGH = 0x0000280b,
|
||||
GUEST_PDPTR1 = 0x0000280c,
|
||||
GUEST_PDPTR1_HIGH = 0x0000280d,
|
||||
GUEST_PDPTR2 = 0x0000280e,
|
||||
GUEST_PDPTR2_HIGH = 0x0000280f,
|
||||
GUEST_PDPTR3 = 0x00002810,
|
||||
GUEST_PDPTR3_HIGH = 0x00002811,
|
||||
GUEST_BNDCFGS = 0x00002812,
|
||||
GUEST_BNDCFGS_HIGH = 0x00002813,
|
||||
HOST_IA32_PAT = 0x00002c00,
|
||||
HOST_IA32_PAT_HIGH = 0x00002c01,
|
||||
HOST_IA32_EFER = 0x00002c02,
|
||||
HOST_IA32_EFER_HIGH = 0x00002c03,
|
||||
HOST_IA32_PERF_GLOBAL_CTRL = 0x00002c04,
|
||||
HOST_IA32_PERF_GLOBAL_CTRL_HIGH = 0x00002c05,
|
||||
PIN_BASED_VM_EXEC_CONTROL = 0x00004000,
|
||||
CPU_BASED_VM_EXEC_CONTROL = 0x00004002,
|
||||
EXCEPTION_BITMAP = 0x00004004,
|
||||
PAGE_FAULT_ERROR_CODE_MASK = 0x00004006,
|
||||
PAGE_FAULT_ERROR_CODE_MATCH = 0x00004008,
|
||||
CR3_TARGET_COUNT = 0x0000400a,
|
||||
VM_EXIT_CONTROLS = 0x0000400c,
|
||||
VM_EXIT_MSR_STORE_COUNT = 0x0000400e,
|
||||
VM_EXIT_MSR_LOAD_COUNT = 0x00004010,
|
||||
VM_ENTRY_CONTROLS = 0x00004012,
|
||||
VM_ENTRY_MSR_LOAD_COUNT = 0x00004014,
|
||||
VM_ENTRY_INTR_INFO_FIELD = 0x00004016,
|
||||
VM_ENTRY_EXCEPTION_ERROR_CODE = 0x00004018,
|
||||
VM_ENTRY_INSTRUCTION_LEN = 0x0000401a,
|
||||
TPR_THRESHOLD = 0x0000401c,
|
||||
SECONDARY_VM_EXEC_CONTROL = 0x0000401e,
|
||||
PLE_GAP = 0x00004020,
|
||||
PLE_WINDOW = 0x00004022,
|
||||
VM_INSTRUCTION_ERROR = 0x00004400,
|
||||
VM_EXIT_REASON = 0x00004402,
|
||||
VM_EXIT_INTR_INFO = 0x00004404,
|
||||
VM_EXIT_INTR_ERROR_CODE = 0x00004406,
|
||||
IDT_VECTORING_INFO_FIELD = 0x00004408,
|
||||
IDT_VECTORING_ERROR_CODE = 0x0000440a,
|
||||
VM_EXIT_INSTRUCTION_LEN = 0x0000440c,
|
||||
VMX_INSTRUCTION_INFO = 0x0000440e,
|
||||
GUEST_ES_LIMIT = 0x00004800,
|
||||
GUEST_CS_LIMIT = 0x00004802,
|
||||
GUEST_SS_LIMIT = 0x00004804,
|
||||
GUEST_DS_LIMIT = 0x00004806,
|
||||
GUEST_FS_LIMIT = 0x00004808,
|
||||
GUEST_GS_LIMIT = 0x0000480a,
|
||||
GUEST_LDTR_LIMIT = 0x0000480c,
|
||||
GUEST_TR_LIMIT = 0x0000480e,
|
||||
GUEST_GDTR_LIMIT = 0x00004810,
|
||||
GUEST_IDTR_LIMIT = 0x00004812,
|
||||
GUEST_ES_AR_BYTES = 0x00004814,
|
||||
GUEST_CS_AR_BYTES = 0x00004816,
|
||||
GUEST_SS_AR_BYTES = 0x00004818,
|
||||
GUEST_DS_AR_BYTES = 0x0000481a,
|
||||
GUEST_FS_AR_BYTES = 0x0000481c,
|
||||
GUEST_GS_AR_BYTES = 0x0000481e,
|
||||
GUEST_LDTR_AR_BYTES = 0x00004820,
|
||||
GUEST_TR_AR_BYTES = 0x00004822,
|
||||
GUEST_INTERRUPTIBILITY_INFO = 0x00004824,
|
||||
GUEST_ACTIVITY_STATE = 0X00004826,
|
||||
GUEST_SYSENTER_CS = 0x0000482A,
|
||||
VMX_PREEMPTION_TIMER_VALUE = 0x0000482E,
|
||||
HOST_IA32_SYSENTER_CS = 0x00004c00,
|
||||
CR0_GUEST_HOST_MASK = 0x00006000,
|
||||
CR4_GUEST_HOST_MASK = 0x00006002,
|
||||
CR0_READ_SHADOW = 0x00006004,
|
||||
CR4_READ_SHADOW = 0x00006006,
|
||||
CR3_TARGET_VALUE0 = 0x00006008,
|
||||
CR3_TARGET_VALUE1 = 0x0000600a,
|
||||
CR3_TARGET_VALUE2 = 0x0000600c,
|
||||
CR3_TARGET_VALUE3 = 0x0000600e,
|
||||
EXIT_QUALIFICATION = 0x00006400,
|
||||
GUEST_LINEAR_ADDRESS = 0x0000640a,
|
||||
GUEST_CR0 = 0x00006800,
|
||||
GUEST_CR3 = 0x00006802,
|
||||
GUEST_CR4 = 0x00006804,
|
||||
GUEST_ES_BASE = 0x00006806,
|
||||
GUEST_CS_BASE = 0x00006808,
|
||||
GUEST_SS_BASE = 0x0000680a,
|
||||
GUEST_DS_BASE = 0x0000680c,
|
||||
GUEST_FS_BASE = 0x0000680e,
|
||||
GUEST_GS_BASE = 0x00006810,
|
||||
GUEST_LDTR_BASE = 0x00006812,
|
||||
GUEST_TR_BASE = 0x00006814,
|
||||
GUEST_GDTR_BASE = 0x00006816,
|
||||
GUEST_IDTR_BASE = 0x00006818,
|
||||
GUEST_DR7 = 0x0000681a,
|
||||
GUEST_RSP = 0x0000681c,
|
||||
GUEST_RIP = 0x0000681e,
|
||||
GUEST_RFLAGS = 0x00006820,
|
||||
GUEST_PENDING_DBG_EXCEPTIONS = 0x00006822,
|
||||
GUEST_SYSENTER_ESP = 0x00006824,
|
||||
GUEST_SYSENTER_EIP = 0x00006826,
|
||||
HOST_CR0 = 0x00006c00,
|
||||
HOST_CR3 = 0x00006c02,
|
||||
HOST_CR4 = 0x00006c04,
|
||||
HOST_FS_BASE = 0x00006c06,
|
||||
HOST_GS_BASE = 0x00006c08,
|
||||
HOST_TR_BASE = 0x00006c0a,
|
||||
HOST_GDTR_BASE = 0x00006c0c,
|
||||
HOST_IDTR_BASE = 0x00006c0e,
|
||||
HOST_IA32_SYSENTER_ESP = 0x00006c10,
|
||||
HOST_IA32_SYSENTER_EIP = 0x00006c12,
|
||||
HOST_RSP = 0x00006c14,
|
||||
HOST_RIP = 0x00006c16,
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define EXIT_REASON_EXCEPTION_NMI 0
|
||||
#define EXIT_REASON_EXTERNAL_INTERRUPT 1
|
||||
#define EXIT_REASON_TRIPLE_FAULT 2
|
||||
#define EXIT_REASON_INIT 3
|
||||
#define EXIT_REASON_SIPI 4
|
||||
#define EXIT_REASON_IO_SMI 5
|
||||
#define EXIT_REASON_OTHER_SMI 6
|
||||
#define EXIT_REASON_PENDING_INTERRUPT 7
|
||||
#define EXIT_REASON_TASK_SWITCH 9
|
||||
#define EXIT_REASON_CPUID 10
|
||||
#define EXIT_REASON_GETSEC 11
|
||||
#define EXIT_REASON_HLT 12
|
||||
#define EXIT_REASON_INVD 13
|
||||
#define EXIT_REASON_INVLPG 14
|
||||
#define EXIT_REASON_RDPMC 15
|
||||
#define EXIT_REASON_RDTSC 16
|
||||
#define EXIT_REASON_RSM 17
|
||||
#define EXIT_REASON_VMCALL 18
|
||||
#define EXIT_REASON_VMCLEAR 19
|
||||
#define EXIT_REASON_VMLAUNCH 20
|
||||
#define EXIT_REASON_VMPTRLD 21
|
||||
#define EXIT_REASON_VMPTRST 22
|
||||
#define EXIT_REASON_VMREAD 23
|
||||
#define EXIT_REASON_VMRESUME 24
|
||||
#define EXIT_REASON_VMWRITE 25
|
||||
#define EXIT_REASON_VMXOFF 26
|
||||
#define EXIT_REASON_VMXON 27
|
||||
#define EXIT_REASON_CR_ACCESS 28
|
||||
#define EXIT_REASON_DR_ACCESS 29
|
||||
#define EXIT_REASON_IO_INSTRUCTION 30
|
||||
#define EXIT_REASON_MSR_READ 31
|
||||
#define EXIT_REASON_MSR_WRITE 32
|
||||
#define EXIT_REASON_INVALID_GUEST_STATE 33
|
||||
#define EXIT_REASON_MSR_LOADING 34
|
||||
#define EXIT_REASON_MWAIT_INSTRUCTION 36
|
||||
#define EXIT_REASON_MTF 37
|
||||
#define EXIT_REASON_MONITOR_INSTRUCTION 39
|
||||
#define EXIT_REASON_PAUSE_INSTRUCTION 40
|
||||
#define EXIT_REASON_MACHINE_CHECK 41
|
||||
#define EXIT_REASON_TPR_BELOW_THRESHOLD 43
|
||||
|
||||
#define EXIT_REASON_ACCESS_GDTR_OR_IDTR 46
|
||||
#define EXIT_REASON_ACCESS_LDTR_OR_TR 47
|
||||
#define EXIT_REASON_EPT_VIOLATION 48
|
||||
#define EXIT_REASON_EPT_CONFIG 49
|
||||
#define EXIT_REASON_INVEPT 50
|
||||
#define EXIT_REASON_RDTSCP 51
|
||||
|
||||
#define VMX_EXIT_PREEMPT_TIMER 52
|
||||
#define EXIT_REASON_XSETBV 55
|
||||
#define EXIT_REASON_INVPCID 58
|
||||
#define EXIT_REASON_VMFUNCALL 59
|
||||
|
||||
|
||||
|
||||
#define CPU_BASED_VIRTUAL_INTR_PENDING 0x00000004
|
||||
#define CPU_BASED_USE_TSC_OFFSETING 0x00000008
|
||||
#define CPU_BASED_HLT_EXITING 0x00000080
|
||||
#define CPU_BASED_INVLPG_EXITING 0x00000200
|
||||
#define CPU_BASED_MWAIT_EXITING 0x00000400
|
||||
#define CPU_BASED_RDPMC_EXITING 0x00000800
|
||||
#define CPU_BASED_RDTSC_EXITING 0x00001000
|
||||
#define CPU_BASED_CR3_LOAD_EXITING 0x00008000
|
||||
#define CPU_BASED_CR3_STORE_EXITING 0x00010000
|
||||
#define CPU_BASED_CR8_LOAD_EXITING 0x00080000
|
||||
#define CPU_BASED_CR8_STORE_EXITING 0x00100000
|
||||
#define CPU_BASED_TPR_SHADOW 0x00200000
|
||||
#define CPU_BASED_VIRTUAL_NMI_PENDING 0x00400000
|
||||
#define CPU_BASED_MOV_DR_EXITING 0x00800000
|
||||
#define CPU_BASED_UNCOND_IO_EXITING 0x01000000
|
||||
#define CPU_BASED_ACTIVATE_IO_BITMAP 0x02000000
|
||||
#define CPU_BASED_MONITOR_TRAP_FLAG 0x08000000
|
||||
#define CPU_BASED_ACTIVATE_MSR_BITMAP 0x10000000
|
||||
#define CPU_BASED_MONITOR_EXITING 0x20000000
|
||||
#define CPU_BASED_PAUSE_EXITING 0x40000000
|
||||
#define CPU_BASED_ACTIVATE_SECONDARY_CONTROLS 0x80000000
|
||||
|
||||
|
||||
#define SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES 0x00000001
|
||||
#define SECONDARY_EXEC_ENABLE_EPT 0x00000002
|
||||
#define SECONDARY_EXEC_DESCRIPTOR_TABLE_EXITING 0x00000004
|
||||
#define SECONDARY_EXEC_ENABLE_RDTSCP 0x00000008
|
||||
#define SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE 0x00000010
|
||||
#define SECONDARY_EXEC_ENABLE_VPID 0x00000020
|
||||
#define SECONDARY_EXEC_WBINVD_EXITING 0x00000040
|
||||
#define SECONDARY_EXEC_UNRESTRICTED_GUEST 0x00000080
|
||||
#define SECONDARY_EXEC_APIC_REGISTER_VIRT 0x00000100
|
||||
#define SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY 0x00000200
|
||||
#define SECONDARY_EXEC_PAUSE_LOOP_EXITING 0x00000400
|
||||
#define SECONDARY_EXEC_ENABLE_INVPCID 0x00001000
|
||||
#define SECONDARY_EXEC_ENABLE_VM_FUNCTIONS 0x00002000
|
||||
#define SECONDARY_EXEC_ENABLE_VMCS_SHADOWING 0x00004000
|
||||
#define SECONDARY_EXEC_ENABLE_PML 0x00020000
|
||||
#define SECONDARY_EXEC_ENABLE_VIRT_EXCEPTIONS 0x00040000
|
||||
#define SECONDARY_EXEC_XSAVES 0x00100000
|
||||
#define SECONDARY_EXEC_PCOMMIT 0x00200000
|
||||
#define SECONDARY_EXEC_TSC_SCALING 0x02000000
|
||||
|
||||
|
||||
|
||||
#define _EPT_HOOK_TAG ('EPHK')
|
||||
#define _EPT_UNHOOK_TAG ('EPUK')
|
||||
Reference in New Issue
Block a user