Skip to content

Guard native xref and Class::Init scans by process architecture - #288

Open
jweivy wants to merge 1 commit into
BepInEx:masterfrom
jweivy:fix/native-xref-architecture-guards
Open

jweivy wants to merge 1 commit into
BepInEx:masterfrom
jweivy:fix/native-xref-architecture-guards

Conversation

@jweivy

@jweivy jweivy commented Oct 2, 2026

Copy link
Copy Markdown

Native runtime scans currently pass process instructions to the x86/x64 Iced decoder even when the process is ARM64. Class::Init discovery also tries x86 byte signatures against ARM code before its existing export-based fallback.

Reject unsupported architectures at native xref entry points before decoding/pointer access, and before metadata initialization for an uncached proxy scan. Skip the x86 Class::Init signatures on other architectures and use the existing ordered export substitutes. Cached xrefs, ordinary managed methods, and generator decoding of explicitly selected input images retain their behavior.

Validation on Apple Silicon:

  • Five native ARM64 xref checks pass; four x64 checks pass in an actual Rosetta process.
  • The Class::Init fixture extracts production resolver source and checks architecture selection, fallback order, and missing substitutes: four ARM64 plus four x64 checks pass. Unmodified upstream fails its ARM negative control by attempting the x86 signature lookup.
  • Runtime Release build passes.
  • Integrated BTD6 56.3/Unity 6000.0.58f2 reaches injected component callbacks and a normal exit using the export fallback. The integration contains additional local ARM64 hook discovery and loader fixes; this PR does not add ARM64 decoding or complete game compatibility.

Commands and fixture boundaries are in tests/NativeXrefRegression/README.md. No game inputs or generated game assemblies are included.

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