Skip to content

macOS support, part 2: find the match hook on Apple Silicon - #35

Merged
osnsyc merged 2 commits into
osnsyc:mainfrom
thelohdown:mac/hook-discovery
Nov 23, 2026
Merged

osnsyc merged 2 commits into
osnsyc:mainfrom
thelohdown:mac/hook-discovery

Conversation

@thelohdown

Copy link
Copy Markdown
Contributor

Windows behaviour is unchanged: its code paths run exactly as before. The macOS logic is in new files behind MacNative.IsMacOS checks, as you suggested.

New files

  • MacHookResolver: the arm64 GAME_MATCH signature, finding game_plugin through dyld, scanning its code, and checking the hook entry (macOS has no VirtualQuery). The macOS game copy is re-signed by the BepInEx package, so its hash never matches and the signature is the way in.
  • NativeDetourHandle: the same create / trampoline / apply steps the hook already uses.
    • On Windows it's BepInEx's INativeDetour itself (WindowsNativeDetour, a thin wrapper).
    • The macOS package has no INativeDetour, so there it's a MonoMod.Core detour through BepInEx's Il2CppDetourFactory (MacNativeDetour).
    • INativeDetour is only referenced in WindowsNativeDetour, so the plugin still loads on macOS.

Existing files

One-line platform checks only, in GameMatchTickHook, GamePluginBuildCatalog, GameMatchTickSignature and HookInstallDiagnostics.

Testing

  • macOS, FM 27.1 (Steam): the hook installs through the arm64 signature, and every install-diagnostics stage runs:
    GAME_MATCH Advance hook installed for AOB fallback (macOS arm64) build
  • Windows: the hook runs the same INativeDetour calls as before, through a thin wrapper. A quick check on your side would be great.

Next: the macOS offsets for 27.1 (part 3).

Lets the capture hook FM's match update on Apple Silicon Macs running the
community macOS BepInEx IL2CPP package. Windows behaviour is unchanged:
its code paths run exactly as before, and the macOS logic is in separate
files behind MacNative.IsMacOS checks.

New files:
- MacHookResolver: the arm64 GAME_MATCH signature, finding game_plugin
  through dyld, scanning its executable ranges, and checking the hook
  entry (macOS has no VirtualQuery). The macOS game copy is re-signed by
  the BepInEx package, so its hash never matches and the signature is
  the way in.
- NativeDetourHandle: the create / trampoline / apply steps the hook
  already uses. On Windows it is BepInEx's INativeDetour itself
  (WindowsNativeDetour). The macOS package has no INativeDetour, so there
  it is a MonoMod.Core detour through BepInEx's Il2CppDetourFactory
  (MacNativeDetour). INativeDetour is only referenced in
  WindowsNativeDetour, so the plugin still loads on macOS.

Existing files, one-line platform checks only:
- GameMatchTickHook: detour field type, game_plugin lookup and detour
  creation.
- GamePluginBuildCatalog: TryResolveAob, IsFunctionEntry and
  GetModulePath hand over to the macOS code on macOS.
- GameMatchTickSignature: a MacArm64 signature next to the list.
- HookInstallDiagnostics: ValidateEntry hands over on macOS.
@thelohdown
thelohdown requested a review from osnsyc as a code owner November 21, 2026 04:35

@osnsyc osnsyc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed the hook works correctly on Windows.

@osnsyc
osnsyc merged commit f0b7f54 into osnsyc:main Nov 23, 2026
1 check passed
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.

2 participants