DirectXHook icon indicating copy to clipboard operation
DirectXHook copied to clipboard

Rewrite using `stubgen`

Open lostmsu opened this issue 1 year ago • 1 comments

I merged the code produced by https://github.com/Francesco149/stubgen and this project prior to "massive rewrite". I believe the merged code does not suffer from some issues reported here.

The major differences from this project are:

  • lack of hooking race conditions: client game calls to the affected APIs will wait until the hook is fully initialized
  • correct stub parameter handling in respect to the complicated x64 calling convention

The major difference from stubgen is that to create the dummy swap chain we need access to the original dxgi.dll functions, which in stubgen are not available (spinlock wait in the asm_wait_init). So the hook installation thread exposes a thread local variable, that bypasses the wait in asm_wait_init.

I tested it on my 64-bit Factorio. For 32 bit version to work one needs check_init_thread and check_init_thread_end MACROs implemented in trampolines32.asm (they aren't)

NOTE: the dxgi.dll exports were recreated from Windows 11 22H2 (e.g. build 22621)

DXGI-Stub.zip

lostmsu avatar Mar 16 '23 05:03 lostmsu

I've long been unsatisfied with the .dll proxying. I have some ideas to make it better, which I think would be similar to how stubgen does it.

techiew avatar Mar 18 '23 17:03 techiew