Skip to content

Refuse late device-attach under ARM64 emulation#40

Open
3vcloud wants to merge 1 commit into
devfrom
fix/refuse-arm64-emulation-late-attach
Open

Refuse late device-attach under ARM64 emulation#40
3vcloud wants to merge 1 commit into
devfrom
fix/refuse-arm64-emulation-late-attach

Conversation

@3vcloud

@3vcloud 3vcloud commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

  • SetDevice (used for late injection into an already-running game) hot-patches the live device's vtable methods via MinHook. On ARM64 emulation (Windows-on-ARM's xtajit, or Wine on FEX-Emu/box64), patching code the render thread is already calling every frame races that emulator's self-modifying-code/JIT-cache invalidation and can silently fail or misbehave.
  • Detect this case with IsWow64Process2 (utils::IsRunningUnderArm64Emulation) and refuse the attach with a new RETURN_UNSUPPORTED_UNDER_EMULATION, rather than risk an unreliable hook.
  • The existing Direct3DCreate9/Direct3DCreate9Ex proxy-DLL path is unaffected and remains the supported way to use gMod under emulation: hooks install on a fresh device before the game ever calls into it, so there's nothing live to race.

Test plan

  • Build on Windows and confirm SetDevice still succeeds normally on native x86/x64
  • Confirm IsWow64Process2 correctly reports emulation on an ARM64 Windows box (or under Wine/FEX/box64) and SetDevice returns RETURN_UNSUPPORTED_UNDER_EMULATION
  • Confirm normal load-before-launch (proxy d3d9.dll) flow is unaffected

Hot-patching an already-live device's vtable methods via SetDevice races
the emulator's self-modifying-code handling (Windows-on-ARM's xtajit, or
Wine on FEX-Emu/box64). Detect that case with IsWow64Process2 and refuse
the attach instead, so callers fall back to loading gMod as d3d9.dll
before the game creates its device.
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