Exemple #1
0
        public static async Task <(CompareResult compareResult, string report, IntegrityCheckResult remoteIntegrity)> CompareIntegrityAsync(IProgress <IntegrityCheckProgress> progress)
        {
            IntegrityCheckResult remoteIntegrity;

            try
            {
                remoteIntegrity = DownloadIntegrityCheckForVersion(XIVGame.GetLocalGameVer());
            }
            catch (WebException)
            {
                return(CompareResult.NoServer, null, null);
            }

            var localIntegrity = await RunIntegrityCheckAsync(new DirectoryInfo(Settings.GetGamePath()), progress);

            var report = "";

            foreach (var hashEntry in remoteIntegrity.Hashes)
            {
                if (localIntegrity.Hashes.Any(h => h.Key == hashEntry.Key))
                {
                    if (localIntegrity.Hashes.First(h => h.Key == hashEntry.Key).Value != hashEntry.Value)
                    {
                        report += $"Mismatch: {hashEntry.Key}\n";
                    }
                }
                else
                {
                    Debug.WriteLine("File not found in local integrity: " + hashEntry.Key);
                }
            }

            return(string.IsNullOrEmpty(report) ? CompareResult.Valid : CompareResult.Invalid, report, remoteIntegrity);
        }
Exemple #2
0
        private void LaunchUpdater()
        {
            var ticks = (uint)Environment.TickCount;
            var key   = ticks & 0xFFFF_0000;

            var argumentBuilder = new ArgumentBuilder()
                                  .Append("T", ticks.ToString())
                                  .Append("BootVersion", XIVGame.GetLocalBootVer())
                                  .Append("CallerWindow", _windowHwnd.ToString())
                                  .Append("GameVersion", XIVGame.GetLocalGameVer())
                                  .Append("IsSteam", "0")
                                  .Append("NextExe", Path.Combine(Settings.GetGamePath(), "game", "ffxiv.exe"))
                                  .Append("ShowMode", "2")
                                  .Append("UserPath", _userPath);

            Debug.WriteLine($"Launching ffxivupdater with key {key}: {argumentBuilder.Build()}");

            var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName  = Path.Combine(_userPath, "downloads", "ffxivupdater.exe"),
                    Arguments = argumentBuilder.BuildEncrypted(key)
                }
            };

            process.Start();
        }
        private void Login(object sender, EventArgs e)
        {
            if (!XIVGame.GetGateStatus())
            {
                MessageBox.Show(
                    "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.");

                return;
            }

            if (saveCheckBox.Checked)
            {
                Properties.Settings.Default["savedid"] = IDTextBox.Text;
                Properties.Settings.Default["savedpw"] = PWTextBox.Text;
                if (autoLoginCheckBox.Checked)
                {
                    DialogResult result = MessageBox.Show("This option will log you in automatically with the credentials you entered.\nTo reset it again, launch this application as administrator once.\n\nDo you really want to enable it?", "Enabling Autologin", MessageBoxButtons.YesNo);

                    if (result == System.Windows.Forms.DialogResult.No)
                    {
                        autoLoginCheckBox.Checked = false;
                    }
                    else
                    {
                        Properties.Settings.Default["autologin"] = true;
                    }
                }
                else
                {
                    Properties.Settings.Default["autologin"] = false;
                }
                Properties.Settings.Default.Save();
            }
            else
            {
                Properties.Settings.Default["savedid"] = "";
                Properties.Settings.Default["savedpw"] = "";
                Properties.Settings.Default.Save();
            }

            StatusLabel.Text = "Logging in...";
            try
            {
                XIVGame.LaunchGame(XIVGame.GetRealSid(IDTextBox.Text, PWTextBox.Text, OTPTextBox.Text), Settings.GetLanguage(), Settings.IsDX11(), Settings.GetExpansionLevel());
                Environment.Exit(0);
            }
            catch (Exception exc)
            {
                MessageBox.Show("Logging in failed, check your login information or try again.\n\n" + exc, "Login failed", MessageBoxButtons.OK);
                StatusLabel.Text = "";
                return;
            }
        }
        public MainForm()
        {
            InitializeComponent();

            if (Properties.Settings.Default.savedid != "")
            {
                IDTextBox.Text       = Properties.Settings.Default.savedid;
                PWTextBox.Text       = Properties.Settings.Default.savedpw;
                saveCheckBox.Checked = true;
            }

            if (Properties.Settings.Default.setupcomplete != true)
            {
                InitialSetup();
            }

            if (Properties.Settings.Default.autologin && !Settings.IsAdministrator())
            {
                try
                {
                    this.Enabled = false;

                    if (!XIVGame.GetGateStatus())
                    {
                        this.Enabled = true;
                        MessageBox.Show(
                            "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.");

                        Properties.Settings.Default["autologin"] = false;
                        Properties.Settings.Default.Save();
                    }
                    else
                    {
                        XIVGame.LaunchGame(XIVGame.GetRealSid(IDTextBox.Text, PWTextBox.Text, OTPTextBox.Text), Settings.GetLanguage(), Settings.IsDX11(), Settings.GetExpansionLevel());
                        Environment.Exit(0);
                    }
                }
                catch (Exception e)
                {
                    this.Enabled = true;
                    MessageBox.Show("Logging in failed, check your login information or try again.\n\n" + e, "Login failed", MessageBoxButtons.OK);
                }
            }
            else
            {
                Properties.Settings.Default["autologin"] = false;
                Properties.Settings.Default.Save();
            }
        }
        public MainForm()
        {
            InitializeComponent();

            if (Settings.Instance.SavedID != "")
            {
                IDTextBox.Text       = Settings.Instance.SavedID;
                PWTextBox.Text       = Settings.Instance.SavedPW;
                saveCheckBox.Checked = true;
            }

            if (Settings.Instance.SetupComplete != true)
            {
                InitialSetup();
            }

            if (Settings.Instance.AutoLogin == true && !SettingsHelper.IsAdministrator())
            {
                try
                {
                    this.Enabled = false;

                    if (!XIVGame.GetGateStatus())
                    {
                        this.Enabled = true;
                        MessageBox.Show(
                            "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.");

                        Settings.Instance.AutoLogin = false;
                        Settings.Instance.Save();
                    }
                    else
                    {
                        XIVGame.LaunchGame(XIVGame.GetRealSid(IDTextBox.Text, PWTextBox.Text, OTPTextBox.Text), SettingsHelper.GetLanguage(), SettingsHelper.IsDX11(), SettingsHelper.UseSteam(), SettingsHelper.GetExpansionLevel());
                        Environment.Exit(0);
                    }
                }
                catch (Exception e)
                {
                    this.Enabled = true;
                    MessageBox.Show("Logging in failed, check your login information or try again.\n\n" + e, "Login failed", MessageBoxButtons.OK);
                }
            }
            else
            {
                Settings.Instance.AutoLogin = false;
                Settings.Instance.Save();
            }
        }
Exemple #6
0
        private static async Task <IntegrityCheckResult> RunIntegrityCheckAsync(DirectoryInfo gameDirectory, IProgress <IntegrityCheckProgress> progress)
        {
            var hashes = new Dictionary <string, string>();

            using (var sha1 = new SHA1Managed())
            {
                CheckDirectory(gameDirectory, sha1, gameDirectory.FullName, ref hashes, progress);
            }

            return(new IntegrityCheckResult
            {
                GameVersion = XIVGame.GetLocalGameVer(),
                Hashes = hashes
            });
        }
        private void StartGame()
        {
            if (!XIVGame.GetGateStatus())
            {
                MessageBox.Show(
                    "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.", "Error", MessageBoxButton.OK, MessageBoxImage.Asterisk);

                return;
            }

            try
            {
                XIVGame.Login(LoginUsername.Text, LoginPassword.Password, OtpTextBox.Text);
                Environment.Exit(0);
            }
            catch (Exception exc)
            {
                Util.ShowError("Logging in failed, check your login information or try again.\n\n" + exc, "Login failed");
            }
        }
        private void QueueButton_OnClick(object sender, RoutedEventArgs e)
        {
            _maintenanceQueueTimer = new System.Timers.Timer
            {
                Interval = 5000
            };

            _maintenanceQueueTimer.Elapsed += (o, args) =>
            {
                if (XIVGame.GetGateStatus())
                {
                    Console.Beep(529, 130);
                    System.Threading.Thread.Sleep(200);
                    Console.Beep(529, 100);
                    System.Threading.Thread.Sleep(30);
                    Console.Beep(529, 100);
                    System.Threading.Thread.Sleep(300);
                    Console.Beep(420, 140);
                    System.Threading.Thread.Sleep(300);
                    Console.Beep(466, 100);
                    System.Threading.Thread.Sleep(300);
                    Console.Beep(529, 160);
                    System.Threading.Thread.Sleep(200);
                    Console.Beep(466, 100);
                    System.Threading.Thread.Sleep(30);
                    Console.Beep(529, 900);

                    this.Dispatcher.BeginInvoke(new Action(() => LoginButton_Click(null, null)));
                    return;
                }

                _maintenanceQueueTimer.Start();
            };

            DialogHost.OpenDialogCommand.Execute(null, MaintenanceQueueDialogHost);
            _maintenanceQueueTimer.Start();
        }
        private void QueueButton_Click(object sender, EventArgs e) //TODO: please do this in a thread when you care enough at some point
        {
            DialogResult result = MessageBox.Show("This will be querying the maintenance status server, until the maintenance is over and then launch the game. Make sure the login information you entered is correct." +
                                                  "\n\n!!!The application will be unresponsive!!!\n\nDo you want to continue?", "Maintenance Queue", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                this.BringToFront();

                while (true)
                {
                    if (XIVGame.GetGateStatus())
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(5000);
                }

                Console.Beep(529, 130);
                System.Threading.Thread.Sleep(200);
                Console.Beep(529, 100);
                System.Threading.Thread.Sleep(30);
                Console.Beep(529, 100);
                System.Threading.Thread.Sleep(300);
                Console.Beep(420, 140);
                System.Threading.Thread.Sleep(300);
                Console.Beep(466, 100);
                System.Threading.Thread.Sleep(300);
                Console.Beep(529, 160);
                System.Threading.Thread.Sleep(200);
                Console.Beep(466, 100);
                System.Threading.Thread.Sleep(30);
                Console.Beep(529, 900);

                Login(null, null);
            }
        }
Exemple #10
0
        public MainForm()
        {
            InitializeComponent();

            if (Properties.Settings.Default.savedid != "")
            {
                IDTextBox.Text       = Properties.Settings.Default.savedid;
                PWTextBox.Text       = Properties.Settings.Default.savedpw;
                saveCheckBox.Checked = true;
            }

            if (Properties.Settings.Default.setupcomplete != true)
            {
                initialSetup();
            }

            if (Properties.Settings.Default.autologin == true && !Settings.IsAdministrator())
            {
                try
                {
                    this.Enabled = false;
                    XIVGame.launchGame(XIVGame.getRealSID(IDTextBox.Text, PWTextBox.Text, OTPTextBox.Text), Settings.GetLanguage(), Settings.IsDX11(), Settings.GetExpansionLevel());
                    Environment.Exit(0);
                }
                catch
                {
                    this.Enabled = true;
                    MessageBox.Show("Logging in failed, check your login information or try again.", "Login failed", MessageBoxButtons.OK);
                }
            }
            else
            {
                Properties.Settings.Default["autologin"] = false;
                Properties.Settings.Default.Save();
            }
        }
        private void InitializeWindow()
        {
            var gateStatus = XIVGame.GetGateStatus();

            if (!gateStatus)
            {
                WorldStatusPackIcon.Foreground = new SolidColorBrush(Color.FromRgb(242, 24, 24));
            }

            var savedCredentials = CredentialManager.GetCredentials(AppName);

            if (savedCredentials != null)
            {
                LoginUsername.Text          = savedCredentials.UserName;
                LoginPassword.Password      = savedCredentials.Password;
                OtpCheckBox.IsChecked       = Settings.NeedsOtp();
                AutoLoginCheckBox.IsChecked = Settings.IsAutologin();
                SaveLoginCheckBox.IsChecked = true;
            }

            if (Settings.IsAutologin() && !Settings.IsAdministrator() && savedCredentials != null)
            {
                try
                {
                    if (!gateStatus)
                    {
                        MessageBox.Show(
                            "Square Enix seems to be running maintenance work right now. The game shouldn't be launched.");
                        Settings.SetAutologin(false);
                    }
                    else
                    {
                        HandleLogin(true);
                    }
                }
                catch (Exception exc)
                {
                    Util.ShowError("Logging in failed, check your login information or try again.\n\n" + exc, "Login failed");
                    Settings.SetAutologin(false);
                }

                Settings.Save();
            }

            if (Settings.GetGamePath() == string.Empty)
            {
                var setup = new FirstTimeSetup();
                setup.ShowDialog();
            }

            try
            {
                _headlines = Headlines.Get();

                _bannerBitmaps = new BitmapImage[_headlines.Banner.Length];
                for (int i = 0; i < _headlines.Banner.Length; i++)
                {
                    var bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.UriSource = _headlines.Banner[i].LsbBanner;
                    bitmap.EndInit();

                    _bannerBitmaps[i] = bitmap;
                }

                _bannerChangeTimer = new System.Timers.Timer
                {
                    Interval = 5000
                };

                _bannerChangeTimer.Elapsed += (o, args) =>
                {
                    if (_currentBannerIndex + 1 > _headlines.Banner.Length - 1)
                    {
                        _currentBannerIndex = 0;
                    }
                    else
                    {
                        _currentBannerIndex++;
                    }

                    this.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        BannerImage.Source = _bannerBitmaps[_currentBannerIndex];
                    }));

                    _bannerChangeTimer.Start();
                };

                _bannerChangeTimer.Start();

                NewsListView.ItemsSource = _headlines.News;
            }
            catch (Exception)
            {
                NewsListView.Items.Add(new News()
                {
                    Title = "Could not download news data.",
                    Tag   = "DlError"
                });
            }

            this.Visibility = Visibility.Visible;
        }