Last active
January 10, 2020 01:54
-
-
Save hugsy/f5494e7ba282986964191b3309fcd383 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* QnD cpuid C script(tested win & lin) | |
*/ | |
#include <stdio.h> | |
#include <stdint.h> | |
using namespace std; | |
#include <iostream> | |
#include <array> | |
#define __cpuid(id, mem) \ | |
__asm__ ("cpuid\n\t" \ | |
: "=a" (mem[0]), "=b" (mem[1]), "=c" (mem[2]), "=d" (mem[3]) \ | |
: "0" (id)) | |
int main(int argc, char** argv) | |
{ | |
std::array<uint32_t, 4> regs; | |
__cpuid(0, regs.data()); | |
char vendor[0x20] = {0}; | |
*reinterpret_cast<uint32_t*>(vendor) = regs[1]; | |
*reinterpret_cast<uint32_t*>(vendor + 4) = regs[3]; | |
*reinterpret_cast<uint32_t*>(vendor + 8) = regs[2]; | |
auto vendor_s = std::string(vendor, 0x20); | |
std::cout << "cpuid(0)=" << vendor_s.c_str() << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment