// Opcodes of NtReadVirtualMemory unsigned char opcodes[] = "\x4c\x8b\xd1\xb8\x3f\x00\x00\x00\xf6\x04\x25\x08\x03\xfe\x7f\x01\x75\x03\x0f\x05\xc3"; // allocate executable memory for opcodes void* executableMemory = VirtualAlloc(0, sizeof opcodes, MEM_COMMIT, PAGE_EXECUTE_READWRITE); // move opcodes over from stack to executable memory memcpy(executableMemory, opcodes, sizeof opcodes); // make a real function pointer to the memory containing opcodes, such that we can actually call it fpNtReadVirtualMemory NtReadVirtualMemory = reinterpret_cast(executableMemory);