Advertisement
Guest User

Untitled

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