主题
启用VT驱动 - EnableVtDriver
函数简介
启用或禁用VT驱动。
接口名称
EnableVtDriverDLL调用
c
int32_t EnableVtDriver(int64_t instance, int32_t enable);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| enable | 整数型 | 是否启用VT驱动(1 启用,0 禁用)。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int ret = ola.EnableVtDriver(1);
if (ret == 1) {
// 启用成功
} else {
// ret 即为错误码,详见驱动错误码说明
}csharp
using OLAPlug;
var ola = new OLAPlugServer();
int ret = ola.EnableVtDriver(0);
if (ret == 1)
{
// 操作成功
}python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
ret = ola.EnableVtDriver(0)
if ret == 1:
pass # 操作成功java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
int ret = ola.EnableVtDriver(0);
if (ret == 1) {
// 操作成功
}go
import "github.com/ola/olaplug/olaplug"
ola, _ := olaplug.NewOLAPlugServer("OLAPlug_x64.dll")
defer ola.ReleaseObj()
ret := ola.EnableVtDriver(0)
if ret == 1 {
// 操作成功
}rust
use olaplug::OLAPlugServer;
let ola = OLAPlugServer::new("OLAPlug_x64.dll").unwrap();
let ret = ola.enablet_vt_driver(0);
if ret == 1 {
// 操作成功
}cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.EnableVtDriver(0)
if(ret == 1) {
// 操作成功
}vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.EnableVtDriver(0)
If ret = 1 Then
' 操作成功
End Iftext
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.EnableVtDriver(0)
.如果真 (ret = 1)
' 操作成功
.如果真结束aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.EnableVtDriver(0);
if(ret == 1){
// 操作成功
}text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.EnableVtDriver(0)
如果真 (ret = 1)
{
// 操作成功
}cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int32_t ret = ola.EnableVtDriver(0);
if (ret == 1) {
// 操作成功
}原生 DLL 调用
cpp
EnableVtDriver(instance, 0);csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int EnableVtDriver(long ola, int enable);
EnableVtDriver(instance, 0);python
from ctypes import CDLL, c_int, c_int64, create_string_buffer
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ola.EnableVtDriver(instance, 0)返回值
成功返回 1;失败时返回值即为错误码(与 DriverTest 一致),可配合 GetLastError() / GetLastErrorString() 查询。
完整错误码表见 驱动错误码说明 - DriverErrorCodes。
| 十进制(int32) | 十六进制 | 说明 |
|---|---|---|
1 | — | 成功(enable=1 时表示 VT 已启用;enable=0 时表示已禁用标志)。 |
0 | — | 权限不足,或与驱动通讯失败(未拿到 Status)。 |
| 其他负数 | 见码表 | 驱动 Status,例如 -536858608(0xE0003010 CPU 不支持 VT-x)、-536858607(0xE0003011 BIOS 禁用 VT)、-1073741790(0xC0000022 权限不足)。 |
TIP
接口返回值即为十进制错误码,可在 驱动错误码说明 中 Ctrl+F 搜索该数字快速定位。
注意事项
| 项目 | 说明 |
|---|---|
| 管理员权限 | 须以 管理员权限 运行;内置欧拉驱动会自动加载,无需手动 LoadDriver。 |
| 驱动 | 启用 VT 驱动后,才可使用 VT 相关的伪造内存读写接口。 |
| 错误排查 | 失败时优先查看返回值与 驱动错误码说明。 |
