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 


A bug in the {$try}/{$except} exception handling

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
kgbfbi
Newbie cheater
Reputation: 0

Joined: 07 Dec 2016
Posts: 10

PostPosted: Tue Jul 21, 2026 12:20 am    Post subject: A bug in the {$try}/{$except} exception handling Reply with quote

When using {$try}/{$except}, a breakpoint cannot be set on the first line of code after {$except}; it can only break on the second line.

The demo program is CE 7.6, Tutorial-x86_64.exe. The demo code is as follows:
Code:

push rax
{$try}
mov rax,[base]
mov rax,[rax]
mov rax,[rax] //Because the address is incorrect, an error will definitely occur here, then jump to {$except}
pop rax
jmp originalcode
{$except}
nop //The debugger cannot interrupt the first line of code after {$except}, and the same applies to any other instruction
pop rax//Interruption can only be performed on the second line


Furthermore, if the interruption occurs at the address to be hooked before the hook is injected, CE will freeze and become unusable. For example, the address injected in the demo program is:
Code:

"Tutorial-x86_64.exe"+89F36 - 66 90 - nop 2 //The address to be hooked. If the interruption occurs before the hook is performed, and then the hook is clicked, the entire CE program will freeze and become unusable.

"Tutorial-x86_64.exe"+89F38 - 90 - nop
"Tutorial-x86_64.exe"+89F39 - 48 8D 65 00 - lea rsp,[rbp+00]


The complete demo code is as follows:
Code:

[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048,"Tutorial-x86_64.exe"+89F36)
label(returnhere)
label(originalcode)
label(exit)

newmem: //this is allocated memory, you have read,write,execute access
//place your code here
push rax
{$try}
mov rax,[base]
mov rax,[rax]
mov rax,[rax] //Because the address is incorrect, an error will definitely occur here, then jump to {$except}
pop rax
jmp originalcode
{$except}
nop //The debugger cannot interrupt the first line of code after {$except}, and it's the same with any other command
pop rax //It can only interrupt on the second line

originalcode:
nop 2
nop
lea rsp,[rbp+00]

exit:
jmp returnhere

base:
dd 12345 //Incorrect address used for demonstration

"Tutorial-x86_64.exe"+89F36:
jmp newmem
nop 2
returnhere:

[DISABLE]

//code from here till the end of the code will be used to disable the cheat
dealloc(newmem)

"Tutorial-x86_64.exe"+89F36:

db 66 90 90 48 8D 65 00
//nop 2
//nop
//lea rsp,[rbp+00]
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