Esempio n. 1
0
        internal static void Main()
        {
            File.Delete("log.txt");

            Log.StartLogging();

            Log.Debug("Setting up current directory: " + Path.GetDirectoryName(Application.ExecutablePath));
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(true);

            Form SplashScreen2 = null;

            Log.Debug("Checking current directory");

            if (Self.isTempFolder(Directory.GetCurrentDirectory()))
            {
                MessageBox.Show(null, "Please, extract me and my DLL files before executing...", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Environment.Exit(0);
            }

            if (!File.Exists("GameLauncherUpdater.exe"))
            {
                Log.Debug("Starting GameLauncherUpdater downloader");
                try {
                    using (WebClientWithTimeout wc = new WebClientWithTimeout()) {
                        wc.DownloadFileCompleted += (object sender, AsyncCompletedEventArgs e) => {
                            if (new FileInfo("GameLauncherUpdater.exe").Length == 0)
                            {
                                File.Delete("GameLauncherUpdater.exe");
                            }
                        };
                        wc.DownloadFileAsync(new Uri(Self.mainserver + "/files/GameLauncherUpdater.exe"), "GameLauncherUpdater.exe");
                    }
                } catch (Exception ex) {
                    Log.Debug("Failed to download updater. " + ex.Message);
                }
            }

            if (!File.Exists("servers.json"))
            {
                try {
                    File.WriteAllText("servers.json", "[]");
                } catch { /* ignored */ }
            }

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            if (Debugger.IsAttached)
            {
                Log.Debug("Checking Proxy");
                ServerProxy.Instance.Start();
                Log.Debug("Starting MainScreen");
                Application.Run(new MainScreen(SplashScreen2));
            }
            else
            {
                if (NFSW.isNFSWRunning())
                {
                    MessageBox.Show(null, "An instance of Need for Speed: World is already running", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Process.GetProcessById(Process.GetCurrentProcess().Id).Kill();
                }

                var mutex = new Mutex(false, "GameLauncherNFSW-MeTonaTOR");
                try {
                    if (mutex.WaitOne(0, false))
                    {
                        string[] files =
                        {
                            "SharpRaven.dll - 2.4.0",
                            "Flurl.dll - 2.8.0",
                            "Flurl.Http.dll - 2.3.2",
                            "INIFileParser.dll - 2.5.2",
                            "Microsoft.WindowsAPICodePack.dll - 1.1.0.0",
                            "Microsoft.WindowsAPICodePack.Shell.dll - 1.1.0.0",
                            "Nancy.dll - 1.4.4",
                            "Nancy.Hosting.Self.dll - 1.4.1",
                            "Newtonsoft.Json.dll - 11.0.2",
                        };

                        var missingfiles = new List <string>();

                        if (!DetectLinux.LinuxDetected())  //MONO Hates that...
                        {
                            foreach (var file in files)
                            {
                                var splitFileVersion = file.Split(new string[] { " - " }, StringSplitOptions.None);

                                if (!File.Exists(Directory.GetCurrentDirectory() + "\\" + splitFileVersion[0]))
                                {
                                    missingfiles.Add(splitFileVersion[0] + " - Not Found");
                                }
                                else
                                {
                                    try {
                                        var      versionInfo  = FileVersionInfo.GetVersionInfo(splitFileVersion[0]);
                                        string[] versionsplit = versionInfo.ProductVersion.Split('+');
                                        string   version      = versionsplit[0];

                                        if (version == "")
                                        {
                                            missingfiles.Add(splitFileVersion[0] + " - Invalid File");
                                        }
                                        else
                                        {
                                            if (Self.CheckArchitectureFile(splitFileVersion[0]) == false)
                                            {
                                                missingfiles.Add(splitFileVersion[0] + " - Wrong Architecture");
                                            }
                                            else
                                            {
                                                if (version != splitFileVersion[1])
                                                {
                                                    missingfiles.Add(splitFileVersion[0] + " - Invalid Version (" + splitFileVersion[1] + " != " + version + ")");
                                                }
                                            }
                                        }
                                    } catch {
                                        missingfiles.Add(splitFileVersion[0] + " - Invalid File");
                                    }
                                }
                            }
                        }
                        if (missingfiles.Count != 0)
                        {
                            var message = "Cannot launch GameLauncher. The following files are invalid:\n\n";

                            foreach (var file in missingfiles)
                            {
                                message += "• " + file + "\n";
                            }

                            MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            Log.Debug("Checking Proxy");
                            ServerProxy.Instance.Start();

                            Application.ThreadException += new ThreadExceptionEventHandler(ThreadExceptionEventHandler);
                            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionEventHandler);

                            Log.Debug("Starting MainScreen");
                            Application.Run(new MainScreen(SplashScreen2));
                        }
                    }
                    else
                    {
                        MessageBox.Show(null, "An instance of the application is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                } finally {
                    mutex.Close();
                    mutex = null;
                }
            }
        }
Esempio n. 2
0
        internal static void checkForUpdate(object sender, EventArgs e)
        {
            try {
                var client = new WebClientWithTimeout();

                Uri StringToUri = new Uri("http://launcher.soapboxrace.world/checkUpdate.php?version=" + Application.ProductVersion);
                client.CancelAsync();
                client.DownloadStringAsync(StringToUri);
                client.DownloadStringCompleted += (sender2, e2) => {
                    try {
                        CheckVersion json = JsonConvert.DeserializeObject <CheckVersion>(e2.Result);

                        if (json.update.info == true)
                        {
                            IniFile SettingFile = new IniFile("Settings.ini");
                            if (SettingFile.Read("IgnoreUpdateVersion") != json.github_build)
                            {
                                TaskDialog dia = new TaskDialog();
                                dia.Caption               = "Update";
                                dia.InstructionText       = "An update is available!";
                                dia.DetailsExpanded       = true;
                                dia.Icon                  = TaskDialogStandardIcon.Information;
                                dia.DetailsCollapsedLabel = "Show Changelog";
                                dia.Text                  = "An update is available. Do you want to download it?\nYour version: " + Application.ProductVersion + "\nUpdated version: " + json.github_build;
                                dia.DetailsExpandedText   = new WebClientWithTimeout().DownloadString("https://launcher.soapboxrace.world/changelog/text.php");
                                dia.ExpansionMode         = TaskDialogExpandedDetailsLocation.ExpandFooter;

                                TaskDialogCommandLink update     = new TaskDialogCommandLink("update", "Yes", "Launcher will be updated to " + json.github_build + ".");
                                TaskDialogCommandLink cancel     = new TaskDialogCommandLink("cancel", "No", "Launcher will ask for update on next launch.");
                                TaskDialogCommandLink skipupdate = new TaskDialogCommandLink("skipupdate", "Ignore", "This update will be skipped. A new prompt will apear as soon as a newer update is available.");

                                update.UseElevationIcon = true;

                                skipupdate.Click += (sender3, e3) => {
                                    SettingFile.Write("IgnoreUpdateVersion", json.github_build);
                                    dia.Close();
                                };

                                cancel.Click += (sender3, e3) => {
                                    dia.Close();
                                };

                                update.Click += (sender3, e3) => {
                                    if (File.Exists("GL_Update.exe"))
                                    {
                                        Process.Start(@"GL_Update.exe", Process.GetCurrentProcess().Id.ToString());
                                    }
                                    else
                                    {
                                        Process.Start(@"https://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases/latest");
                                    }

                                    dia.Close();
                                };

                                dia.Controls.Add(update);
                                dia.Controls.Add(cancel);
                                dia.Controls.Add(skipupdate);

                                dia.Show();

                                //new UpdatePopup(json.github_build).Show();
                            }
                        }
                        else
                        {
                            try {
                                if (((Form)sender).Name == "mainScreen")
                                {
                                }
                            } catch {
                                MessageBox.Show("Your launcher is up-to-date");
                            }
                        }
                    } catch {
                        try {
                            if (((Form)sender).Name == "mainScreen")
                            {
                            }
                        } catch {
                            MessageBox.Show("Failed to check for update!");
                        }
                    }
                };
            } catch {
                MessageBox.Show("Failed to check for update!");
            }
        }
Esempio n. 3
0
        private static void Main2(Arguments args)
        {
            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture("en-US");
            Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("en-US");

            if (UriScheme.IsCommandLineArgumentsInstalled())
            {
                UriScheme.InstallCommandLineArguments(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), AppDomain.CurrentDomain.FriendlyName));
                if (args.Parse != null)
                {
                    new UriScheme(args.Parse);
                }
            }

            try {
                new WebClient().DownloadData("http://l.mtntr.pl/generate_204.php");
            } catch (Exception) {
                MessageBox.Show("There's no internet connection, launcher might crash");
            }

            IniFile _settingFile = new IniFile("Settings.ini");

            if (!(_settingFile.KeyExists("PatchesApplied")))
            {
                String _OS = (string)Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion").GetValue("productName");
                if (_OS.Contains("Windows 7"))
                {
                    if (Self.getInstalledHotFix("KB3020369") == false || Self.getInstalledHotFix("KB3125574") == false)
                    {
                        String messageBoxPopupKB = String.Empty;
                        messageBoxPopupKB  = "Hey Windows 7 User, in order to play on this server, we need to make additional tweaks to your system.\n";
                        messageBoxPopupKB += "We must make sure you have those Windows Update packages installed:\n\n";

                        if (Self.getInstalledHotFix("KB3020369") == false)
                        {
                            messageBoxPopupKB += "- Update KB3020369\n";
                        }
                        if (Self.getInstalledHotFix("KB3125574") == false)
                        {
                            messageBoxPopupKB += "- Update KB3125574\n";
                        }

                        messageBoxPopupKB += "\nAditionally, we must add a value to the registry:\n";

                        messageBoxPopupKB += "- HKLM/SYSTEM/CurrentControlSet/Control/SecurityProviders\n/SCHANNEL/Protocols/TLS 1.2/Client\n";
                        messageBoxPopupKB += "- Value: DisabledByDefault -> 0\n\n";

                        messageBoxPopupKB += "Would you like to add those values?";
                        DialogResult replyPatchWin7 = MessageBox.Show(null, messageBoxPopupKB, "GameLauncherReborn", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                        if (replyPatchWin7 == DialogResult.Yes)
                        {
                            RegistryKey key = Registry.LocalMachine.CreateSubKey(@"SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client");
                            key.SetValue("DisabledByDefault", 0x0);

                            MessageBox.Show(null, "Registry option set, Remember that the following patch might work after a system reboot", "GameLauncherReborn", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                        else
                        {
                            MessageBox.Show(null, "Roger that, There will be some issues connecting to the servers.", "GameLauncherReborn", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }

                        _settingFile.Write("PatchesApplied", "1");
                    }
                }
            }

            Console.WriteLine("Application path: " + Path.GetDirectoryName(Application.ExecutablePath));

            if (!Self.hasWriteAccessToFolder(Path.GetDirectoryName(Application.ExecutablePath)))
            {
                MessageBox.Show("This application requires admin priviledge");
            }

            if (DetectLinux.LinuxDetected())
            {
                if (!_settingFile.KeyExists("InstallationDirectory"))
                {
                    _settingFile.Write("InstallationDirectory", "GameFiles");
                }

                if (!_settingFile.KeyExists("CDN"))
                {
                    try {
                        List <CDNObject>     CDNList = new List <CDNObject>();
                        WebClientWithTimeout wc3     = new WebClientWithTimeout();
                        String _slresponse           = wc3.DownloadString(Self.CDNUrlList);
                        CDNList = JsonConvert.DeserializeObject <List <CDNObject> >(_slresponse);
                        _settingFile.Write("CDN", CDNList.First().url);
                    } catch {
                        _settingFile.Write("CDN", "http://cdn.worldunited.gg/gamefiles/packed/");
                    }
                }
            }

            if (!string.IsNullOrEmpty(_settingFile.Read("InstallationDirectory")))
            {
                Console.WriteLine("Game path: " + _settingFile.Read("InstallationDirectory"));

                if (!Self.hasWriteAccessToFolder(_settingFile.Read("InstallationDirectory")))
                {
                    MessageBox.Show("This application requires admin priviledge. Restarting...");
                }
            }

            File.Delete("communication.log");
            File.Delete("launcher.log");

            Log.StartLogging();
            Log.Debug("GameLauncher " + Application.ProductVersion);

            if (_settingFile.KeyExists("InstallationDirectory"))
            {
                if (!File.Exists(_settingFile.Read("InstallationDirectory")))
                {
                    Directory.CreateDirectory(_settingFile.Read("InstallationDirectory"));
                }
            }

            //StaticConfiguration.DisableErrorTraces = false;

            Log.Debug("Setting up current directory: " + Path.GetDirectoryName(Application.ExecutablePath));
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(true);

            Log.Debug("Checking current directory");

            if (Self.isTempFolder(Directory.GetCurrentDirectory()))
            {
                MessageBox.Show(null, "Please, extract me and my DLL files before executing...", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Environment.Exit(0);
            }

            String[] removeFiles = new String[] { "GameLauncherUpdater.exe", "Update.exe", "update.sbrw" };

            foreach (string file in removeFiles)
            {
                if (File.Exists(file))
                {
                    File.Delete(file);
                }
            }

            //Also remove new one on next launch.
            if (File.Exists("Update.exe"))
            {
                File.Delete("GameLauncherUpdater.exe");
            }

            if (!File.Exists("servers.json"))
            {
                try {
                    File.WriteAllText("servers.json", "[]");
                } catch { /* ignored */ }
            }

            if (Properties.Settings.Default.IsRestarting)
            {
                Properties.Settings.Default.IsRestarting = false;
                Properties.Settings.Default.Save();
                Thread.Sleep(3000);
            }

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            if (Debugger.IsAttached)
            {
                Log.Debug("Checking Proxy");
                ServerProxy.Instance.Start();
                Log.Debug("Starting MainScreen");
                Application.Run(new MainScreen());
            }
            else
            {
                if (NFSW.isNFSWRunning())
                {
                    MessageBox.Show(null, "An instance of Need for Speed: World is already running", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Process.GetProcessById(Process.GetCurrentProcess().Id).Kill();
                }

                var mutex = new Mutex(false, "GameLauncherNFSW-MeTonaTOR");
                try {
                    if (mutex.WaitOne(0, false))
                    {
                        string[] files =
                        {
                            "CommandLine.dll - 2.8.0",
                            "DiscordRPC.dll - 1.0.150.0",
                            "Flurl.dll - 2.8.2",
                            "Flurl.Http.dll - 2.4.2",
                            "INIFileParser.dll - 2.5.2",
                            "Microsoft.WindowsAPICodePack.dll - 1.1.0.0",
                            "Microsoft.WindowsAPICodePack.Shell.dll - 1.1.0.0",
                            "Microsoft.WindowsAPICodePack.ShellExtensions.dll - 1.1.0.0",
                            "Nancy.dll - 2.0.0",
                            "Nancy.Hosting.Self.dll - 2.0.0",
                            "Newtonsoft.Json.dll - 12.0.3",
                            "System.Runtime.InteropServices.RuntimeInformation.dll - 4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97"
                        };

                        var missingfiles = new List <string>();

                        if (!DetectLinux.LinuxDetected())  //MONO Hates that...
                        {
                            foreach (var file in files)
                            {
                                var splitFileVersion = file.Split(new string[] { " - " }, StringSplitOptions.None);

                                if (!File.Exists(Directory.GetCurrentDirectory() + "\\" + splitFileVersion[0]))
                                {
                                    missingfiles.Add(splitFileVersion[0] + " - Not Found");
                                }
                                else
                                {
                                    try {
                                        var      versionInfo  = FileVersionInfo.GetVersionInfo(splitFileVersion[0]);
                                        string[] versionsplit = versionInfo.ProductVersion.Split('+');
                                        string   version      = versionsplit[0];

                                        if (version == "")
                                        {
                                            missingfiles.Add(splitFileVersion[0] + " - Invalid File");
                                        }
                                        else
                                        {
                                            if (Self.CheckArchitectureFile(splitFileVersion[0]) == false)
                                            {
                                                missingfiles.Add(splitFileVersion[0] + " - Wrong Architecture");
                                            }
                                            else
                                            {
                                                if (version != splitFileVersion[1])
                                                {
                                                    missingfiles.Add(splitFileVersion[0] + " - Invalid Version (" + splitFileVersion[1] + " != " + version + ")");
                                                }
                                            }
                                        }
                                    } catch {
                                        missingfiles.Add(splitFileVersion[0] + " - Invalid File");
                                    }
                                }
                            }
                        }
                        if (missingfiles.Count != 0)
                        {
                            var message = "Cannot launch GameLauncher. The following files are invalid:\n\n";

                            foreach (var file in missingfiles)
                            {
                                message += "• " + file + "\n";
                            }

                            MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            Log.Debug("Checking Proxy");
                            ServerProxy.Instance.Start();

                            Log.Debug("Starting MainScreen");
                            Application.Run(new MainScreen());
                        }
                    }
                    else
                    {
                        MessageBox.Show(null, "An instance of Launcher is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                } finally {
                    mutex.Close();
                    mutex = null;
                }
            }
        }
Esempio n. 4
0
        internal static void Main()
        {
            try {
                new WebClient().DownloadData("http://l.mtntr.pl/generate_204.php");
            } catch (Exception) {
                MessageBox.Show("There's no internet connection, launcher might crash");
            }

            Console.WriteLine("Application path: " + Path.GetDirectoryName(Application.ExecutablePath));

            /*GPU getinfo = null;
             *
             * switch(GPUHelper.getManufacturer()) {
             *  case GPUHelper.GPUManufacturer.NVIDIA:
             *      getinfo = new NVIDIA();
             *      break;
             *  case GPUHelper.GPUManufacturer.AMD:
             *      getinfo = new AMD();
             *      break;
             *  case GPUHelper.GPUManufacturer.INTEL:
             *      getinfo = new INTEL();
             *      break;
             *  default:
             *      getinfo = null;
             *      break;
             * }
             *
             * MeTonaTOR.MessageBox.Show(getinfo.DriverVersion());*/

            if (!Self.hasWriteAccessToFolder(Path.GetDirectoryName(Application.ExecutablePath)))
            {
                MessageBox.Show("This application requires admin priviledge. Restarting...");
                Self.runAsAdmin();
            }

            IniFile _settingFile = new IniFile("Settings.ini");

            if (DetectLinux.LinuxDetected())
            {
                if (!_settingFile.KeyExists("InstallationDirectory"))
                {
                    _settingFile.Write("InstallationDirectory", "GameFiles");
                }

                if (!_settingFile.KeyExists("CDN"))
                {
                    try {
                        List <CDNObject>     CDNList = new List <CDNObject>();
                        WebClientWithTimeout wc3     = new WebClientWithTimeout();
                        String _slresponse           = wc3.DownloadString(Self.CDNUrlList);
                        CDNList = JsonConvert.DeserializeObject <List <CDNObject> >(_slresponse);
                        _settingFile.Write("CDN", CDNList.First().url);
                    } catch {
                        _settingFile.Write("CDN", "http://cdn.worldunited.gg/gamefiles/packed/");
                    }
                }
            }

            if (!_settingFile.KeyExists("DisableVerifyHash"))
            {
                _settingFile.Write("DisableVerifyHash", "1");
            }

            if (!string.IsNullOrEmpty(_settingFile.Read("InstallationDirectory")))
            {
                Console.WriteLine("Game path: " + _settingFile.Read("InstallationDirectory"));

                if (!Self.hasWriteAccessToFolder(_settingFile.Read("InstallationDirectory")))
                {
                    MessageBox.Show("This application requires admin priviledge. Restarting...");
                    Self.runAsAdmin();
                }
            }

            File.Delete("log.txt");

            Log.StartLogging();

            //StaticConfiguration.DisableErrorTraces = false;

            Log.Debug("Setting up current directory: " + Path.GetDirectoryName(Application.ExecutablePath));
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(true);

            Log.Debug("Checking current directory");

            if (Self.isTempFolder(Directory.GetCurrentDirectory()))
            {
                MessageBox.Show(null, "Please, extract me and my DLL files before executing...", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Environment.Exit(0);
            }

            if (!File.Exists("GameLauncherUpdater.exe"))
            {
                Log.Debug("Starting GameLauncherUpdater downloader");
                try {
                    using (WebClientWithTimeout wc = new WebClientWithTimeout()) {
                        wc.DownloadFileCompleted += (object sender, AsyncCompletedEventArgs e) => {
                            if (new FileInfo("GameLauncherUpdater.exe").Length == 0)
                            {
                                File.Delete("GameLauncherUpdater.exe");
                            }
                        };
                        wc.DownloadFileAsync(new Uri(Self.fileserver + "/GameLauncherUpdater.exe"), "GameLauncherUpdater.exe");
                    }
                } catch (Exception ex) {
                    Log.Debug("Failed to download updater. " + ex.Message);
                }
            }

            if (!File.Exists("servers.json"))
            {
                try {
                    File.WriteAllText("servers.json", "[]");
                } catch { /* ignored */ }
            }

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            if (Debugger.IsAttached)
            {
                Log.Debug("Checking Proxy");
                ServerProxy.Instance.Start();
                Log.Debug("Starting MainScreen");
                Application.Run(new MainScreen());
            }
            else
            {
                if (NFSW.isNFSWRunning())
                {
                    MessageBox.Show(null, "An instance of Need for Speed: World is already running", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Process.GetProcessById(Process.GetCurrentProcess().Id).Kill();
                }

                var mutex = new Mutex(false, "GameLauncherNFSW-MeTonaTOR");
                try {
                    if (mutex.WaitOne(0, false))
                    {
                        string[] files =
                        {
                            "DiscordRPC.dll - 1.0.150.0",
                            "Flurl.dll - 2.8.2",
                            "Flurl.Http.dll - 2.4.2",
                            "INIFileParser.dll - 2.5.2",
                            "LZMA.dll - 9.10 beta",
                            "Microsoft.WindowsAPICodePack.dll - 1.1.0.0",
                            "Microsoft.WindowsAPICodePack.Shell.dll - 1.1.0.0",
                            "Microsoft.WindowsAPICodePack.ShellExtensions.dll - 1.1.0.0",
                            "Nancy.dll - 2.0.0",
                            "Nancy.Hosting.Self.dll - 2.0.0",
                            "Newtonsoft.Json.dll - 12.0.3",
                            "System.Runtime.InteropServices.RuntimeInformation.dll - 4.6.24705.01. Commit Hash: 4d1af962ca0fede10beb01d197367c2f90e92c97"
                        };

                        var missingfiles = new List <string>();

                        if (!DetectLinux.LinuxDetected())  //MONO Hates that...
                        {
                            foreach (var file in files)
                            {
                                var splitFileVersion = file.Split(new string[] { " - " }, StringSplitOptions.None);

                                if (!File.Exists(Directory.GetCurrentDirectory() + "\\" + splitFileVersion[0]))
                                {
                                    missingfiles.Add(splitFileVersion[0] + " - Not Found");
                                }
                                else
                                {
                                    try {
                                        var      versionInfo  = FileVersionInfo.GetVersionInfo(splitFileVersion[0]);
                                        string[] versionsplit = versionInfo.ProductVersion.Split('+');
                                        string   version      = versionsplit[0];

                                        if (version == "")
                                        {
                                            missingfiles.Add(splitFileVersion[0] + " - Invalid File");
                                        }
                                        else
                                        {
                                            if (Self.CheckArchitectureFile(splitFileVersion[0]) == false)
                                            {
                                                missingfiles.Add(splitFileVersion[0] + " - Wrong Architecture");
                                            }
                                            else
                                            {
                                                if (version != splitFileVersion[1])
                                                {
                                                    missingfiles.Add(splitFileVersion[0] + " - Invalid Version (" + splitFileVersion[1] + " != " + version + ")");
                                                }
                                            }
                                        }
                                    } catch {
                                        missingfiles.Add(splitFileVersion[0] + " - Invalid File");
                                    }
                                }
                            }
                        }
                        if (missingfiles.Count != 0)
                        {
                            var message = "Cannot launch GameLauncher. The following files are invalid:\n\n";

                            foreach (var file in missingfiles)
                            {
                                message += "• " + file + "\n";
                            }

                            MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            Log.Debug("Checking Proxy");
                            ServerProxy.Instance.Start();

                            Application.ThreadException += new ThreadExceptionEventHandler(ThreadExceptionEventHandler);
                            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptionEventHandler);

                            Log.Debug("Starting MainScreen");
                            Application.Run(new MainScreen());
                        }
                    }
                    else
                    {
                        MessageBox.Show(null, "An instance of Launcher is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                } finally {
                    mutex.Close();
                    mutex = null;
                }
            }
        }
Esempio n. 5
0
        static void Main()
        {
            int  SysVersion = (int)Environment.OSVersion.Platform;
            bool mono       = DetectLinux.MonoDetected();
            bool wine       = DetectLinux.WineDetected();
            bool linux      = DetectLinux.LinuxDetected();

            if (Environment.OSVersion.Version.Major <= 5 && !linux)
            {
                MessageBox.Show(null, "Windows XP Support has been terminated. Please upgrade your Operating System to 'Vista' or newer.", "GameLauncher.exe", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Environment.Exit(Environment.ExitCode);
            }

            Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));

            if (!Directory.Exists("Languages"))
            {
                Directory.CreateDirectory("Languages");
            }

            try {
                WebClientWithTimeout client = new WebClientWithTimeout();
                File.Delete("Languages\\Default.lng");
                client.DownloadFile("https://raw.githubusercontent.com/metonator/GameLauncher_NFSW-translations/master/Languages/English.lng", "Languages\\Default.lng");
            } catch { }

            try {
                File.Delete(Directory.GetCurrentDirectory() + "\\tempname.zip");
            } catch { }

            if (mono == true)
            {
                MessageBox.Show(null, "Mono support is still under alpha stage. Therefore, launcher could not launch.", "GameLauncher.exe", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (!File.Exists("LZMA.dll"))
            {
                File.WriteAllBytes("LZMA.dll", ExtractResource.AsByte("GameLauncher.LZMA.LZMA.dll"));
            }

            if (!File.Exists("discord-rpc.dll"))
            {
                File.WriteAllBytes("discord-rpc.dll", ExtractResource.AsByte("GameLauncher.Discord.discord-rpc.dll"));
            }

            if (File.Exists("GameLauncherUpdater.exe"))
            {
                File.Delete("GameLauncherUpdater.exe");
            }

            try {
                File.Delete("GL_Update.exe");
                File.WriteAllBytes("GL_Update.exe", ExtractResource.AsByte("GameLauncher.Updater.GL_Update.exe"));
            } catch { }

            if (NFSW.isNFSWRunning())
            {
                MessageBox.Show(null, "An instance of Need for Speed: World is already running", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Process.GetProcessById(Process.GetCurrentProcess().Id).Kill();
            }

            Mutex mutex = new Mutex(false, "GameLauncherNFSW-MeTonaTOR");

            try {
                if (mutex.WaitOne(0, false))
                {
                    String[]      files        = { "Newtonsoft.Json.dll", "LZMA.dll", "ICSharpCode.SharpZipLib.dll" };
                    List <string> missingfiles = new List <string>();

                    foreach (string file in files)
                    {
                        if (!File.Exists(file))
                        {
                            missingfiles.Add(file);
                        }
                    }

                    if (missingfiles.Count != 0)
                    {
                        string message = "Cannot launch GameLauncher. The following files are missing:\n\n";

                        foreach (string file in missingfiles)
                        {
                            message += "• " + file + "\n";
                        }

                        message += "\nCurrent directory: " + Directory.GetCurrentDirectory();
                        message += "\nYou will be moved to the project page for re-download.";

                        MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Process.Start(@"https://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases");
                        Environment.Exit(1);
                    }

                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new mainScreen());
                }
                else
                {
                    MessageBox.Show(null, "An instance of the application is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            } finally {
                if (mutex != null)
                {
                    mutex.Close();
                    mutex = null;
                }
            }
        }
        private void Verify(object parameters)
        {
            string[] array = (string[])parameters;
            string   str   = array[0].Trim();
            string   text  = array[1].Trim();

            if (!string.IsNullOrEmpty(text))
            {
                str = str + "/" + text;
            }
            string text2 = array[2].Trim();
            bool   flag  = bool.Parse(array[3]);
            bool   flag2 = bool.Parse(array[4]);
            bool   flag3 = bool.Parse(array[5]);
            bool   flag4 = false;

            try
            {
                XmlDocument indexFile = this.GetIndexFile(str + "/index.xml", false);
                if (indexFile == null)
                {
                    ISynchronizeInvoke arg_B9_0 = this.mFE;
                    Delegate           arg_B9_1 = this.mDownloadFailed;
                    object[]           args     = new object[1];
                    arg_B9_0.BeginInvoke(arg_B9_1, args);
                }
                else
                {
                    long num = long.Parse(indexFile.SelectSingleNode("/index/header/length").InnerText);
                    WebClientWithTimeout webClient = new WebClientWithTimeout();
                    webClient.Headers.Add("Accept", "text/html,text/xml,application/xhtml+xml,application/xml,application/*,*/*;q=0.9,*/*;q=0.8");
                    webClient.Headers.Add("Accept-Language", "en-us,en;q=0.5");
                    webClient.Headers.Add("Accept-Encoding", "gzip,deflate");
                    webClient.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
                    XmlNodeList xmlNodeList = indexFile.SelectNodes("/index/fileinfo");
                    HashManager.Instance.Clear();
                    HashManager.Instance.Start(indexFile, text2, text + ".hsh", this.mHashThreads);
                    long  num2 = 0L;
                    ulong num3 = 0uL;
                    ulong num4 = 0uL;
                    foreach (XmlNode xmlNode in xmlNodeList)
                    {
                        string text3     = xmlNode.SelectSingleNode("path").InnerText;
                        string innerText = xmlNode.SelectSingleNode("file").InnerText;
                        if (!string.IsNullOrEmpty(text2))
                        {
                            int num5 = text3.IndexOf("/");
                            if (num5 >= 0)
                            {
                                text3 = text3.Replace(text3.Substring(0, num5), text2);
                            }
                            else
                            {
                                text3 = text2;
                            }
                        }
                        string text4 = text3 + "/" + innerText;
                        int    num6  = int.Parse(xmlNode.SelectSingleNode("length").InnerText);
                        if (xmlNode.SelectSingleNode("hash") != null)
                        {
                            if (!HashManager.Instance.HashesMatch(text4))
                            {
                                num3 += ulong.Parse(xmlNode.SelectSingleNode("length").InnerText);
                                ulong num7;
                                if (xmlNode.SelectSingleNode("compressed") != null)
                                {
                                    num7 = ulong.Parse(xmlNode.SelectSingleNode("compressed").InnerText);
                                }
                                else
                                {
                                    num7 = ulong.Parse(xmlNode.SelectSingleNode("length").InnerText);
                                }
                                num4 += num7;
                                if (flag)
                                {
                                    this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                                    {
                                    });
                                    return;
                                }
                                flag4 = true;
                            }
                        }
                        else
                        {
                            if (flag)
                            {
                                throw new DownloaderException("Without hash in the metadata I cannot verify the download");
                            }
                            flag4 = true;
                        }
                        if (Downloader.mStopFlag)
                        {
                            ISynchronizeInvoke arg_367_0 = this.mFE;
                            Delegate           arg_367_1 = this.mDownloadFailed;
                            object[]           args2     = new object[1];
                            arg_367_0.BeginInvoke(arg_367_1, args2);
                            return;
                        }
                        num2 += (long)num6;
                        object[] args3 = new object[]
                        {
                            num,
                            num2,
                            0,
                            innerText,
                            0
                        };
                        this.mFE.BeginInvoke(this.mProgressUpdated, args3);
                    }
                    if (flag3)
                    {
                        //Downloader.mLogger.Info("Writing hash cache");
                        HashManager.Instance.WriteHashCache(text + ".hsh", true);
                    }
                    if (flag4)
                    {
                        this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                        {
                        });
                    }
                    else
                    {
                        this.mFE.BeginInvoke(this.mDownloadFinished, null);
                    }
                }
            }
            catch (DownloaderException ex)
            {
                this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                {
                    ex
                });
            }
            catch (Exception ex2)
            {
                this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                {
                    ex2
                });
            }
            finally
            {
                if (flag2)
                {
                    HashManager.Instance.Clear();
                }
                GC.Collect();
            }
        }
        private void Download(object parameters)
        {
            this.mDownloading = true;
            string[]    array       = (string[])parameters;
            byte[]      array2      = null;
            XmlNodeList xmlNodeList = null;
            string      text        = array[0];
            string      text2       = array[1];

            if (!string.IsNullOrEmpty(text2))
            {
                text = text + "/" + text2;
            }
            string text3    = array[2];
            bool   flag     = bool.Parse(array[3]);
            bool   useCache = bool.Parse(array[4]);
            ulong  num      = ulong.Parse(array[5]);

            try
            {
                XmlDocument indexFile = this.GetIndexFile(text + "/index.xml", useCache);
                if (indexFile == null)
                {
                    ISynchronizeInvoke arg_AE_0 = this.mFE;
                    Delegate           arg_AE_1 = this.mDownloadFailed;
                    object[]           args     = new object[1];
                    arg_AE_0.BeginInvoke(arg_AE_1, args);
                }
                else
                {
                    long num2 = long.Parse(indexFile.SelectSingleNode("/index/header/length").InnerText);
                    long num3 = 0L;
                    long num4;
                    if (num == 0uL)
                    {
                        num4 = long.Parse(indexFile.SelectSingleNode("/index/header/compressed").InnerText);
                    }
                    else
                    {
                        num4 = (long)num;
                    }
                    long num5 = 0L;
                    WebClientWithTimeout webClient = new WebClientWithTimeout();
                    webClient.Headers.Add("Accept", "text/html,text/xml,application/xhtml+xml,application/xml,application/*,*/*;q=0.9,*/*;q=0.8");
                    webClient.Headers.Add("Accept-Language", "en-us,en;q=0.5");
                    webClient.Headers.Add("Accept-Encoding", "gzip,deflate");
                    webClient.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
                    int num6 = 1;
                    array2      = null;
                    xmlNodeList = indexFile.SelectNodes("/index/fileinfo");
                    this.mDownloadManager.Initialize(indexFile, text);
                    if (flag)
                    {
                        HashManager.Instance.Clear();
                        HashManager.Instance.Start(indexFile, text3, text2 + ".hsh", this.mHashThreads);
                    }
                    int           num7  = 0;
                    List <string> list  = new List <string>();
                    int           i     = 0;
                    bool          flag2 = false;
                    int           num11;
                    int           fileschecked = 0;
                    foreach (XmlNode xmlNode in xmlNodeList)
                    {
                        XmlNodeList xmlNodeList2 = xmlNode.SelectNodes("compressed");
                        int         num8;
                        if (xmlNodeList2.Count == 0)
                        {
                            num8 = int.Parse(xmlNode.SelectNodes("length")[0].InnerText);
                        }
                        else
                        {
                            num8 = int.Parse(xmlNodeList2[0].InnerText);
                        }
                        num7 = ((num8 > num7) ? num8 : num7);
                        string text4 = xmlNode.SelectSingleNode("path").InnerText;
                        if (!string.IsNullOrEmpty(text3))
                        {
                            int num9 = text4.IndexOf("/");
                            if (num9 >= 0)
                            {
                                text4 = text4.Replace(text4.Substring(0, num9), text3);
                            }
                            else
                            {
                                text4 = text3;
                            }
                        }
                        string innerText = xmlNode.SelectSingleNode("file").InnerText;
                        string fileName  = text4 + "/" + innerText;
                        int    num10     = int.Parse(xmlNode.SelectSingleNode("section").InnerText);
                        num11 = int.Parse(xmlNode.SelectSingleNode("offset").InnerText);
                        if (flag)
                        {
                            if (list.Count == 0)
                            {
                                i = num10;
                            }
                            while (i <= num10)
                            {
                                list.Insert(0, string.Format("{0}/section{1}.dat", text, i));
                                i++;
                            }
                        }
                        else if (!HashManager.Instance.HashesMatch(fileName))
                        {
                            if (i <= num10)
                            {
                                if (list.Count == 0)
                                {
                                    i = num10;
                                }
                                while (i <= num10)
                                {
                                    list.Insert(0, string.Format("{0}/section{1}.dat", text, i));
                                    i++;
                                }
                            }
                            flag2 = true;
                        }
                        else
                        {
                            if (flag2)
                            {
                                int num12 = num10;
                                if (num11 == 0)
                                {
                                    num12--;
                                }
                                while (i <= num12)
                                {
                                    list.Insert(0, string.Format("{0}/section{1}.dat", text, i));
                                    i++;
                                }
                            }
                            if (i < num10)
                            {
                                i = num10;
                            }
                            flag2 = false;
                        }
                    }
                    foreach (string current in list)
                    {
                        this.mDownloadManager.ScheduleFile(current);
                    }
                    list.Clear();
                    list  = null;
                    num11 = 0;
                    this.mDownloadManager.Start();
                    byte[] array3 = new byte[num7];
                    byte[] array4 = new byte[13];
                    int    num13  = 0;
                    foreach (XmlNode xmlNode2 in xmlNodeList)
                    {
                        fileschecked++;

                        if (Downloader.mStopFlag)
                        {
                            break;
                        }
                        string text5      = xmlNode2.SelectSingleNode("path").InnerText;
                        string innerText2 = xmlNode2.SelectSingleNode("file").InnerText;
                        if (!string.IsNullOrEmpty(text3))
                        {
                            int num14 = text5.IndexOf("/");
                            if (num14 >= 0)
                            {
                                text5 = text5.Replace(text5.Substring(0, num14), text3);
                            }
                            else
                            {
                                text5 = text3;
                            }
                        }
                        string  text6    = text5 + "/" + innerText2;
                        int     num15    = int.Parse(xmlNode2.SelectSingleNode("length").InnerText);
                        int     num16    = 0;
                        XmlNode xmlNode3 = xmlNode2.SelectSingleNode("compressed");
                        if (xmlNode2.SelectSingleNode("section") != null && num6 < int.Parse(xmlNode2.SelectSingleNode("section").InnerText))
                        {
                            num6 = int.Parse(xmlNode2.SelectSingleNode("section").InnerText);
                        }
                        string text7 = null;
                        if (xmlNode2.SelectSingleNode("hash") != null && HashManager.Instance.HashesMatch(text6))
                        {
                            num16 += num15;
                            if (xmlNode3 != null)
                            {
                                if (num == 0uL)
                                {
                                    num3 += (long)int.Parse(xmlNode3.InnerText);
                                }
                                num5  += (long)int.Parse(xmlNode3.InnerText);
                                num11 += int.Parse(xmlNode3.InnerText);
                            }
                            else
                            {
                                if (num == 0uL)
                                {
                                    num3 += (long)num15;
                                }
                                num5  += (long)num15;
                                num11 += num15;
                            }
                            if (this.mProgressUpdated != null)
                            {
                                object[] args2 = new object[]
                                {
                                    num2,
                                    num3,
                                    num4,
                                    text6,
                                    0
                                };
                                this.mFE.Invoke(this.mProgressUpdated, args2);
                            }
                            int num17 = int.Parse(xmlNode2.SelectSingleNode("section").InnerText);
                            if (num13 != num17)
                            {
                                for (int j = num13 + 1; j < num17; j++)
                                {
                                    this.mDownloadManager.CancelDownload(string.Format("{0}/section{1}.dat", text, j));
                                }
                                num13 = num17 - 1;
                            }
                        }
                        else
                        {
                            Directory.CreateDirectory(text5);
                            FileStream fileStream = File.Create(text6);
                            int        num18      = num15;
                            if (xmlNode3 != null)
                            {
                                num18 = int.Parse(xmlNode3.InnerText);
                            }
                            int  k     = 0;
                            bool flag3 = false;
                            int  num19 = 13;
                            while (k < num18)
                            {
                                if (array2 == null || num11 >= array2.Length)
                                {
                                    if (xmlNode2.SelectSingleNode("offset") != null && !flag3)
                                    {
                                        num11 = int.Parse(xmlNode2.SelectSingleNode("offset").InnerText);
                                    }
                                    else
                                    {
                                        num11 = 0;
                                    }
                                    text7 = string.Format("{0}/section{1}.dat", text, num6);
                                    for (int l = num13 + 1; l < num6; l++)
                                    {
                                        this.mDownloadManager.CancelDownload(string.Format("{0}/section{1}.dat", text, l));
                                    }
                                    array2 = null;
                                    GC.Collect();
                                    array2 = this.mDownloadManager.GetFile(text7);
                                    if (array2 == null)
                                    {
                                        //MessageBox.Show("DownloadManager returned a null buffer for file '" + text7 + "', aborting");
                                        if (this.mDownloadFailed != null)
                                        {
                                            if (!Downloader.mStopFlag)
                                            {
                                                this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                                                {
                                                    new Exception("DownloadManager returned a null buffer")
                                                });
                                            }
                                            else
                                            {
                                                ISynchronizeInvoke arg_887_0 = this.mFE;
                                                Delegate           arg_887_1 = this.mDownloadFailed;
                                                object[]           args      = new object[1];
                                                arg_887_0.BeginInvoke(arg_887_1, args);
                                            }
                                        }
                                        return;
                                    }
                                    num13 = num6;
                                    num5 += (long)array2.Length;
                                    num6++;
                                    if (!this.mDownloadManager.GetStatus(string.Format("{0}/section{1}.dat", text, num6)).HasValue&& num5 < num4)
                                    {
                                        this.mDownloadManager.ScheduleFile(string.Format("{0}/section{1}.dat", text, num6));
                                    }
                                }
                                else
                                {
                                    if (num18 - k > array2.Length - num11)
                                    {
                                        text7 = string.Format("{0}/section{1}.dat", text, num6);
                                        this.mDownloadManager.ScheduleFile(text7);
                                        flag3 = true;
                                    }
                                    int num20 = Math.Min(array2.Length - num11, num18 - k);
                                    if (num19 != 0)
                                    {
                                        if (xmlNode3 != null)
                                        {
                                            int num21 = Math.Min(num19, num20);
                                            Buffer.BlockCopy(array2, num11, array4, 13 - num19, num21);
                                            Buffer.BlockCopy(array2, num11 + num21, array3, 0, num20 - num21);
                                            num19 -= num21;
                                        }
                                        else
                                        {
                                            Buffer.BlockCopy(array2, num11, array3, 0, num20);
                                            num19 = 0;
                                        }
                                    }
                                    else
                                    {
                                        Buffer.BlockCopy(array2, num11, array3, k - ((xmlNode3 != null) ? 13 : 0), num20);
                                    }
                                    num11 += num20;
                                    k     += num20;
                                    num3  += (long)num20;
                                }
                                if (this.mProgressUpdated != null)
                                {
                                    object[] args3 = new object[]
                                    {
                                        num2,
                                        num3,
                                        num4,
                                        text6,
                                        0
                                    };
                                    this.mFE.BeginInvoke(this.mProgressUpdated, args3);
                                }
                            }
                            if (xmlNode3 != null)
                            {
                                if (!Downloader.IsLzma(array4))
                                {
                                    MessageBox.Show("Compression algorithm not recognized" + text7);
                                    throw new DownloaderException("Compression algorithm not recognized: " + text7);
                                }
                                fileStream.Close();
                                fileStream.Dispose();
                                //(IntPtr)num15;
                                IntPtr outPropsSize = new IntPtr(5);
                                byte[] array5       = new byte[5];
                                for (int m = 0; m < 5; m++)
                                {
                                    array5[m] = array4[m];
                                }
                                long num22 = 0L;
                                for (int n = 0; n < 8; n++)
                                {
                                    num22 += (long)((long)array4[n + 5] << 8 * n);
                                }
                                if (num22 != (long)num15)
                                {
                                    MessageBox.Show("Compression data length in header '" + num22 + "' != than in metadata '" + num15 + "'");
                                    throw new DownloaderException("Compression data length in header '" + num22 + "' != than in metadata '" + num15 + "'");
                                }
                                int num23 = num18;
                                num18 -= 13;
                                IntPtr intPtr = new IntPtr(num18);
                                IntPtr value  = new IntPtr(num22);
                                int    num24  = LZMA.LzmaUncompressBuf2File(text6, ref value, array3, ref intPtr, array5, outPropsSize);

                                object[] xxxxxx = new object[] { text6, fileschecked, xmlNodeList.Count };
                                this.mFE.BeginInvoke(this.mShowExtract, xxxxxx);

                                if (num24 != 0)
                                {
                                    MessageBox.Show("Decompression returned " + num24);
                                    throw new UncompressionException(num24, "Decompression returned " + num24);
                                }
                                if (value.ToInt32() != num15)
                                {
                                    MessageBox.Show("Decompression returned different size '" + value.ToInt32() + "' than metadata '" + num15 + "'");
                                    throw new DownloaderException("Decompression returned different size '" + value.ToInt32() + "' than metadata '" + num15 + "'");
                                }
                                num16 += (int)value;
                            }
                            else
                            {
                                fileStream.Write(array3, 0, num15);
                                num16 += num15;
                            }
                            if (fileStream != null)
                            {
                                fileStream.Close();
                                fileStream.Dispose();
                            }
                        }
                    }
                    if (!Downloader.mStopFlag)
                    {
                        HashManager.Instance.WriteHashCache(text2 + ".hsh", false);
                    }
                    if (Downloader.mStopFlag)
                    {
                        if (this.mDownloadFailed != null)
                        {
                            ISynchronizeInvoke arg_D16_0 = this.mFE;
                            Delegate           arg_D16_1 = this.mDownloadFailed;
                            object[]           args      = new object[1];
                            arg_D16_0.BeginInvoke(arg_D16_1, args);
                        }
                    }
                    else if (this.mDownloadFinished != null)
                    {
                        this.mFE.BeginInvoke(this.mDownloadFinished, null);
                    }
                }
            }
            catch (DownloaderException ex)
            {
                MessageBox.Show("Download DownloaderException: " + ex.ToString());
                if (this.mDownloadFailed != null)
                {
                    try
                    {
                        this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                        {
                            ex
                        });
                    }
                    catch
                    {
                    }
                }
            }
            catch (Exception ex2)
            {
                MessageBox.Show("Download Exception: " + ex2.ToString());
                if (this.mDownloadFailed != null)
                {
                    try
                    {
                        this.mFE.BeginInvoke(this.mDownloadFailed, new object[]
                        {
                            ex2
                        });
                    }
                    catch
                    {
                    }
                }
            }
            finally
            {
                if (flag)
                {
                    HashManager.Instance.Clear();
                }
                this.mDownloadManager.Clear();
                array2      = null;
                xmlNodeList = null;
                GC.Collect();
                this.mDownloading = false;
            }
        }