Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <stdio.h>
- #include <stdlib.h>
- #include <windows.h>
- #include <vector>
- #define KEY_WOW64_64KEY 0x0100
- #define KEY_WOW64_32KEY 0x0200
- using namespace std;
- int* cpuid(int eax, int ecx) {
- static int r[4];
- asm volatile (
- "mov %%eax,%0;"
- "mov %%ecx,%1;"
- "cpuid;"
- : "=a" (r[0]), "=b" (r[1]), "=c" (r[2]), "=d" (r[3])
- : "r" (eax), "r" (ecx)
- );
- return r;
- }
- vector<unsigned char> intToBytes(int paramInt)
- {
- vector<unsigned char> arrayOfByte(4);
- for (int i = 0; i < 4; i++)
- arrayOfByte[3 - i] = (paramInt >> (i * 8));
- return arrayOfByte;
- }
- int main() {
- int h1, h2, h3, h4;
- h2 = 0;
- int* reg = cpuid(0,0);
- h3 = reg[3];
- cpuid(1,0);
- h1 = reg[3] & 0xFFFFFDFF;
- h4 = reg[0] | 0x20;
- printf(" 0x%08x",h1);
- printf(" 0x%08x",h2);
- printf(" 0x%08x",h3);
- printf(" 0x%08x",h4);
- printf(" ProductID");
- printf(" [f1.xyz_len24]\n");
- HKEY hKey;
- DWORD dwBufSize = 200;
- byte dwReturn[dwBufSize];
- if( RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",0, KEY_QUERY_VALUE | KEY_WOW64_64KEY | KEY_WOW64_32KEY, &hKey) == ERROR_SUCCESS)
- {
- DWORD error = RegQueryValueEx(hKey,"ProductId",0,0, (LPBYTE)dwReturn, &dwBufSize);
- if(error == ERROR_SUCCESS)
- {
- cout << "ProductID: " << dwReturn << endl;
- }
- else
- {
- cout << "Cannot query for key value; Error is : " << error << ", dwBufSize="<<dwBufSize<<endl;
- }
- }
- RegCloseKey(hKey);
- UCHAR t[4];
- t = intToBytes(h1);
- cout << t << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement