Exemplo n.º 1
0
        private void OnLogin(string username)
        {
            Utility.Log(LogStatus.Ok, "Login", string.Format("Succesfully signed in as {0}", username), Logs.MainLog);
            Browser.Visibility    = Visibility.Visible;
            TosBrowser.Visibility = Visibility.Visible;
            try
            {
                Utility.MapClassToXmlFile(typeof(Config), Config.Instance, Directories.ConfigFilePath);
            }
            catch
            {
                MessageBox.Show(Utility.GetMultiLanguageText("ConfigWriteError"));
            }

            if (!PathRandomizer.CopyFiles())
            {
            }

            InjectThread = new Thread(
                () =>
            {
                while (true)
                {
                    if (Config.Instance.Install)
                    {
                        Injection.Pulse();
                    }
                    Thread.Sleep(3000);
                }
            });

            InjectThread.Start();
        }
Exemplo n.º 2
0
        private void InitSystem()
        {
            PathRandomizer.CopyFiles();
            Remoting.Init();

            this.InjectThread = new Thread(
                () =>
            {
                var trigger = new EdgeTrigger();

                trigger.Rising += (sender, args) =>
                {
                    Application.Current.Dispatcher.InvokeAsync(
                        () =>
                    {
                        this.icon_connected.Visibility    = Visibility.Visible;
                        this.icon_disconnected.Visibility = Visibility.Collapsed;
                    });
                };

                trigger.Falling += (sender, args) =>
                {
                    Application.Current.Dispatcher.InvokeAsync(
                        async() =>
                    {
                        this.icon_connected.Visibility    = Visibility.Collapsed;
                        this.icon_disconnected.Visibility = Visibility.Visible;
                        await this.UpdateAccount();
                    });
                };

                while (true)
                {
                    try
                    {
                        Thread.Sleep(3000);

                        if (Config.Instance.Install)
                        {
                            Injection.Pulse();
                            trigger.Value = Injection.IsInjected;

                            Console.WriteLine(Injection.SharedMemory.Data.IsLoaded);
                        }
                    }
                    catch
                    {
                        // ignored - A task was canceled.
                    }
                }
            });

            this.InjectThread.SetApartmentState(ApartmentState.STA);
            this.InjectThread.Start();
        }
        private void OnLogin(string username)
        {
            Utility.Log(LogStatus.Ok, "Login", string.Format("Succesfully signed in as {0}", username), Logs.MainLog);
            this.Browser.Visibility    = Visibility.Visible;
            this.TosBrowser.Visibility = Visibility.Visible;

            try
            {
                Utility.MapClassToXmlFile(typeof(Config), Config.Instance, Directories.ConfigFilePath);
            }
            catch
            {
                MessageBox.Show(Utility.GetMultiLanguageText("ConfigWriteError"));
            }

            if (!PathRandomizer.CopyFiles())
            {
            }

            Remoting.Init();

            this.InjectThread = new Thread(
                () =>
            {
                while (true)
                {
                    if (Config.Instance.Install)
                    {
                        Injection.Pulse();
                    }

                    Application.Current.Dispatcher.Invoke(
                        () =>
                    {
                        if (Injection.IsInjected)
                        {
                            this.icon_connected.Visibility    = Visibility.Visible;
                            this.icon_disconnected.Visibility = Visibility.Collapsed;
                        }
                        else
                        {
                            this.icon_connected.Visibility    = Visibility.Collapsed;
                            this.icon_disconnected.Visibility = Visibility.Visible;
                        }
                    });

                    Thread.Sleep(3000);
                }
            });

            this.InjectThread.SetApartmentState(ApartmentState.STA);
            this.InjectThread.Start();
        }
Exemplo n.º 4
0
        internal static void InstallFilesRoutine(UpdateWindow ui, Dictionary <string, object> args)
        {
            ui.CurrentProgress       = ui.MaxProgress;
            ui.OveralCurrentProgress = ui.OveralMaxProgress;
            ui.Status  = MultiLanguage.Text.UpdateStatusInstallingFiles;
            ui.Details = MultiLanguage.Text.UpdateDetailsInstallingFiles;

            foreach (
                var file in
                Directory.GetFiles(Settings.Instance.Directories.SystemDirectory, "*.dll",
                                   SearchOption.AllDirectories)
                .Where(
                    file =>
                    !Md5Hash.Compare(Md5Hash.ComputeFromFile(file),
                                     Md5Hash.ComputeFromFile(
                                         Path.Combine(Settings.Instance.Directories.LibrariesDirectory,
                                                      Path.GetFileName(file))))))
            {
                try
                {
                    FileHelper.CopyFile(file, Settings.Instance.Directories.LibrariesDirectory);
                }
                catch (Exception)
                {
                    MessageBox.Show(
                        string.Format(MultiLanguage.Text.ErrorUpdateFailedToCopyFile, Path.GetFileName(file)),
                        MultiLanguage.Text.UpdateStatusInstallingFiles, MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }

            foreach (var file in Directory.GetFiles(Environment.CurrentDirectory, "*.old", SearchOption.AllDirectories))
            {
                try
                {
                    File.Delete(file);
                }
                catch (Exception)
                {
                    // ignored
                }
            }

            if (args.ContainsKey("restartRequired") && (bool)args["restartRequired"])
            {
                EnvironmentHelper.Restart(true);
            }

            PathRandomizer.Randomize();
        }
Exemplo n.º 5
0
        private async Task <bool> UpdateCore()
        {
            this.UpdateMessage = "Core " + this.FindResource("Updating");

            using (var client = new WebClient())
            {
                client.DownloadProgressChanged += this.WebClientOnDownloadProgressChanged;

                try
                {
                    if (File.Exists(Updater.UpdateZip))
                    {
                        File.Delete(Updater.UpdateZip);
                        Thread.Sleep(500);
                    }

                    await client.DownloadFileTaskAsync(this.UpdateUrl, Updater.UpdateZip);

                    using (var archive = ZipFile.OpenRead(Updater.UpdateZip))
                    {
                        foreach (var entry in archive.Entries)
                        {
                            try
                            {
                                File.Delete(Path.Combine(Directories.CoreDirectory, entry.FullName));
                                entry.ExtractToFile(Path.Combine(Directories.CoreDirectory, entry.FullName), true);
                            }
                            catch
                            {
                                File.WriteAllText(Directories.CoreFilePath, "-"); // force an update
                                return(false);
                            }
                        }
                    }

                    PathRandomizer.CopyFiles();
                    Config.Instance.TosAccepted = false;

                    return(true);
                }
                catch (Exception e)
                {
                    MessageBox.Show(Utility.GetMultiLanguageText("FailedToDownload") + e);
                }
            }

            return(false);
        }
Exemplo n.º 6
0
        private void OnLogin(string username)
        {
            Utility.Log(LogStatus.Ok, "Login", string.Format("Succesfully signed in as {0}", username), Logs.MainLog);
            Browser.Visibility    = Visibility.Visible;
            TosBrowser.Visibility = Visibility.Visible;
            try
            {
                Utility.MapClassToXmlFile(typeof(Config), Config.Instance, Directories.ConfigFilePath);
            }
            catch
            {
                MessageBox.Show(Utility.GetMultiLanguageText("ConfigWriteError"));
            }

            if (!PathRandomizer.CopyFiles())
            {
                MessageBox.Show(Utility.GetMultiLanguageText("RandomizationFailed"));
                Environment.Exit(0);
            }

            Injection.OnInject += hwnd => Task.Factory.StartNew(
                () =>
            {
                Injection.SendLoginCredentials(hwnd, Config.Instance.Username, Config.Instance.Password);
                Injection.SendConfig(hwnd);
            });

            InjectThread = new Thread(
                () =>
            {
                while (true)
                {
                    if (Config.Instance.Install)
                    {
                        Injection.Pulse();
                    }
                    Thread.Sleep(3000);
                }
            });

            InjectThread.Start();
        }
Exemplo n.º 7
0
        private void InitSystem()
        {
            PathRandomizer.CopyFiles();
            Remoting.Init();

            this.InjectThread = new Thread(
                () =>
            {
                while (true)
                {
                    if (Config.Instance.Install)
                    {
                        Injection.Pulse();
                    }

                    Application.Current.Dispatcher.Invoke(
                        () =>
                    {
                        if (Injection.IsInjected)
                        {
                            this.icon_connected.Visibility    = Visibility.Visible;
                            this.icon_disconnected.Visibility = Visibility.Collapsed;
                        }
                        else
                        {
                            this.icon_connected.Visibility    = Visibility.Collapsed;
                            this.icon_disconnected.Visibility = Visibility.Visible;
                        }
                    });

                    Thread.Sleep(3000);
                }
            });

            this.InjectThread.SetApartmentState(ApartmentState.STA);
            this.InjectThread.Start();
        }
Exemplo n.º 8
0
        private async Task <bool> UpdateCore()
        {
            this.UpdateMessage = "Core " + this.FindResource("Updating");

            try
            {
                if (File.Exists(Updater.UpdateZip))
                {
                    File.Delete(Updater.UpdateZip);
                    Thread.Sleep(500);
                }

                var downloadResult = await Policy
                                     .Handle <Exception>()
                                     .WaitAndRetryAsync(
                    3,
                    retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)),
                    (exception, timeSpan, context) => { Utility.Log(LogStatus.Error, $"ReTry {exception.Message}"); })
                                     .ExecuteAndCaptureAsync(
                    () =>
                {
                    using (var client = new WebClient())
                    {
                        client.DownloadProgressChanged += this.WebClientOnDownloadProgressChanged;
                        return(client.DownloadFileTaskAsync(this.UpdateUrl, Updater.UpdateZip));
                    }
                },
                    true);

                if (downloadResult.Outcome == OutcomeType.Failure)
                {
                    return(false);
                }

                using (var archive = ZipFile.OpenRead(Updater.UpdateZip))
                {
                    foreach (var entry in archive.Entries)
                    {
                        try
                        {
                            File.Delete(Path.Combine(Directories.CoreDirectory, entry.FullName));
                            entry.ExtractToFile(Path.Combine(Directories.CoreDirectory, entry.FullName), true);
                        }
                        catch
                        {
                            File.WriteAllText(Directories.CoreFilePath, "-"); // force an update
                            return(false);
                        }
                    }
                }

                PathRandomizer.CopyFiles();
                Config.Instance.TosAccepted = false;

                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(Utility.GetMultiLanguageText("FailedToDownload") + e);
            }

            return(false);
        }