techiew / DirectXHook

DirectX 11/12 hook including a simple overlay framework.
181 stars 23 forks source link

resize game windows = crash! #2

Closed geometry88 closed 3 years ago

geometry88 commented 3 years ago

resize game windows = crash!

geometry88 commented 3 years ago

fix

techiew commented 3 years ago

I didn't really test ResizeBuffers after the update, I'll check it out. Anyhow it seems it was unrelated to the offset issue we were talking about previously. Thank you for the video and potential fix, I wonder what happened to warrant this extra input argument?

techiew commented 3 years ago

First of all, where did you find out that you had to add this specific argument?

geometry88 commented 3 years ago

First of all, where did you find out that you had to add this specific argument?

I still in the first version when I corrected this error found a mismatch of your version resizebuffer with the version found on unknowncheats

Honestly, I lost the link a long time ago..

techiew commented 3 years ago

Thats ok, I've seen posts on unknowncheats and other places where they have the "this" pointer as an extra argument, I actually have that argument in my definition of Present, but not in my ResizeBuffers definition. I never really understood why it was there though, since it was not in the official documentation of these functions (https://docs.microsoft.com/en-us/windows/win32/api/dxgi/nf-dxgi-idxgiswapchain-resizebuffers) and ResizeBuffers (usually) seemed to work without it, so I paid it no mind untill now.

Turns out the compiler adds a hidden argument to all non-static member function calls, which is the "this" pointer which points to the object which is having its function called. Your compiler usually deals with this kind of thing, and you usually don't need to think about it, except in this situation.

So I'll be fixing this issue right away. (There are also issues with overlays like the steam overlay currently, which will cause a crash, I'll fix that too)