Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Game crashes after injecting this short piece of code.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Fri Mar 25, 2016 11:33 pm    Post subject: Game crashes after injecting this short piece of code. Reply with quote

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. Very Happy
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sat Mar 26, 2016 7:13 am    Post subject: Reply with quote

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
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Mar 26, 2016 7:46 am    Post subject: Reply with quote

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
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Sat Mar 26, 2016 9:17 am    Post subject: Reply with quote

@++METHOS

Thank you as I always do. Very Happy
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. Very Happy
http://forum.cheatengine.org/viewtopic.php?t=588737

Did I misunderstand something? If so, I am sorry.
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sat Mar 26, 2016 9:25 am    Post subject: Reply with quote

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
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Sat Mar 26, 2016 9:42 am    Post subject: Reply with quote

++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
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sat Mar 26, 2016 9:48 am    Post subject: Reply with quote

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
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Sat Mar 26, 2016 9:58 am    Post subject: Reply with quote

++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. Very Happy
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat Mar 26, 2016 10:54 am    Post subject: Reply with quote

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
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Sat Mar 26, 2016 5:08 pm    Post subject: Reply with quote

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. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites