I have this code that is supposed to insert the address of my function into memory by using LEA and then Calling it but when I do this it insert the correct function address using LEA but something completely different. How would I change the code down below to lea rax to the correct function?
BYTE orig[] = { 0x48, 0x8D, 0x04, 0x25 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00, 0x00, 0x00, 0x00, 0xFF, 0xD0 };
BYTE shell_code[] = { 0x48, 0x8D, 0x04, 0x25 }; //lea rax
memcpy((PVOID)((ULONG_PTR)orig), &shell_code, sizeof(shell_code));
uintptr_t hook_address = reinterpret_cast<uintptr_t>(kernel_function_address);
memcpy((PVOID)((ULONG_PTR)orig + sizeof(shell_code)), &hook_address, sizeof(void*));
This is the output:
But the function address should be something more similar to:
I would appreciate any help possible, thank you!