cfun/c_cpu.rs
1#[cfg(all(target_arch = "x86_64", target_os = "windows"))]
2pub fn cpu_is_enable_virtual() -> bool {
3 use std::arch::x86_64::__cpuid;
4 let cpuid_result = unsafe { __cpuid(1) };
5 // 检查 HyperVisor 是否存在(ECX 位 31)
6 let hypervisor_present = (cpuid_result.ecx & (1 << 31)) != 0;
7 hypervisor_present
8}