 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Mon Feb 20, 2012 12:39 pm Post subject: |
|
|
i have finally managed to write my own exception handler code and fully understand it ... i think
however now the code works like before for the levels that have "the feature on" ... but for those level who don't have it, there's still a cheat/code bug.
now the game doesn't crash at all (because of the exception handler) and therefore doesn't close at the very beginning of level load 1% ...
now the game just stop's loading at 90% and in task manager i see "the process is not responding"
ce is not attached to the process _________________
... Fresco |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 475
Joined: 09 May 2003 Posts: 25989 Location: The netherlands
|
Posted: Mon Feb 20, 2012 2:17 pm Post subject: |
|
|
Looks like it is in an infinite loop
If you also implemented an counter to see how many exceptions have happened you could check that to see if it's looping on the exception handler or something else
Make sure the "onException" part that the exception handler makes the code jump to does not raise an exception again.
and most importantly, do not make the exception handler cause an exception itself.
If you used any push or esp modifying code before the first mov eax,[esp+4] you need to take that into account
edit:
Make sure you ONLY handle exceptions caused by your code. Do not handle those generated by the game. _________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Tue Feb 21, 2012 7:51 am Post subject: |
|
|
doing some break tracing to original code ...
at 90% of no feature level load the code continuously writes to multiple values ... however ...my pointer point's nowhere.
here's what i did in my code:
| Code: |
globalalloc(featurehandler,2048)
alloc(feature,2048)
label(various labels)
featurehandler:
db 90 90
mov eax,[esp+4] //this section here is standard
mov eax,[eax+4] // we check if it was us who provoked the exception
lea eax,[eax+0B8] // 0b8 ... 0 it's just a zero extension //b8 meand to check for a pointer exception ... it mey be different if you divide by 0
cmp [eax],pointer
jb short invalid //jmp "pointer is invalid" if below (it wasn't us to make the exception)
cmp [eax],pointer_end (we check only the section after pointer and pointer_end)
jae short invalid //jmp above equal ... jum if it's not our pointer
mov eax,FFFFFFFF // all test's have been passed we are responsable for the break ... write -1 in eax to let the handler know that
ret 4 //return to the caller ...
invalid:
mov eax,0 //write zero so we know that we don't have to execute our customized code
ret 4
pointer_is_valid:
//////////// Here we have 0 (if is invalid) or (-1)dec(if is valid)
feature:
pushfd
push eax
cmp [pointer_is_valid],0
jne pointer //jump if valid ...// the first time execution never jumps
push featurehandler //give vectorhandler info about what to check
push 1 //give maximum priority // 0 = don't care
call RtlAddVectoredExceptionHandler // execute exceptio check... it returns eax = 0 if pointer is valid; eax=-1(dec) if pointer is invalid
mov [pointer_is_valid],eax //make pointer_is_valid zero or -1
jmp orgcode //if pointer is not valid run orgcode // this is because the first time code is run, it is always not valid
pointer:
mov eax,"game.exe"+base address
mov eax,[eax]
add eax,offset 1
mov eax,[eax]
add eax,offset 2
mov eax,[eax]
add eax, ...3
mov eax,[eax]
add eax, ...4
cmp [eax],0 // cause an exception if pointer points to 0
db 90 90 90
pointer_end:
mov [found_featureaddress],eax // put the address of pointer in the value of found_feature...
// check if my code writes to my feature address, if not do original code
// if yes ...jump here and do my customized code
found_featureaddress:
dd 0
|
thast's my code ... where is it wrong ...? _________________
... Fresco
Last edited by Fresco on Tue Feb 21, 2012 9:05 am; edited 1 time in total |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 475
Joined: 09 May 2003 Posts: 25989 Location: The netherlands
|
Posted: Tue Feb 21, 2012 8:06 am Post subject: |
|
|
| Code: |
cmp [eax],pointer
jb short invalid //jmp "pointer is invalid" if below (it wasn't us to make the exception)
cmp [eax],pointer_end (we check only the section after pointer and pointer_end)
jae short invalid //jmp above equal ... jum if it's not our pointer
mov eax,FFFFFFFF // all test's have been passed we are responsable for the break ... write -1 in eax to let the handler know that
ret 4 //return to the caller ...
|
This code does not change eip when an exception happens
That means that when you return it goes back to the instruction that caused the exception, which raises an exception so your handler gets called, which doesn't change eip so returns to the instruction that caused the exception, which raises an exception so your handler gets called, which doesn't change eip so returns to the instruction that caused the exception, which raises an exce....
You get the point I hope
you need to add a mov [eax], orgcode before the mov eax,ffffffff (assuming orgcode also does the pop eax/popfd part) _________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Tue Feb 21, 2012 8:53 am Post subject: |
|
|
i really cant get it work ...
that's my code
i only hide the processname and the offsets.
| Code: | [ENABLE]
globalalloc(featurehandler,2048)
alloc(feature,2048)
label(featureret)
label(invalid)
label(pointer)
label(orgcode)
label(featuredisable)
label(pointer_end)
label(pointer_is_valid)
label(found_featureaddress)
label(orgcode_no_ecx)
"game.exe"+basecodeaddress:
jmp feature
nop
featureret:
featurehandler:
db 90 90
mov eax,[esp+4]
mov eax,[eax+4]
lea eax,[eax+0B8]
cmp [eax],pointer
jb short invalid
cmp [eax],pointer_end
jae short invalid
mov [eax],orgcode_no_ecx //added now ... but still doesn't work
mov eax,FFFFFFFF
ret 4
invalid:
mov eax,0
ret 4
pointer_is_valid:
//////////// Here we have 0 or (-1)dec
feature:
pushfd
push eax
cmp [pointer_is_valid],0
jne pointer //jump if valid
push featurehandler
push 0
call RtlAddVectoredExceptionHandler
mov [pointer_is_valid],eax
jmp orgcode_no_ecx //if not valid run orgcode
pointer:
mov eax,"game.exe"+basepointer
mov eax,[eax]
add eax,offset1
mov eax,[eax]
add eax,offset2
mov eax,[eax]
add eax,offset3
mov eax,[eax]
add eax,last offest
cmp [eax],0
db 90 90 90
pointer_end:
mov [found_featureaddress],eax
push ecx
lea ecx,[esi+000000E0] // esi+e0 is the code that writes on my pointer
cmp eax,ecx
je featuredisable
orgcode:
popfd
pop eax
pop ecx
mov [esi+000000E0],eax
jmp featureret
featuredisable:
cmp [esi+000000E0],1 // i just want that code to NOT write 1 at the pointer value
jne orgcode
mov [esi+000000E0],0
popfd
pop eax
pop ecx
jmp featureret
orgcode_no_ecx: // i used this because there is no push ecx in the handler
popfd
pop eax
mov [esi+000000E0],eax
jmp featureret
found_featureaddress:
dd 0
[DISABLE]
dealloc(feature)
"game.exe"+basecodeaddress:
mov [esi+000000E0],eax |
this code works in main menu and when loading a level that have the feature when pointer point to a valid address.
it gives me an error when loading a level when pointer points nowhere
... before adding ... mov [eax],orgcode_no_ecx ... the game didn't gave any error but continued looping ... now it gives an error ... game.exe has encountred a problen an need to be closed ... if you were in a middle of ... _________________
... Fresco |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 475
Joined: 09 May 2003 Posts: 25989 Location: The netherlands
|
Posted: Tue Feb 21, 2012 9:49 am Post subject: |
|
|
hmm, really no idea.
Change one of the "mov eax,[eax]" lines to "mov eax,[00000000]"
And see if it also crashes in levels where that feature is present ?
If it does there is a problem with the exception handler
And you really don't have another script running that might cause the crash instead ? _________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping
Last edited by Dark Byte on Tue Feb 21, 2012 9:57 am; edited 1 time in total |
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Tue Feb 21, 2012 9:56 am Post subject: |
|
|
but then the pointer would not point anymore to my featureaddress in a level where there is the feature _________________
... Fresco |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 475
Joined: 09 May 2003 Posts: 25989 Location: The netherlands
|
Posted: Tue Feb 21, 2012 9:58 am Post subject: |
|
|
True, but then you can see if the exception is handled properly or not (Sometimes you have to cause an expected bug to debug stuff)
Also, is there any other place where you write to the memory ? (e.g another script or a cheat table entry ? ) _________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 475
Joined: 09 May 2003 Posts: 25989 Location: The netherlands
|
Posted: Tue Feb 21, 2012 10:00 am Post subject: |
|
|
Nevermind. I just saw the mistake you made
that should be
you have to pop in the reverse order as you push.
and at the other spots too. (I'm surprised it doesn't crash on parts where the pointer is valid) _________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
|
| Back to top |
|
 |
Fresco Grandmaster Cheater
Reputation: 4
Joined: 07 Nov 2010 Posts: 600
|
Posted: Wed Feb 22, 2012 5:00 am Post subject: |
|
|
now this is very very weird.
for the level that have the feature ... works.
for the level who don't have it, also works.
but now there's a level where if the feature gets turned on the mission fails.
now my code, as you see above, checks the address on which the code is writing then checks if the code writes 1 ... if yes ... my code say to write 0.
... the pointer points correctly to the address of the feature, and in the level's who have the feature, if it gets turned on ... the feature address is never set to 1 ... in the levels who don't have it ... runs original code ...
but in this new level where, if the feature gets turned on i fail the mission, the feature can till go to 1 for a millisecond ...
now i tried to search for what writes on the address and also what accesses it ... i checked the registers and NO instruction was writing 1 in it...
recapping ...
level 1 = my code NEVER lets feature set to 1.
level 2 = my code runs original code because level 2 don't have feature.
level 3 = pointer points correctly, no code writes 1, but feature address can still go to 1 for a very short amount of time (the needed to fail the mission).
strangely if i nop the code, works, ... but then other features will be disabled as well and i certainly don't want this to happen. _________________
... Fresco |
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 475
Joined: 09 May 2003 Posts: 25989 Location: The netherlands
|
Posted: Wed Feb 22, 2012 5:13 am Post subject: |
|
|
This is quite game specific so you'll have to figure out yourself what is happening here.
Perhaps you could find out the address where the current level is stored and apply that info to your code? _________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
|
|
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
|
|