我就加了一个检测是否为虚拟机的函数,像每次加多行汇编老是报错,求解
[Error] expected '(' before '{' token
[Error] 'push' was not declared in this scope
[Error] expected ')' before numeric constant
[Error] expected type-specifier before numeric constant
[Error] expected '{' before numeric constant
[Error] expected ';' before ')' token
BOOL IsInsideVMWare()
{
bool rc = true;
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
}
}catch(EXCEPTION_EXECUTE_HANDLER)
{
rc = false;
}
return rc;
}
/*
from https://www.codeproject.com/Articles/9823/Detect-if-your-program-is-running-inside-a-Virtual
*/