| View previous topic :: View next topic |
| Author |
Message |
xXDarkBloodXx How do I cheat?
Reputation: 0
Joined: 20 May 2011 Posts: 3
|
Posted: Fri May 20, 2011 5:47 pm Post subject: [HELP] problem with asm jmp code in C++ |
|
|
Ok I have no problems with most of my dll! It injects and ejects from the game with no problem. Code caves are initialized correctly everything seems to work fine! if I access my codecave with a simple call instead of a jmp, and use a ret to return it works perfectly. However if i try to do a jmp and then a jmp back it immediately crashes the game upon execution of the returning jmp. My problem is that when it writes my code to the codecave and I look at it in Cheat Engine the jmp back looks like this "jmp dword ptr ds:[00484766]" and the game crashes the momment it tries to execute the jmp. however if i use cheat engine to re-write the jmp so it looks like so "jmp 00484766" it works perfectly. Anyone have any ideas how I might be able to fix this issue? Is there a different way of writing the jmp in the asm block that will write it in a way it will look like "jmp 00484766"?
| Code: |
DWORD Addy_GodMode = 0x00484761;
*(BYTE*)Addy_GodMode = 0xe9;
*(DWORD*)(Addy_GodMode+1) = JMP(Addy_GodMode,GodMode_CodeCave);
__declspec(naked) void GodMode_CodeCave(){
__asm{
jmp dword ptr ds:[Addy_GodMode+5]
}
}
|
Ive also tried "jmp dword [Addy_GodMode+5]" and "jmp dword ptr [Addy_GodMode+5]" they all crash the game immediatly on execution.
**Note: The only reason im doing an immediate jump back is for testing. Once I get the jmp working correctly then ill add the rest of my code back in!
Anyone got any ideas?
Thanks in advance, for any help!
|
|
| Back to top |
|
 |
661089799107 Expert Cheater
Reputation: 3
Joined: 25 Jan 2009 Posts: 186
|
Posted: Fri May 20, 2011 9:04 pm Post subject: |
|
|
| You're adding '5' to the address of your variable (&Addy_GodMode+5), and then trying to jump to the value of that address. Instead of adding '5' to '0x00484761', and jumping to '0x00484766'.
|
|
| Back to top |
|
 |
xXDarkBloodXx How do I cheat?
Reputation: 0
Joined: 20 May 2011 Posts: 3
|
Posted: Sat May 21, 2011 12:45 am Post subject: |
|
|
Thank you for your help, and forgive me if im wrong but if that was the case then why would cheat engine show "jmp dword ptr ds:[00484766]" with the correct address of 00484766?
Furthermore if doing this is incorrect!
| Code: | | jmp dword ptr ds:[Addy_GodMode+5] |
then what would be the correct way?
I also tried
| Code: | | jmp dword ptr ds:0x00484766 |
Again unfortunately this caused an immediate crash on execution of jmp.
Ive been looking through the forums and google for almost a week now trying to figure this out, with no success! Apparently when it comes to jmps in dll injection routines im at a loss! Any help would be greatly appreciated!
Thank You
|
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Sat May 21, 2011 1:01 am Post subject: |
|
|
| Code: | mov eax, dword ptr ds:[Addy_Godmode]
add eax, 5
jmp eax |
_________________
|
|
| Back to top |
|
 |
661089799107 Expert Cheater
Reputation: 3
Joined: 25 Jan 2009 Posts: 186
|
Posted: Sat May 21, 2011 2:30 am Post subject: |
|
|
| Remove __declspec(naked)
|
|
| Back to top |
|
 |
xXDarkBloodXx How do I cheat?
Reputation: 0
Joined: 20 May 2011 Posts: 3
|
Posted: Sun May 22, 2011 2:04 am Post subject: |
|
|
Thanks both for your help! I changed the code to that of what sponge suggested and that did the trick! Removing the __declspec(naked) had no effect one way or the other however, but thanks for the suggestion none the less.
| Code: |
mov eax, dword ptr ds:[Addy_GodMode]
add eax, 5
jmp eax
|
|
|
| Back to top |
|
 |
|