I am trying to detect if my Windows is running on Virtual Machine or not. I've found this C code which is known as Joanna Rutkowska's Red Pill:
int swallow_redpill ()
{
unsigned char m[2+4], rpill[] = "\x0f\x01\x0d\x00\x00\x00\x00\xc3";
*((unsigned*)&rpill[3]) = (unsigned)m;
((void(*)())&rpill)();
return (m[5]>0xd0) ? 1 : 0;
}
But when I am running it in my VC++ Project it fails on line
((void(*)())&rpill)();
with message: Access violation executing location 0x003AFCE8. Am I doing smth wrong?