Refuse late device-attach under ARM64 emulation#40
Open
3vcloud wants to merge 1 commit into
Open
Conversation
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.
4 tasks
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.
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.IsWow64Process2(utils::IsRunningUnderArm64Emulation) and refuse the attach with a newRETURN_UNSUPPORTED_UNDER_EMULATION, rather than risk an unreliable hook.Direct3DCreate9/Direct3DCreate9Exproxy-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
SetDevicestill succeeds normally on native x86/x64IsWow64Process2correctly reports emulation on an ARM64 Windows box (or under Wine/FEX/box64) andSetDevicereturnsRETURN_UNSUPPORTED_UNDER_EMULATIONd3d9.dll) flow is unaffected