osy / Polaris22Fixup

Metal driver patches for Vega M
MIT License
47 stars 7 forks source link

Add disassembly for more robust patcher #2

Closed osy closed 4 years ago

osy commented 5 years ago

Currently, we do not disassemble the original function. We hard code a "safe" length of code to save ("safe" as in we do not copy half an instruction) and then we copy that code elsewhere and execute it before jumping to the original implementation when attempting to call back into the original function.

This will fail if, in the future, the function changes and the hard coded length is no longer safe. Additionally, if a relative jmp is added to the first couple of bytes in the future, it will also fail.

The likelihood for either case is slim but still a possibility. Ideally we use something like libsubstitute and disassemble the instruction and optionally rewrite relative jumps into absolute jumps.

osy commented 4 years ago

Closing as we are back to Lilu