In 32 bit it wasn't problem to understand if the program runs on virtual or native machine using inline assembly. But in 64 bit inline assemblers is no longer avaible and MSDN site says use x64 intrinsics instead. Does anyone know how to cope with it?
bool IsInsideVMWare(void)
{
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
}
}
__except(filter(GetExceptionCode()))
{
rc = false;
}
of course it is better if there is no differences between wm and native machine :) but it can be done in 32bit system with inline assembly but can't in 64bit because i can't use that. i need to detect it :)