Пример #1
0
        private void LauncherForm_Shown(object sender, EventArgs e)
        {
            var settings = Helpers.LoadSettings(this._config.KeyName);

            if (settings == null)
            {
                MessageBox.Show(@"There was an error loading your settings. If this was after an update, it may be intentional, however, " +
                                @"if it happens often please file a bug report.", @"Error Loading Settings", MessageBoxButtons.OK, MessageBoxIcon.Information);
                settings = new Settings();
            }

            if (string.IsNullOrEmpty(settings.ClientBin))
            {
                var settingsDialog = new SettingsForm(this._config, this._isWin8OrHigher);
                var dialogResult   = settingsDialog.ShowDialog();

                if (dialogResult != DialogResult.OK)
                {
                    settings = Helpers.LoadSettings(this._config.KeyName);

                    if (settings == null || string.IsNullOrEmpty(settings.ClientBin))
                    {
                        MessageBox.Show("You must configure your settings before continuing. Closing launcher.");
                        Application.Exit();
                    } //end if
                }     //end if
            }         //end if

            this.updateChecker.RunWorkerAsync();

            this.lblVersion.Text = Version;
            this.cmbServer.Items.AddRange(this._config.Servers.Keys.ToArray());
            this.cmbServer.SelectedIndex = 0;
        }
Пример #2
0
        private void configChecker_DoWork(object sender, DoWorkEventArgs e)
        {
            this._versionInfo = Helpers.GetVersionInfo(this._config.VersionInfoUrl, this._config.PublicKey);

            var force            = e.Argument != null && (bool)e.Argument;
            var launcherKey      = Registry.CurrentUser.OpenSubKey(@"Software\" + this._config.KeyName, true);
            var lastUpdatedCheck = launcherKey.GetValue("LastUpdated");
            var updatesLastRun   = (int?)lastUpdatedCheck ?? 0;

            if (this._versionInfo == null)
            {
                return;
            }

            var settings = Helpers.LoadSettings(this._config.KeyName);

            if (Helpers.UpdateConfig(this._versionInfo, settings.DisableServerUpdate))
            {
                MessageBox.Show("Configuration information was updated from the server.\n\nThe launcher will close. Please re-launch.",
                                @"Configuration Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.Invoke((MethodInvoker) delegate
                {
                    this.Close();
                });
            }

            if (Helpers.StringToNumber(this._versionInfo.Version) > Helpers.StringToNumber(Version))
            {
                var applicationPath = Application.ExecutablePath;
                var appDataPath     = Directory.GetParent(Application.UserAppDataPath).ToString();
                var updaterLocation = Path.Combine(appDataPath, "Updater.exe");
                var updaterChecksum = Helpers.GetChecksum(updaterLocation);

                var result = DialogResult.Cancel;

                // push to the UI thread to actually display the dialog... ugly hack
                var dialog = this.BeginInvoke(new MethodInvoker(delegate
                {
                    result = new UpdateForm(this._versionInfo).ShowDialog();
                }));

                this.EndInvoke(dialog);

                if (result == DialogResult.OK)
                {
                    var info = new ProcessStartInfo(updaterLocation);
                    info.Arguments = "\"" + applicationPath + "\"";

                    if (Environment.OSVersion.Version.Major >= 6)
                    {
                        info.Verb = "runas";
                    }

                    Process.Start(info);
                } //end if
            }     //end if

            Helpers.SetControlPropertyThreadSafe(this.btnPlay, "Enabled", true);
        }
Пример #3
0
 public LineageClient(string settingsKeyName, string processName, string clientDirectory, ProxyServer proxyServer, List <LineageClient> hookedWindows)
 {
     this._processName = processName;
     this.ProxyServer  = proxyServer;
     _hookedWindows    = hookedWindows;
     _appSettings      = Helpers.LoadSettings(settingsKeyName);
 }
Пример #4
0
        private void LauncherForm_Load(object sender, EventArgs e)
        {
            //TODO -- maybe I want to thread this in the future to stop the UI freeze?
            //TODO -- 2 seconds doesn't seem too bad so far
            this._versionInfo = Helpers.GetVersionInfo();

            cmbServer.Items.AddRange(this._servers.Keys.ToArray());
            cmbServer.SelectedIndex = 0;

            var settings     = Helpers.LoadSettings();
            var serverOnline = this.CheckServerStatus(false);

            if (!settings.AutoPlay || ModifierKeys == Keys.Control ||
                (this._versionInfo != null && Version != this._versionInfo.Version))
            {
                return;
            }

            if (!serverOnline)
            {
                MessageBox.Show("Did not auto play because server is offline.");
                return;
            }

            this.WindowState   = FormWindowState.Minimized;
            this.ShowInTaskbar = false;

            this.Launch();
        }
Пример #5
0
        } //end btnCheck_Click

        private void tmrCheckProcess_Tick(object sender, EventArgs e)
        {
            var revertResolution = this._revertResolution;
            var settings         = Helpers.LoadSettings(this._config.KeyName);

            lock (this._lockObject)
            {
                for (var i = Clients.Count - 1; i >= 0; i--)
                {
                    try
                    {
                        var runningProcess = Process.GetProcessById(Clients[i].Process.Id);
                    }
                    catch (Exception)
                    {
                        Clients[i].Stop();
                        Clients.RemoveAt(i);
                    }
                }

                if (Clients.Count == 0)
                {
                    this.tmrCheckProcess.Enabled = false;

                    if (settings.Windowed || settings.Resize)
                    {
                        LineageClient.ChangeDisplaySettings(revertResolution);
                    }

                    tmrCheckProcess.Stop();
                }
            }
        }
Пример #6
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            this.cmbResolution.Items.AddRange(WindowStyling.GetResolutions().ToArray());

            var savedSettings = Helpers.LoadSettings();

            this.chkResize.Checked           = savedSettings.Resize;
            this.chkWindowed.Checked         = savedSettings.Windowed;
            this.chkCentre.Checked           = savedSettings.Centred;
            this.chkAutoPlay.Checked         = savedSettings.AutoPlay;
            this.chkDisableDark.Checked      = savedSettings.DisableDark;
            this.cmbResolution.SelectedIndex = this.cmbResolution.FindString(savedSettings.Resolution.ToString());

            this.txtDirectory.Text = savedSettings.ClientDirectory ?? "";

            if (this.txtDirectory.Text != string.Empty)
            {
                FindBins();

                this.cmbBin.Text = savedSettings.ClientBin;
            }
            else
            {
                this.cmbBin.SelectedIndex = 0;
            }

            if (string.IsNullOrEmpty(savedSettings.MusicType))
            {
                this.cmbMusic.SelectedIndex = 0;
            }
            else
            {
                this.cmbMusic.SelectedIndex = this.cmbMusic.FindString(savedSettings.MusicType);
            }
        }
Пример #7
0
 public LineageClient(string settingsKeyName, string processName, string clientDirectory, ProxyServer proxyServer, List <LineageClient> hookedWindows)
 {
     this._processName      = processName;
     this.ProxyServer       = proxyServer;
     this._captureDirectory = Path.Combine(clientDirectory, @"Capture\Launcher\");
     _hookedWindows         = hookedWindows;
     _appSettings           = Helpers.LoadSettings(settingsKeyName);
 }
Пример #8
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            var savedSettings = Helpers.LoadSettings(this._config.KeyName) ?? new Settings(this._windowDelay);
            var resolutions   = LineageClient.GetResolutions(this._isWin8OrHigher);

            if (resolutions.Count > 0)
            {
                this.cmbResolution.Items.AddRange(resolutions.ToArray());
                this.cmbResolution.SelectedIndex = savedSettings.Resolution == null
                    ? 0
                    : this.cmbResolution.FindString(savedSettings.Resolution.ToString());
            }
            else
            {
                MessageBox.Show("Unable to load screen resolutions. Screen resize is not available.", "No Resolutions Found",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.chkResize.Enabled = false;
            }

            this.chkResize.Checked   = savedSettings.Resize;
            this.chkWindowed.Checked = savedSettings.Windowed;

            this.chkDisableDark.Checked       = savedSettings.DisableDark;
            this.chkMobColours.Checked        = savedSettings.EnableMobColours;
            this.chkDisableUnderwater.Checked = savedSettings.DisableUnderwater;

            this.chkUseProxy.Checked = savedSettings.UseProxy;

            FindBins();
            if (!string.IsNullOrEmpty(savedSettings.ClientBin))
            {
                this.cmbBin.Text = savedSettings.ClientBin;
            }
            else
            {
                if (this._isWin8OrHigher)
                {
                    this.cmbBin.Text = "S3EP1U.bin";
                }
            }

            if (string.IsNullOrEmpty(savedSettings.MusicType))
            {
                this.cmbMusic.SelectedIndex = 0;
            }
            else
            {
                this.cmbMusic.SelectedIndex = this.cmbMusic.FindString(savedSettings.MusicType);
            }

            this.txtLoginInjectionTiming.Text = savedSettings.LoginDelay.ToString();
            this.txtWinInjectionTiming.Text   = savedSettings.WindowedDelay.ToString();
            this.chkSyncServers.Checked       = !savedSettings.DisableServerUpdate;

            this._initialLoad = false;
        }
Пример #9
0
        } //end MoveWindowCallback

        public LineageClient(string settingsKeyName, string processName, string clientDirectory, ProxyServer proxyServer, IPAddress ip,
                             int port, List <LineageClient> hookedWindows)
        {
            this._processName = processName;
            _hookedWindows    = hookedWindows;
            _appSettings      = Helpers.LoadSettings(settingsKeyName);
            this._serverIp    = ip;
            this._serverPort  = port;
            this._proxyServer = proxyServer;
        } //end constructor
Пример #10
0
        private void Launch()
        {
            var settings = Helpers.LoadSettings();

            if (settings.ClientDirectory == string.Empty || settings.ClientBin == string.Empty)
            {
                MessageBox.Show(@"You must select your lineage directory under settings before continuing.",
                                @"Cannot continue!", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            var binFile = Path.GetFileNameWithoutExtension(settings.ClientBin);

            var selectedServer = this._servers[this.cmbServer.SelectedItem.ToString()];
            var ip             = (uint)IPAddress.NetworkToHostOrder(BitConverter.ToInt32(IPAddress.Parse(selectedServer.Ip).GetAddressBytes(), 0));

            var revertResolution = new User32.DevMode();

            if (settings.Resize)
            {
                revertResolution = WindowStyling.ChangeDisplaySettings(settings.Resolution.Width, settings.Resolution.Height, 16);
            }
            else if (settings.Windowed)
            {
                revertResolution = WindowStyling.ChangeDisplayColour(16);
            }

            Lineage.Run(settings, settings.ClientBin, ip, (ushort)selectedServer.Port);

            var hookedProcId = -1;

            if (settings.Windowed)
            {
                lock (this._lockObject)
                    hookedProcId = WindowStyling.SetWindowed(binFile, HookedProcIds);
            }

            if (settings.Centred)
            {
                var windowSize = Screen.PrimaryScreen.WorkingArea;
                hookedProcId = WindowStyling.SetCentred(binFile, windowSize.Width, windowSize.Height, hookedProcId);
            }

            if (hookedProcId != -1)
            {
                lock (this._lockObject)
                    HookedProcIds.Add(hookedProcId);
            }

            if (!this.processChecker.IsBusy)
            {
                this.processChecker.RunWorkerAsync(revertResolution);
            }
        }
Пример #11
0
        private void Launch(ProxyServer proxyServer)
        {
            var settings         = Helpers.LoadSettings(this._config.KeyName);
            var binFile          = Path.GetFileNameWithoutExtension(settings.ClientBin);
            var ip               = (uint)IPAddress.NetworkToHostOrder(BitConverter.ToInt32(IPAddress.Parse("127.0.0.1").GetAddressBytes(), 0));
            var revertResolution = new User32.DevMode();

            if (settings.Resize)
            {
                revertResolution = LineageClient.ChangeDisplaySettings(settings.Resolution.Width, settings.Resolution.Height, settings.Resolution.Colour);
            }
            else if (settings.Windowed)
            {
                revertResolution = LineageClient.ChangeDisplayColour(this._isWin8OrHigher ? 32 : 16);
            }

            Lineage.Run(settings, this._config.InstallDir, settings.ClientBin, ip, (ushort)proxyServer.LocalPort);

            var client = new LineageClient(this._config.KeyName, binFile, this._config.InstallDir, proxyServer, Clients);

            client.Initialize();

            if (settings.Centred)
            {
                var windowSize = Screen.PrimaryScreen.WorkingArea;
                client.SetCentred(windowSize.Width, windowSize.Height);
            }

            if (settings.CaptureMouse)
            {
                client.SetAllowCapture();
            }

            lock (this._lockObject)
                Clients.Add(client);

            if (!tmrCheckProcess.Enabled)
            {
                this._revertResolution       = revertResolution;
                this.tmrCheckProcess.Enabled = true;
            }

            if (!tmrProxyStatus.Enabled)
            {
                tmrProxyStatus.Enabled = true;
            }
        }
Пример #12
0
        }     //end LauncherForm_KeyDown

        private void updateChecker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                var force            = e.Argument != null && (bool)e.Argument;
                var versionInfo      = Helpers.GetVersionInfo(this._config.VersionInfoUrl, this._config.PublicKey);
                var launcherKey      = Registry.CurrentUser.OpenSubKey(@"Software\" + this._config.KeyName, true);
                var lastUpdatedCheck = launcherKey.GetValue("LastUpdated");
                var updatesLastRun   = (int?)lastUpdatedCheck ?? 0;

                if (versionInfo == null)
                {
                    return;
                }

                var settings = Helpers.LoadSettings(this._config.KeyName);

                if (Helpers.UpdateConfig(versionInfo))
                {
                    MessageBox.Show("Configuration information was updated from the server.\n\nThe launcher will close. Please re-launch.",
                                    @"Configuration Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                    return;
                }

                var applicationPath = Application.ExecutablePath;
                var appDataPath     = Directory.GetParent(Application.UserAppDataPath).ToString();
                var updaterLocation = Path.Combine(appDataPath, "Updater.exe");
                var updaterChecksum = Helpers.GetChecksum(updaterLocation);

                if (!File.Exists(updaterLocation) || updaterChecksum != versionInfo.FileChecksums["Updater.exe"])
                {
                    using (var client = new WebClient())
                    {
                        client.DownloadProgressChanged += client_DownloadProgressChanged;
                        client.DownloadFileAsyncSync(new Uri(this._config.UpdaterUrl.ToString()),
                                                     updaterLocation);
                    }

                    this.updateChecker.ReportProgress(1);
                } //end if

                if (versionInfo.Version != Version)
                {
                    var result = DialogResult.Cancel;

                    // push to the UI thread to actually display the dialog... ugly hack
                    var dialog = this.BeginInvoke(new MethodInvoker(delegate
                    {
                        result = new UpdateForm(versionInfo).ShowDialog();
                    }));

                    this.EndInvoke(dialog);

                    if (result == DialogResult.OK)
                    {
                        var info = new ProcessStartInfo(updaterLocation);
                        info.Arguments = "\"" + applicationPath + "\"";

                        if (Environment.OSVersion.Version.Major >= 6)
                        {
                            info.Verb = "runas";
                        }

                        Process.Start(info);
                    } //end if
                }     //end if

                if (versionInfo.LastUpdated < updatesLastRun && !force)
                {
                    return;
                }

                // checks for > 1 because the Updater.exe is always present.
                if (versionInfo.FileChecksums != null && versionInfo.FileChecksums.Count > 1)
                {
                    Helpers.SetControlPropertyThreadSafe(this.prgUpdates, "Maximum", versionInfo.FileChecksums.Count);

                    for (var i = 1; i < versionInfo.FileChecksums.Count; i++)
                    {
                        var file     = versionInfo.FileChecksums.ElementAt(i).Key;
                        var checksum = versionInfo.FileChecksums.ElementAt(i).Value;
                        var filePath = Path.Combine(this._config.InstallDir, file);

                        if (!File.Exists(filePath) || Helpers.GetChecksum(filePath) != checksum)
                        {
                            var extension = Path.GetExtension(file);
                            using (var client = new WebClient())
                            {
                                client.DownloadProgressChanged += client_DownloadProgressChanged;

                                if (File.Exists(filePath) && extension != null &&
                                    extension.Equals(".pak", StringComparison.CurrentCultureIgnoreCase) &&
                                    !file.Contains("zelgo"))
                                {
                                    var idxFile  = filePath.Replace(".pak", ".idx");
                                    var pakIndex = PakTools.RebuildPak(filePath, versionInfo.PakFiles[file], true);

                                    PakTools.RebuildIndex(idxFile, pakIndex, true);
                                }
                                else
                                {
                                    client.DownloadFileAsyncSync(
                                        new Uri(this._config.UpdaterFilesRoot + file.Replace("\\", "/")),
                                        filePath);
                                }
                            }
                        }

                        this.updateChecker.ReportProgress(i);
                    } //end for

                    var currentTime = DateTime.UtcNow - new DateTime(1970, 1, 1);
                    launcherKey.SetValue("LastUpdated", (int)currentTime.TotalSeconds, RegistryValueKind.DWord);

                    string versionName;
                    var    isWin8OrHigher = Helpers.IsWin8OrHigher(out versionName);

                    if (isWin8OrHigher && versionName == "Windows 10" && settings.ClientBin.ToLower() != "s3ep1u.bin")
                    {
                        settings.ClientBin = "S3EP1U.bin";
                        Helpers.SaveSettings(this._config.KeyName, settings, this._config.InstallDir, true);

                        MessageBox.Show(
                            "You're running Windows 10, but aren't using the S3EP1U.bin file. It has now been automatically set.\n\n" +
                            @"If you want to use the normal S3EP1.bin file, you can update it under Settings -> Client Settings.",
                            @"Windows 10 Detected",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
                    } //end if
                }     //end if
            }
            finally
            {
                this.updateChecker.ReportProgress(this.prgUpdates.Maximum);
            } //end try/finally
        }     //end updateChecker
Пример #13
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            var savedSettings = Helpers.LoadSettings(this._config.KeyName) ?? new Settings();

            this.chkBlurAc.Checked      = savedSettings.BlurAc;
            this.chkBlurChat.Checked    = savedSettings.BlurChat;
            this.chkBlurHotKeys.Checked = savedSettings.BlurHotKeys;
            this.chkBlurHpMp.Checked    = savedSettings.BlurHpMp;
            this.chkBlurLevel.Checked   = savedSettings.BlurLevel;

            this.cmbBlurOptions.SelectedIndex = savedSettings.BlurSaveSetting == null ? 0 : this.cmbBlurOptions.FindString(savedSettings.BlurSaveSetting);

            this.chkCaptureMouse.Checked = savedSettings.CaptureMouse;

            var resolutions = LineageClient.GetResolutions(this._isWin8OrHigher);

            if (resolutions.Count > 0)
            {
                this.cmbResolution.Items.AddRange(resolutions.ToArray());
                this.cmbResolution.SelectedIndex = savedSettings.Resolution == null
                    ? 0
                    : this.cmbResolution.FindString(savedSettings.Resolution.ToString());
            }
            else
            {
                MessageBox.Show("Unable to load screen resolutions. Screen resize is not available.", "No Resolutions Found",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.chkResize.Enabled = false;
            }

            this.chkResize.Checked   = savedSettings.Resize;
            this.chkWindowed.Checked = savedSettings.Windowed;
            this.chkCentre.Checked   = savedSettings.Centred;

            this.chkDisableDark.Checked = savedSettings.DisableDark;
            this.chkMobColours.Checked  = savedSettings.EnableMobColours;

            if (!string.IsNullOrEmpty(savedSettings.ClientBin))
            {
                FindBins();

                this.cmbBin.Text = savedSettings.ClientBin;
            }
            else
            {
                FindBins();
            }


            if (string.IsNullOrEmpty(savedSettings.MusicType))
            {
                this.cmbMusic.SelectedIndex = 0;
            }
            else
            {
                this.cmbMusic.SelectedIndex = this.cmbMusic.FindString(savedSettings.MusicType);
            }

            this._initialLoad = false;
        }
Пример #14
0
        private void Launch(Server server)
        {
            var settings = Helpers.LoadSettings(this._config.KeyName);
            var binFile  = Path.GetFileNameWithoutExtension(settings.ClientBin);
            var binpath  = Path.Combine(this._config.InstallDir, binFile);

            IPAddress[] ipOrDns;

            try
            {
                ipOrDns = Dns.GetHostAddresses(server.IpOrDns);
            }
            catch (SocketException)
            {
                MessageBox.Show(@"There was an error connecting to the server. Check the forums for any issues.",
                                @"Error Connecting!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.CheckServerStatus(false);
                return;
            }

            var revertResolution = new Win32Api.DevMode();

            if (settings.Resize)
            {
                revertResolution = LineageClient.ChangeDisplaySettings(settings.Resolution.Width, settings.Resolution.Height, settings.Resolution.Colour);
            }
            else if (settings.Windowed)
            {
                revertResolution = LineageClient.ChangeDisplayColour(this._isWin8OrHigher ? 32 : 16);
            }

            try
            {
                ProxyServer proxyServer = null;
                if (settings.UseProxy)
                {
                    proxyServer = new ProxyServer();
                    proxyServer.LocalAddress = "127.0.0.1";
                    proxyServer.LocalPort    = new Random().Next(1025, 50000);

                    proxyServer.RemoteAddress = server.IpOrDns;
                    proxyServer.RemotePort    = server.Port;
                    proxyServer.Start();
                }

                if (Lineage.Run(settings, this._config.InstallDir, settings.ClientBin,
                                (ushort)(settings.UseProxy ? proxyServer.LocalPort : server.Port), settings.UseProxy ? null : ipOrDns[0]))
                {
                    var client = new LineageClient(this._config.KeyName, binFile, this._config.InstallDir,
                                                   proxyServer, ipOrDns[0], server.Port, Clients);
                    client.Initialize();

                    lock (this._lockObject)
                        Clients.Add(client);

                    if (!tmrCheckProcess.Enabled)
                    {
                        this._revertResolution       = revertResolution;
                        this.tmrCheckProcess.Enabled = true;
                    }

                    if (!settings.Windowed && this._isWin8OrHigher)
                    {
                        this.Win10SetClientFocus();
                    }
                }
                else
                {
                    MessageBox.Show("There was an error injecting into the Lineage client. Try running it again!", "Error Launching!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("An unknown error occurred launching the Lineage client. Try running it again!", "Error Launching!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }