TheDreadedAndy / SkyrimAEUncapper-Rust

Rust continuation of the Skyrim AE Uncapper.
10 stars 0 forks source link

Dangerous register usage. #4

Closed TheDreadedAndy closed 1 year ago

TheDreadedAndy commented 1 year ago

According to the x64 calling convention spec:

Consider volatile registers destroyed on function calls unless otherwise safety-provable by analysis such as whole program optimization.

That last line is the rub. It seems skyrim does have some amount of this in it. At the very least, the level exp patch comes after a call and assumes rcx is preserved across that call.

In order to be super safe, it seems I will need to inject saveall/restoreall in every wrapper, not just the ones which aren't replacing a call.