Auto Assembler:TRY EXCEPT

From Cheat Engine

Jump to: navigation, search

CE 6.8 added {$try}/{$except} to auto assembler scripts.

Essentially, any code included in the {$try}/{$except} block will jump to the {$EXCEPT} part when any kind of exception happens within the block.

This means, you will want to put the code likely to result in an error between {$try} and {$except}.

Next, at the end of {$try} you will want to force a jump to a location indicating success; if you do not, then the code after {$except} will be executed.

Also note that the exception may break from any line in the {$try}/{$except} block, so make sure that your exception code can handle unexpected register values.

How does it work? It works by assembling an exception handler in the game and then register it using addvectoredexception handler. Then, it adds a list of eip/rip ranges and where to jump to on exception. So, when an exception happens it checks if it's in the list, and if so, change eip/rip to the exception address.

In this example, if any error occurs - for example, ecx is zero or ecx+10 is unreadable -, eax will be set to zero:


mov eax,[ecx+10]

jmp short noerror


xor eax,eax



- There should be hardly any performance hit as long as no exception happens.

Personal tools