Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(fspy): report tracking loss on 32-bit Windows subprocesses - #1058

Open
wan9chi wants to merge 1 commit into
ci/windows-arm64-testsfrom
fix/fspy-windows-32bit-subprocess
Open

wan9chi wants to merge 1 commit into
ci/windows-arm64-testsfrom
fix/fspy-windows-32bit-subprocess

Conversation

@wan9chi

@wan9chi wan9chi commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Motivation

On 64-bit Windows, cached tasks that spawn 32-bit or other cross-architecture child processes (such as 32-bit gpg.exe during Git commit signing in vp create or vp run, or an emulated x64 child launched from a native ARM64 process on Windows 11 ARM64) hit DetourCreateProcessWithDllEx*'s cross-bitness fallback—launching syswow64\rundll32.exe against our 64-bit preload DLL and triggering a RunDLL error dialog—or inject a mismatched DLL that fails at load time. Spawning a cross-architecture executable directly as a root task command similarly failed injection with ERROR_INVALID_HANDLE.

Now that Sender::report_loss carries structured, wincode-encoded loss reasons (#1056), we can detect cross-architecture processes before touching their headers, let them run untracked, and report the exact executable and architecture so vp run skips caching cleanly instead of breaking the task.

Changes

  • Add TrackingLoss::UnsupportedProcessArchitecture { program, machine } in fspy_shared::ipc and TrackingIncomplete::UnsupportedProcessArchitecture in fspy with human-readable architecture formatting (e.g. cannot track 32-bit x86 process \...``).
  • Add shared Windows helpers unsupported_process_machine and query_process_image_name (QueryFullProcessImageNameW) in fspy_shared::windows, using GetProcessInformation(ProcessMachineTypeInfo) (Windows 11+) to distinguish native ARM64 from emulated x64 processes and falling back to comparing parent and child IsWow64Process2 results on older Windows versions, with pure detect_unsupported_machine unit tests covering x86, x64, ARM64, and emulated x64-on-ARM64 cases on all platforms.
  • Replace DetourCreateProcessWithDllExW / DetourCreateProcessWithDllExA in fspy_preload_windows with create_process_with_tracking, which skips Detours injection on architecture mismatch, calls Client::report_loss before resuming the child untracked, and never invokes rundll32.exe.
  • Apply the same architecture check in fspy::windows::SpyImpl::spawn_inner when the root task command itself is a cross-architecture executable.
  • Add Windows integration tests in crates/fspy/tests/winapi.rs (CreateProcessW, CreateProcessA, and direct root spawn), unit tests in fspy_shared, fspy, and vt, and an E2E snapshot fixture (windows_32bit_subprocess) exercising both a 64-bit parent spawning 32-bit SysWOW64\cmd.exe and a direct 32-bit task command.
  • Update CHANGELOG.md.

Note

Medium Risk
Changes Windows process creation hooks and cache-eligibility for file tracking; behavior is security-adjacent but limited to untracked fallback rather than blocking execution.

Overview
Fixes Windows cached tasks that spawn or run 32-bit / other cross-architecture programs (e.g. SysWOW64 gpg.exe) so they complete successfully instead of failing or showing a RunDLL dialog from Detours’ cross-bitness helper.

Detection happens before DLL injection: new UnsupportedProcessArchitecture loss types flow through IPC with readable messages (executable + arch). CreateProcess* detours now use create_process_with_tracking (same logic for root spawns in fspy)—inject only when architectures match; otherwise resume untracked, report loss, and skip caching with guidance to set manual input/output.

Shared unsupported_process_machine / query_process_image_name cover Win11 ProcessMachineTypeInfo plus older WOW64 fallbacks, with broad unit/integration/E2E coverage.

Reviewed by Cursor Bugbot for commit dc5637a. Bugbot is set up for automated code reviews on this repo. Configure here.

@wan9chi
wan9chi force-pushed the fix/fspy-windows-32bit-subprocess branch from 1eea451 to 9671a9c Compare December 2, 2026 15:42
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change  +0.54%  [ -3.62% ..  +3.89%]  overhead   +55.39%
dynamic/access             change  -1.28%  [ -5.27% ..  +3.46%]  overhead   +21.06%
dynamic/access-relative    change  +1.21%  [ -1.48% ..  +4.20%]  overhead   +70.01%
dynamic/access-contended   change  +2.00%  [ -3.08% ..  +6.18%]  overhead   +42.85%
static/launch              change  -0.30%  [ -3.14% ..  +3.36%]  overhead  +200.09%
static/access              change  -0.33%  [ -1.14% ..  +0.59%]  overhead +1449.28%
static/access-relative     change  -1.09%  [ -2.03% ..  -0.22%]  overhead +1953.67%
static/access-contended    change  -0.40%  [ -2.10% ..  +0.73%]  overhead +1673.46%

macos

dynamic/launch             change  -0.18%  [ -2.59% ..  +2.50%]  overhead  +224.48%
dynamic/access             change  -0.01%  [ -1.92% ..  +1.41%]  overhead    +4.52%
dynamic/access-relative    change  +0.12%  [ -2.79% ..  +3.04%]  overhead  +245.12%
dynamic/access-contended   change  +0.19%  [ -2.28% ..  +3.70%]  overhead    +3.58%

windows

dynamic/launch             change  +1.04%  [ -3.04% ..  +5.26%]  overhead   +25.78%
dynamic/access             change  -0.36%  [ -3.71% ..  +3.41%]  overhead    +1.27%
dynamic/access-relative    change  -0.18%  [ -1.27% ..  +1.53%]  overhead    +1.23%
dynamic/access-contended   change  -0.18%  [ -0.53% ..  +0.70%]  overhead    +1.25%

@wan9chi
wan9chi force-pushed the fix/fspy-windows-32bit-subprocess branch from 9671a9c to 91dfc57 Compare December 2, 2026 16:53
@wan9chi
wan9chi changed the base branch from main to ci/windows-arm64-tests December 2, 2026 16:53
@wan9chi
wan9chi added this pull request to stack #1061 December 2, 2026 16:53
@wan9chi
wan9chi force-pushed the fix/fspy-windows-32bit-subprocess branch from 91dfc57 to 26563a8 Compare December 2, 2026 17:05
@wan9chi
wan9chi force-pushed the fix/fspy-windows-32bit-subprocess branch from 26563a8 to bc6c4dd Compare December 2, 2026 17:11
@wan9chi
wan9chi force-pushed the fix/fspy-windows-32bit-subprocess branch from bc6c4dd to 1338005 Compare December 2, 2026 17:13
@wan9chi
wan9chi force-pushed the fix/fspy-windows-32bit-subprocess branch 3 times, most recently from 6a8a2e1 to f30bfc6 Compare December 3, 2026 03:46
Co-authored-by: Gemini 4 Neon <noreply@google.com>
@wan9chi
wan9chi force-pushed the fix/fspy-windows-32bit-subprocess branch from f30bfc6 to dc5637a Compare December 3, 2026 04:09

This branch has not been deployed

No deployments
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.

1 participant