Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#pragma section(".remotery_code", read, execute)
__declspec(allocate(".remotery_code"))
static const uint8_t code[] =
{
0x50, // push rax
0x9C, // pushfq
0x53, // push rbx
0x51, // push rcx
0x52, // push rdx
0xB8, 0x01, 0x00, 0x00, 0x00, // mov eax, 1
0x0F, 0xA2, // cpuid
0xC1, 0xEB, 0x18, // shr ebx, 24
0x89, 0x5F, 0x10, // mov dword ptr [rdi + 16], ebx
0xC7, 0x47, 0x0C, 0x00, 0x00, 0x00, 0x00, // mov dword ptr [rdi + 12], 0
0x5A, // pop rdx
0x59, // pop rcx
0x5B, // pop rbx
0x48, 0x8B, 0x07, // mov rax, qword ptr [rdi + 0]
0x48, 0x8B, 0x7F, 0x08, // mov rdi, qword ptr [rdi + 8]
0x9D, // popfq
0xC3 // ret
};
static void (*const func)() = (void (*const)())code;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment