Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.75 KB | None | 0 0
  1. void cpu_chk()
  2. {
  3.     uint32_t returnEAX;
  4.     char vendor[13];
  5.  
  6.     __asm__ __volatile__(
  7.         "pushfl                  \n\t"
  8.         "pushfl                  \n\t"
  9.         "xorl  $0x200000, (%esp) \n\t"
  10.         "popfl                   \n\t"
  11.         "pushfl                  \n\t"
  12.         "popl  %eax              \n\t"
  13.         "xorl (%esp), %eax       \n\t"
  14.         "popfl                   \n\t"
  15.     : "=a" (returnEAX) );
  16.  
  17.     if (eax == 0) return;
  18.  
  19.     ((unsigned int*)vendor)[0] = cpuid_getreg(0, CR_EBX);
  20.     ((unsigned int*)vendor)[1] = cpuid_getreg(0, CR_EDX);
  21.     ((unsigned int*)vendor)[2] = cpuid_getreg(0, CR_ECX);
  22.  
  23.     /* null termination */
  24.     vendor[12] = '\0';
  25.  
  26.     console_print("CPU Vendor: %s 0x%X\n", vendor, eax);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement