Example #1
0
        private static int Run()
        {
            Config.Initialize();

            RemoteAPI.Contact();

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

            dumper = new Il2CppDumper();
            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);
        }
Example #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();
            deobfuscationRegex       = new DeobfuscationRegex();

            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)}");
            MelonLogger.Msg($"Using Deobfuscation Regex = {(string.IsNullOrEmpty(deobfuscationRegex.Regex) ? "null" : deobfuscationRegex.Regex)}");

            if (!dumper.Setup() ||
                !il2cppassemblyunhollower.Setup() ||
                !unitydependencies.Setup() ||
                !deobfuscationMap.Setup())
            {
                return(1);
            }

            deobfuscationRegex.Setup();

            string CurrentGameAssemblyHash;

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

            if (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!");
            deobfuscationRegex.Save();
            Config.Values.GameAssemblyHash = CurrentGameAssemblyHash;
            Config.Save();

            return(0);
        }