Advertisement
waliedassar

Detect Hypervisor

Oct 8th, 2012
5,689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. //http://waleedassar.blogspot.com (@waleedassar)
  2. //Detect Hypervisors
  3. #include "stdafx.h"
  4. #include "windows.h"
  5. #include "stdio.h"
  6.  
  7. int main(int argc, char* argv[])
  8. {
  9.     bool x=0;
  10.     __asm
  11.     {
  12.         pushad
  13.         pushfd
  14.         pop eax
  15.         or eax,0x00200000
  16.         push eax
  17.         popfd
  18.         pushfd
  19.         pop eax
  20.         and eax,0x00200000
  21.         jz CPUID_NOT_SUPPORTED ;Are you still alive?
  22.         xor eax,eax
  23.         xor edx,edx
  24.         xor ecx,ecx
  25.         xor ebx,ebx
  26.         inc eax ;processor info and feature bits
  27.         cpuid
  28.         test ecx,0x80000000 ;Hypervisor present
  29.         jnz Hypervisor
  30.         mov x,0
  31.         jmp bye
  32. Hypervisor:
  33.         mov x,1
  34.         jmp bye
  35. CPUID_NOT_SUPPORTED:
  36.         mov x,2
  37. bye:
  38.         popad
  39.     }
  40.     if(x==1)
  41.     {
  42.         MessageBox(0,"Hypervisor detected","waliedassar",0);
  43.         ExitProcess(3);
  44.     }
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement