Skip to content

Instantly share code, notes, and snippets.

Last active August 20, 2022 21:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
windows cpuid shellcode
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <Windows.h>
static const char cpuidCode[] =
0x48, 0x89, 0xCE, // mov rsi, rcx
0x31, 0xC0, // xor eax, eax
0x0F, 0xA2, // cpuid
0x89, 0x1E, // mov [esi+0], bax
0x89, 0x56, 0x04, // mov [esi+4], edx
0x89, 0x4E, 0x08, // mov [esi+8], ecx
0xC3 // ret
typedef void(*CpuidFn)(char* id);
int main()
DWORD oldProtect;
VirtualProtect((void*)cpuidCode, sizeof(cpuidCode), PAGE_EXECUTE_READWRITE, &oldProtect);
auto cpuid = (CpuidFn)&cpuidCode[0];
char idStr[12+1];
idStr[12] = '\0';
printf("%s\n", idStr);
Copy link

tuket commented Aug 20, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment