Joined: 30 Jan 2017
|Posted: Wed Aug 09, 2017 8:41 pm Post subject: Help with opcodes, please.
|I'm currently hacking a unity game and all I want to do is to call a function which opens the bank, pretty useful when farming items.
I can call it through Cheat Engine, just jitting the code using mono and looking at the instructions to find the call.
The function I jit calls the actual "show" function, so I allocate some memory and copy the call (__cdecl) with its opcode/address (0xDEADBEEF).
I just create a new thread from that code and it works like a charm, BUT, I don't want to keep opening the Cheat Engine to do it, neither create a thread all the time I need to open the bank through this call.
So I created a C++ Project to automate this, there's the problem, I got the compiled function address just as Cheat Engine does, but I can't copy the "show" function using memcpy or even memset, because when I allocate some memory to put the call in it, instead of copying the exact same function opcode (The Address) it takes the new memory allocated and calls the address relative to it.
This is the original code location:
0xDEADBEEF: E8 05000000 call 0xDEADBEF0 -> Show Bank
I copied the memory address of it (0xDEADBEEF) and allocated some space to put the address in it, but I didn't find any way to copy a memory address directly, then I copied its bytes (E8 05000000) to the new location, now the bytes got copied, but the new location doesn't point anymore to 0xDEADBEEF, but instead it points to the new memory location which is a bunch of INT 3.
I hope I could explain it in a easy way.
In case you didn't understand what I want, I just want to allocate some space just like I did with Cheat Engine and put the same call which is in the jit to the memory allocated, but copying the bytes didn't solve.