Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot unpatch extern method patch #92

Open
alexhaffner opened this issue Nov 30, 2023 · 0 comments
Open

Cannot unpatch extern method patch #92

alexhaffner opened this issue Nov 30, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@alexhaffner
Copy link

alexhaffner commented Nov 30, 2023

Hey! I'm using HarmonyX with unity (in editor directly), trying to patch & unpatch in play mode.
After I call Harmony.UnpatchAll(); the methods still seems to be patched.

public class DestroyPatch
{
    [HarmonyPostfix]
    [HarmonyPatch(nameof(Object.Destroy), new Type[] { typeof(Object), typeof(float) })]
    public static void PrefixA(Object obj, float t)
    {
        Debug.Log("Destroy(Object obj, float t) called");
    }
    
    [HarmonyPostfix]
    [HarmonyPatch(nameof(Object.DestroyImmediate), new Type[] { typeof(Object), typeof(bool) })]
    public static void PrefixB(Object obj, bool allowDestroyingAssets)
    {
        Debug.Log("DestroyImmediate(Object obj, bool allowDestroyingAssets) called");
    }
}

Both are extern calls. I don't have issues with "normal" methods.

Looking into UnpatchConditional, it seems that HasMethodBody returns 0, and thus those methods are skipped and never unpatched.

Thanks!

@ManlyMarco ManlyMarco added the bug Something isn't working label Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants