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

Patching ref parameter with IL2Cpp results in invalid IL #93

Open
wund3rcr4zy opened this issue Dec 2, 2023 · 0 comments
Open

Patching ref parameter with IL2Cpp results in invalid IL #93

wund3rcr4zy opened this issue Dec 2, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@wund3rcr4zy
Copy link

Patch:

        [HarmonyPatch]
        public class SpeakHook
        {
            [HarmonyTargetMethod]
            static MethodBase TargetMethod()
            {
                MethodInfo target = AccessTools.Method(typeof(SpeechController), nameof(SpeechController.Speak),
                    [
                        typeof(Il2CppSystem.Collections.Generic.List<redacted extends Il2CppSystem.Object>).MakeByRefType(),
                        ... other types
                    ]);
                return target;
            }

            [HarmonyPostfix]
            public static void Postfix()
            {
                ByTheBookPlugin.Logger.LogInfo($"Speak triggered!!");
            }
        }

The MethodBase is correctly found by the TargetMethod function when I logged out the information.

Error:

[Error  :Il2CppInterop] During invoking native->managed trampoline
Exception: System.InvalidProgramException: Common Language Runtime detected an invalid program.
   at DMD<SpeechController::Speak>(SpeechController this, List`1& speechOptions, <other params redacted>)
   at (il2cpp -> managed) Speak(IntPtr , IntPtr* , IntPtr , IntPtr , IntPtr , IntPtr , Il2CppMethodInfo* )
@wund3rcr4zy wund3rcr4zy changed the title Patching Ref parameter with IL2Cpp results in invalid IL Patching ref parameter with IL2Cpp results in invalid IL Dec 2, 2023
@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