bool IsSomethingUnknown() { __try { __asm { // Execute the magic code sequence // Taken from Microsoft's vmcheck.dll _emit 0x0F mov eax, 0x45C70001 cld _emit 0xFF _emit 0xFF _emit 0xFF _emit 0xFF }; } __except(1) { // An exception occured, this is possibly a real processor return false; } // We succeeded, we're something unknown (Virtual PC for MAC?) return true; } bool IsVirtualPC() { __try { __asm { // Execute the magic code sequence // Taken from Microsoft's vmcheck.dll mov eax, 1 _emit 0x0F // db 0fh _emit 0x3F // aas _emit 0x07 // pop es _emit 0x0B // or eax, edi _emit 0xC7 _emit 0x45 // inc ebp _emit 0xFC // cld _emit 0xFF // dd 0ffffffffh _emit 0xFF _emit 0xFF _emit 0xFF }; } __except(1) { // An exception occured, we ain't in Virtual PC return false; } // We succeeded, we're Virtual PC emulated return true; } bool IsVMWare() { unsigned long _EBX; __try { __asm { // Execute the magic code sequence // Taken from some website // http://www.delphipraxis.net/topic7552_testen+ob+das+programm+in+einer+vmware+vm+ausgefuehrt+wird.html push ebx mov eax, 0x564D5868 mov ebx, 0x8685D465 // Ensure 0x564D5868 isn't in EBX :) mov ecx, 10 // The command for obtaining VMWare version information mov dx, 0x5658 in eax, dx mov _EBX, ebx pop ebx }; } __except(1) { // An exception occured, we ain't in VMWare return false; } // The code was executed successfuly, check for the magic value return _EBX == 0x564D5868; }