Beispiel #1
0
        public static int Main(string[] args)
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol  = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | (SecurityProtocolType)3072;
            webClient.Headers.Add("User-Agent", "Unity web player");

            if (args.Length < 4)
            {
                Logger.LogError("Bad arguments for generator process; expected arguments: <unityVersion> <gameRoot> <gameData> <regenerate> <force_version_unhollower>");
                return(-1);
            }

            if ((args.Length >= 4) && !string.IsNullOrEmpty(args[3]) && args[3].Equals("true"))
            {
                Force_Regenerate = true;
            }

            if (args.Length >= 5)
            {
                try
                {
                    string Force_Version_Unhollower = args[4];
                    if (!string.IsNullOrEmpty(Force_Version_Unhollower))
                    {
                        if (!Force_Version_Unhollower.Equals("0.2.0.0") && !Force_Version_Unhollower.Equals("0.1.1.0") && !Force_Version_Unhollower.Equals("0.1.0.0"))
                        {
                            JsonArray data = (JsonArray)JsonValue.Parse(webClient.DownloadString("https://api.github.com/repos/knah/Il2CppAssemblyUnhollower/releases")).AsJsonArray;
                            if (data.Count > 0)
                            {
                                bool found_version = false;
                                foreach (var x in data)
                                {
                                    string version = x["tag_name"].AsString;
                                    if (!string.IsNullOrEmpty(version) && version.Equals("v" + Force_Version_Unhollower))
                                    {
                                        found_version = true;
                                        ExternalToolVersions.Il2CppAssemblyUnhollowerVersion = Force_Version_Unhollower;
                                        ExternalToolVersions.Il2CppAssemblyUnhollowerUrl     = "https://github.com/knah/Il2CppAssemblyUnhollower/releases/download/v" + Force_Version_Unhollower + "/Il2CppAssemblyUnhollower." + Force_Version_Unhollower + ".zip";
                                        break;
                                    }
                                }
                                if (!found_version)
                                {
                                    throw new Exception("Invalid Version Specified!");
                                }
                            }
                            else
                            {
                                throw new Exception("Unable to Verify Version!");
                            }
                        }
                        else
                        {
                            throw new Exception("Invalid Version! Only Supports v0.3.0.0 and up!");
                        }
                    }
                }
                catch (Exception e)
                {
                    Logger.LogError("Failed to Force Unhollower Version, Defaulting to " + ExternalToolVersions.Il2CppAssemblyUnhollowerVersion + "  |  " + e.Message);
                }
            }

            try
            {
                int returnval = (AssemblyGenerator.Main.Initialize(args[0], args[1], args[2]) ? 0 : -2);
                TempFileCache.ClearCache();
                return(returnval);
            }
            catch (Exception ex)
            {
                TempFileCache.ClearCache();
                Logger.LogError("Failed to generate assemblies;");
                Logger.LogError(ex.ToString());

                return(-3);
            }
        }
Beispiel #2
0
        private static void DownloadDependencies(string unityVersion)
        {
            Logger.Log("Downloading Il2CppDumper");
            try
            {
                DownloaderAndUnpacker.Run(ExternalToolVersions.Il2CppDumperUrl, ExternalToolVersions.Il2CppDumperVersion, localConfig.DumperVersion, Il2CppDumper.BaseFolder, TempFileCache.CreateFile());
                localConfig.DumperVersion = ExternalToolVersions.Il2CppDumperVersion;
                localConfig.Save(localConfigPath);
            }
            catch (Exception ex)
            {
                DownloadedSuccessfully = false;
                Logger.LogError(ex.ToString());
                Logger.Log("Can't download Il2CppDumper!");
            }
            if (!DownloadedSuccessfully)
            {
                return;
            }

            Logger.Log("Downloading Il2CppAssemblyUnhollower");
            try
            {
                DownloaderAndUnpacker.Run(ExternalToolVersions.Il2CppAssemblyUnhollowerUrl, ExternalToolVersions.Il2CppAssemblyUnhollowerVersion, localConfig.UnhollowerVersion, Il2CppAssemblyUnhollower.BaseFolder, TempFileCache.CreateFile());
                localConfig.UnhollowerVersion = ExternalToolVersions.Il2CppAssemblyUnhollowerVersion;
                localConfig.Save(localConfigPath);
            }
            catch (Exception ex)
            {
                DownloadedSuccessfully = false;
                Logger.LogError(ex.ToString());
                Logger.Log("Can't download Il2CppAssemblyUnhollower!");
            }
            if (!DownloadedSuccessfully)
            {
                return;
            }

            Logger.Log("Downloading Unity Dependencies");
            string tempfile     = TempFileCache.CreateFile();
            bool   run_fallback = false;

            try
            {
                DownloaderAndUnpacker.Run($"{ExternalToolVersions.UnityDependenciesBaseUrl}{unityVersion}.zip", unityVersion, localConfig.UnityVersion, UnityDependencies.BaseFolder, tempfile);
                localConfig.UnityVersion = unityVersion;
                localConfig.Save(localConfigPath);
            }
            catch (Exception ex)
            {
                run_fallback = true;
                Logger.LogError(ex.ToString());
                Logger.Log("Can't download Unity Dependencies for " + unityVersion + ", downloading Fallback...");
            }
            if (run_fallback)
            {
                string subver = unityVersion.Substring(0, unityVersion.LastIndexOf("."));
                try
                {
                    JsonArray data = (JsonArray)JsonValue.Parse(Program.webClient.DownloadString("https://api.github.com/repos/Goatxz/CumLoader/contents/BaseLibs/UnityDependencies")).AsJsonArray;
                    if (data.Count > 0)
                    {
                        List <string> versionlist = new List <string>();
                        foreach (var x in data)
                        {
                            string version = Path.GetFileNameWithoutExtension(x["name"].AsString);
                            if (version.StartsWith(subver))
                            {
                                versionlist.Add(version);
                                string[] semvertbl = version.Split(new char[] { '.' });
                            }
                        }
                        if (versionlist.Count > 0)
                        {
                            versionlist = versionlist.OrderBy(x => int.Parse(x.Split(new char[] { '.' })[2])).ToList();
                            string latest_version = versionlist.Last();
                            Logger.Log("Fallback Unity Version: " + latest_version);

                            DownloaderAndUnpacker.Run($"{ExternalToolVersions.UnityDependenciesBaseUrl}{latest_version}.zip", latest_version, localConfig.UnityVersion, UnityDependencies.BaseFolder, tempfile);
                            localConfig.UnityVersion = unityVersion;
                            localConfig.Save(localConfigPath);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex.ToString());
                    Logger.LogError("Can't download Unity Dependencies, Unstripping will NOT be done!");
                }
            }
        }