WIP: Mask hook inspection reads from VirtualAlloc WriteWatch queries - #179
Draft
doomedraven wants to merge 1 commit into
Draft
WIP: Mask hook inspection reads from VirtualAlloc WriteWatch queries#179doomedraven wants to merge 1 commit into
doomedraven wants to merge 1 commit into
Conversation
Owner
doomedraven
marked this pull request as draft
September 1, 2026 06:07
Contributor
Author
|
im gonna do a deeper review of windows behavior of this, as with only write it says it sets it to 1 already. But im gonna focus on dotnet PR #188 first as is more interesting and important |
doomedraven
force-pushed
the
opt/writewatch-masking
branch
from
September 1, 2026 08:46
f102f8c to
9fed6e5
Compare
Owner
|
Currently failing compilation |
Contributor
Author
|
im gonna set this one to WIP in title as i still need to research the proper solution for this one, but dotnet and golang is more important |
Anti-analysis code (e.g. Pikabot, sample 2ebf4db49a8a7875e9c443482f82af1 febd9751eee65be155355c3525331ae88; technique ref BaumFX/cpp-anti-debug anti_debug.cpp#L260) allocates MEM_WRITE_WATCH memory and calls GetWriteWatch to spot instrumentation that touched the region. Replace the old global EnableFakeCount toggle with: - x86: stateful guard (g_writewatch_prior_failure) so the reported dirty count is only zeroed on a successful query that follows a failed one and reports exactly one page - the shape produced by capemon's own hook-logging inspection. - x64: zero a lone single-page count directly. Known limitations (follow-up): the single-page heuristic can suppress a legitimate count of 1 from packers that use MEM_WRITE_WATCH themselves, and does not help checks that expect exactly 1 (it would make a clean run look instrumented). A precise fix needs per-region tracking of the pages capemon actually dirties.
doomedraven
force-pushed
the
opt/writewatch-masking
branch
from
September 2, 2026 08:31
8ea38d5 to
10263d9
Compare
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.

Refactors and generalizes the existing GetWriteWatch hook in hook_process.c to mask sandbox and debug inspection artifacts under both x86 and x64 architectures:
x86 Stack-Passing vs. x64 Register-Passing Behavior
In Windows systems programming, 32-bit and 64-bit architectures handle parameters very differently:
likelihood that a user-mode hook thrashes or touches memory pages in ways that trigger write-watch flags.
virtual memory page, triggering a write-watch flag on both x86 and x64! The original author missed this fact.