View previous topic :: View next topic |
Author |
Message |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Fri Mar 25, 2016 11:33 pm Post subject: Game crashes after injecting this short piece of code. |
|
|
Game crashes after injecting my code, so I did some tests to figure out which part caused the crash by deleting my code step by step, and here is the result:
Code: |
[ENABLE]
alloc(newmem,2048)
label(conditionOne)
label(returnhere)
label(originalcode)
label(exit)
newmem:
conditionOne: <----------------------
db 0
jmp originalcode
originalcode:
mov [ebx+4C],eax
mov esi,[esi]
exit:
jmp returnhere
"game.exe"+110000:
jmp newmem
returnhere:
[DISABLE]
dealloc(newmem)
"game.exe"+110000:
mov [ebx+4C],eax
mov esi,[esi]
|
I only declare a variable and the game crashes. Can't figure out the problem with the declaration though. Thanks in advance.
ParkourPenguin, I need you.
|
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Sat Mar 26, 2016 7:13 am Post subject: |
|
|
What is conditionOne being used for?
Anyway, you can try this:
Code: | [ENABLE]
alloc(newmem,2048)
label(conditionOne)
label(returnhere)
label(originalcode)
label(exit)
registersymbol(conditionOne)
newmem:
jmp originalcode
originalcode:
mov [ebx+4C],eax
mov esi,[esi]
exit:
jmp returnhere
conditionOne:
db 0
"game.exe"+110000:
jmp newmem
returnhere:
[DISABLE]
dealloc(newmem)
"game.exe"+110000:
mov [ebx+4C],eax
mov esi,[esi]
unregistersymbol(conditionOne) |
|
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Mar 26, 2016 7:46 am Post subject: |
|
|
You cannot declare variables inside of the execution path.
Your code jumps to the newmem label and then tries to execute your variable as if it were an instruction.
Notice how ++METHOS defined it outside of the execution path.
The instruction before it causes the execution to jump over the variable.
|
|
Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Sat Mar 26, 2016 9:17 am Post subject: |
|
|
@++METHOS
Thank you as I always do.
conditionOne is just an integer variable that I will use to compare with another value and do some actions based on the comparison. To be more specific, I want to call "getTickCount" and then "srand" and then "rand", then "mov [conditionOne],eax" to get the random value.
@Zaner
I did what exactly you told me to.
http://forum.cheatengine.org/viewtopic.php?t=588737
Did I misunderstand something? If so, I am sorry.
|
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Sat Mar 26, 2016 9:25 am Post subject: |
|
|
By the way, you can do things like this, as child entries, as long as things are set up properly inside the parent script:
Code: | [ENABLE]
ep2_switch:
db 1
[DISABLE]
ep2_switch:
db 0 |
I know that's not what you were asking about, but just to elaborate on what can be done.
|
|
Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Sat Mar 26, 2016 9:42 am Post subject: |
|
|
++METHOS wrote: | By the way, you can do things like this, as child entries, as long as things are set up properly inside the parent script:
Code: | [ENABLE]
ep2_switch:
db 1
[DISABLE]
ep2_switch:
db 0 |
I know that's not what you were asking about, but just to elaborate on what can be done. |
Thanks for showing me that. I don't quite understand what you said, what do you mean by "set up properly"? What needs to be set up? Anyway, I am asking too many questions, sorry. But I will keep it in mind and come back to it when I have a better understanding of CE.
|
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Sat Mar 26, 2016 9:48 am Post subject: |
|
|
What the above code does, is allow you to create toggle entries for activating cheats in lieu of setting up custom addresses and assigning hotkeys for values. Doing this will allow you to assign activation/deactivation sounds to your cheats if you decide to compile a trainer and will also allow users to simply click the toggle boxes for cheat activation/deactivation, instead of setting values manually or using multiple hotkeys. This comes in handy when you have multi-cheat scripts (e.g. one script that handles god mode and one-hit kills).
As far as being set up properly, you have to integrate these variables inside your script(s), obviously, as well as allocate any memory as needed.
|
|
Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Sat Mar 26, 2016 9:58 am Post subject: |
|
|
++METHOS wrote: | What the above code does, is allow you to create toggle entries for activating cheats in lieu of setting up custom addresses and assigning hotkeys for values. Doing this will allow you to assign activation/deactivation sounds to your cheats if you decide to compile a trainer and will also allow users to simply click the toggle boxes for cheat activation/deactivation, instead of setting values manually or using multiple hotkeys. This comes in handy when you have multi-cheat scripts (e.g. one script that handles god mode and one-hit kills).
As far as being set up properly, you have to integrate these variables inside your script(s), obviously, as well as allocate any memory as needed. |
Thanks for the explanation.
|
|
Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Mar 26, 2016 10:54 am Post subject: |
|
|
When you use the AOB Injection instead of Code Injection, it creates a block like the following:
Code: | newmem:
code:
//original code
INJECT:
jmp code |
Notice how this template uses JMP CODE instead of JMP NEWMEM.
This means you could define your variables directly under NEWMEM if you choose.
You just need to make sure that you don't define your variables in a place that is going to be executed as instructions.
|
|
Back to top |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Sat Mar 26, 2016 5:08 pm Post subject: |
|
|
Zanzer wrote: | When you use the AOB Injection instead of Code Injection, it creates a block like the following:
Code: | newmem:
code:
//original code
INJECT:
jmp code |
Notice how this template uses JMP CODE instead of JMP NEWMEM.
This means you could define your variables directly under NEWMEM if you choose.
You just need to make sure that you don't define your variables in a place that is going to be executed as instructions. |
Sorry for the late reply. Thank you Zaner, your explanation helps a lot.
|
|
Back to top |
|
 |
|