// создаем новый GameObject и вешаем на него компанент Player
    public static IPlayer GetPlayer()
    {
        if (Player == null)
        {
            Player = MonoExtensions.MakeComponent <Player>();
        }

        return(Player);
    }
    // e t c

    // создаем новый GameObject и вешаем на него компанент MainScreen
    public static IMainScreen GetMainScreen()
    {
        if (MainScreen == null)
        {
            MainScreen = MonoExtensions.MakeComponent <MainScreen>();
        }

        return(MainScreen);
    }
    public void DestroyGameObject(Object o)
    {
        GameObject go = MonoExtensions.GetGameObject(o);

        if (go != null)
        {
            Destroy(go);
        }
    }
    public void DestroyRootGameObject(Object o)
    {
        GameObject go = MonoExtensions.GetGameObject(o);

        if (go != null)
        {
            Destroy(go.transform.root.gameObject);
        }
    }
Example #5
0
        public static FastNativeDetour CreateAndApply <T>(IntPtr from, T to, out T original, CallingConvention?callingConvention = null) where T : Delegate
        {
            var toPtr = callingConvention != null?MonoExtensions.GetFunctionPointerForDelegate(to, callingConvention.Value) : Marshal.GetFunctionPointerForDelegate(to);

            var result = new FastNativeDetour(from, toPtr);

            original = result.GenerateTrampoline <T>();
            result.Apply();
            return(result);
        }
Example #6
0
        public override unsafe void Initialize(string gameExePath = null)
        {
            UnhollowerBaseLib.GeneratedDatabasesUtil.DatabasesLocationOverride = Preloader.IL2CPPUnhollowedPath;
            PatchManager.ResolvePatcher += IL2CPPDetourMethodPatcher.TryResolve;

            base.Initialize(gameExePath);
            Instance = this;

            var version =             //Version.Parse(Application.unityVersion);
                          Version.Parse(Process.GetCurrentProcess().MainModule.FileVersionInfo.FileVersion);

            UnityVersionHandler.Initialize(version.Major, version.Minor, version.Revision);

            // One or the other here for Unhollower to work correctly

            //ClassInjector.Detour = new DetourHandler();

            ClassInjector.DoHook = (ptr, patchedFunctionPtr) =>
            {
                IntPtr originalFunc = new IntPtr(*(void **)ptr);

                var detour = new FastNativeDetour(originalFunc, patchedFunctionPtr);

                detour.Apply();

                *(void **)ptr = (void *)detour.TrampolinePtr;
            };

            var gameAssemblyModule = Process.GetCurrentProcess().Modules.Cast <ProcessModule>().First(x => x.ModuleName.Contains("GameAssembly"));

            var functionPtr = GetProcAddress(gameAssemblyModule.BaseAddress, "il2cpp_runtime_invoke");             //DynDll.GetFunction(gameAssemblyModule.BaseAddress, "il2cpp_runtime_invoke");


            PreloaderLogger.Log.LogDebug($"Runtime invoke pointer: 0x{functionPtr.ToInt64():X}");

            RuntimeInvokeDetour = new FastNativeDetour(functionPtr,
                                                       MonoExtensions.GetFunctionPointerForDelegate(new RuntimeInvokeDetourDelegate(OnInvokeMethod), CallingConvention.Cdecl));

            RuntimeInvokeDetour.Apply();

            originalInvoke = RuntimeInvokeDetour.GenerateTrampoline <RuntimeInvokeDetourDelegate>();

            PreloaderLogger.Log.LogDebug("Runtime invoke patched");
        }
Example #7
0
    }                           //include this function so the designers can see the checkbox to disable this component

    public void ApplyForceToObject(Object o)
    {
        if (!enabled || o == null)
        {
            return;
        }

        GameObject go = MonoExtensions.GetGameObject(o);

        if (go != null)
        {
            Collider2D c = go.GetComponent <Collider2D>();
            if (c != null)
            {
                ApplyForceToCollider(c);
            }
            else
            {
                ApplyForceToRigidbody(go.GetComponentInParent <Rigidbody2D>());
            }
        }
    }