Skip to content

Suppress Windows DLL hard-error dialog on incompatible plugin load#185

Merged
nicoddemus merged 4 commits into
masterfrom
fb-ASIM-6677-dll-load-error
Jul 1, 2026
Merged

Suppress Windows DLL hard-error dialog on incompatible plugin load#185
nicoddemus merged 4 commits into
masterfrom
fb-ASIM-6677-dll-load-error

Conversation

@nicoddemus

@nicoddemus nicoddemus commented Jun 23, 2026

Copy link
Copy Markdown
Member

When a plugin DLL has unresolved imports (e.g. a conflicting bundled dependency), Windows would raise a modal hard-error dialog during LoadLibrary before any code could react to the failure.

This change suppresses that dialog and now surface a new typed exception (SharedLibraryLoadError) on the Python side, and as a human-readable RuntimeError (via FormatMessageA) on the C++ side, rather than blocking dialogs.

Plugin discovery is also made resilient: a single failing plugin no longer aborts enumeration of all others. The new get_plugins_available_and_failures() method returns successful plugins alongside a list of PluginLoadFailure records that callers can use to report the specific reason to the user.

Comment thread src/hookman/exceptions.py Outdated
Comment thread src/hookman/hookman_utils.py Outdated
Comment thread src/hookman/hooks.py Outdated
Comment thread src/hookman/hooks.py Outdated
Comment thread src/hookman/hooks.py Outdated
Comment thread tests/test_hookman_generator/HookCaller.hpp Outdated
Comment thread src/hookman/hookman_utils.py Outdated
Comment thread tests/test_hookman_utils.py Outdated
Comment thread src/hookman/hookman_utils.py Outdated
Comment thread src/hookman/hooks.py
Comment thread src/hookman/hookman_utils.py Outdated
Comment thread src/hookman/hooks.py Outdated
@nicoddemus nicoddemus marked this pull request as ready for review June 24, 2026 14:31
@nicoddemus nicoddemus requested a review from BeneBr June 24, 2026 14:32
@nicoddemus nicoddemus force-pushed the fb-ASIM-6677-dll-load-error branch from 45452f6 to 02e4633 Compare June 24, 2026 14:38
@nicoddemus nicoddemus force-pushed the fb-ASIM-6677-dll-load-error branch from 81e2b4f to 02e4633 Compare June 25, 2026 13:10
Documents how to set up the virtualenv, run type checking, run tests,
build C++ artifacts, and regenerate file regression snapshots.

Also ignore the .claude/ session directory.
@nicoddemus nicoddemus force-pushed the fb-ASIM-6677-dll-load-error branch from 73959fd to 0460a54 Compare June 25, 2026 13:20
nicoddemus and others added 3 commits June 25, 2026 10:21
The build task only knew VS 2017 and VS 2019 Enterprise paths; add the
VS 2019 BuildTools path so 'inv build' works on machines that have
BuildTools installed instead of the full IDE.

pybind11 was not found by CMake because no CMAKE_PREFIX_PATH was set;
pass it from the pybind11 Python package so the binding target builds
correctly with the active virtualenv.

Move the build/artifacts sys.path injection from tox's PYTHONPATH setenv
into an autouse pytest fixture, so the .pyd is found when running pytest
directly outside of tox.
When a plugin DLL has unresolved imports (e.g. a conflicting bundled
dependency), Windows would raise a modal hard-error dialog during
LoadLibrary before any code could react to the failure.

This change suppresses that dialog by setting SEM_FAILCRITICALERRORS
via SetThreadErrorMode around every DLL load — both in the Python
ctypes path (discovery) and in the generated C++ HookCaller path
(hook caller construction). Load failures now surface as a new typed
exception (SharedLibraryLoadError) on the Python side, and as a
human-readable RuntimeError (via FormatMessageA) on the C++ side,
rather than blocking dialogs.

Plugin discovery is also made resilient: a single failing plugin no
longer aborts enumeration of all others. The new
get_plugins_available_and_failures() method returns successful plugins
alongside a list of PluginLoadFailure records that callers can use to
report the specific reason to the user.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@nicoddemus nicoddemus force-pushed the fb-ASIM-6677-dll-load-error branch from 50dc09d to 6dd2187 Compare June 25, 2026 13:21
@nicoddemus nicoddemus merged commit 8dc2970 into master Jul 1, 2026
7 checks passed
@nicoddemus nicoddemus deleted the fb-ASIM-6677-dll-load-error branch July 1, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants