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 


Debug aa random crash

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
thefreestyle
Cheater
Reputation: 0

Joined: 29 Oct 2015
Posts: 35

PostPosted: Sat May 06, 2017 4:51 am    Post subject: Debug aa random crash Reply with quote

Hi everybody,

I'm making trainer for C&C Tiberian Sun. After some successful scripts i got stuck at Invincibility script.
I found the relevant opcode, made an AOB injection and put my own code which differentiates between my units and ai and make zero damage to mine. Thing is that Invincibility script randomly crashes the game. Sometimes it could take an hour and sometimes few minutes, and im unable to find the cause yet. And here is where i need your help guys ...
My hunch is that somewhere in my code i stumble upon value that is incomparable or not compatible when i move it to another register and thus only when i hit those occasions the game crashes. Of course its a guess. How can i found what causes the crash ? The game crashes with an error and then quits to desktop. I cant find crash logs anywhere. This is the code :
Code:

{ Game   : game.exe
}

[ENABLE]

aobscanmodule(INJECT,game.exe,8B 45 00 8B CA 2B) // should be unique
alloc(newmem,$1000)

label(code)
label(return)
//label(original)
label(player)

newmem:

code:
  push eax
  push ebx
  mov ebx,["game.exe"+003E2284]+0
  cmp ebx,[esi+ec]
  pop eax
  pop ebx
  je player

  push eax
  mov eax,[esi+ec]
  mov eax,[eax+34]
  cmp eax,00000101
  pop eax
  je player

  mov eax,[ebp+00]
  mov ecx,edx
  jmp return

player:
  mov [ebp+00],0
  mov eax,[ebp+00]
  mov ecx,edx
  jmp return
//  jmp original

//original:
//  mov eax,[ebp+00]
//  mov ecx,edx
//  jmp return

INJECT:
  jmp newmem
return:
registersymbol(INJECT)

[DISABLE]

INJECT:
  db 8B 45 00 8B CA

unregistersymbol(INJECT)
dealloc(newmem)

{
// ORIGINAL CODE - INJECTION POINT: "game.exe"+1860DF

"game.exe"+1860BE: EB 03                    -  jmp game.exe+1860C3
"game.exe"+1860C0: 89 55 00                 -  mov [ebp+00],edx
"game.exe"+1860C3: DB 44 24 38              -  fild dword ptr [esp+38]
"game.exe"+1860C7: A1 88 C4 74 00           -  mov eax,[game.exe+34C488]
"game.exe"+1860CC: DC 88 B0 0E 00 00        -  fmul qword ptr [eax+00000EB0]
"game.exe"+1860D2: DB 44 24 14              -  fild dword ptr [esp+14]
"game.exe"+1860D6: D8 D9                    -  fcomp st(0),st(1)
"game.exe"+1860D8: DF E0                    -  fnstsw ax
"game.exe"+1860DA: F6 C4 41                 -  test ah,41
"game.exe"+1860DD: 75 24                    -  jne game.exe+186103
// ---------- INJECTING HERE ----------
"game.exe"+1860DF: 8B 45 00                 -  mov eax,[ebp+00]
"game.exe"+1860E2: 8B CA                    -  mov ecx,edx
// ---------- DONE INJECTING  ----------
"game.exe"+1860E4: 2B C8                    -  sub ecx,eax
"game.exe"+1860E6: 89 4C 24 38              -  mov [esp+38],ecx
"game.exe"+1860EA: DB 44 24 38              -  fild dword ptr [esp+38]
"game.exe"+1860EE: D8 D9                    -  fcomp st(0),st(1)
"game.exe"+1860F0: DF E0                    -  fnstsw ax
"game.exe"+1860F2: F6 C4 01                 -  test ah,01
"game.exe"+1860F5: DD D8                    -  fstp st(0)
"game.exe"+1860F7: 74 0C                    -  je game.exe+186105
"game.exe"+1860F9: C7 44 24 10 03 00 00 00  -  mov [esp+10],00000003
"game.exe"+186101: EB 02                    -  jmp game.exe+186105
}


Any insights would be very appreciated !
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 May 06, 2017 6:07 am    Post subject: Reply with quote

Not sure what you're doing with [esi+EC], but did notice this:

Code:
push eax
push ebx
//code
pop eax
pop ebx


Should be:

Code:
push eax
push ebx
//code
pop ebx
pop eax
Back to top
View user's profile Send private message
thefreestyle
Cheater
Reputation: 0

Joined: 29 Oct 2015
Posts: 35

PostPosted: Sat May 06, 2017 11:42 am    Post subject: Reply with quote

Hi ++METHOS,

Good catch, missed that one.

Eventually it seems that i got it sorted. Apparently the problem was at :

Code:

  mov eax,[esi+ec]
  mov eax,[eax+34]
 


While playing with break points i managed to find that sometimes the 1st line was zero and eax was zero too and in turn it crashed at second line.

None the less thank you very much for helping !!

p.s. - On the side note, im still curious how one actually can debug those random crashes except of using break points and playing with them (which is very time consuming and no result is guaranteed) ? What steps you take in this situation ?
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 May 06, 2017 12:44 pm    Post subject: Reply with quote

Again, not sure what you're doing with [esi+EC], but there are many ways to validate data before moving it around in an effort to mitigate crashing the target process.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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