fix(injector): verify injection via module list, not truncated thread exit code#43
Merged
Merged
Conversation
… exit code inject_dll() returned `GetExitCodeThread(...) != 0` as the success oracle, but a thread exit code is a DWORD — only the LOW 32 bits of LoadLibraryW's HMODULE. A module whose load base is 4 GiB-aligned (low dword == 0) makes a SUCCESSFUL injection report failure (false negative; cannot false-positive a real failure). Fix: after the remote thread completes, confirm vmhook.dll is actually mapped into the target by scanning its module list for the DLL's base name via K32EnumProcessModulesEx + K32GetModuleBaseNameW (both exported by kernel32 — the K32* psapi forwarders — so no psapi.lib link; injector.exe stays statically self-contained: KERNEL32 + msvcrt only). The legacy exit-code test is retained only as a fallback for the rare case enumeration is unavailable (e.g. access denied), so behaviour is never worse than before. Buffer grows once if the target loaded modules between the two enum calls. Builds clean under the project -Werror mingw flags; links kernel32-only. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
inject_dll()usedGetExitCodeThread(...) != 0as the success oracle. A thread exit code is aDWORD— only the low 32 bits ofLoadLibraryW'sHMODULE. A module whose load base is 4 GiB-aligned (low dword0) makes a successful injection report failure (false negative; it can't false-positive a real failure).Fix
After the remote thread completes, confirm
vmhook.dllis actually mapped into the target by scanning its module list for the DLL base name viaK32EnumProcessModulesEx+K32GetModuleBaseNameW.K32*psapi forwarders) → nopsapi.lib;injector.exestays statically self-contained (KERNEL32 + msvcrt only).Validation
-Werrormingw flags; links kernel32-only.Trial-branch per policy so master stays green during validation.
🤖 Generated with Claude Code