登录  | 立即注册

游客您好!登录后享受更多精彩

查看: 154|回复: 0

VT虚拟化源码支持32位多核

[复制链接]

171

主题

21

回帖

1048

积分

管理员

积分
1048
发表于 2025-2-22 23:17:05 | 显示全部楼层 |阅读模式
// 开启Intel VT内核调试
NTSTATUS NTAPI StartVirtualTechnology()
{
        CCHAR cProcessorNumber;
        NTSTATUS Status, CallbackStatus;
        KIRQL OldIrql;

        DbgPrint("mvx:在每隔核心上开启VT HvmSwallowBluepill(): Going to subvert %d processor%s\n",
                KeNumberProcessors, KeNumberProcessors == 1 ? "" : "s");

        MmInitManager();
        KeInitializeMutex(&MY_HvmMutex, 0);
        KeWaitForSingleObject(&MY_HvmMutex, Executive, KernelMode, FALSE, NULL);
        for (cProcessorNumber = 0; cProcessorNumber < KeNumberProcessors; cProcessorNumber++) 
        {
                DbgPrint("vmx:HvmSwallowBluepill(): CPU数量 #%d\n", cProcessorNumber);
                KeSetSystemAffinityThread((KAFFINITY)(1 << cProcessorNumber));
                OldIrql = KeRaiseIrqlToDpcLevel();
                Asm_CreateVmx();
                KeLowerIrql(OldIrql);
                KeRevertToUserAffinityThread();
        }
        KeReleaseMutex(&MY_HvmMutex, FALSE);
        return STATUS_SUCCESS;
}


/* 关闭VT内核调试 */
NTSTATUS NTAPI StopVirtualTechnology()
{
        CCHAR cProcessorNumber;
        NTSTATUS Status, CallbackStatus;
        KIRQL OldIrql;
        RegCR4 uCr4;

        DbgPrint("vmx:HvmSpitOutBluepill(): Going to liberate %d processor%s\n",
                KeNumberProcessors, KeNumberProcessors == 1 ? "" : "s");
        KeWaitForSingleObject(&MY_HvmMutex, Executive, KernelMode, FALSE, NULL);
        for (cProcessorNumber = 0; cProcessorNumber < KeNumberProcessors; cProcessorNumber++) 
        {
                KeSetSystemAffinityThread((KAFFINITY)(1 << cProcessorNumber));
                OldIrql = KeRaiseIrqlToDpcLevel();
                {
                        Vmx_VmCall('SVT');
                        TO_DATA32(uCr4) = Asm_GetCr4();
                        uCr4.VMXE = 0;
                        Asm_SetCr4(TO_DATA32(uCr4));
                }
                KeLowerIrql(OldIrql);
                KeRevertToUserAffinityThread();
        }
        DbgPrint("vmx:HvmSpitOutBluepill(): Finished at irql %d\n", KeGetCurrentIrql());
        KeReleaseMutex(&MY_HvmMutex, FALSE);
        MmShutdownManager();
        return STATUS_SUCCESS;
}



游客,如果您要查看本帖隐藏内容请回复

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|断点社区 |网站地图

GMT+8, 2025-4-5 04:06 , Processed in 0.180280 second(s), 19 queries , Yac On.

Powered by XiunoBBS

Copyright © 2001-2025, 断点社区.

快速回复 返回顶部 返回列表