Skip to content

Remove InstancePatchFix patches (fix reverse patch crash) - #1106

Merged
HerpDerpinstine merged 1 commit into
LavaGang:alpha-developmentfrom
RaptorRush135:alpha-development
Feb 25, 2026
Merged

HerpDerpinstine merged 1 commit into
LavaGang:alpha-developmentfrom
RaptorRush135:alpha-development

Conversation

@RaptorRush135

Copy link
Copy Markdown
Contributor

Fixes #1003

As described in the issue, applying a HarmonyReversePatch causes a AccessViolationException
This is because here it patches HarmonyLib.PatchFunctions:ReversePatch that has a parameter of type HarmonyMethod, while the patch method has a parameter of type MethodBase

One possible solution would be to use the correct type on that patch, however IMO a better fix would be to remove them altogether, as HarmonyX now does these checks itself:

  • Nov 25, 2021: InstancePatchFix with these checks was added
  • Mar 22, 2022: HarmonyX added null & static check to ReversePatch & ImportMethod (same methods and checks as InstancePatchFix)

Changes (all internal):

  • Remove both harmony patches from InstancePatchFix.Install
  • Move InstancePatchFix to MelonLoader.Fixes.MonoMod, now all code is related to MonoMod
  • Rename PatchMethod to EnsureStatic, is no longer a Harmony patch
  • Rename parameter __0 to method, is no longer a Harmony injected parameter
  • Removed null check of parameter, following the flow of both OnDetour, it doesnt seem they can be null

@HerpDerpinstine
HerpDerpinstine merged commit 583a6f2 into LavaGang:alpha-development Feb 25, 2026
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