View previous topic :: View next topic |
Author |
Message |
Frouk Master Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 494
|
Posted: Sun Feb 20, 2022 11:05 am Post subject: calling functions crashes the game |
|
|
Why is it always happens? When calling too much functions game is crashing
|
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1066 Location: 0x90
|
Posted: Sun Feb 20, 2022 11:38 am Post subject: |
|
|
Is it a function pertaining to the game, or one of your functions?
|
|
Back to top |
|
 |
Frouk Master Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 494
|
Posted: Sun Feb 20, 2022 11:38 am Post subject: |
|
|
the game one, i've posted in wrong section
|
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1066 Location: 0x90
|
Posted: Sun Feb 20, 2022 11:47 am Post subject: |
|
|
I know that stack faults can cause crashes. It's worth checking up calling conventions:
x86 Calling Conventions
|
|
Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 36
Joined: 16 Feb 2017 Posts: 1499
|
Posted: Sun Feb 20, 2022 11:50 am Post subject: |
|
|
1) Call functions one by one and find out in which code it crashed.
2) Connect the functions to a timer and activate them sequentially.
Code: | if executeTimer then executeTimer.Destroy() executeTimer=nil end
executeTimer=createTimer() executeTimer.Interval=100 executeTimer.Enabled=false
function hack1() executeTimer.Enabled=false print(1) executeTimer.Enabled=true end
function hack2() executeTimer.Enabled=false print(2) executeTimer.Enabled=true end
function hack3() executeTimer.Enabled=false print(3) executeTimer.Enabled=true end
function hack4() executeTimer.Enabled=false print(4) executeTimer.Enabled=true end
function hack5() executeTimer.Enabled=false print(5) executeTimer.Enabled=true end
function hack6() executeTimer.Enabled=false print(6) executeTimer.Enabled=true end
local exIndex1=0
local exEnabled=true
executeTimer.OnTimer=function()
exIndex1=tonumber(exIndex1) + 1
if exEnabled==true then
if exIndex1==1 then hack1() end
if exIndex1==2 then hack2() end
if exIndex1==3 then hack3() end
if exIndex1==4 then hack4() end
if exIndex1==5 then hack5() end
if exIndex1==6 then hack6() end
if exIndex1==7 then print("Hack Enabled Finished")
exEnabled=false
executeTimer.Enabled=false
end
end
if exEnabled==false then
-- if exIndex1==1 then hack1Deaktif() end
-- ..
--if exIndex1==7 then print("Hack Deaktivate Finished")
--exEnabled=true
--executeTimer.Enabled=false
--end
end
end
function button1Click()
if exEnabled~=false then
exIndex1=0
executeTimer.Enabled=true
else
showMessage("The hack has already been activated!\nIf you have a deactivated code, add it.")
-- exIndex1=0
-- executeTimer.Enabled=true
end
end
|
_________________
|
|
Back to top |
|
 |
Frouk Master Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 494
|
Posted: Sun Feb 20, 2022 12:13 pm Post subject: |
|
|
LeFiXER wrote: | I know that stack faults can cause crashes. It's worth checking up calling conventions:
x86 Calling Conventions |
so to call function ccode is the best one in cheat engine?
|
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1066 Location: 0x90
|
Posted: Sun Feb 20, 2022 1:13 pm Post subject: |
|
|
Frouk wrote: |
so to call function ccode is the best one in cheat engine? |
I don't think it matters so long as you are setting up the stack the the same way as the convention which is used by the game.
I can't say for certain what is causing the crash but if the function is expecting a certain amount of paramaters and you are passing fewer than what is required, it can crash.
Perhaps someone with more knowledge about this can give a better answer.
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 204
Joined: 25 Jan 2006 Posts: 8581 Location: 127.0.0.1
|
Posted: Sun Feb 20, 2022 1:45 pm Post subject: |
|
|
Wrong section, moved to General Gamehacking.
Crashing when calling a games function directly can be the result of several things.
1. Incorrect parameters. If you call the function without properly handling the expected variables, it will likely crash the game. This can be due to several reasons such as pushing too little or too much onto the stack causing things to misalign, not handling register based parameters properly, not restoring registers after calling properly, etc.
2. Incorrect stack handling. Depending on the calling convention used by the function, you may be responsible for dealing with stack cleanup before and/or after the call. Failing to do so properly could again lead to a misaligned stack causing a crash.
3. Incorrect state handling. If you are just injecting a new thread to call the function at any time, then you could be causing the state of the games flow to corrupt. By this, I mean that when you just inject and call the function at random, you may be causing registers/flags/stack info/etc. to change in unexpected ways at the time of calling the function. You may need to store all registers and flags first before making the call, then restore them afterward, ensuring everything was like it was before you made the call.
4. Race conditions. This goes along with point 3. If you are just injecting a thread and calling the function whenever, you may be hitting a race condition where the game is not expecting that call at a given point and is corrupting other data elsewhere. You may need to introduce a locking method to prevent the race conditions from happening, or you may need to change how you are injecting your code and calls to the function so they run on the same thread as the normal logic of the game that would normally call that function.
5. The call may expect other things to be prepared before being called (either by other calls or state related information) that aren't ready yet. For example, if the game call is to set a value on a specific entity, perhaps another call was expected first to ensure the entity is loaded/ready to take any additional calls first. Or perhaps the call is related to pulling information about the game map, but the map is not available/ready/loaded and the call you are making wouldn't actually be possible normally due to those kinds of conditions.
Generally if you are experiencing crashes, you need to debug the crash to find the exact cause of what happened. There's a lot of conditions that can lead to crashes with this kind of thing.
_________________
- Retired. |
|
Back to top |
|
 |
Frouk Master Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 494
|
Posted: Sun Feb 20, 2022 4:15 pm Post subject: |
|
|
atom0s wrote: | Wrong section, moved to General Gamehacking.
Crashing when calling a games function directly can be the result of several things.
1. Incorrect parameters. If you call the function without properly handling the expected variables, it will likely crash the game. This can be due to several reasons such as pushing too little or too much onto the stack causing things to misalign, not handling register based parameters properly, not restoring registers after calling properly, etc.
2. Incorrect stack handling. Depending on the calling convention used by the function, you may be responsible for dealing with stack cleanup before and/or after the call. Failing to do so properly could again lead to a misaligned stack causing a crash.
3. Incorrect state handling. If you are just injecting a new thread to call the function at any time, then you could be causing the state of the games flow to corrupt. By this, I mean that when you just inject and call the function at random, you may be causing registers/flags/stack info/etc. to change in unexpected ways at the time of calling the function. You may need to store all registers and flags first before making the call, then restore them afterward, ensuring everything was like it was before you made the call.
4. Race conditions. This goes along with point 3. If you are just injecting a thread and calling the function whenever, you may be hitting a race condition where the game is not expecting that call at a given point and is corrupting other data elsewhere. You may need to introduce a locking method to prevent the race conditions from happening, or you may need to change how you are injecting your code and calls to the function so they run on the same thread as the normal logic of the game that would normally call that function.
5. The call may expect other things to be prepared before being called (either by other calls or state related information) that aren't ready yet. For example, if the game call is to set a value on a specific entity, perhaps another call was expected first to ensure the entity is loaded/ready to take any additional calls first. Or perhaps the call is related to pulling information about the game map, but the map is not available/ready/loaded and the call you are making wouldn't actually be possible normally due to those kinds of conditions.
Generally if you are experiencing crashes, you need to debug the crash to find the exact cause of what happened. There's a lot of conditions that can lead to crashes with this kind of thing. |
1. Function that i'm making have no parameters
2. I'm popping all registers, so nothing can cause a crash
3. It might be since i've imported AA script into lua and every time function get called its creating a new thread
4. I've made conditions that won't cause any issues (like if player in menu or not in focus)
5. I don't having this issue tho
|
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Sun Feb 20, 2022 6:07 pm Post subject: |
|
|
The way that you are calling the function might be an issue, also. Have you tried calling it in an different way? For example, if you are using createthread, maybe try a different way and see if it crashes. Set a breakpoint and step through the code to see where/how it is failing.
|
|
Back to top |
|
 |
Frouk Master Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 494
|
Posted: Sun Feb 20, 2022 11:21 pm Post subject: |
|
|
++METHOS wrote: | The way that you are calling the function might be an issue, also. Have you tried calling it in an different way? For example, if you are using createthread, maybe try a different way and see if it crashes. Set a breakpoint and step through the code to see where/how it is failing. |
I tried, but it's will not call the function, i saw where code is failing, the push parameters are kinda broken
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 468
Joined: 09 May 2003 Posts: 25719 Location: The netherlands
|
Posted: Mon Feb 21, 2022 12:12 am Post subject: |
|
|
Quote: |
Function that i'm making have no parameter
|
not even a class instance in e/rcx ?
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
 |
atom0s Moderator
Reputation: 204
Joined: 25 Jan 2006 Posts: 8581 Location: 127.0.0.1
|
Posted: Mon Feb 21, 2022 1:22 am Post subject: |
|
|
Frouk wrote: |
1. Function that i'm making have no parameters
2. I'm popping all registers, so nothing can cause a crash
3. It might be since i've imported AA script into lua and every time function get called its creating a new thread
4. I've made conditions that won't cause any issues (like if player in menu or not in focus)
5. I don't having this issue tho |
Would help to show the disassembly what you are trying to call. As well as the disassembly of the game making a call to that function as well so we can see what it looks like. I'd wager you aren't handing parameters properly even though you think there are none.
_________________
- Retired. |
|
Back to top |
|
 |
Frouk Master Cheater
Reputation: 5
Joined: 22 Jun 2021 Posts: 494
|
Posted: Mon Feb 21, 2022 10:11 am Post subject: |
|
|
Dark Byte wrote: | Quote: |
Function that i'm making have no parameter
|
not even a class instance in e/rcx ? |
idk what about this,but in disassembly i see that function get called without any parameters
atom0s wrote: |
Would help to show the disassembly what you are trying to call. As well as the disassembly of the game making a call to that function as well so we can see what it looks like. I'd wager you aren't handing parameters properly even though you think there are none.
|
Code: | mov fs:[00000000],esp
sub esp,1C
push -01
call 0056E210
mov ecx,[eax+0000047C]
add esp,04
call 00601110
test eax,eax
jne 004396AF
push 70
call 0061A5A0
add esp,04
mov [esp+00],eax
test eax,eax
mov [esp+24],00000000
je 0043965F
push 00
push 00
push 41200000
push 00
mov ecx,eax
call 0067B4E0
jmp 00439661
xor eax,eax
push 00
push eax
push 03
lea ecx,[esp+10]
mov [esp+30],FFFFFFFF
call 004B0A00
push -01
mov [esp+28],00000001
call 0056E210
mov eax,[eax+0000047C]
add esp,04
push 00
lea ecx,[esp+08]
push ecx
lea ecx,[eax+68]
call 004AB420
lea ecx,[esp+04]
mov [esp+24],FFFFFFFF
call 004B0A50
mov ecx,[esp+1C]
mov fs:[00000000],ecx
add esp,28
ret
|
|
|
Back to top |
|
 |
|