stevemk14ebr / PolyHook_2_0

C++20, x86/x64 Hooking Libary v2.0
MIT License
1.6k stars 226 forks source link

Implement detour unit tests with emulator #192

Open stevemk14ebr opened 12 months ago

stevemk14ebr commented 12 months ago

The current approach to unit testing the x86 and x64 detours is limited. It involves directly executing manually crafted assembly within the unit testing process. This is error prone and can make it hard to actually inspect CPU effects like ensuring registers / stack data is preserved and control flow is successful.

Instead, implement unit testing with an x86 / x64 emulator. We can create a set of CPU constraints that model what the before / after architectural state should look like per hook. We can then call polyhook functions to edit the memory buffers of the emulator, or mirror them temporarily and write back. This should be much better and unlock more confidence in quality and new tests to be written.

This is a long term goal. If someone is interested in working on this, please let me know. Unit Tests Here.

stevemk14ebr commented 11 months ago

There is a $250 USD bounty on this issue: https://twitter.com/stevemk14ebr/status/1720549142634566102?t=VbYJ_vg_bTZ9fahTtq0Qvg&s=19