Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

D3D9 Device + Window soundness safety overhaul #20

Open
MaulingMonkey opened this issue Feb 9, 2022 · 1 comment
Open

D3D9 Device + Window soundness safety overhaul #20

MaulingMonkey opened this issue Feb 9, 2022 · 1 comment
Assignees

Comments

@MaulingMonkey
Copy link
Owner

I believe I can make d3d9 hwnd handling 100% sound.

Validate HWND on creation

Validation failures can be coerced to Result s, which should be 100% defined behavior.

Detect Device outliving HWND

Now, to detect when an HWND is yanked out from under a device:

Option 1: Hooks

SetWindowsHookExW(WH_CALLWNDPROCRET, ...)
High overhead - hooks every wndproc, including for window handles we don't really care much about.

Option 2: Patch WNDPROCs

SetWindowLongPtrW(hwnd, GWLP_WNDPROC, ...)
Saner, probably? Note that CallWindowProcW is required to call the original WNDPROC sanely.

Error Handling

  • Emergency destruction of the device is likely impossible.
  • Canceling the destruction of the HWND might be possible (hide it instead?), but would be a bit sketchy?
  • Reparenting the device to a new (hidden) HWND might be possible, but would be a bit sketchy?
  • bugsalot::bug!(...) + std::process::abort() ?
@MaulingMonkey
Copy link
Owner Author

MaulingMonkey commented Feb 12, 2022

ae1c72a misc. HWND APIs for future hwnd thread ownership testing
c44f2c8 win32::get_window_thread_id

@MaulingMonkey MaulingMonkey self-assigned this Feb 12, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant