Resolve the runtime module rather than assuming the executable - #21
Merged
Conversation
kasperisager
requested changes
Aug 12, 2026
kasperisager
approved these changes
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On win32 a prebuilt addon delay-loads
bare.dll, and the hook answers withGetModuleHandle(NULL), then looks upbare_module_findon it. That's the executable. Right forbare, wrong for anything that embeds the runtime in a library instead: bare-kit keeps it inbare-kit.dll, which exports all 3433 symbols but never gets consulted, so no addon loads. There's currently no way to embed bare-kit on win32 and load a stock prebuilt addon.This resolves the runtime module instead of assuming it: use the executable when it exports
bare_module_find, otherwise take whichever loaded module does. No name is hardcoded, so it holds for any embedder.PSAPI_VERSION 2makesEnumProcessModulesresolve against kernel32, so no new link dependency - I checked,delayimp.libalone still links.Verified both branches on win32-arm64 by compiling the hook into a test exe and asking it what it resolved:
Worth being explicit about the propagation: the hook is compiled into each addon, so this only reaches a host as addons are rebuilt and republished.
sodium-nativeandudx-nativeas published today still carry the current hook. Until they're refreshed, a bare-kit host on win32 still needs to re-export the runtime symbols itself, which is the workaround this exists to remove (holepunchto/bare-windows#7).What I haven't done: an end-to-end run of a freshly built addon inside a bare-kit host with no forwarders. Happy to do that if you want it before this lands.