#include #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; }