Exemplo n.º 1
0
        private static IntPtr OnInvokeMethod(IntPtr method, IntPtr obj, IntPtr parameters, IntPtr exc)
        {
            var methodName = Marshal.PtrToStringAnsi(UnhollowerBaseLib.IL2CPP.il2cpp_method_get_name(method));

            var unhook = false;

            if (methodName == "Internal_ActiveSceneChanged")
            {
                try
                {
                    if (ConfigUnityLogging.Value)
                    {
                        Logger.Sources.Add(new IL2CPPUnityLogSource());

                        Application.CallLogCallback("Test call after applying unity logging hook", "", LogType.Assert,
                                                    true);
                    }

                    unhook = true;

                    Instance.Execute();
                }
                catch (Exception ex)
                {
                    Logger.LogFatal("Unable to execute IL2CPP chainloader");
                    Logger.LogError(ex);
                }
            }

            var result = originalInvoke(method, obj, parameters, exc);

            if (unhook)
            {
                RuntimeInvokeDetour.Dispose();

                PreloaderLogger.Log.LogDebug("Runtime invoke unpatched");
            }

            return(result);
        }