@Khrys,
Yeah I dumped the addresses and they were too far apart. Just wanted to double-check If I was doing anything wrong. Will replace
jmp rel32 with
mov rax, imm64 and test it out.
However I am trying a few other things
1. The Detour:
a) I tried to use the Microsoft Detours (My OCD kicked in and now I wanna try it) now that I have the boilerplate stuff in place. The thing is, it is designed to be built/used as a static library and the default Makefile provided only works with MSVC. Is there any way to make MSVC *.lib work with FPC/Lazarus? Parallelly I wrote my own Makefile and compiled it with MinGW got the libdetours.a, but trying to link it with {$LINKLIB} throws a lot of undefined symbols in libdetours.a itself. Tried adding libkernel32.a and got most of them fixed but in the end can't get a few symbols resolved, linking libstdc++.a fails with some COFF error.
https://github.com/microsoft/detours How do I proceed with this now??
b) Will also try to modify your code with
mov rax, imm64, just so I have a way to do it without any external dependency.
2. The Payload:
a) Is there any other way to get the address/pointer of the sum function from payload code besides what I did?
b) Is it possbile to calculate even the offset dynamically at runtime??
BTW, in case someone wants to setup (Only the) MSVC compiler without the full visual studio BS, helped me setup an MSVC build environment quickly and easy to get rid off.
https://gist.github.com/mmozeiko/7f3162ec2988e81e56d5c4e22cde9977