2010-07-27 121 views
1

我有一个内联汇编程序函数检测程序是否在虚拟机上运行。但是在64位内联汇编中不再可用,现在在这里是x64内在函数。是否有另一种方法来检测它?检测虚拟化

下面是代码适用于32位的VMWare

布尔IsInsideVMWare(无效) {

布尔RC =真;

__try

{

__asm 
{ 

    push edx 
    push ecx 
    push ebx 

    mov eax, 'VMXh' 
    mov ebx, 0 // any value but not the MAGIC VALUE 
    mov ecx, 10 // get VMWare version 
    mov edx, 'VX' // port number 

    in  eax, dx // read port 
       // on return EAX returns the VERSION 
    cmp ebx, 'VMXh' // is it a reply from VMWare? 
    setz [rc] // set return value 

    pop ebx 
    pop ecx 
    pop edx 
} 

} __except(过滤器(GetExceptionCode()))

{ RC = FALSE; }

return rc; }

回答

0

感谢一位响应者,我找到了一种使用汇编语言创建函数的方法,并将这些函数分隔为.asm文件并将其添加到我的解决方案中。这里是问题:)我不知道如何正确地转换这些代码来编译与VS中的masm(ml.exe)。