private static int Run()
        {
            Config.Initialize();

            if (!MelonLaunchOptions.Il2CppAssemblyGenerator.OfflineMode)
            {
                RemoteAPI.Contact();

                unitydependencies = new UnityDependencies();
                if (!unitydependencies.Download())
                {
                    return(1);
                }

                dumper = new Cpp2IL();
                if (!dumper.Download())
                {
                    return(1);
                }

                il2cppassemblyunhollower = new Il2CppAssemblyUnhollower();
                if (!il2cppassemblyunhollower.Download())
                {
                    return(1);
                }

                deobfuscationMap = new DeobfuscationMap();
                if (!deobfuscationMap.Download())
                {
                    return(1);
                }
            }

            // Check for Regex Change against Config

            string CurrentGameAssemblyHash;

            MelonLogger.Msg("Checking GameAssembly...");
            MelonDebug.Msg($"Last GameAssembly Hash: {Config.Values.GameAssemblyHash}");
            MelonDebug.Msg($"Current GameAssembly Hash: {CurrentGameAssemblyHash = GetGameAssemblyHash()}");

            if (!AssemblyGenerationNeeded &&
                (string.IsNullOrEmpty(Config.Values.GameAssemblyHash) ||
                 !Config.Values.GameAssemblyHash.Equals(CurrentGameAssemblyHash)))
            {
                AssemblyGenerationNeeded = true;
            }

            if (!AssemblyGenerationNeeded)
            {
                MelonLogger.Msg("Assembly is up to date. No Generation Needed.");
                return(0);
            }
            MelonLogger.Msg("Assembly Generation Needed!");

            dumper.Cleanup();
            il2cppassemblyunhollower.Cleanup();

            if (!dumper.Execute())
            {
                dumper.Cleanup();
                return(1);
            }

            if (!il2cppassemblyunhollower.Execute())
            {
                dumper.Cleanup();
                il2cppassemblyunhollower.Cleanup();
                return(1);
            }

            OldFiles_Cleanup();
            OldFiles_LAM();

            dumper.Cleanup();
            il2cppassemblyunhollower.Cleanup();

            MelonLogger.Msg("Assembly Generation Successful!");
            Config.Values.GameAssemblyHash = CurrentGameAssemblyHash;
            deobfuscationMap.Save();

            return(0);
        }
Exemple #2
0
        private static int Run()
        {
            Config.Initialize();

            if (!MelonLaunchOptions.Il2CppAssemblyGenerator.OfflineMode)
            {
                RemoteAPI.Contact();
            }

            // Temporary Workaround for Cpp2IL Failing on Unsupported OSes
            if (!MelonUtils.IsUnderWineOrSteamProton() && ((Environment.OSVersion.Version.Major < 6) || // Is Older than Vista
                                                           ((Environment.OSVersion.Version.Major == 6) && (Environment.OSVersion.Version.Minor < 1)))) // Is Older than Windows 7 or Server 2008 R2
            {
                dumper = new Il2CppDumper();
            }
            else
            {
                dumper = new Cpp2IL();
            }

            il2cppassemblyunhollower = new Il2CppAssemblyUnhollower();
            unitydependencies        = new UnityDependencies();
            deobfuscationMap         = new DeobfuscationMap();

            MelonLogger.Msg($"Using Dumper Version: {(string.IsNullOrEmpty(dumper.Version) ? "null" : dumper.Version)}");
            MelonLogger.Msg($"Using Il2CppAssemblyUnhollower Version = {(string.IsNullOrEmpty(il2cppassemblyunhollower.Version) ? "null" : il2cppassemblyunhollower.Version)}");
            MelonLogger.Msg($"Using Unity Dependencies Version = {(string.IsNullOrEmpty(unitydependencies.Version) ? "null" : unitydependencies.Version)}");
            if (!string.IsNullOrEmpty(deobfuscationMap.ObfuscationRegex))
            {
                MelonLogger.Msg($"Using Deobfuscation Regex = {deobfuscationMap.ObfuscationRegex}");
            }

            if (!MelonLaunchOptions.Il2CppAssemblyGenerator.OfflineMode)
            {
                if (!dumper.Download() ||
                    !il2cppassemblyunhollower.Download() ||
                    !unitydependencies.Download() ||
                    !deobfuscationMap.Download())
                {
                    return(1);
                }
            }

            // Check for Regex Change against Config

            string CurrentGameAssemblyHash;

            MelonLogger.Msg("Checking GameAssembly...");
            MelonDebug.Msg($"Last GameAssembly Hash: {Config.Values.GameAssemblyHash}");
            MelonDebug.Msg($"Current GameAssembly Hash: {CurrentGameAssemblyHash = GetGameAssemblyHash()}");

            if (!AssemblyGenerationNeeded &&
                (string.IsNullOrEmpty(Config.Values.GameAssemblyHash) ||
                 !Config.Values.GameAssemblyHash.Equals(CurrentGameAssemblyHash)))
            {
                AssemblyGenerationNeeded = true;
            }

            if (!AssemblyGenerationNeeded)
            {
                MelonLogger.Msg("Assembly is up to date. No Generation Needed.");
                return(0);
            }
            MelonLogger.Msg("Assembly Generation Needed!");

            dumper.Cleanup();
            il2cppassemblyunhollower.Cleanup();

            if (!dumper.Execute())
            {
                dumper.Cleanup();
                return(1);
            }

            if (!il2cppassemblyunhollower.Execute())
            {
                dumper.Cleanup();
                il2cppassemblyunhollower.Cleanup();
                return(1);
            }

            OldFiles_Cleanup();
            OldFiles_LAM();

            dumper.Cleanup();
            il2cppassemblyunhollower.Cleanup();

            MelonLogger.Msg("Assembly Generation Successful!");
            Config.Values.GameAssemblyHash = CurrentGameAssemblyHash;
            deobfuscationMap.Save();

            return(0);
        }