diff --git a/App.config b/App.config index 4e52de0..b17bfae 100644 --- a/App.config +++ b/App.config @@ -11,7 +11,23 @@ - + + + + + + + + + + + + + + + + + diff --git a/App.xaml.cs b/App.xaml.cs index 522df15..c6caa3d 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -1,750 +1,776 @@ -using System; +using ISBoxerEVELauncher.Enums; +using ISBoxerEVELauncher.Extensions; +using ISBoxerEVELauncher.Games.EVE; +using ISBoxerEVELauncher.InnerSpace; +using ISBoxerEVELauncher.Interface; +using ISBoxerEVELauncher.Windows; +using Microsoft.Win32; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Configuration; -using System.Data; using System.Diagnostics; using System.Linq; +using System.Net; using System.Reflection; using System.Runtime.InteropServices; using System.Text; -using System.Threading.Tasks; using System.Windows; -using Microsoft.Win32; -using ISBoxerEVELauncher.Extensions; -using ISBoxerEVELauncher.InnerSpace; -using ISBoxerEVELauncher.Enums; -using ISBoxerEVELauncher.Games.EVE; -using ISBoxerEVELauncher.Interface; -using System.Net; + namespace ISBoxerEVELauncher { - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - public static bool HasInnerSpace { get; set; } - - public static string AppVersion - { - get - { - return Assembly.GetExecutingAssembly().GetName().Version.ToString(); - } - } - - - public static void ReloadGameConfiguration() - { - try - { - GameConfiguration = InnerSpaceSettings.Load(ISPath + @"\GameConfiguration.XML"); - } - catch - { - GameConfiguration = null; - } - } - - public static string DetectedEVESharedCachePath - { - get - { - RegistryKey hkcu = Registry.CurrentUser; - RegistryKey PathKey = hkcu.OpenSubKey(@"SOFTWARE\CCP\EVEONLINE"); - if (PathKey != null) - { - string value = PathKey.GetValue("CACHEFOLDER", Environment.SpecialFolder.CommonApplicationData + @"\CCP\EVE\SharedCache\") as string; - return value; + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + public static bool HasInnerSpace + { + get; set; + } + public static EVELoginBrowser myLB = new EVELoginBrowser(); + public static byte[] requestBody; + public static bool tofCaptcha; + public static string strUserName + { + get; set; + } + public static string strPassword + { + get; set; + } + + + public static string AppVersion + { + get + { + return Assembly.GetExecutingAssembly().GetName().Version.ToString(); } - return null; - } - - } - - public static string[] CommandLine; - public static bool ExitAfterLaunch; - public static bool searchCharactersOnly; - - static Settings _Settings; - public static Settings Settings - { - get - { - if (_Settings == null) - { - try - { - _Settings = Settings.Load(); - if (EVEAccount.ShouldUgradeCookieStorage) - { - _Settings.Store(); - } - } - catch (System.IO.FileNotFoundException) - { - _Settings = new Settings(); - _Settings.Store(); - } - } - return _Settings; - } - } - - public static string ISBoxerEVELauncherPath - { - get - { - return System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - } - } - - public static string ISExecutable - { - get - { - return ISPath + "\\InnerSpace.exe"; - } - } - - public static string BaseDirectory - { - get - { - return System.AppDomain.CurrentDomain.BaseDirectory; - } - } - - static string _ISPath = string.Empty; - /// - /// Path to Inner Space, which should either be in the registry, or the current folder. Otherwise, the user likely doesn't care about Inner Space integration. - /// - public static string ISPath - { - get - { - // already detected? - if (!string.IsNullOrEmpty(_ISPath)) - return _ISPath; - - // nope. - - // we're expected to be installed into the IS/ISBoxer folder.... - if (System.IO.File.Exists(BaseDirectory + @"\InnerSpace.exe")) - { - _ISPath = BaseDirectory; - return _ISPath; - } - - // oh well... the path SHOULD be in the registry... - { - RegistryKey hklm = Registry.LocalMachine; - RegistryKey ISPathKey = hklm.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\InnerSpace.exe"); - if (ISPathKey != null) - { - string reg_path = ISPathKey.GetValue("Path", Environment.SpecialFolder.ProgramFiles + @"\InnerSpace") as string; - if (System.IO.File.Exists(reg_path + "\\InnerSpace.exe")) - { - _ISPath = reg_path; - return _ISPath; - } - } - } - - // didn't find it. maybe not even installed. - return BaseDirectory; - } - set - { - _ISPath = value; - } - } - - static void ReloadGameProfiles() - { - InnerSpaceGameProfile gpSingularity = Settings.SingularityGameProfile; - InnerSpaceGameProfile gpTranquility = Settings.TranquilityGameProfile; - - if (_GameProfiles == null) - { - _GameProfiles = new ObservableCollection(); - } - else - _GameProfiles.Clear(); - - if (GameConfiguration != null) - { - if (GameConfiguration.Sets != null) - { - foreach (Set gameSet in GameConfiguration.Sets) - { - Set profilesSet = gameSet.FindSet("Profiles"); - if (profilesSet == null || profilesSet.Sets == null) - continue; - - foreach (Set gameProfileSet in profilesSet.Sets) - { - InnerSpaceGameProfile gp = new InnerSpaceGameProfile() { Game = gameSet.Name, GameProfile = gameProfileSet.Name }; - _GameProfiles.Add(gp); - } - } - } - } - - Settings.SingularityGameProfile = App.FindGlobalGameProfile(gpSingularity); - Settings.TranquilityGameProfile = App.FindGlobalGameProfile(gpTranquility); - } - - public static Set FindGameProfileSet(string gameName, string gameProfileName) - { - if (string.IsNullOrWhiteSpace(gameName) || string.IsNullOrWhiteSpace(gameProfileName)) - return null; + } - if (GameConfiguration == null || GameConfiguration.Sets == null) - return null; - Set gameSet = GameConfiguration.FindSet(gameName); - if (gameSet == null) - return null; + public static void ReloadGameConfiguration() + { + try + { + GameConfiguration = InnerSpaceSettings.Load(ISPath + @"\GameConfiguration.XML"); + } + catch + { + GameConfiguration = null; + } + } - Set profilesSet = gameSet.FindSet("Profiles"); - if (profilesSet == null || profilesSet.Sets == null) - return null; + public static string DetectedEVESharedCachePath + { + get + { + RegistryKey hkcu = Registry.CurrentUser; + RegistryKey PathKey = hkcu.OpenSubKey(@"SOFTWARE\CCP\EVEONLINE"); + if (PathKey != null) + { + string value = PathKey.GetValue("CACHEFOLDER", Environment.SpecialFolder.CommonApplicationData + @"\CCP\EVE\SharedCache\") as string; + return value; + } + return null; + } + + } + + public static string[] CommandLine; + public static bool ExitAfterLaunch; + public static bool searchCharactersOnly; + + static Settings _Settings; + public static Settings Settings + { + get + { + if (_Settings == null) + { + try + { + _Settings = Settings.Load(); + if (EVEAccount.ShouldUgradeCookieStorage) + { + _Settings.Store(); + } + } + catch (System.IO.FileNotFoundException) + { + _Settings = new Settings(); + _Settings.Store(); + } + } + return _Settings; + } + } + + public static string ISBoxerEVELauncherPath + { + get + { + return System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + } + } - return profilesSet.FindSet(gameProfileName); - } + public static string ISExecutable + { + get + { + return ISPath + "\\InnerSpace.exe"; + } + } + + public static string BaseDirectory + { + get + { + return System.AppDomain.CurrentDomain.BaseDirectory; + } + } + + static string _ISPath = string.Empty; + /// + /// Path to Inner Space, which should either be in the registry, or the current folder. Otherwise, the user likely doesn't care about Inner Space integration. + /// + public static string ISPath + { + get + { + // already detected? + if (!string.IsNullOrEmpty(_ISPath)) + return _ISPath; + + // nope. + + // we're expected to be installed into the IS/ISBoxer folder.... + if (System.IO.File.Exists(BaseDirectory + @"\InnerSpace.exe")) + { + _ISPath = BaseDirectory; + return _ISPath; + } + + // oh well... the path SHOULD be in the registry... + { + RegistryKey hklm = Registry.LocalMachine; + RegistryKey ISPathKey = hklm.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\App Paths\InnerSpace.exe"); + if (ISPathKey != null) + { + string reg_path = ISPathKey.GetValue("Path", Environment.SpecialFolder.ProgramFiles + @"\InnerSpace") as string; + if (System.IO.File.Exists(reg_path + "\\InnerSpace.exe")) + { + _ISPath = reg_path; + return _ISPath; + } + } + } + + // didn't find it. maybe not even installed. + return BaseDirectory; + } + set + { + _ISPath = value; + } + } + + static void ReloadGameProfiles() + { + InnerSpaceGameProfile gpSingularity = Settings.SingularityGameProfile; + InnerSpaceGameProfile gpTranquility = Settings.TranquilityGameProfile; - static Set _GameConfiguration; - public static Set GameConfiguration { get { return _GameConfiguration; } private set { _GameConfiguration = value; ReloadGameProfiles(); } } - static ObservableCollection _GameProfiles; - public static ObservableCollection GameProfiles - { - get - { if (_GameProfiles == null) { - _GameProfiles = new ObservableCollection(); - ReloadGameProfiles(); - } - return _GameProfiles; - } - private set - { - _GameProfiles = value; - } - } - - public static InnerSpaceGameProfile FindGlobalGameProfile(InnerSpaceGameProfile likeThis) - { - if (GameProfiles == null || likeThis == null) - return likeThis; - - InnerSpaceGameProfile found = GameProfiles.FirstOrDefault(q => q.Game.Equals(likeThis.Game, StringComparison.InvariantCultureIgnoreCase) && q.GameProfile.Equals(likeThis.GameProfile, StringComparison.InvariantCultureIgnoreCase)); - if (found == null) - return likeThis; - - return found; - } - - static bool AddGameToXML(string gameName, string gameProfileName, string executablePath, string executableName, string parameters) - { - // not running, just edit the XML - if (GameConfiguration == null) - { - // no existing XML. - return false; - } - - Set gameSet = GameConfiguration.FindSet(gameName); - if (gameSet == null) - { - gameSet = new Set(gameName); - GameConfiguration.Add(gameSet); - gameSet.Add(new Setting("OpenGL", "1")); - gameSet.Add(new Setting("Direct3D8", "1")); - gameSet.Add(new Setting("Direct3D9", "1")); - gameSet.Add(new Setting("Win32I Keyboard", "1")); - gameSet.Add(new Setting("Win32I Mouse", "1")); - gameSet.Add(new Setting("DirectInput8 Keyboard", "1")); - gameSet.Add(new Setting("DirectInput8 Mouse", "1")); - gameSet.Add(new Setting("modules", "auto")); - gameSet.Add(new Setting("Background Mouse", "1")); - gameSet.Add(new Setting("Keystroke Delay", "1")); - } - - Set gameProfilesSet = gameSet.FindSet("Profiles"); - if (gameProfilesSet == null) - { - gameProfilesSet = new Set("Profiles"); - gameSet.Add(gameProfilesSet); - } - - Set gameProfileSet = gameSet.FindSet(gameProfileName); - if (gameProfileSet == null) - { - gameProfileSet = new Set(gameProfileName); - gameProfilesSet.Add(gameProfileSet); - } - - Setting setting = gameProfileSet.FindSetting("Executable"); - if (setting == null) - gameProfileSet.Add(new Setting("Executable", executableName)); - else - setting.Value = executableName; - - setting = gameProfileSet.FindSetting("Path"); - if (setting == null) - gameProfileSet.Add(new Setting("Path", executablePath)); - else - setting.Value = executablePath; - - setting = gameProfileSet.FindSetting("Parameters"); - if (setting == null) - { - if (!string.IsNullOrEmpty(parameters)) - gameProfileSet.Add(new Setting("Parameters", parameters)); - } - else - { - if (string.IsNullOrEmpty(parameters)) - gameProfileSet.Settings.Remove(setting); + _GameProfiles = new ObservableCollection(); + } + else + _GameProfiles.Clear(); + + if (GameConfiguration != null) + { + if (GameConfiguration.Sets != null) + { + foreach (Set gameSet in GameConfiguration.Sets) + { + Set profilesSet = gameSet.FindSet("Profiles"); + if (profilesSet == null || profilesSet.Sets == null) + continue; + + foreach (Set gameProfileSet in profilesSet.Sets) + { + InnerSpaceGameProfile gp = new InnerSpaceGameProfile() { Game = gameSet.Name, GameProfile = gameProfileSet.Name }; + _GameProfiles.Add(gp); + } + } + } + } + + Settings.SingularityGameProfile = App.FindGlobalGameProfile(gpSingularity); + Settings.TranquilityGameProfile = App.FindGlobalGameProfile(gpTranquility); + } + + public static Set FindGameProfileSet(string gameName, string gameProfileName) + { + if (string.IsNullOrWhiteSpace(gameName) || string.IsNullOrWhiteSpace(gameProfileName)) + return null; + + if (GameConfiguration == null || GameConfiguration.Sets == null) + return null; + + Set gameSet = GameConfiguration.FindSet(gameName); + if (gameSet == null) + return null; + + Set profilesSet = gameSet.FindSet("Profiles"); + if (profilesSet == null || profilesSet.Sets == null) + return null; + + return profilesSet.FindSet(gameProfileName); + } + + static Set _GameConfiguration; + public static Set GameConfiguration + { + get + { + return _GameConfiguration; + } + private set + { + _GameConfiguration = value; + ReloadGameProfiles(); + } + } + static ObservableCollection _GameProfiles; + public static ObservableCollection GameProfiles + { + get + { + if (_GameProfiles == null) + { + _GameProfiles = new ObservableCollection(); + ReloadGameProfiles(); + } + return _GameProfiles; + } + private set + { + _GameProfiles = value; + } + } + + public static InnerSpaceGameProfile FindGlobalGameProfile(InnerSpaceGameProfile likeThis) + { + if (GameProfiles == null || likeThis == null) + return likeThis; + + InnerSpaceGameProfile found = GameProfiles.FirstOrDefault(q => q.Game.Equals(likeThis.Game, StringComparison.InvariantCultureIgnoreCase) && q.GameProfile.Equals(likeThis.GameProfile, StringComparison.InvariantCultureIgnoreCase)); + if (found == null) + return likeThis; + + return found; + } + + static bool AddGameToXML(string gameName, string gameProfileName, string executablePath, string executableName, string parameters) + { + // not running, just edit the XML + if (GameConfiguration == null) + { + // no existing XML. + return false; + } + + Set gameSet = GameConfiguration.FindSet(gameName); + if (gameSet == null) + { + gameSet = new Set(gameName); + GameConfiguration.Add(gameSet); + gameSet.Add(new Setting("OpenGL", "1")); + gameSet.Add(new Setting("Direct3D8", "1")); + gameSet.Add(new Setting("Direct3D9", "1")); + gameSet.Add(new Setting("Win32I Keyboard", "1")); + gameSet.Add(new Setting("Win32I Mouse", "1")); + gameSet.Add(new Setting("DirectInput8 Keyboard", "1")); + gameSet.Add(new Setting("DirectInput8 Mouse", "1")); + gameSet.Add(new Setting("modules", "auto")); + gameSet.Add(new Setting("Background Mouse", "1")); + gameSet.Add(new Setting("Keystroke Delay", "1")); + } + + Set gameProfilesSet = gameSet.FindSet("Profiles"); + if (gameProfilesSet == null) + { + gameProfilesSet = new Set("Profiles"); + gameSet.Add(gameProfilesSet); + } + + Set gameProfileSet = gameSet.FindSet(gameProfileName); + if (gameProfileSet == null) + { + gameProfileSet = new Set(gameProfileName); + gameProfilesSet.Add(gameProfileSet); + } + + Setting setting = gameProfileSet.FindSetting("Executable"); + if (setting == null) + gameProfileSet.Add(new Setting("Executable", executableName)); + else + setting.Value = executableName; + + setting = gameProfileSet.FindSetting("Path"); + if (setting == null) + gameProfileSet.Add(new Setting("Path", executablePath)); else - setting.Value = parameters; - } - - if (GameProfiles.FirstOrDefault(q => q.GameProfile.Equals(gameProfileName)) == null) - { - GameProfiles.Add(new InnerSpaceGameProfile() { Game = gameName, GameProfile = gameProfileName }); - } - - GameConfiguration.Store(ISPath + @"\GameConfiguration.XML"); - return true; - } - /// - /// Add a Game/Game Profile to Inner Space - /// - /// - /// - /// - /// - /// - /// - public static bool AddGame(string gameName, string gameProfileName, string executablePath, string executableName, string parameters) - { - string isboxerFilename = System.IO.Path.Combine(ISPath, "ISBoxer Toolkit.exe"); - while (true) - { - System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("InnerSpace"); - if (processes.Length == 0) - { - if (!AddGameToXML(gameName, gameProfileName, executablePath, executableName, parameters)) - { - MessageBox.Show("In order to Add Game for you, ISBoxer EVE Launcher requires that GameConfiguration.XML exist in the Inner Space folder -- looking for: " + isboxerFilename); - return false; - } - return true; - } - - if (!System.IO.File.Exists(isboxerFilename)) - { - switch (MessageBox.Show("ISBoxer EVE Launcher has determined that Inner Space is running. Please Exit Inner Space and click OK to try again, otherwise click Cancel.", "Adding a Game this way requires Inner Space to be closed", MessageBoxButton.OKCancel)) - { - case MessageBoxResult.OK: - continue; - case MessageBoxResult.Cancel: - return false; - } + setting.Value = executablePath; + + setting = gameProfileSet.FindSetting("Parameters"); + if (setting == null) + { + if (!string.IsNullOrEmpty(parameters)) + gameProfileSet.Add(new Setting("Parameters", parameters)); } else { - FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(isboxerFilename); - if (fvi.ProductMajorPart < 42) - { - switch (MessageBox.Show("ISBoxer EVE Launcher has determined that Inner Space is running. Please Exit Inner Space and click OK to try again, otherwise click Cancel.", "Adding a Game this way requires Inner Space to be closed", MessageBoxButton.OKCancel)) - { - case MessageBoxResult.OK: - continue; - case MessageBoxResult.Cancel: + if (string.IsNullOrEmpty(parameters)) + gameProfileSet.Settings.Remove(setting); + else + setting.Value = parameters; + } + + if (GameProfiles.FirstOrDefault(q => q.GameProfile.Equals(gameProfileName)) == null) + { + GameProfiles.Add(new InnerSpaceGameProfile() { Game = gameName, GameProfile = gameProfileName }); + } + + GameConfiguration.Store(ISPath + @"\GameConfiguration.XML"); + return true; + } + /// + /// Add a Game/Game Profile to Inner Space + /// + /// + /// + /// + /// + /// + /// + public static bool AddGame(string gameName, string gameProfileName, string executablePath, string executableName, string parameters) + { + string isboxerFilename = System.IO.Path.Combine(ISPath, "ISBoxer Toolkit.exe"); + while (true) + { + System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("InnerSpace"); + if (processes.Length == 0) + { + if (!AddGameToXML(gameName, gameProfileName, executablePath, executableName, parameters)) + { + MessageBox.Show("In order to Add Game for you, ISBoxer EVE Launcher requires that GameConfiguration.XML exist in the Inner Space folder -- looking for: " + isboxerFilename); return false; - } - } + } + return true; + } + + if (!System.IO.File.Exists(isboxerFilename)) + { + switch (MessageBox.Show("ISBoxer EVE Launcher has determined that Inner Space is running. Please Exit Inner Space and click OK to try again, otherwise click Cancel.", "Adding a Game this way requires Inner Space to be closed", MessageBoxButton.OKCancel)) + { + case MessageBoxResult.OK: + continue; + case MessageBoxResult.Cancel: + return false; + } + } + else + { + FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(isboxerFilename); + if (fvi.ProductMajorPart < 42) + { + switch (MessageBox.Show("ISBoxer EVE Launcher has determined that Inner Space is running. Please Exit Inner Space and click OK to try again, otherwise click Cancel.", "Adding a Game this way requires Inner Space to be closed", MessageBoxButton.OKCancel)) + { + case MessageBoxResult.OK: + continue; + case MessageBoxResult.Cancel: + return false; + } + } + } + + + string cmdLine = "run isboxer -inituplink;isboxeraddgame \"" + gameName.Replace("\"", "\\\"") + "\" \"" + gameProfileName.Replace("\"", "\\\"") + "\" \"" + executablePath.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\" \"" + executableName.Replace("\"", "\\\"") + "\" \"" + parameters.Replace("\"", "\\\"") + "\""; + System.Diagnostics.Process.Start(ISExecutable, cmdLine); + return true; + } + } + + /// + /// Have Inner Space launch EVE via a specified Game and Game Profile + /// + /// + /// + /// + /// + /// + /// + static public bool Launch(string gameName, string gameProfileName, bool sisi, DirectXVersion dxVersion, long characterID, EVEAccount.Token token) + { + //if (ssoToken == null) + // throw new ArgumentNullException("ssoToken"); + if (gameName == null) + throw new ArgumentNullException("gameName"); + if (gameProfileName == null) + throw new ArgumentNullException("gameProfileName"); + + string cmdLine = "open \"" + gameName + "\" \"" + gameProfileName + "\" -addparam \"/noconsole\" -addparam \"/ssoToken=" + token.TokenString + "\""; + if (dxVersion != DirectXVersion.Default) + { + cmdLine += " -addparam \"/triPlatform=" + dxVersion.ToString() + "\""; + } + + if (characterID != 0) + { + cmdLine += " -addparam \"/character=" + characterID + "\""; } + if (sisi) + { + cmdLine += " -addparam \"/server:Singularity\""; + } + else + { + cmdLine += " -addparam \"/server:tranquility\""; + } - string cmdLine = "run isboxer -inituplink;isboxeraddgame \"" + gameName.Replace("\"", "\\\"") + "\" \"" + gameProfileName.Replace("\"", "\\\"") + "\" \"" + executablePath.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\" \"" + executableName.Replace("\"", "\\\"") + "\" \"" + parameters.Replace("\"", "\\\"") + "\""; - System.Diagnostics.Process.Start(ISExecutable, cmdLine); + cmdLine += " -addparam \"settingsprofile=ISBEL\" -addparam \"/machineHash=" + App.Settings.MachineHash + "\" \"\""; + + try + { + System.Diagnostics.Process.Start(App.ISExecutable, cmdLine); + } + catch (Exception e) + { + MessageBox.Show("Launch failed. executable=" + App.ISExecutable + "; args=" + cmdLine + System.Environment.NewLine + e.ToString()); + return false; + } return true; - } - } - - /// - /// Have Inner Space launch EVE via a specified Game and Game Profile - /// - /// - /// - /// - /// - /// - /// - static public bool Launch(string gameName, string gameProfileName, bool sisi, DirectXVersion dxVersion, long characterID, EVEAccount.Token token) - { - //if (ssoToken == null) - // throw new ArgumentNullException("ssoToken"); - if (gameName == null) - throw new ArgumentNullException("gameName"); - if (gameProfileName == null) - throw new ArgumentNullException("gameProfileName"); - - string cmdLine = "open \"" + gameName + "\" \"" + gameProfileName + "\" -addparam \"/noconsole\" -addparam \"/ssoToken=" + token.TokenString + "\""; - if (dxVersion != DirectXVersion.Default) - { - cmdLine += " -addparam \"/triPlatform=" + dxVersion.ToString() + "\""; - } - - if (characterID != 0) - { - cmdLine += " -addparam \"/character=" + characterID + "\""; - } - - if (sisi) - { - cmdLine += " -addparam \"/server:Singularity\""; - } - else - { - cmdLine += " -addparam \"/server:tranquility\""; - } - - cmdLine += " -addparam \"settingsprofile=ISBEL\" -addparam \"/machineHash=" + App.Settings.MachineHash + "\" \"\""; - - try - { - System.Diagnostics.Process.Start(App.ISExecutable, cmdLine); - } - catch (Exception e) - { - MessageBox.Show("Launch failed. executable=" + App.ISExecutable + "; args=" + cmdLine + System.Environment.NewLine + e.ToString()); - return false; - } - return true; - } - - /// - /// Launch EVE directly - /// - /// - /// - /// - /// - /// - static public bool Launch(string sharedCachePath, bool sisi, DirectXVersion dxVersion, long characterID, EVEAccount.Token token) - { - //if (ssoToken == null) - // throw new ArgumentNullException("ssoToken"); - if (sharedCachePath == null) - throw new ArgumentNullException("sharedCachePath"); - - string args = "/noconsole /ssoToken=" + token.TokenString; - if (dxVersion != DirectXVersion.Default) - { - args += " /triPlatform=" + dxVersion.ToString(); - } - - if (sisi) - { - args += " /server:Singularity"; - } - else - { - args += " /server:tranquility"; - } - - if (characterID != 0) - { - args += " /character=" + characterID; - } - - args += " /settingsprofile=ISBEL /machineHash=" + App.Settings.MachineHash + " \"\""; - - string executable; - if (sisi) - executable = App.Settings.GetSingularityEXE(); - else - executable = App.Settings.GetTranquilityEXE(); - - if (!System.IO.File.Exists(executable)) - { - MessageBox.Show("Cannot find exefile.exe for launch -- looking at: " + executable); - return false; - } - - try - { - System.Diagnostics.Process.Start(executable, args); - } - catch (Exception e) - { - MessageBox.Show("Launch failed. executable=" + executable + "; args=" + args + System.Environment.NewLine + e.ToString()); - return false; - } - return true; - } - - public static void ProcessCommandLine(string Args) - { - ProcessCommandLine(Args.SplitCommandLine()); - } - - public static void ProcessCommandLine(IEnumerable Args) - { - - if (Args == null || Args.Count() == 0) - { - ProfileManager.MigrateSettingsToISBEL(); - return; - } - - List LaunchAccountNames = new List(); - - bool useInnerSpace = false; - foreach (string s in Args) - { - switch (s.ToLowerInvariant()) - { - case "-dx9": - Settings.UseDirectXVersion = DirectXVersion.dx9; - break; - case "-dx11": - Settings.UseDirectXVersion = DirectXVersion.dx11; - break; - case "-singularity": - Settings.UseSingularity = true; - break; - case "-tranquility": - Settings.UseSingularity = false; - break; - case "-innerspace": - useInnerSpace = true; - break; - case "-eve": - useInnerSpace = false; - break; - case "-multiinstance": - break; - case "-exit": - ExitAfterLaunch = true; - break; - case "-c": - searchCharactersOnly = true; - break; - case "null": - // ignore - break; - default: - LaunchAccountNames.Add(s); - break; - } - } - - if (LaunchAccountNames.Count == 0) - { - - return; - } - - List LaunchAccounts = new List(); - - foreach (string name in LaunchAccountNames) - { - - if (!searchCharactersOnly) - { - EVEAccount acct = Settings.Accounts.FirstOrDefault(q => q.Username.Equals(name, StringComparison.InvariantCultureIgnoreCase)); - if (acct != null) - { - LaunchAccounts.Add(acct); - continue; - } - } - EVECharacter ec = Settings.Characters.FirstOrDefault(q => q.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); - if (ec != null) - { - LaunchAccounts.Add(ec); - continue; - } - - MessageBox.Show("Unrecognized EVE Account or Character name '" + name + "' -- if this is correct, please use Add Account/Character to enable it before launching."); - return; - } - - ILauncher launcher; - if (useInnerSpace) - { - InnerSpaceGameProfile gp; - if (Settings.UseSingularity) - { - gp = Settings.SingularityGameProfile; + } + + /// + /// Launch EVE directly + /// + /// + /// + /// + /// + /// + static public bool Launch(string sharedCachePath, bool sisi, DirectXVersion dxVersion, long characterID, EVEAccount.Token token) + { + //if (ssoToken == null) + // throw new ArgumentNullException("ssoToken"); + if (sharedCachePath == null) + throw new ArgumentNullException("sharedCachePath"); + + string args = "/noconsole /ssoToken=" + token.TokenString; + if (dxVersion != DirectXVersion.Default) + { + args += " /triPlatform=" + dxVersion.ToString(); + } + + if (sisi) + { + args += " /server:Singularity"; } else { - gp = Settings.TranquilityGameProfile; + args += " /server:tranquility"; } - if (gp == null || string.IsNullOrEmpty(gp.Game) || string.IsNullOrEmpty(gp.GameProfile)) + if (characterID != 0) { - MessageBox.Show("Please select a Game Profile first!"); - return; + args += " /character=" + characterID; } - launcher = new Launchers.InnerSpace(gp, Settings.UseDirectXVersion, Settings.UseSingularity); - } - else - { - launcher = new Launchers.Direct(Settings.EVESharedCachePath, Settings.UseDirectXVersion, Settings.UseSingularity); - } - Windows.LaunchProgressWindow lpw = new Windows.LaunchProgressWindow(LaunchAccounts, launcher); - lpw.ShowDialog(); + args += " /settingsprofile=ISBEL /machineHash=" + App.Settings.MachineHash + " \"\""; - if (ExitAfterLaunch) - { - App.Current.Shutdown(); - } - } + string executable; + if (sisi) + executable = App.Settings.GetSingularityEXE(); + else + executable = App.Settings.GetTranquilityEXE(); - /// - /// Gets what we think is the "master" ISBoxer EVE Launcher instance - /// - /// true if we should be more secure about it (e.g. Master Key transfer), false if we're just passing command-line around - /// - static public Process GetMasterInstance(bool ensureMainModule) - { - Process currentProcess = Process.GetCurrentProcess(); + if (!System.IO.File.Exists(executable)) + { + MessageBox.Show("Cannot find exefile.exe for launch -- looking at: " + executable); + return false; + } - //Note: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.mainwindowhandle?view=netframework-4.7 - //When the Main window is hidden, it will return a MainWindowHandle of 0. This makes the following code fail when trying to find the master window that is minimized to the system tray: - IEnumerable processList = Process.GetProcesses().Where(q => q.NameMatches(currentProcess) && (q.MainWindowHandle != IntPtr.Zero || q.Id == currentProcess.Id)); + try + { + System.Diagnostics.Process.Start(executable, args); + } + catch (Exception e) + { + MessageBox.Show("Launch failed. executable=" + executable + "; args=" + args + System.Environment.NewLine + e.ToString()); + return false; + } + return true; + } - if (processList == null) - return null; + public static void ProcessCommandLine(string Args) + { + ProcessCommandLine(Args.SplitCommandLine()); + } - Process[] processes = processList.ToArray(); - Array.Sort(processes, (a, b) => a.StartTime > b.StartTime ? 1 : -1); - if (processes.Length > 1) - { - for (int i = 0; i < processes.Length; i++) - { - if (processes[i].Id == currentProcess.Id) - continue; - - // ensure that the Master Instance is indeed this app by checking the module list? (note: if the other process is Administrator, this one also needs to be Administrator) - if (!ensureMainModule) - return processes[i]; - - try - { - - if (processes[i].MainModuleNameMatches(currentProcess)) - return processes[i]; - } - catch (System.ComponentModel.Win32Exception we) - { - if (we.NativeErrorCode == 5) - { - // this might be the right instance, but since it's Administrator and we're not, we can't use it. - continue; - } - throw; - } - } - } - return null; - } - - /// - /// Transmit the command-line to an already-running Master instance, if one is available - /// - /// - public bool TransmitCommandLine() - { - // check if it's already running. - - System.Diagnostics.Process masterInstance = GetMasterInstance(false); - - if (masterInstance != null) - { - string joinedCommandLine = string.Empty; - foreach (string s in CommandLine) - { - // if it's another process, don't exit - switch (s.ToLowerInvariant()) - { - case "null": - // ignore... - break; - case "-exit": - // the -exit is intended for THIS process, not the other one. - break; - case "-multiinstance": - return false; - } - - if (!s.Equals("-exit", StringComparison.InvariantCultureIgnoreCase)) - joinedCommandLine += "\"" + s.Replace("\"", "\\\"") + "\" "; - } - joinedCommandLine.TrimEnd(); + public static void ProcessCommandLine(IEnumerable Args) + { - byte[] buff = Encoding.Unicode.GetBytes(joinedCommandLine); + if (Args == null || Args.Count() == 0) + { + ProfileManager.MigrateSettingsToISBEL(); + return; + } - Windows.COPYDATASTRUCT cds = new Windows.COPYDATASTRUCT(); - cds.cbData = buff.Length; - cds.lpData = Marshal.AllocHGlobal(buff.Length); - Marshal.Copy(buff, 0, cds.lpData, buff.Length); - cds.dwData = IntPtr.Zero; - cds.cbData = buff.Length; - var ret = ISBoxerEVELauncher.Windows.MainWindow.SendMessage(masterInstance.MainWindowHandle, ISBoxerEVELauncher.Windows.MainWindow.WM_COPYDATA, IntPtr.Zero, ref cds); - Marshal.FreeHGlobal(cds.lpData); + List LaunchAccountNames = new List(); - Shutdown(); - return true; - } - return false; - } + bool useInnerSpace = false; + foreach (string s in Args) + { + switch (s.ToLowerInvariant()) + { + case "-dx9": + Settings.UseDirectXVersion = DirectXVersion.dx9; + break; + case "-dx11": + Settings.UseDirectXVersion = DirectXVersion.dx11; + break; + case "-singularity": + Settings.UseSingularity = true; + break; + case "-tranquility": + Settings.UseSingularity = false; + break; + case "-innerspace": + useInnerSpace = true; + break; + case "-eve": + useInnerSpace = false; + break; + case "-multiinstance": + break; + case "-exit": + ExitAfterLaunch = true; + break; + case "-c": + searchCharactersOnly = true; + break; + case "null": + // ignore + break; + default: + LaunchAccountNames.Add(s); + break; + } + } + + if (LaunchAccountNames.Count == 0) + { + + return; + } + + List LaunchAccounts = new List(); + + foreach (string name in LaunchAccountNames) + { + + if (!searchCharactersOnly) + { + EVEAccount acct = Settings.Accounts.FirstOrDefault(q => q.Username.Equals(name, StringComparison.InvariantCultureIgnoreCase)); + if (acct != null) + { + LaunchAccounts.Add(acct); + continue; + } + } + EVECharacter ec = Settings.Characters.FirstOrDefault(q => q.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase)); + if (ec != null) + { + LaunchAccounts.Add(ec); + continue; + } + + MessageBox.Show("Unrecognized EVE Account or Character name '" + name + "' -- if this is correct, please use Add Account/Character to enable it before launching."); + return; + } + + ILauncher launcher; + if (useInnerSpace) + { + InnerSpaceGameProfile gp; + if (Settings.UseSingularity) + { + gp = Settings.SingularityGameProfile; + } + else + { + gp = Settings.TranquilityGameProfile; + } + + if (gp == null || string.IsNullOrEmpty(gp.Game) || string.IsNullOrEmpty(gp.GameProfile)) + { + MessageBox.Show("Please select a Game Profile first!"); + return; + } + + launcher = new Launchers.InnerSpace(gp, Settings.UseDirectXVersion, Settings.UseSingularity); + } + else + { + launcher = new Launchers.Direct(Settings.EVESharedCachePath, Settings.UseDirectXVersion, Settings.UseSingularity); + } + Windows.LaunchProgressWindow lpw = new Windows.LaunchProgressWindow(LaunchAccounts, launcher); + lpw.ShowDialog(); + + if (ExitAfterLaunch) + { + App.Current.Shutdown(); + } + } + + /// + /// Gets what we think is the "master" ISBoxer EVE Launcher instance + /// + /// true if we should be more secure about it (e.g. Master Key transfer), false if we're just passing command-line around + /// + static public Process GetMasterInstance(bool ensureMainModule) + { + Process currentProcess = Process.GetCurrentProcess(); + + //Note: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.mainwindowhandle?view=netframework-4.7 + //When the Main window is hidden, it will return a MainWindowHandle of 0. This makes the following code fail when trying to find the master window that is minimized to the system tray: + IEnumerable processList = Process.GetProcesses().Where(q => q.NameMatches(currentProcess) && (q.MainWindowHandle != IntPtr.Zero || q.Id == currentProcess.Id)); + + if (processList == null) + return null; + + Process[] processes = processList.ToArray(); + Array.Sort(processes, (a, b) => a.StartTime > b.StartTime ? 1 : -1); + if (processes.Length > 1) + { + for (int i = 0; i < processes.Length; i++) + { + if (processes[i].Id == currentProcess.Id) + continue; - private void ApplicationStart(object sender, StartupEventArgs e) - { - AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; - // Allows the operating system to choose the best protocol to use, and to block protocols that are not secure. Unless your app has a specific reason not to, you should use this value. - ServicePointManager.SecurityProtocol = SecurityProtocolType.SystemDefault; + // ensure that the Master Instance is indeed this app by checking the module list? (note: if the other process is Administrator, this one also needs to be Administrator) + if (!ensureMainModule) + return processes[i]; + + try + { + + if (processes[i].MainModuleNameMatches(currentProcess)) + return processes[i]; + } + catch (System.ComponentModel.Win32Exception we) + { + if (we.NativeErrorCode == 5) + { + // this might be the right instance, but since it's Administrator and we're not, we can't use it. + continue; + } + throw; + } + } + } + return null; + } - CommandLine = e.Args; + /// + /// Transmit the command-line to an already-running Master instance, if one is available + /// + /// + public bool TransmitCommandLine() + { + // check if it's already running. - if (!TransmitCommandLine()) - { - ReloadGameConfiguration(); + System.Diagnostics.Process masterInstance = GetMasterInstance(false); - if (GameConfiguration != null || System.IO.File.Exists(ISExecutable)) + if (masterInstance != null) { - HasInnerSpace = true; + string joinedCommandLine = string.Empty; + foreach (string s in CommandLine) + { + // if it's another process, don't exit + switch (s.ToLowerInvariant()) + { + case "null": + // ignore... + break; + case "-exit": + // the -exit is intended for THIS process, not the other one. + break; + case "-multiinstance": + return false; + } + + if (!s.Equals("-exit", StringComparison.InvariantCultureIgnoreCase)) + joinedCommandLine += "\"" + s.Replace("\"", "\\\"") + "\" "; + } + joinedCommandLine.TrimEnd(); + + byte[] buff = Encoding.Unicode.GetBytes(joinedCommandLine); + + Windows.COPYDATASTRUCT cds = new Windows.COPYDATASTRUCT(); + cds.cbData = buff.Length; + cds.lpData = Marshal.AllocHGlobal(buff.Length); + Marshal.Copy(buff, 0, cds.lpData, buff.Length); + cds.dwData = IntPtr.Zero; + cds.cbData = buff.Length; + var ret = ISBoxerEVELauncher.Windows.MainWindow.SendMessage(masterInstance.MainWindowHandle, ISBoxerEVELauncher.Windows.MainWindow.WM_COPYDATA, IntPtr.Zero, ref cds); + Marshal.FreeHGlobal(cds.lpData); + + Shutdown(); + return true; } + return false; + } + + private void ApplicationStart(object sender, StartupEventArgs e) + { + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + // Allows the operating system to choose the best protocol to use, and to block protocols that are not secure. Unless your app has a specific reason not to, you should use this value. + ServicePointManager.SecurityProtocol = SecurityProtocolType.SystemDefault; - var mainWindow = new Windows.MainWindow(); - //Re-enable normal shutdown mode. - Current.ShutdownMode = ShutdownMode.OnMainWindowClose; - Current.MainWindow = mainWindow; - mainWindow.Show(); + CommandLine = e.Args; + if (!TransmitCommandLine()) + { + ReloadGameConfiguration(); + + if (GameConfiguration != null || System.IO.File.Exists(ISExecutable)) + { + HasInnerSpace = true; + } + + tofCaptcha = false; - ProcessCommandLine(CommandLine); - } - } + var mainWindow = new Windows.MainWindow(); + //Re-enable normal shutdown mode. + Current.ShutdownMode = ShutdownMode.OnMainWindowClose; + Current.MainWindow = mainWindow; + mainWindow.Show(); + + ProcessCommandLine(CommandLine); + } + } - void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) - { - MessageBox.Show("Exception unhandled by ISBoxer EVE Launcher: " + e.ExceptionObject.ToString()); - } + void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + MessageBox.Show("Exception unhandled by ISBoxer EVE Launcher: " + e.ExceptionObject.ToString()); + } - } + } } diff --git a/Enums/DirectXVersion.cs b/Enums/DirectXVersion.cs index fec9aa3..ed72066 100644 --- a/Enums/DirectXVersion.cs +++ b/Enums/DirectXVersion.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ISBoxerEVELauncher.Enums +namespace ISBoxerEVELauncher.Enums { public enum DirectXVersion { diff --git a/Enums/LoginResult.cs b/Enums/LoginResult.cs index febe3b8..ea1b88b 100644 --- a/Enums/LoginResult.cs +++ b/Enums/LoginResult.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ISBoxerEVELauncher.Enums -{ +namespace ISBoxerEVELauncher.Enums +{ public enum LoginResult { Success, diff --git a/Enums/RelatedExecutable.cs b/Enums/RelatedExecutable.cs index f5da542..8681fa1 100644 --- a/Enums/RelatedExecutable.cs +++ b/Enums/RelatedExecutable.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ISBoxerEVELauncher.Enums +namespace ISBoxerEVELauncher.Enums { public enum RelatedExecutable { diff --git a/Enums/WebRequestType.cs b/Enums/WebRequestType.cs new file mode 100644 index 0000000..16cd174 --- /dev/null +++ b/Enums/WebRequestType.cs @@ -0,0 +1,9 @@ +namespace ISBoxerEVELauncher.Enums +{ + public enum WebRequestType + { + RequestVerificationToken, + VerficationCode, + Result + } +} diff --git a/Extensions/ControlExtensions.cs b/Extensions/ControlExtensions.cs new file mode 100644 index 0000000..80412f3 --- /dev/null +++ b/Extensions/ControlExtensions.cs @@ -0,0 +1,34 @@ +using System; +using System.Windows.Forms; + + +namespace ISBoxerEVELauncher.Extensions +{ + public static class ControlExtensions + { + /// + /// Executes the Action asynchronously on the UI thread, does not block execution on the calling thread. + /// + /// the control for which the update is required + /// action to be performed on the control + public static void InvokeOnUiThreadIfRequired(this Control control, Action action) + { + //If you are planning on using a similar function in your own code then please be sure to + //have a quick read over https://stackoverflow.com/questions/1874728/avoid-calling-invoke-when-the-control-is-disposed + //No action + if (control.Disposing || control.IsDisposed || !control.IsHandleCreated) + { + return; + } + + if (control.InvokeRequired) + { + control.BeginInvoke(action); + } + else + { + action.Invoke(); + } + } + } +} diff --git a/Extensions/HttpWebRequestExtension.cs b/Extensions/HttpWebRequestExtension.cs index 9948f25..2c9a603 100644 --- a/Extensions/HttpWebRequestExtension.cs +++ b/Extensions/HttpWebRequestExtension.cs @@ -1,13 +1,9 @@ -using ISBoxerEVELauncher; +using ISBoxerEVELauncher.Security; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; -using System.Text; -using System.Threading.Tasks; -using ISBoxerEVELauncher.Security; using System.Reflection; +using System.Text; namespace ISBoxerEVELauncher.Extensions { @@ -23,17 +19,20 @@ public static void SetBody(this HttpWebRequest webRequest, byte[] body) { webRequest.ContentLength = body.Length; - + App.requestBody = body; try { - using (Stream reqStream = webRequest.GetRequestStream()) + if (!App.tofCaptcha) { - reqStream.Write(body, 0, body.Length); + using (Stream reqStream = webRequest.GetRequestStream()) + { + reqStream.Write(body, 0, body.Length); + } } - } catch (Exception) - { } + { + } } public static void SetBody(this HttpWebRequest webRequest, SecureBytesWrapper body) @@ -50,7 +49,8 @@ public static void SetBody(this HttpWebRequest webRequest, SecureBytesWrapper bo } catch (Exception) - { } + { + } } public static void SetCustomheaders(this HttpWebRequest webRequest, WebHeaderCollection webHeaderCollection) diff --git a/Extensions/HttpWebResponseExtension.cs b/Extensions/HttpWebResponseExtension.cs index 96fc289..fa6b700 100644 --- a/Extensions/HttpWebResponseExtension.cs +++ b/Extensions/HttpWebResponseExtension.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; +using System.IO; using System.Net; -using System.Text; -using System.Threading.Tasks; namespace ISBoxerEVELauncher.Extensions { diff --git a/Extensions/ProcessExtension.cs b/Extensions/ProcessExtension.cs index 22ea1c5..73caf96 100644 --- a/Extensions/ProcessExtension.cs +++ b/Extensions/ProcessExtension.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ISBoxerEVELauncher.Extensions +namespace ISBoxerEVELauncher.Extensions { public static class ProcessExtension { @@ -36,7 +30,7 @@ public static bool MainModuleNameMatches(this System.Diagnostics.Process process return cleanA == cleanB; } - + } } diff --git a/Extensions/WebResponseExtension.cs b/Extensions/WebResponseExtension.cs index d0a5a78..7b4b148 100644 --- a/Extensions/WebResponseExtension.cs +++ b/Extensions/WebResponseExtension.cs @@ -1,10 +1,5 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; +using System.IO; using System.Net; -using System.Text; -using System.Threading.Tasks; namespace ISBoxerEVELauncher.Extensions { diff --git a/FodyWeavers.xsd b/FodyWeavers.xsd index e82ada3..05e92c1 100644 --- a/FodyWeavers.xsd +++ b/FodyWeavers.xsd @@ -19,12 +19,12 @@ - A list of (.NET Core) runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks - A list of (.NET Core) runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks. @@ -55,7 +55,12 @@ - Controls if (.NET Core) runtime assemblies are also embedded. + Controls if runtime assemblies are also embedded. + + + + + Controls whether the runtime assemblies are embedded with their full path or only with their assembly name. @@ -90,12 +95,12 @@ - A list of (.NET Core) runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with | + A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with | - A list of (.NET Core) runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |. + A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |. diff --git a/Games/EVE/EVEAccount.cs b/Games/EVE/EVEAccount.cs index 0caa114..3be2ff2 100644 --- a/Games/EVE/EVEAccount.cs +++ b/Games/EVE/EVEAccount.cs @@ -1,5 +1,10 @@ //#define REFRESH_TOKENS +using ISBoxerEVELauncher.Enums; +using ISBoxerEVELauncher.Extensions; +using ISBoxerEVELauncher.Interface; +using ISBoxerEVELauncher.Security; +using ISBoxerEVELauncher.Web; using Microsoft.IdentityModel.Tokens; using Newtonsoft.Json; using System; @@ -7,15 +12,10 @@ using System.IO; using System.Net; using System.Runtime.Serialization.Formatters.Binary; +using System.Security.Cryptography; using System.Text; using System.Web; using System.Xml.Serialization; -using ISBoxerEVELauncher.Security; -using ISBoxerEVELauncher.Extensions; -using ISBoxerEVELauncher.Enums; -using ISBoxerEVELauncher.Web; -using System.Security.Cryptography; -using ISBoxerEVELauncher.Interface; namespace ISBoxerEVELauncher.Games.EVE @@ -39,7 +39,10 @@ public class EVEAccount : INotifyPropertyChanged, IDisposable, ILaunchTarget [XmlIgnore] private string code; - public string Profile { get; set; } + public string Profile + { + get; set; + } public EVEAccount() @@ -94,11 +97,17 @@ public bool IsExpired /// /// The actual token data /// - public string TokenString { get; set; } + public string TokenString + { + get; set; + } /// /// When the token is good until... /// - public DateTime Expiration { get; set; } + public DateTime Expiration + { + get; set; + } } CookieContainer _Cookies; @@ -158,7 +167,18 @@ public void UpdateCookieStorage() /// /// EVE Account username /// - public string Username { get { return _Username; } set { _Username = value; OnPropertyChanged("Username"); } } + public string Username + { + get + { + return _Username; + } + set + { + _Username = value; + OnPropertyChanged("Username"); + } + } /// /// Old cookie storage. If found in the XML, it will automatically be split into separate storage @@ -179,7 +199,10 @@ public string CookieStorage } } - public static bool ShouldUgradeCookieStorage { get; private set; } + public static bool ShouldUgradeCookieStorage + { + get; private set; + } /// /// New method of storing cookies /// @@ -203,7 +226,20 @@ public string NewCookieStorage /// A Secure (and non-plaintext) representation of the password. This will NOT be stored in XML. /// [XmlIgnore] - public System.Security.SecureString SecurePassword { get { return _SecurePassword; } set { _SecurePassword = value; OnPropertyChanged("SecurePassword"); EncryptedPassword = null; EncryptedPasswordIV = null; } } + public System.Security.SecureString SecurePassword + { + get + { + return _SecurePassword; + } + set + { + _SecurePassword = value; + OnPropertyChanged("SecurePassword"); + EncryptedPassword = null; + EncryptedPasswordIV = null; + } + } string _EncryptedPassword; /// @@ -215,14 +251,29 @@ public string EncryptedPassword { return _EncryptedPassword; } - set { _EncryptedPassword = value; OnPropertyChanged("EncryptedPassword"); } + set + { + _EncryptedPassword = value; + OnPropertyChanged("EncryptedPassword"); + } } string _EncryptedPasswordIV; /// /// The Initialization Vector used to encrypt the password /// - public string EncryptedPasswordIV { get { return _EncryptedPasswordIV; } set { _EncryptedPasswordIV = value; OnPropertyChanged("EncryptedPasswordIV"); } } + public string EncryptedPasswordIV + { + get + { + return _EncryptedPasswordIV; + } + set + { + _EncryptedPasswordIV = value; + OnPropertyChanged("EncryptedPasswordIV"); + } + } /// /// Sets the encrypted password to the given SecureString, if possible @@ -364,7 +415,20 @@ public void DecryptPassword(bool allowPopup) /// A Secure (and non-plaintext) representation of the CharacterName. This will NOT be stored in XML. /// [XmlIgnore] - public System.Security.SecureString SecureCharacterName { get { return _SecureCharacterName; } set { _SecureCharacterName = value; OnPropertyChanged("SecureCharacterName"); EncryptedCharacterName = null; EncryptedCharacterNameIV = null; } } + public System.Security.SecureString SecureCharacterName + { + get + { + return _SecureCharacterName; + } + set + { + _SecureCharacterName = value; + OnPropertyChanged("SecureCharacterName"); + EncryptedCharacterName = null; + EncryptedCharacterNameIV = null; + } + } string _EncryptedCharacterName; /// @@ -376,14 +440,29 @@ public string EncryptedCharacterName { return _EncryptedCharacterName; } - set { _EncryptedCharacterName = value; OnPropertyChanged("EncryptedCharacterName"); } + set + { + _EncryptedCharacterName = value; + OnPropertyChanged("EncryptedCharacterName"); + } } string _EncryptedCharacterNameIV; /// /// The Initialization Vector used to encrypt the CharacterName /// - public string EncryptedCharacterNameIV { get { return _EncryptedCharacterNameIV; } set { _EncryptedCharacterNameIV = value; OnPropertyChanged("EncryptedCharacterNameIV"); } } + public string EncryptedCharacterNameIV + { + get + { + return _EncryptedCharacterNameIV; + } + set + { + _EncryptedCharacterNameIV = value; + OnPropertyChanged("EncryptedCharacterNameIV"); + } + } /// /// Attempts to prepare the encrypted verison of the currently active SecureCharacterName @@ -509,14 +588,36 @@ public void DecryptCharacterName(bool allowPopup) /// AccessToken for Tranquility. Lasts up to 11 hours? /// [XmlIgnore] - public Token TranquilityToken { get { return _TranquilityToken; } set { _TranquilityToken = value; OnPropertyChanged("TranquilityToken"); } } + public Token TranquilityToken + { + get + { + return _TranquilityToken; + } + set + { + _TranquilityToken = value; + OnPropertyChanged("TranquilityToken"); + } + } Token _SisiToken; /// /// AccessToken for Singularity. Lasts up to 11 hours? /// [XmlIgnore] - public Token SisiToken { get { return _SisiToken; } set { _SisiToken = value; OnPropertyChanged("SisiToken"); } } + public Token SisiToken + { + get + { + return _SisiToken; + } + set + { + _SisiToken = value; + OnPropertyChanged("SisiToken"); + } + } #region Refresh Tokens /* This section is for experimental implemtnation using Refresh Tokens, which are used by the official EVE Launcher and described as insecure. @@ -989,88 +1090,99 @@ public LoginResult GetAccessToken(bool sisi, HttpWebRequest req, out Token acces try { - response = new Response(req); - - string responseBody = response.Body; - UpdateCookieStorage(); + if (App.myLB.strHTML_RequestVerificationToken == "") + { + response = new Response(req); + } + else + { + response = new Response(req, WebRequestType.Result); + } - if (responseBody.Contains("Incorrect character name entered")) - { - accessToken = null; - SecurePassword = null; - SecureCharacterName = null; - return LoginResult.InvalidCharacterChallenge; - } - if (responseBody.Contains("Invalid username / password")) - { - accessToken = null; - SecurePassword = null; - return LoginResult.InvalidUsernameOrPassword; - } + string responseBody = response.Body; + UpdateCookieStorage(); - // I'm just guessing on this one at the moment. - if (responseBody.Contains("Invalid authenticat") - || (responseBody.Contains("Verification code mismatch") && responseBody.Contains("/account/authenticator")) - ) - { - accessToken = null; - SecurePassword = null; - return LoginResult.InvalidAuthenticatorChallenge; - } - //The 2FA page now has "Character challenge" in the text but it is hidden. This should fix it from - //Coming up during 2FA challenge - if (responseBody.Contains("Character challenge") && !responseBody.Contains("visuallyhidden")) - { - return GetCharacterChallenge(sisi, out accessToken); - } + if (responseBody.Contains("Incorrect character name entered")) + { + accessToken = null; + SecurePassword = null; + SecureCharacterName = null; + return LoginResult.InvalidCharacterChallenge; + } - if (responseBody.Contains("Email verification required")) - { - return GetEmailChallenge(sisi, responseBody, out accessToken); - } + if (responseBody.Contains("Invalid username / password")) + { + accessToken = null; + SecurePassword = null; + return LoginResult.InvalidUsernameOrPassword; + } - if (responseBody.Contains("Authenticator is enabled")) - { - return GetAuthenticatorChallenge(sisi, out accessToken); - } + // I'm just guessing on this one at the moment. + if (responseBody.Contains("Invalid authenticat") + || (responseBody.Contains("Verification code mismatch") && responseBody.Contains("/account/authenticator")) + ) + { + accessToken = null; + SecurePassword = null; + return LoginResult.InvalidAuthenticatorChallenge; + } + //The 2FA page now has "Character challenge" in the text but it is hidden. This should fix it from + //Coming up during 2FA challenge + if (responseBody.Contains("Character challenge") && !responseBody.Contains("visuallyhidden")) + { + return GetCharacterChallenge(sisi, out accessToken); + } - if (responseBody.Contains("Please enter the verification code ")) - { - return GetEmailCodeChallenge(sisi, responseBody, out accessToken); - } + if (responseBody.Contains("Email verification required")) + { + return GetEmailChallenge(sisi, responseBody, out accessToken); + } - if (responseBody.Contains("Security Warning")) - { - return GetSecurityWarningChallenge(sisi, responseBody, response.ResponseUri, out accessToken); - } + if (responseBody.Contains("Authenticator is enabled")) + { + return GetAuthenticatorChallenge(sisi, out accessToken); + } - if (responseBody.ToLower().Contains("form action=\"/oauth/eula\"")) - { - return GetEULAChallenge(sisi, responseBody, response.ResponseUri, out accessToken); - } + if (responseBody.Contains("Please enter the verification code ")) + { + return GetEmailCodeChallenge(sisi, responseBody, out accessToken); + } - try - { - code = HttpUtility.ParseQueryString(response.ResponseUri.ToString()).Get("code"); - if (code == null) - { - - return LoginResult.Error; - } - GetAccessToken(sisi, code, out response); - accessToken = new Token(JsonConvert.DeserializeObject(response.Body)); - } - catch (Exception) + if (responseBody.Contains("Security Warning")) + { + return GetSecurityWarningChallenge(sisi, responseBody, response.ResponseUri, out accessToken); + } + + if (responseBody.ToLower().Contains("form action=\"/oauth/eula\"")) + { + return GetEULAChallenge(sisi, responseBody, response.ResponseUri, out accessToken); + } + + try + { + + code = HttpUtility.ParseQueryString(response.ResponseUri.OriginalString).Get("code"); + + + if (code == null) { - Windows.UnhandledResponseWindow urw = new Windows.UnhandledResponseWindow(responseBody); - urw.ShowDialog(); - // can't get the token - accessToken = null; - SecurePassword = null; - return LoginResult.TokenFailure; + return LoginResult.Error; } + GetAccessToken(sisi, code, out response); + accessToken = new Token(JsonConvert.DeserializeObject(response.Body)); + } + catch (Exception) + { + Windows.UnhandledResponseWindow urw = new Windows.UnhandledResponseWindow(responseBody); + urw.ShowDialog(); + + // can't get the token + accessToken = null; + SecurePassword = null; + return LoginResult.TokenFailure; + } if (!sisi) { @@ -1102,7 +1214,10 @@ public LoginResult GetAccessToken(bool sisi, HttpWebRequest req, out Token acces public class authObj { private int _expiresIn; - public string access_token { get; set; } + public string access_token + { + get; set; + } public int expires_in { get @@ -1115,10 +1230,19 @@ public int expires_in Expiration = DateTime.Now.AddMinutes(_expiresIn); } } - public string token_type { get; set; } - public string refresh_token { get; set; } + public string token_type + { + get; set; + } + public string refresh_token + { + get; set; + } - public DateTime Expiration { get; private set; } + public DateTime Expiration + { + get; private set; + } } @@ -1182,12 +1306,20 @@ public LoginResult GetAccessToken(bool sisi, out Token accessToken) } } + App.strUserName = Username; + App.strPassword = new System.Net.NetworkCredential(string.Empty, SecurePassword).Password; var uri = RequestResponse.GetLoginUri(sisi, state.ToString(), challengeHash); string RequestVerificationToken = string.Empty; var result = GetRequestVerificationToken(uri, sisi, out RequestVerificationToken); + if (result == LoginResult.Error) + { + accessToken = null; + return result; + } + var req = RequestResponse.CreatePostRequest(uri, sisi, true, "URL", Cookies); using (SecureBytesWrapper body = new SecureBytesWrapper()) @@ -1214,7 +1346,7 @@ public LoginResult GetAccessToken(bool sisi, out Token accessToken) public LoginResult GetSSOToken(bool sisi, out Token ssoToken) { LoginResult lr = this.GetAccessToken(sisi, out ssoToken); - + return lr; } @@ -1291,12 +1423,18 @@ public override string ToString() EVEAccount ILaunchTarget.EVEAccount { - get { return this; } + get + { + return this; + } } public long CharacterID { - get { return 0; } + get + { + return 0; + } } } } diff --git a/Games/EVE/EVECharacter.cs b/Games/EVE/EVECharacter.cs index a89c77f..fc73b81 100644 --- a/Games/EVE/EVECharacter.cs +++ b/Games/EVE/EVECharacter.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using ISBoxerEVELauncher.Interface; +using System; using System.Net; -using System.Text; -using System.Threading.Tasks; using System.Xml.Serialization; -using ISBoxerEVELauncher.Interface; namespace ISBoxerEVELauncher.Games.EVE { @@ -17,12 +13,18 @@ public class EVECharacter : ILaunchTarget /// /// Name of the Character /// - public string Name { get; set; } + public string Name + { + get; set; + } /// /// Name of the EVE Account this Character is on /// - public string EVEAccountName { get; set; } + public string EVEAccountName + { + get; set; + } /// /// EVE Account this Character is on @@ -30,7 +32,7 @@ public class EVECharacter : ILaunchTarget [XmlIgnore] public EVEAccount EVEAccount { - get + get { return App.Settings.FindEVEAccount(EVEAccountName); } @@ -47,12 +49,18 @@ public EVEAccount EVEAccount /// /// Character ID as reported by ESI ... /// - public long CharacterID { get; set; } + public long CharacterID + { + get; set; + } /// /// Use Singularity for this Character /// - public bool UseSingularity { get; set; } + public bool UseSingularity + { + get; set; + } public long GetCharacterID() { @@ -63,7 +71,7 @@ public long GetCharacterID() public static long GetCharacterID(bool sisi, string characterName) { - string uri = string.Format("https://esi.evetech.net/v1/search/?categories=character&datasource={0}&language=en-us&search={1}&strict=true", (sisi?"singularity":"tranquility"), WebUtility.UrlEncode(characterName)); + string uri = string.Format("https://esi.evetech.net/latest/search/?categories=character&datasource={0}&language=en-us&search={1}&strict=true", (sisi ? "singularity" : "tranquility"), WebUtility.UrlEncode(characterName)); using (WebClient wc = new WebClient()) { @@ -74,7 +82,7 @@ public static long GetCharacterID(bool sisi, string characterName) return 0;// Character does not exist // Response is JSON, but since it's not complex we'll just strip the formatting instead of using a JSON parser. -// {"character":[90664221]} + // {"character":[90664221]} string prefix = "{\"character\":["; string suffix = "]}"; @@ -104,8 +112,11 @@ public static long GetCharacterID(bool sisi, string characterName) [XmlIgnore] EVEAccount ILaunchTarget.EVEAccount { - get { return EVEAccount; } + get + { + return EVEAccount; + } } - + } } diff --git a/Games/EVE/ProfileManager.cs b/Games/EVE/ProfileManager.cs index f62aaef..149c23b 100644 --- a/Games/EVE/ProfileManager.cs +++ b/Games/EVE/ProfileManager.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.IO; namespace ISBoxerEVELauncher.Games.EVE diff --git a/Games/EVE/Profiles.cs b/Games/EVE/Profiles.cs index f6f9439..b02391f 100644 --- a/Games/EVE/Profiles.cs +++ b/Games/EVE/Profiles.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace ISBoxerEVELauncher.Games.EVE { diff --git a/ISBoxerEVELauncher.csproj b/ISBoxerEVELauncher.csproj index 8a70e3c..b80a412 100644 --- a/ISBoxerEVELauncher.csproj +++ b/ISBoxerEVELauncher.csproj @@ -1,6 +1,6 @@  - + Debug @@ -43,7 +43,7 @@ prompt 4 true - true + false AnyCPU @@ -55,6 +55,9 @@ 4 true true + + - + ISBEL.ico @@ -62,42 +65,95 @@ app.manifest + + true + bin\x64\Debug\ + DEBUG;TRACE + true + full + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + + + bin\x64\Release\ + TRACE + true + true + pdbonly + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + true + + + true + bin\x86\Debug\ + DEBUG;TRACE + true + full + x86 + 7.3 + prompt + MinimumRecommendedRules.ruleset + + + bin\x86\Release\ + TRACE + true + true + pdbonly + x86 + 7.3 + prompt + MinimumRecommendedRules.ruleset + true + - - packages\Costura.Fody.5.0.0-alpha0281\lib\netstandard1.0\Costura.dll + + packages\Costura.Fody.5.6.0\lib\netstandard1.0\Costura.dll - - packages\HtmlAgilityPack.1.11.24\lib\Net45\HtmlAgilityPack.dll + + ..\..\MyProject\iEVE\iTrader\packages\HtmlAgilityPack.1.11.37\lib\Net45\HtmlAgilityPack.dll - - packages\Microsoft.IdentityModel.Logging.6.7.2-preview-10803222715\lib\netstandard2.0\Microsoft.IdentityModel.Logging.dll + + packages\Microsoft.IdentityModel.Logging.6.12.2\lib\net472\Microsoft.IdentityModel.Logging.dll - - packages\Microsoft.IdentityModel.Tokens.6.7.2-preview-10803222715\lib\netstandard2.0\Microsoft.IdentityModel.Tokens.dll + + packages\Microsoft.IdentityModel.Tokens.6.12.2\lib\net472\Microsoft.IdentityModel.Tokens.dll + packages\Microsoft.Win32.Primitives.4.3.0\lib\net46\Microsoft.Win32.Primitives.dll True True - - packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll + + packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll + + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.dll - packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll True True + + packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + - - packages\System.Console.4.3.0\lib\net46\System.Console.dll + + packages\System.Console.4.3.1\lib\net46\System.Console.dll True True - - packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll + + + packages\System.Diagnostics.DiagnosticSource.5.0.1\lib\net46\System.Diagnostics.DiagnosticSource.dll packages\System.Diagnostics.Tracing.4.3.0\lib\net462\System.Diagnostics.Tracing.dll @@ -146,8 +202,11 @@ True True - - packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll + + packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + packages\System.Net.Http.4.3.4\lib\net46\System.Net.Http.dll True True @@ -157,18 +216,24 @@ True + + packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll True True - - packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll + + packages\System.Runtime.4.3.1\lib\net462\System.Runtime.dll True True - - packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll + + packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll + + + packages\System.Runtime.Extensions.4.3.1\lib\net462\System.Runtime.Extensions.dll True True @@ -183,13 +248,14 @@ True + - packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll + packages\System.Security.Cryptography.Algorithms.4.3.1\lib\net463\System.Security.Cryptography.Algorithms.dll True True - - packages\System.Security.Cryptography.Cng.4.5.0\lib\net47\System.Security.Cryptography.Cng.dll + + packages\System.Security.Cryptography.Cng.5.0.0\lib\net47\System.Security.Cryptography.Cng.dll packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll @@ -201,13 +267,13 @@ True True - - packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + packages\System.Security.Cryptography.X509Certificates.4.3.2\lib\net461\System.Security.Cryptography.X509Certificates.dll True True - packages\System.Text.RegularExpressions.4.3.0\lib\net463\System.Text.RegularExpressions.dll + packages\System.Text.RegularExpressions.4.3.1\lib\net463\System.Text.RegularExpressions.dll True True @@ -222,7 +288,7 @@ 4.0 - packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + packages\System.Xml.ReaderWriter.4.3.1\lib\net46\System.Xml.ReaderWriter.dll True True @@ -237,11 +303,14 @@ + + + @@ -280,6 +349,12 @@ EVEEULAWindow.xaml + + Form + + + EVELoginBrowser.cs + LaunchProgressWindow.xaml @@ -392,6 +467,9 @@ ResXFileCodeGenerator Resources.Designer.cs + + EVELoginBrowser.cs + @@ -437,16 +515,23 @@ if "$(ConfigurationName)"=="Debug" ( ) - copy /Y "$(TargetDir)$(TargetFileName)" "N:\Dropbox\InnerSpace\$(TargetFileName)" + + - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAdQSURBVFhH7ZZrTJvXGcezrWulbdq0rZWmdpvUL/2wliUp + JE2a0FS7tOmaStwCBNKmWVSEGghDSbhEpCRtSNZtStu0I2RJw8UECDcXfONiMJibb6+N7xdsYxvfAIOB + LU0qTfrvnDevGcI0Ito+9i/99fq8fs7ze85zzjFs+Ubf6GG064zuqeSzTEFyhVqSfIbRbK9g/k1NP7Pv + yHc0hgv//2nvWSZx7xnNjdcv6VHa7kEts4BmQwSDgWXIZ79Em2UZddpF9jsaQ2PpHG76/6Y9Zeq/7L/A + 4EOJCwLnHMTeJQiIhY4gbKEIOh2zaHMvQuCJose/AunsXXw0FMZrFydB53JpHl6/qjQ9uqdk4upb1Xo0 + 6b1QOmcwuxCF2hNCu8GD+cUoVlZW4AzOYcIVgD04D7k7jC9cUYiDdyH038XR6zZShKqa5uLSbl4Unn/T + iE69G/65CJaXl1c9G1nA0tLSqtd+p3SH0EqK6A3dgyB4D4VNLuw5rajm0m5OL54c/2vmZQ34OiciCwuI + RqMbenFxMW48T4prNofR7rkDceAeOrx3kfN3C3afmtjcduw9KX/h5TOjuD5iQYQkiyVeIIWsdSQSwdzc + HMLhMILBIAKBAELkSccCsx8tzhW0er6EiGxFjWUFv63UYFfJ+E4O8/XaVTTUUMTTYCYQioPGPD8/z8Km + p6dht9ths1pZm8xWmG12DFq8aLJHcdt9B62cCzs92P2nsVoOs7F2Fgw//XLZKNoVZoRCIRa0kWdnZ+H1 + ejGgNaNF5cRt7TQatD606HzkOgbQYwmgyRpFy9S/WPNJAZd1S/hNhQqUweHi9cKJ4bKDn+lRO2aH0e6E + 3+9nW0pbHTOF0+J8Ph9uqVzgmRZwy7qEW7bl/5obN9n/ueprpmVk1VhAGRwuXknvygaOtU7jhnYOtxV2 + +MgqKYxCY3tNwR6PB273NHgqNykgikbryjovg2deIo4SL7PjOvMKjrV5QBkcLl6J78r8BaIAGoxRNKim + CYRcQa4L1BQuZ4zQTBphNpsh0blQp19Ag2mJfX7OhPG5Joyb2jB4TBAiYwC1Kh/7rk4fwXGhH5TB4eKV + lD/wVVEfDY7ihtIPPTlUtIiZmRl29fQp1ZhxTe4ET+nBDVUItboF1vVqP4Lk98JMfqj69R4wUz72wNIb + ZJwOolXjQ4HIB8rgcPFKfEf61YmeEI5LgninYwqlzWP4QtSL8bExTE5OwmQyoUM6jj/eNiO/24fTQidK + u604wtPiQscEXC7Xqqemplg7HA72OaA2IZ8/BcrgcPF6/liPP5/vRbk0jJNdDsj0LpxqGIawX4aJ8XG2 + CCWjQ3GHGWV9AVRI3GgfM8PpdLJeC11relVrJCrkNVtAGRwuXtuPivverHWgvD+EMr4FXrLnl7p0KG0j + N0M4AplsCEqlEpVdJlT0kgJ6/SjtmsKnAiWMRiNsNtvGJr8RPeM6ZFczoAwOF69tR8Rlb1xicFrix0WB + iV1Vm9yIswIn3hO68V6nEY19KnzUY8V50oH3+4M41zODsnYDxhgDu9L1pgVYyIEVjjB47ZwclMHh4rX1 + LcFTO/L6cJzs70WRDWaLFb0TBpwTuVAlDeH9Hi8qux3EdpwXucl7N6oEVvAG9LA77rd+PZyeG9qdD9oV + SDwmAmVwuI31XK6wOv3yJMpJa/vHJzGq1uMDgQN/lgZRJZ7GmMEJtdkFkcIG/gjZf7dn9dDFoDHTq2ow + GNA9rMYbVXIk5HZd5TBfr4QcfkLSUQnyWqbwscgAvd6Avwkt+JC0/KLYjV7F/a2JnXb6ma58LdhK/y6Q + lev1ekyotTjRqEHS20LQ3BzmwUrI7rq0r3gQBa1WdMgYXJdM4kKXjXWNSMcC1gNjtlgsMJGWU7iG0eJc + qwrJJ3pBc3LpN6dnM/mfvlIuR2GzHt1DDEwWO0a1VtSJ1VBqDWx715vuNb2qWq0WCqUK55vl+N1pKZ7L + 7PyMS7spfauysvLbeXl5303IaL/6UkEvTvIU6OyRQUcS0z1VM5MsKGadTsdCNRoNFAoSK5ai6KYcycfF + eDa95dr+/fsfO3jw4Hdo7vuIB4jCCwsLH8vIyPgJ8dPb0upvbs3uQFrVMIrrR1BVK0RjpwQDg0MYGhrC + MDF98kX9uMwToLReRmKHQOdsz6ity8rKeobAf3b48OHv79u37xGCeHARtFIaTCb+IjMzc0d2dvbrr2aW + lySl/2NwWw4fr5RIkXtFgSM1ChQ3TuBU4yjevjqOnE8m8PuSfmzL6UBS6jXZq5ll5WRuKsnxEi2CLojk + pv+cPriA9R0gCbYS7zp06NDeP2QVpe1I/+TjhLR6VUIaz/lMyq071AmpPOevU3jqnelXrhzILE4nwGQS + vzsnJyfxoTtAtHoGDhw48L3c3NwfkkQ/pgWRpI/TZKmpqT+nHSKffxkzHZMVP0ninkhJSfkpnUPe/4j4 + Bw91BtaIBrPFxEyT0FXQ4qjJ+NGY6ZjEPEJj1s6J5aEJ47Vly38AKNEuwJsGLnEAAAAASUVORK5CYII= + + + \ No newline at end of file diff --git a/Windows/EmailChallengeWindow.xaml.cs b/Windows/EmailChallengeWindow.xaml.cs index 2aa8d9a..9f2a344 100644 --- a/Windows/EmailChallengeWindow.xaml.cs +++ b/Windows/EmailChallengeWindow.xaml.cs @@ -1,16 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; +using System.Windows; namespace ISBoxerEVELauncher.Windows { @@ -95,7 +83,7 @@ public EmailChallengeWindow(string body) //body = body.Replace("\"/Images/eve.png\"", "\"https://login.eveonline.com/Images/eve.png\""); this.webBrowser.NavigateToString(body); /**/ - + string header = @" Email verification required @@ -104,7 +92,7 @@ public EmailChallengeWindow(string body) int startIndex = body.IndexOf(""); - + string sectionOnly = body.Substring(startIndex, (endIndex - startIndex) + "".Length); this.webBrowser.NavigateToString(header + sectionOnly); diff --git a/Windows/LaunchProgressWindow.xaml.cs b/Windows/LaunchProgressWindow.xaml.cs index f87aa12..a4fa94c 100644 --- a/Windows/LaunchProgressWindow.xaml.cs +++ b/Windows/LaunchProgressWindow.xaml.cs @@ -14,9 +14,15 @@ namespace ISBoxerEVELauncher.Windows /// public partial class LaunchProgressWindow : Window, INotifyPropertyChanged { - public ObservableCollection Accounts { get; set; } + public ObservableCollection Accounts + { + get; set; + } - public ObservableCollection AccountsLaunched { get; set; } + public ObservableCollection AccountsLaunched + { + get; set; + } float _DelaySeconds; public float DelaySeconds @@ -32,13 +38,22 @@ public float DelaySeconds } } - public bool AutoClose { get; set; } + public bool AutoClose + { + get; set; + } DateTime LastLaunch = DateTime.MinValue; - public ILauncher Launcher { get; set; } + public ILauncher Launcher + { + get; set; + } - public int NumErrors { get; set; } + public int NumErrors + { + get; set; + } public LaunchProgressWindow(IEnumerable accounts, ILauncher launcher) { @@ -74,13 +89,13 @@ public void Stop() Timer.Stop(); Timer = null; } - if (AutoClose && NumErrors==0) + if (AutoClose && NumErrors == 0) this.Close(); } void Timer_Tick(object sender, EventArgs e) { - if (Accounts.Count==0) + if (Accounts.Count == 0) { Stop(); return; @@ -115,12 +130,12 @@ void Timer_Tick(object sender, EventArgs e) ILaunchTarget a = Accounts[0]; LoginResult lr = LoginResult.Error; try - { - lr = Launcher.Launch(a); + { + lr = Launcher.Launch(a); } - catch(ArgumentNullException ane) + catch (ArgumentNullException ane) { - switch(ane.ParamName) + switch (ane.ParamName) { case "sharedCachePath": { @@ -147,24 +162,29 @@ void Timer_Tick(object sender, EventArgs e) break; } } - catch(Exception ex) + catch (Exception ex) { AddDetailsLine(ex.ToString()); } - switch(lr) - { - case LoginResult.Success: - AccountsLaunched.Add(a); - Accounts.Remove(a); - LastLaunch = DateTime.Now; - AddDetailsLine("Account '"+a.EVEAccount.Username+"' launched"); - break; - default: - AddDetailsLine("Account '" + a.EVEAccount.Username + "' failed to launch: " + lr.ToString() + ". Aborting!"); - NumErrors++; - Stop(); - break; - } + switch (lr) + { + case LoginResult.Success: + AccountsLaunched.Add(a); + Accounts.Remove(a); + LastLaunch = DateTime.Now; + AddDetailsLine("Account '" + a.EVEAccount.Username + "' launched"); + break; + case LoginResult.Error: + Accounts.Remove(a); + LastLaunch = DateTime.Now; + AddDetailsLine("Account '" + a.EVEAccount.Username + "' cannot be launched, skip to the next one if there is any."); + break; + default: + AddDetailsLine("Account '" + a.EVEAccount.Username + "' failed to launch: " + lr.ToString() + ". Aborting!"); + NumErrors++; + Stop(); + break; + } } public void AddDetailsLine(string text) diff --git a/Windows/MainWindow.xaml.cs b/Windows/MainWindow.xaml.cs index cc98fe3..a8f3f11 100644 --- a/Windows/MainWindow.xaml.cs +++ b/Windows/MainWindow.xaml.cs @@ -1,965 +1,961 @@ -using System; +using ISBoxerEVELauncher.Enums; +using ISBoxerEVELauncher.Games.EVE; +using ISBoxerEVELauncher.InnerSpace; +using ISBoxerEVELauncher.Security; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Linq; +using System.Runtime.InteropServices; using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using System.Windows.Interop; -using System.Runtime.InteropServices; -using ISBoxerEVELauncher.Enums; -using ISBoxerEVELauncher.Security; -using ISBoxerEVELauncher.InnerSpace; -using ISBoxerEVELauncher.Games.EVE; namespace ISBoxerEVELauncher.Windows { - [StructLayout(LayoutKind.Sequential)] - public struct COPYDATASTRUCT - { - public IntPtr dwData; // Any value the sender chooses. Perhaps its main window handle? - public int cbData; // The count of bytes in the message. - public IntPtr lpData; // The address of the message. - } - - [StructLayout(LayoutKind.Sequential)] - public struct CHANGEFILTERSTRUCT - { - public uint size; - public MessageFilterInfo info; - } - public enum ChangeWindowMessageFilterExAction : uint - { - Reset = 0, Allow = 1, DisAllow = 2 - }; - public enum MessageFilterInfo : uint - { - None = 0, AlreadyAllowed = 1, AlreadyDisAllowed = 2, AllowedHigher = 3 - }; - - /// - /// Interaction logic for MainWindow.xaml - /// - public partial class MainWindow : Window, INotifyPropertyChanged - { - public const int WM_COPYDATA = 0x004a; - [DllImport("User32.dll", SetLastError = true, EntryPoint = "SendMessage")] - public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, ref COPYDATASTRUCT lParam); - [DllImport("User32.dll", SetLastError = true, EntryPoint = "SendMessage")] - public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); - // [DllImport("User32.dll", SetLastError = true, EntryPoint = "PostMessage")] - // public static extern bool PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); - [DllImport("User32.dll")] - static extern uint GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId); - [DllImport("user32")] - public static extern bool ChangeWindowMessageFilterEx(IntPtr hWnd, uint msg, ChangeWindowMessageFilterExAction action, ref CHANGEFILTERSTRUCT changeInfo); - - public System.Windows.Forms.NotifyIcon NotifyIcon; - - public MainWindow() - { - InitializeComponent(); - - Style itemContainerStyle = new Style(typeof(ListBoxItem)); - itemContainerStyle.Setters.Add(new Setter(ListBoxItem.AllowDropProperty, true)); - itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.PreviewMouseMoveEvent, new MouseEventHandler(s_PreviewMouseMoveEvent))); - itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.DropEvent, new DragEventHandler(listAccounts_Drop))); - listAccounts.ItemContainerStyle = itemContainerStyle; - - checkSavePasswords.IsChecked = App.Settings.UseMasterKey; - - App.Settings.PropertyChanged += Settings_PropertyChanged; - - this.Title += " (v" + VersionString + ")"; - - - NotifyIcon = new System.Windows.Forms.NotifyIcon(); - var iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/ISBoxerEVELauncher;component/ISBEL.ico")).Stream; - NotifyIcon.Icon = new System.Drawing.Icon(iconStream); - - NotifyIcon.DoubleClick += - delegate (object sender, EventArgs args) - { - this.Show(); - this.WindowState = WindowState.Normal; - NotifyIcon.Visible = false; - }; - } - - protected override void OnStateChanged(EventArgs e) - { - //if (WindowState == System.Windows.WindowState.Minimized) - //{ - // this.Hide(); - // NotifyIcon.Visible = true; - //} - base.OnStateChanged(e); - } - - #region Drag and drop for Accounts list - void s_PreviewMouseMoveEvent(object sender, MouseEventArgs e) - { - if (e.LeftButton != MouseButtonState.Pressed) - return; - - if (sender is ListBoxItem) - { - ListBoxItem draggedItem = sender as ListBoxItem; - DragDrop.DoDragDrop(draggedItem, draggedItem.DataContext, DragDropEffects.Move); - draggedItem.IsSelected = true; - } - } - - void listAccounts_Drop(object sender, DragEventArgs e) - { - EVEAccount droppedData = e.Data.GetData(typeof(EVEAccount)) as EVEAccount; - EVEAccount target = ((ListBoxItem)(sender)).DataContext as EVEAccount; - - int removedIdx = listAccounts.Items.IndexOf(droppedData); - int targetIdx = listAccounts.Items.IndexOf(target); - - if (removedIdx == targetIdx) - return; - - if (removedIdx < targetIdx) - { - Accounts.Insert(targetIdx + 1, droppedData); - Accounts.RemoveAt(removedIdx); - } - else - { - int remIdx = removedIdx + 1; - if (Accounts.Count + 1 > remIdx) - { - Accounts.Insert(targetIdx, droppedData); - Accounts.RemoveAt(remIdx); - } - } - App.Settings.Store(); - } - #endregion - - /// - /// Enables a specified message to be sent to the window from non-Administrator processes - /// - /// - /// - /// - static bool EnableWindowMessage(HwndSource source, uint msg) - { - CHANGEFILTERSTRUCT filterStatus = new CHANGEFILTERSTRUCT(); - filterStatus.size = (uint)Marshal.SizeOf(filterStatus); - filterStatus.info = 0; - return ChangeWindowMessageFilterEx(source.Handle, msg, ChangeWindowMessageFilterExAction.Allow, ref filterStatus); - } - - /// - /// Request Master Key from Master Instance - /// - /// True if a request was transmitted to the Master Instance - public bool RequestMasterKey() - { - if (App.Settings.UseMasterKey && (App.Settings.PasswordMasterKey == null || !App.Settings.PasswordMasterKey.HasData)) - { - - System.Diagnostics.Process masterInstance = App.GetMasterInstance(true); - if (masterInstance == null) - return false; - - if (masterInstance.MainWindowHandle == null) - return false; - - KeyTransmitter.RequestMasterKey(this, masterInstance.MainWindowHandle, masterInstance); - App.Settings.MasterKeyRequested = DateTime.Now; - return true; - } - - return false; - } - - protected override void OnSourceInitialized(EventArgs e) - { - base.OnSourceInitialized(e); - - - HwndSource source = PresentationSource.FromVisual(this) as HwndSource; - - // enable WM_COPYDATA from non-Administrator - EnableWindowMessage(source, WM_COPYDATA); - - source.AddHook(WndProc); - - if (!RequestMasterKey()) - App.Settings.RequestMasterPassword(); - - } - - - private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) - { - // Handle messages... - switch (msg) - { - case WM_COPYDATA: - handled = true; - COPYDATASTRUCT cds = (COPYDATASTRUCT)Marshal.PtrToStructure(lParam, typeof(COPYDATASTRUCT)); - switch ((long)cds.dwData) - { - case 0: - byte[] buff = new byte[cds.cbData]; - Marshal.Copy(cds.lpData, buff, 0, cds.cbData); - string receivedString = Encoding.Unicode.GetString(buff, 0, cds.cbData); - - //MessageBox.Show("Processing " + receivedString); - App.ProcessCommandLine(receivedString); - break; - case 10: - case 11: - case 12: - { - int processId = 0; - GetWindowThreadProcessId(wParam, out processId); - - if (processId == 0) - return IntPtr.Zero; - - System.Diagnostics.Process newInstance = System.Diagnostics.Process.GetProcessById(processId); - // ensure this is the same app, otherwise we might be leaking ... - - try + [StructLayout(LayoutKind.Sequential)] + public struct COPYDATASTRUCT + { + public IntPtr dwData; // Any value the sender chooses. Perhaps its main window handle? + public int cbData; // The count of bytes in the message. + public IntPtr lpData; // The address of the message. + } + + [StructLayout(LayoutKind.Sequential)] + public struct CHANGEFILTERSTRUCT + { + public uint size; + public MessageFilterInfo info; + } + public enum ChangeWindowMessageFilterExAction : uint + { + Reset = 0, Allow = 1, DisAllow = 2 + }; + public enum MessageFilterInfo : uint + { + None = 0, AlreadyAllowed = 1, AlreadyDisAllowed = 2, AllowedHigher = 3 + }; + + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window, INotifyPropertyChanged + { + public const int WM_COPYDATA = 0x004a; + [DllImport("User32.dll", SetLastError = true, EntryPoint = "SendMessage")] + public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, ref COPYDATASTRUCT lParam); + [DllImport("User32.dll", SetLastError = true, EntryPoint = "SendMessage")] + public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); + // [DllImport("User32.dll", SetLastError = true, EntryPoint = "PostMessage")] + // public static extern bool PostMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam); + [DllImport("User32.dll")] + static extern uint GetWindowThreadProcessId(IntPtr hWnd, out int lpdwProcessId); + [DllImport("user32")] + public static extern bool ChangeWindowMessageFilterEx(IntPtr hWnd, uint msg, ChangeWindowMessageFilterExAction action, ref CHANGEFILTERSTRUCT changeInfo); + + public System.Windows.Forms.NotifyIcon NotifyIcon; + + public MainWindow() + { + InitializeComponent(); + + Style itemContainerStyle = new Style(typeof(ListBoxItem)); + itemContainerStyle.Setters.Add(new Setter(ListBoxItem.AllowDropProperty, true)); + itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.PreviewMouseMoveEvent, new MouseEventHandler(s_PreviewMouseMoveEvent))); + itemContainerStyle.Setters.Add(new EventSetter(ListBoxItem.DropEvent, new DragEventHandler(listAccounts_Drop))); + listAccounts.ItemContainerStyle = itemContainerStyle; + + checkSavePasswords.IsChecked = App.Settings.UseMasterKey; + + App.Settings.PropertyChanged += Settings_PropertyChanged; + + this.Title += " (v" + VersionString + ")"; + + + NotifyIcon = new System.Windows.Forms.NotifyIcon(); + var iconStream = Application.GetResourceStream(new Uri("pack://application:,,,/ISBoxerEVELauncher;component/ISBEL.ico")).Stream; + NotifyIcon.Icon = new System.Drawing.Icon(iconStream); + + NotifyIcon.DoubleClick += + delegate (object sender, EventArgs args) + { + this.Show(); + this.WindowState = WindowState.Normal; + NotifyIcon.Visible = false; + }; + } + + protected override void OnStateChanged(EventArgs e) + { + //if (WindowState == System.Windows.WindowState.Minimized) + //{ + // this.Hide(); + // NotifyIcon.Visible = true; + //} + base.OnStateChanged(e); + } + + #region Drag and drop for Accounts list + void s_PreviewMouseMoveEvent(object sender, MouseEventArgs e) + { + if (e.LeftButton != MouseButtonState.Pressed) + return; + + if (sender is ListBoxItem) + { + ListBoxItem draggedItem = sender as ListBoxItem; + DragDrop.DoDragDrop(draggedItem, draggedItem.DataContext, DragDropEffects.Move); + draggedItem.IsSelected = true; + } + } + + void listAccounts_Drop(object sender, DragEventArgs e) + { + EVEAccount droppedData = e.Data.GetData(typeof(EVEAccount)) as EVEAccount; + EVEAccount target = ((ListBoxItem)(sender)).DataContext as EVEAccount; + + int removedIdx = listAccounts.Items.IndexOf(droppedData); + int targetIdx = listAccounts.Items.IndexOf(target); + + if (removedIdx == targetIdx) + return; + + if (removedIdx < targetIdx) + { + Accounts.Insert(targetIdx + 1, droppedData); + Accounts.RemoveAt(removedIdx); + } + else + { + int remIdx = removedIdx + 1; + if (Accounts.Count + 1 > remIdx) + { + Accounts.Insert(targetIdx, droppedData); + Accounts.RemoveAt(remIdx); + } + } + App.Settings.Store(); + } + #endregion + + /// + /// Enables a specified message to be sent to the window from non-Administrator processes + /// + /// + /// + /// + static bool EnableWindowMessage(HwndSource source, uint msg) + { + CHANGEFILTERSTRUCT filterStatus = new CHANGEFILTERSTRUCT(); + filterStatus.size = (uint)Marshal.SizeOf(filterStatus); + filterStatus.info = 0; + return ChangeWindowMessageFilterEx(source.Handle, msg, ChangeWindowMessageFilterExAction.Allow, ref filterStatus); + } + + /// + /// Request Master Key from Master Instance + /// + /// True if a request was transmitted to the Master Instance + public bool RequestMasterKey() + { + if (App.Settings.UseMasterKey && (App.Settings.PasswordMasterKey == null || !App.Settings.PasswordMasterKey.HasData)) + { + + System.Diagnostics.Process masterInstance = App.GetMasterInstance(true); + if (masterInstance == null) + return false; + + if (masterInstance.MainWindowHandle == null) + return false; + + KeyTransmitter.RequestMasterKey(this, masterInstance.MainWindowHandle, masterInstance); + App.Settings.MasterKeyRequested = DateTime.Now; + return true; + } + + return false; + } + + protected override void OnSourceInitialized(EventArgs e) + { + base.OnSourceInitialized(e); + + + HwndSource source = PresentationSource.FromVisual(this) as HwndSource; + + // enable WM_COPYDATA from non-Administrator + EnableWindowMessage(source, WM_COPYDATA); + + source.AddHook(WndProc); + + if (!RequestMasterKey()) + App.Settings.RequestMasterPassword(); + + } + + + private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) + { + // Handle messages... + switch (msg) + { + case WM_COPYDATA: + handled = true; + COPYDATASTRUCT cds = (COPYDATASTRUCT)Marshal.PtrToStructure(lParam, typeof(COPYDATASTRUCT)); + switch ((long)cds.dwData) + { + case 0: + byte[] buff = new byte[cds.cbData]; + Marshal.Copy(cds.lpData, buff, 0, cds.cbData); + string receivedString = Encoding.Unicode.GetString(buff, 0, cds.cbData); + + //MessageBox.Show("Processing " + receivedString); + App.ProcessCommandLine(receivedString); + break; + case 10: + case 11: + case 12: + { + int processId = 0; + GetWindowThreadProcessId(wParam, out processId); + + if (processId == 0) + return IntPtr.Zero; + + System.Diagnostics.Process newInstance = System.Diagnostics.Process.GetProcessById(processId); + // ensure this is the same app, otherwise we might be leaking ... + + try + { + if (newInstance == null || newInstance.MainModule.FileName != System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) + { + // different thing, sorry. + return IntPtr.Zero; + } + } + catch (System.ComponentModel.Win32Exception we) + { + if (we.NativeErrorCode == 5) + { + // other instance is Administrator and we are not; cannot confirm main module + return IntPtr.Zero; + } + MessageBox.Show("Error=" + we.NativeErrorCode); + throw; + } + /**/ + + KeyTransmitter.ReceiveTransmission(this, wParam, newInstance, cds); + } + break; + } + + break; + } + + return IntPtr.Zero; + } + + public string VersionString + { + get + { + return App.AppVersion; + } + } + + void Settings_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + OnPropertyChanged(e.PropertyName); + } + + public ObservableCollection GameProfiles + { + get + { + return App.GameProfiles; + } + } + + public ObservableCollection Accounts + { + get + { + return App.Settings.Accounts; + } + } + + public ObservableCollection Characters + { + get + { + return App.Settings.Characters; + } + } + + public InnerSpaceGameProfile TranquilityGameProfile + { + get + { + return App.Settings.TranquilityGameProfile; + } + set + { + App.Settings.TranquilityGameProfile = value; + App.Settings.Store(); + } + } + public InnerSpaceGameProfile SingularityGameProfile + { + get + { + return App.Settings.SingularityGameProfile; + } + set + { + App.Settings.SingularityGameProfile = value; + App.Settings.Store(); + } + } + public string EVESharedCachePath + { + get + { + return App.Settings.EVESharedCachePath; + } + set + { + App.Settings.EVESharedCachePath = value; + App.Settings.Store(); + } + } + + public Visibility InnerSpaceVisibility + { + get + { + if (App.HasInnerSpace) + return System.Windows.Visibility.Visible; + return System.Windows.Visibility.Collapsed; + } + set + { + + } + } + + public bool UseSingularity + { + get + { + return App.Settings.UseSingularity; + } + set + { + App.Settings.UseSingularity = value; + App.Settings.Store(); + } + } + + public bool X64 + { + get + { + return App.Settings.X64; + } + set + { + App.Settings.X64 = value; + App.Settings.Store(); + } + } + + public bool? UseDirectX9 + { + get + { + switch (App.Settings.UseDirectXVersion) + { + case DirectXVersion.Default: + return null; + case DirectXVersion.dx11: + return false; + case DirectXVersion.dx9: + return true; + } + return null; + } + set + { + if (!value.HasValue) + { + App.Settings.UseDirectXVersion = DirectXVersion.Default; + } + else + { + if (value.Value) + App.Settings.UseDirectXVersion = DirectXVersion.dx9; + else + App.Settings.UseDirectXVersion = DirectXVersion.dx11; + } + App.Settings.Store(); + } + } + + public float LaunchDelay + { + get + { + return App.Settings.LaunchDelay; + } + set + { + App.Settings.LaunchDelay = value; + App.Settings.Store(); + } + } + + private void buttonBrowse_Click(object sender, RoutedEventArgs e) + { + // Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog() { InitialDirectory = EVESharedCachePath, CheckPathExists=true, RestoreDirectory=true, }; + var dialog = new System.Windows.Forms.FolderBrowserDialog() { SelectedPath = EVESharedCachePath, ShowNewFolderButton = false, Description = "Please select the EVE SharedCache folder, typically C:\\ProgramData\\EVE\\CCP\\SharedCache" }; + System.Windows.Forms.DialogResult result = dialog.ShowDialog(); + switch (result) + { + case System.Windows.Forms.DialogResult.OK: + EVESharedCachePath = dialog.SelectedPath; + break; + } + } + + private void buttonCreateTranquility_Click(object sender, RoutedEventArgs e) + { + string filepath = App.Settings.GetTranquilityPath(); + if (string.IsNullOrEmpty(filepath)) + { + MessageBox.Show("Please configure Path to EVE's SharedCache first!"); + return; + } + + CreateGameProfileWindow cgpw = new CreateGameProfileWindow(false, "EVE Online", "Tranquility (Skip Launcher)"); + cgpw.ShowDialog(); + if (cgpw.DialogResult.HasValue && cgpw.DialogResult.Value) + { + App.AddGame(cgpw.Game, cgpw.GameProfile, System.IO.Path.Combine(filepath, "bin"), "exefile.exe", "/noconsole"); + App.AddGame(cgpw.Game, cgpw.GameProfile + " x64", System.IO.Path.Combine(filepath, "bin64"), "exefile.exe", "/noconsole"); + App.ReloadGameConfiguration(); + App.Settings.TranquilityGameProfile = App.FindGlobalGameProfile(new InnerSpaceGameProfile() { Game = cgpw.Game, GameProfile = cgpw.GameProfile }); + } + } + + private void buttonCreateSingularity_Click(object sender, RoutedEventArgs e) + { + string filepath = App.Settings.GetSingularityPath(); + if (string.IsNullOrEmpty(filepath)) + { + MessageBox.Show("Please configure Path to EVE's SharedCache first!"); + return; + } + + CreateGameProfileWindow cgpw = new CreateGameProfileWindow(true, "EVE Online", "Singularity (Skip Launcher)"); + cgpw.ShowDialog(); + if (cgpw.DialogResult.HasValue && cgpw.DialogResult.Value) + { + App.AddGame(cgpw.Game, cgpw.GameProfile, System.IO.Path.Combine(filepath, "bin"), "exefile.exe", "/noconsole /server:Singularity"); + App.AddGame(cgpw.Game, cgpw.GameProfile + " x64", System.IO.Path.Combine(filepath, "bin64"), "exefile.exe", "/noconsole"); + App.ReloadGameConfiguration(); + App.Settings.SingularityGameProfile = App.FindGlobalGameProfile(new InnerSpaceGameProfile() { Game = cgpw.Game, GameProfile = cgpw.GameProfile }); + } + } + + + private void buttonAddAccount_Click(object sender, RoutedEventArgs e) + { + EVEAccount newAccount = new EVEAccount(); + EVELogin el = new EVELogin(newAccount, false); + el.ShowDialog(); + + if (el.DialogResult.HasValue && el.DialogResult.Value) + { + // user clicked Go + + // check password... + // string refreshToken; + // switch (newAccount.GetRefreshToken(false, out refreshToken)) + EVEAccount.Token token; + LoginResult lr = newAccount.GetAccessToken(false, out token); + switch (lr) + { + case LoginResult.Success: + break; + case LoginResult.InvalidUsernameOrPassword: { - if (newInstance == null || newInstance.MainModule.FileName != System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName) - { - // different thing, sorry. - return IntPtr.Zero; - } + MessageBox.Show("Invalid Username or Password. Account NOT added."); + return; } - catch (System.ComponentModel.Win32Exception we) + case LoginResult.Timeout: { - if (we.NativeErrorCode == 5) - { - // other instance is Administrator and we are not; cannot confirm main module - return IntPtr.Zero; - } - MessageBox.Show("Error=" + we.NativeErrorCode); - throw; + MessageBox.Show("Timed out attempting to log in. Account NOT added."); + return; } - /**/ - - KeyTransmitter.ReceiveTransmission(this, wParam, newInstance, cds); - } - break; - } - - break; - } - - return IntPtr.Zero; - } - - public string VersionString - { - get - { - return App.AppVersion; - } - } - - void Settings_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) - { - OnPropertyChanged(e.PropertyName); - } - - public ObservableCollection GameProfiles - { - get - { - return App.GameProfiles; - } - } - - public ObservableCollection Accounts - { - get - { - return App.Settings.Accounts; - } - } - - public ObservableCollection Characters - { - get - { - return App.Settings.Characters; - } - } - - public InnerSpaceGameProfile TranquilityGameProfile - { - get - { - return App.Settings.TranquilityGameProfile; - } - set - { - App.Settings.TranquilityGameProfile = value; - App.Settings.Store(); - } - } - public InnerSpaceGameProfile SingularityGameProfile - { - get - { - return App.Settings.SingularityGameProfile; - } - set - { - App.Settings.SingularityGameProfile = value; - App.Settings.Store(); - } - } - public string EVESharedCachePath - { - get { return App.Settings.EVESharedCachePath; } - set - { - App.Settings.EVESharedCachePath = value; - App.Settings.Store(); - } - } - - public Visibility InnerSpaceVisibility - { - get - { - if (App.HasInnerSpace) - return System.Windows.Visibility.Visible; - return System.Windows.Visibility.Collapsed; - } - set - { - - } - } - - public bool UseSingularity - { - get - { - return App.Settings.UseSingularity; - } - set - { - App.Settings.UseSingularity = value; - App.Settings.Store(); - } - } - - public bool X64 - { - get - { - return App.Settings.X64; - } - set - { - App.Settings.X64 = value; - App.Settings.Store(); - } - } - - public bool? UseDirectX9 - { - get - { - switch (App.Settings.UseDirectXVersion) - { - case DirectXVersion.Default: - return null; - case DirectXVersion.dx11: - return false; - case DirectXVersion.dx9: - return true; - } - return null; - } - set - { - if (!value.HasValue) - { - App.Settings.UseDirectXVersion = DirectXVersion.Default; + case LoginResult.InvalidCharacterChallenge: + { + MessageBox.Show("Invalid Character Name entered, or Invalid Username or Password. Account NOT added."); + return; + } + case LoginResult.EmailVerificationRequired: + // message already provided + return; + default: + { + MessageBox.Show("Failed to log in: " + lr.ToString() + ". Account NOT added."); + return; + } + } + + + + EVEAccount existingAccount = App.Settings.Accounts.FirstOrDefault(q => q.Username.Equals(newAccount.Username, StringComparison.InvariantCultureIgnoreCase)); + + if (existingAccount != null) + { + // update existing account? + existingAccount.Username = newAccount.Username; + existingAccount.SecurePassword = newAccount.SecurePassword.Copy(); + existingAccount.EncryptPassword(); + + if (newAccount.SecureCharacterName != null && newAccount.SecureCharacterName.Length > 0) + { + existingAccount.SecureCharacterName = newAccount.SecureCharacterName.Copy(); + existingAccount.EncryptCharacterName(); + } + + newAccount.Dispose(); + newAccount = existingAccount; + } + else + { + // new account + App.Settings.Accounts.Add(newAccount); + } + + App.Settings.Store(); + } + + } + + private void checkSavePasswords_Click(object sender, RoutedEventArgs e) + { + e.Handled = true; + if (checkSavePasswords.IsChecked.HasValue && checkSavePasswords.IsChecked.Value) + { + SetMasterKeyWindow smkw = new SetMasterKeyWindow(); + smkw.ShowDialog(); + + checkSavePasswords.IsChecked = App.Settings.HasPasswordMasterKey; } else { - if (value.Value) - App.Settings.UseDirectXVersion = DirectXVersion.dx9; - else - App.Settings.UseDirectXVersion = DirectXVersion.dx11; + // clear master key + if (App.Settings.UseMasterKey) + { + switch (MessageBox.Show("By un-checking this box, this launcher will immediately clear out all *saved* passwords. Do you wish to continue?", "Wait! You are about to lose any saved passwords!", MessageBoxButton.YesNo)) + { + case MessageBoxResult.Yes: + App.Settings.ClearPasswordMasterKey(); + break; + default: + checkSavePasswords.IsChecked = true; + return; + } + + + + } } - App.Settings.Store(); - } - } - - public float LaunchDelay - { - get - { - return App.Settings.LaunchDelay; - } - set - { - App.Settings.LaunchDelay = value; - App.Settings.Store(); - } - } - - private void buttonBrowse_Click(object sender, RoutedEventArgs e) - { - // Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog() { InitialDirectory = EVESharedCachePath, CheckPathExists=true, RestoreDirectory=true, }; - var dialog = new System.Windows.Forms.FolderBrowserDialog() { SelectedPath = EVESharedCachePath, ShowNewFolderButton = false, Description = "Please select the EVE SharedCache folder, typically C:\\ProgramData\\EVE\\CCP\\SharedCache" }; - System.Windows.Forms.DialogResult result = dialog.ShowDialog(); - switch (result) - { - case System.Windows.Forms.DialogResult.OK: - EVESharedCachePath = dialog.SelectedPath; - break; - } - } - - private void buttonCreateTranquility_Click(object sender, RoutedEventArgs e) - { - string filepath = App.Settings.GetTranquilityPath(); - if (string.IsNullOrEmpty(filepath)) - { - MessageBox.Show("Please configure Path to EVE's SharedCache first!"); - return; - } - - CreateGameProfileWindow cgpw = new CreateGameProfileWindow(false, "EVE Online", "Tranquility (Skip Launcher)"); - cgpw.ShowDialog(); - if (cgpw.DialogResult.HasValue && cgpw.DialogResult.Value) - { - App.AddGame(cgpw.Game, cgpw.GameProfile, System.IO.Path.Combine(filepath, "bin"), "exefile.exe", "/noconsole"); - App.AddGame(cgpw.Game, cgpw.GameProfile + " x64", System.IO.Path.Combine(filepath, "bin64"), "exefile.exe", "/noconsole"); - App.ReloadGameConfiguration(); - App.Settings.TranquilityGameProfile = App.FindGlobalGameProfile(new InnerSpaceGameProfile() { Game = cgpw.Game, GameProfile = cgpw.GameProfile }); - } - } - - private void buttonCreateSingularity_Click(object sender, RoutedEventArgs e) - { - string filepath = App.Settings.GetSingularityPath(); - if (string.IsNullOrEmpty(filepath)) - { - MessageBox.Show("Please configure Path to EVE's SharedCache first!"); - return; - } - - CreateGameProfileWindow cgpw = new CreateGameProfileWindow(true, "EVE Online", "Singularity (Skip Launcher)"); - cgpw.ShowDialog(); - if (cgpw.DialogResult.HasValue && cgpw.DialogResult.Value) - { - App.AddGame(cgpw.Game, cgpw.GameProfile, System.IO.Path.Combine(filepath, "bin"), "exefile.exe", "/noconsole /server:Singularity"); - App.AddGame(cgpw.Game, cgpw.GameProfile + " x64", System.IO.Path.Combine(filepath, "bin64"), "exefile.exe", "/noconsole"); - App.ReloadGameConfiguration(); - App.Settings.SingularityGameProfile = App.FindGlobalGameProfile(new InnerSpaceGameProfile() { Game = cgpw.Game, GameProfile = cgpw.GameProfile }); - } - } - - - private void buttonAddAccount_Click(object sender, RoutedEventArgs e) - { - EVEAccount newAccount = new EVEAccount(); - EVELogin el = new EVELogin(newAccount, false); - el.ShowDialog(); - - if (el.DialogResult.HasValue && el.DialogResult.Value) - { - // user clicked Go - - // check password... - // string refreshToken; - // switch (newAccount.GetRefreshToken(false, out refreshToken)) - EVEAccount.Token token; - LoginResult lr = newAccount.GetAccessToken(false, out token); - switch (lr) - { - case LoginResult.Success: - break; - case LoginResult.InvalidUsernameOrPassword: - { - MessageBox.Show("Invalid Username or Password. Account NOT added."); - return; - } - case LoginResult.Timeout: - { - MessageBox.Show("Timed out attempting to log in. Account NOT added."); - return; - } - case LoginResult.InvalidCharacterChallenge: - { - MessageBox.Show("Invalid Character Name entered, or Invalid Username or Password. Account NOT added."); - return; - } - case LoginResult.EmailVerificationRequired: - // message already provided - return; - default: - { - MessageBox.Show("Failed to log in: " + lr.ToString() + ". Account NOT added."); - return; - } - } - - - - EVEAccount existingAccount = App.Settings.Accounts.FirstOrDefault(q => q.Username.Equals(newAccount.Username, StringComparison.InvariantCultureIgnoreCase)); - - if (existingAccount != null) - { - // update existing account? - existingAccount.Username = newAccount.Username; - existingAccount.SecurePassword = newAccount.SecurePassword.Copy(); - existingAccount.EncryptPassword(); - - if (newAccount.SecureCharacterName != null && newAccount.SecureCharacterName.Length > 0) - { - existingAccount.SecureCharacterName = newAccount.SecureCharacterName.Copy(); - existingAccount.EncryptCharacterName(); - } - - newAccount.Dispose(); - newAccount = existingAccount; + } + + private void buttonLaunchNonIS_Click(object sender, RoutedEventArgs e) + { + List launchAccounts = new List(); + foreach (EVEAccount a in listAccounts.SelectedItems) + { + launchAccounts.Add(a); + } + + if (launchAccounts.Count == 0) + return; + + if (string.IsNullOrWhiteSpace(App.Settings.EVESharedCachePath)) + { + MessageBox.Show("Please set the EVE SharedCache path first!"); + return; + } + + Windows.LaunchProgressWindow lpw = new LaunchProgressWindow(launchAccounts, new Launchers.Direct(App.Settings.EVESharedCachePath, App.Settings.UseDirectXVersion, App.Settings.UseSingularity)); + lpw.ShowDialog(); + } + + private void buttonLaunchIS_Click(object sender, RoutedEventArgs e) + { + List launchAccounts = new List(); + foreach (EVEAccount a in listAccounts.SelectedItems) + { + launchAccounts.Add(a); + } + + if (launchAccounts.Count == 0) + return; + + InnerSpaceGameProfile gp; + if (App.Settings.UseSingularity) + { + gp = App.Settings.SingularityGameProfile; } else { - // new account - App.Settings.Accounts.Add(newAccount); + gp = App.Settings.TranquilityGameProfile; } - App.Settings.Store(); - } - - } - - private void checkSavePasswords_Click(object sender, RoutedEventArgs e) - { - e.Handled = true; - if (checkSavePasswords.IsChecked.HasValue && checkSavePasswords.IsChecked.Value) - { - SetMasterKeyWindow smkw = new SetMasterKeyWindow(); - smkw.ShowDialog(); - - checkSavePasswords.IsChecked = App.Settings.HasPasswordMasterKey; - } - else - { - // clear master key - if (App.Settings.UseMasterKey) - { - switch (MessageBox.Show("By un-checking this box, this launcher will immediately clear out all *saved* passwords. Do you wish to continue?", "Wait! You are about to lose any saved passwords!", MessageBoxButton.YesNo)) - { - case MessageBoxResult.Yes: - App.Settings.ClearPasswordMasterKey(); - break; - default: - checkSavePasswords.IsChecked = true; - return; - } - - - - } - } - } - - private void buttonLaunchNonIS_Click(object sender, RoutedEventArgs e) - { - List launchAccounts = new List(); - foreach (EVEAccount a in listAccounts.SelectedItems) - { - launchAccounts.Add(a); - } - - if (launchAccounts.Count == 0) - return; - - if (string.IsNullOrWhiteSpace(App.Settings.EVESharedCachePath)) - { - MessageBox.Show("Please set the EVE SharedCache path first!"); - return; - } - - Windows.LaunchProgressWindow lpw = new LaunchProgressWindow(launchAccounts, new Launchers.Direct(App.Settings.EVESharedCachePath, App.Settings.UseDirectXVersion, App.Settings.UseSingularity)); - lpw.ShowDialog(); - } - - private void buttonLaunchIS_Click(object sender, RoutedEventArgs e) - { - List launchAccounts = new List(); - foreach (EVEAccount a in listAccounts.SelectedItems) - { - launchAccounts.Add(a); - } - - if (launchAccounts.Count == 0) - return; - - InnerSpaceGameProfile gp; - if (App.Settings.UseSingularity) - { - gp = App.Settings.SingularityGameProfile; - } - else - { - gp = App.Settings.TranquilityGameProfile; - } - - if (gp == null || string.IsNullOrEmpty(gp.Game) || string.IsNullOrEmpty(gp.GameProfile)) - { - MessageBox.Show("Please select a Game Profile first!"); - return; - } - - Windows.LaunchProgressWindow lpw = new LaunchProgressWindow(launchAccounts, new Launchers.InnerSpace(gp, App.Settings.UseDirectXVersion, App.Settings.UseSingularity)); - lpw.ShowDialog(); - } - - private void buttonDeleteAccount_Click(object sender, RoutedEventArgs e) - { - List deleteAccounts = new List(); - foreach (EVEAccount a in listAccounts.SelectedItems) - { - deleteAccounts.Add(a); - } - - if (deleteAccounts.Count == 0) - return; - - if (deleteAccounts.Count == 1) - { - switch (MessageBox.Show("Are you sure you want to delete '" + deleteAccounts[0].Username + "'?", "Wait! You are about to lose an account!", MessageBoxButton.YesNo)) - { - case MessageBoxResult.Yes: - break; - default: - return; - } - } - else - { - switch (MessageBox.Show("Are you sure you want to delete " + deleteAccounts.Count + " accounts?", "Wait! You are about to lose some accounts!", MessageBoxButton.YesNo)) - { - case MessageBoxResult.Yes: - break; - default: - return; - } - } - - foreach (EVEAccount toDelete in deleteAccounts) - { - Accounts.Remove(toDelete); - toDelete.Dispose(); - - } - - App.Settings.Store(); - } - - #region INotifyPropertyChanged - public event PropertyChangedEventHandler PropertyChanged; - - public void FirePropertyChanged(string value) - { - PropertyChangedEventHandler handler = PropertyChanged; - if (handler != null) - { - handler(this, new PropertyChangedEventArgs(value)); - } - } - public void OnPropertyChanged(string value) - { - FirePropertyChanged(value); - } - #endregion - - private void buttonCreateLauncherProfiles_Click(object sender, RoutedEventArgs e) - { - List launchAccounts = new List(); - foreach (EVEAccount a in listAccounts.SelectedItems) - { - launchAccounts.Add(a); - } - - if (launchAccounts.Count == 0) - return; - - CreateAccountGameProfilesWindow cagpw = new CreateAccountGameProfilesWindow("ISBoxer EVE Launcher", "ISBEL - {0}"); - cagpw.ShowDialog(); - - if (cagpw.DialogResult.HasValue && cagpw.DialogResult.Value) - { - - foreach (EVEAccount acct in launchAccounts) - { - string flags = string.Empty; - if (cagpw.UseEVEDirect) - flags += "-eve "; - else - flags += "-innerspace "; - - if (cagpw.UseNewLauncher) - { - flags += "-multiinstance "; - - if (!cagpw.LeaveLauncherOpen) - flags += "-exit "; - } - - - if (!App.AddGame(cagpw.Game, string.Format(cagpw.GameProfile, acct.Username), App.BaseDirectory, "ISBoxerEVELauncher.exe", flags + "\"" + acct.Username + "\"")) - { - App.ReloadGameConfiguration(); - return; - - } - } - - App.ReloadGameConfiguration(); - - } - } - - private void TranquilityGameProfile_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - // only perform validation if the user is touching the control - if (!comboTranquilityGameProfile.IsMouseOver && !comboTranquilityGameProfile.IsFocused && !comboTranquilityGameProfile.IsKeyboardFocused) - return; - - InnerSpaceGameProfile gp = TranquilityGameProfile; - if (gp == null) - return; - - switch (gp.Executable) - { - case RelatedExecutable.EXEFile: - // good - break; - case RelatedExecutable.EVELauncher: - case RelatedExecutable.InnerSpace: - case RelatedExecutable.InvalidGameProfile: - case RelatedExecutable.ISBoxerEVELauncher: - case RelatedExecutable.Other: - MessageBox.Show("This Game Profile does not appear to point to exefile.exe. Please select a Game Profile that points at exefile.exe, or use 'Create one now' to have one correctly set up for you."); - TranquilityGameProfile = null; - break; - } - - } - - private void SingularityGameProfile_SelectionChanged(object sender, SelectionChangedEventArgs e) - { - // only perform validation if the user is touching the control - if (!comboSingularityGameProfile.IsMouseOver && !comboSingularityGameProfile.IsFocused && !comboSingularityGameProfile.IsKeyboardFocused) - return; - - InnerSpaceGameProfile gp = SingularityGameProfile; - if (gp == null) - return; - - switch (gp.Executable) - { - case RelatedExecutable.EXEFile: - // good - break; - case RelatedExecutable.EVELauncher: - case RelatedExecutable.InnerSpace: - case RelatedExecutable.InvalidGameProfile: - case RelatedExecutable.ISBoxerEVELauncher: - case RelatedExecutable.Other: - MessageBox.Show("This Game Profile does not appear to point to exefile.exe. Please select a Game Profile that points at exefile.exe, or use 'Create one now' to have one correctly set up for you."); - SingularityGameProfile = null; - break; - } - - } - - private void buttonAddCharacter_Click(object sender, RoutedEventArgs e) - { - EVECharacter newCharacter = new EVECharacter(); - AddCharacterWindow acw = new AddCharacterWindow(newCharacter); - acw.ShowDialog(); - - if (acw.DialogResult.HasValue && acw.DialogResult.Value) - { - // user clicked Go - EVECharacter existing = App.Settings.FindEVECharacter(acw.UseSingularity, acw.CharacterName); - if (existing != null) - { - existing.EVEAccount = acw.Account; + if (gp == null || string.IsNullOrEmpty(gp.Game) || string.IsNullOrEmpty(gp.GameProfile)) + { + MessageBox.Show("Please select a Game Profile first!"); + return; + } + + Windows.LaunchProgressWindow lpw = new LaunchProgressWindow(launchAccounts, new Launchers.InnerSpace(gp, App.Settings.UseDirectXVersion, App.Settings.UseSingularity)); + lpw.ShowDialog(); + } + + private void buttonDeleteAccount_Click(object sender, RoutedEventArgs e) + { + List deleteAccounts = new List(); + foreach (EVEAccount a in listAccounts.SelectedItems) + { + deleteAccounts.Add(a); + } + + if (deleteAccounts.Count == 0) + return; + + if (deleteAccounts.Count == 1) + { + switch (MessageBox.Show("Are you sure you want to delete '" + deleteAccounts[0].Username + "'?", "Wait! You are about to lose an account!", MessageBoxButton.YesNo)) + { + case MessageBoxResult.Yes: + break; + default: + return; + } } else { - // no existing. - App.Settings.Characters.Add(newCharacter); + switch (MessageBox.Show("Are you sure you want to delete " + deleteAccounts.Count + " accounts?", "Wait! You are about to lose some accounts!", MessageBoxButton.YesNo)) + { + case MessageBoxResult.Yes: + break; + default: + return; + } + } + + foreach (EVEAccount toDelete in deleteAccounts) + { + Accounts.Remove(toDelete); + toDelete.Dispose(); + } App.Settings.Store(); - } - } + } - private void buttonLaunchCharacterIS_Click(object sender, RoutedEventArgs e) - { - List launchCharacters = new List(); - foreach (EVECharacter a in listCharacters.SelectedItems) - { - launchCharacters.Add(a); - } + #region INotifyPropertyChanged + public event PropertyChangedEventHandler PropertyChanged; - if (launchCharacters.Count == 0) - return; + public void FirePropertyChanged(string value) + { + PropertyChangedEventHandler handler = PropertyChanged; + if (handler != null) + { + handler(this, new PropertyChangedEventArgs(value)); + } + } + public void OnPropertyChanged(string value) + { + FirePropertyChanged(value); + } + #endregion + + private void buttonCreateLauncherProfiles_Click(object sender, RoutedEventArgs e) + { + List launchAccounts = new List(); + foreach (EVEAccount a in listAccounts.SelectedItems) + { + launchAccounts.Add(a); + } - InnerSpaceGameProfile gp; - if (App.Settings.UseSingularity) - { - gp = App.Settings.SingularityGameProfile; - } - else - { - gp = App.Settings.TranquilityGameProfile; - } - - if (gp == null || string.IsNullOrEmpty(gp.Game) || string.IsNullOrEmpty(gp.GameProfile)) - { - MessageBox.Show("Please select a Game Profile first!"); - return; - } - - Windows.LaunchProgressWindow lpw = new LaunchProgressWindow(launchCharacters, new Launchers.InnerSpace(gp, App.Settings.UseDirectXVersion, App.Settings.UseSingularity)); - lpw.ShowDialog(); - } - - private void buttonLaunchCharacterNonIS_Click(object sender, RoutedEventArgs e) - { - - List launchCharacters = new List(); - foreach (EVECharacter a in listCharacters.SelectedItems) - { - launchCharacters.Add(a); - } + if (launchAccounts.Count == 0) + return; - if (launchCharacters.Count == 0) - return; + CreateAccountGameProfilesWindow cagpw = new CreateAccountGameProfilesWindow("ISBoxer EVE Launcher", "ISBEL - {0}"); + cagpw.ShowDialog(); - if (string.IsNullOrWhiteSpace(App.Settings.EVESharedCachePath)) - { - MessageBox.Show("Please set the EVE SharedCache path first!"); - return; - } + if (cagpw.DialogResult.HasValue && cagpw.DialogResult.Value) + { - Windows.LaunchProgressWindow lpw = new LaunchProgressWindow(launchCharacters, new Launchers.Direct(App.Settings.EVESharedCachePath, App.Settings.UseDirectXVersion, App.Settings.UseSingularity)); - lpw.ShowDialog(); - } + foreach (EVEAccount acct in launchAccounts) + { + string flags = string.Empty; + if (cagpw.UseEVEDirect) + flags += "-eve "; + else + flags += "-innerspace "; - private void buttonCreateCharacterLauncherProfiles_Click(object sender, RoutedEventArgs e) - { - List launchCharacters = new List(); - foreach (EVECharacter a in listCharacters.SelectedItems) - { - launchCharacters.Add(a); - } + if (cagpw.UseNewLauncher) + { + flags += "-multiinstance "; - if (launchCharacters.Count == 0) - return; + if (!cagpw.LeaveLauncherOpen) + flags += "-exit "; + } - CreateAccountGameProfilesWindow cagpw = new CreateAccountGameProfilesWindow("ISBoxer EVE Launcher", "ISBEL - {0}"); - cagpw.ShowDialog(); - if (cagpw.DialogResult.HasValue && cagpw.DialogResult.Value) - { + if (!App.AddGame(cagpw.Game, string.Format(cagpw.GameProfile, acct.Username), App.BaseDirectory, "ISBoxerEVELauncher.exe", flags + "\"" + acct.Username + "\"")) + { + App.ReloadGameConfiguration(); + return; - foreach (EVECharacter acct in launchCharacters) + } + } + + App.ReloadGameConfiguration(); + + } + } + + private void TranquilityGameProfile_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + // only perform validation if the user is touching the control + if (!comboTranquilityGameProfile.IsMouseOver && !comboTranquilityGameProfile.IsFocused && !comboTranquilityGameProfile.IsKeyboardFocused) + return; + + InnerSpaceGameProfile gp = TranquilityGameProfile; + if (gp == null) + return; + + switch (gp.Executable) + { + case RelatedExecutable.EXEFile: + // good + break; + case RelatedExecutable.EVELauncher: + case RelatedExecutable.InnerSpace: + case RelatedExecutable.InvalidGameProfile: + case RelatedExecutable.ISBoxerEVELauncher: + case RelatedExecutable.Other: + MessageBox.Show("This Game Profile does not appear to point to exefile.exe. Please select a Game Profile that points at exefile.exe, or use 'Create one now' to have one correctly set up for you."); + TranquilityGameProfile = null; + break; + } + + } + + private void SingularityGameProfile_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + // only perform validation if the user is touching the control + if (!comboSingularityGameProfile.IsMouseOver && !comboSingularityGameProfile.IsFocused && !comboSingularityGameProfile.IsKeyboardFocused) + return; + + InnerSpaceGameProfile gp = SingularityGameProfile; + if (gp == null) + return; + + switch (gp.Executable) + { + case RelatedExecutable.EXEFile: + // good + break; + case RelatedExecutable.EVELauncher: + case RelatedExecutable.InnerSpace: + case RelatedExecutable.InvalidGameProfile: + case RelatedExecutable.ISBoxerEVELauncher: + case RelatedExecutable.Other: + MessageBox.Show("This Game Profile does not appear to point to exefile.exe. Please select a Game Profile that points at exefile.exe, or use 'Create one now' to have one correctly set up for you."); + SingularityGameProfile = null; + break; + } + + } + + private void buttonAddCharacter_Click(object sender, RoutedEventArgs e) + { + EVECharacter newCharacter = new EVECharacter(); + AddCharacterWindow acw = new AddCharacterWindow(newCharacter); + acw.ShowDialog(); + + if (acw.DialogResult.HasValue && acw.DialogResult.Value) + { + // user clicked Go + EVECharacter existing = App.Settings.FindEVECharacter(acw.UseSingularity, acw.CharacterName); + if (existing != null) + { + existing.EVEAccount = acw.Account; + } + else + { + // no existing. + App.Settings.Characters.Add(newCharacter); + } + + App.Settings.Store(); + } + } + + private void buttonLaunchCharacterIS_Click(object sender, RoutedEventArgs e) + { + List launchCharacters = new List(); + foreach (EVECharacter a in listCharacters.SelectedItems) + { + launchCharacters.Add(a); + } + + if (launchCharacters.Count == 0) + return; + + InnerSpaceGameProfile gp; + if (App.Settings.UseSingularity) + { + gp = App.Settings.SingularityGameProfile; + } + else { - string flags = string.Empty; - flags += "-c "; + gp = App.Settings.TranquilityGameProfile; + } + + if (gp == null || string.IsNullOrEmpty(gp.Game) || string.IsNullOrEmpty(gp.GameProfile)) + { + MessageBox.Show("Please select a Game Profile first!"); + return; + } - if (cagpw.UseEVEDirect) - flags += "-eve "; - else - flags += "-innerspace "; + Windows.LaunchProgressWindow lpw = new LaunchProgressWindow(launchCharacters, new Launchers.InnerSpace(gp, App.Settings.UseDirectXVersion, App.Settings.UseSingularity)); + lpw.ShowDialog(); + } - if (cagpw.UseNewLauncher) - { - flags += "-multiinstance "; + private void buttonLaunchCharacterNonIS_Click(object sender, RoutedEventArgs e) + { + + List launchCharacters = new List(); + foreach (EVECharacter a in listCharacters.SelectedItems) + { + launchCharacters.Add(a); + } - if (!cagpw.LeaveLauncherOpen) - flags += "-exit "; - } + if (launchCharacters.Count == 0) + return; + if (string.IsNullOrWhiteSpace(App.Settings.EVESharedCachePath)) + { + MessageBox.Show("Please set the EVE SharedCache path first!"); + return; + } - if (!App.AddGame(cagpw.Game, string.Format(cagpw.GameProfile, acct.Name), App.BaseDirectory, "ISBoxerEVELauncher.exe", flags + "\"" + acct.Name + "\"")) - { - App.ReloadGameConfiguration(); - return; + Windows.LaunchProgressWindow lpw = new LaunchProgressWindow(launchCharacters, new Launchers.Direct(App.Settings.EVESharedCachePath, App.Settings.UseDirectXVersion, App.Settings.UseSingularity)); + lpw.ShowDialog(); + } - } + private void buttonCreateCharacterLauncherProfiles_Click(object sender, RoutedEventArgs e) + { + List launchCharacters = new List(); + foreach (EVECharacter a in listCharacters.SelectedItems) + { + launchCharacters.Add(a); } - App.ReloadGameConfiguration(); + if (launchCharacters.Count == 0) + return; + + CreateAccountGameProfilesWindow cagpw = new CreateAccountGameProfilesWindow("ISBoxer EVE Launcher", "ISBEL - {0}"); + cagpw.ShowDialog(); + + if (cagpw.DialogResult.HasValue && cagpw.DialogResult.Value) + { + + foreach (EVECharacter acct in launchCharacters) + { + string flags = string.Empty; + flags += "-c "; - } + if (cagpw.UseEVEDirect) + flags += "-eve "; + else + flags += "-innerspace "; - } + if (cagpw.UseNewLauncher) + { + flags += "-multiinstance "; - private void buttonDeleteCharacter_Click(object sender, RoutedEventArgs e) - { - List deleteCharacters = new List(); - foreach (EVECharacter a in listCharacters.SelectedItems) - { - deleteCharacters.Add(a); - } + if (!cagpw.LeaveLauncherOpen) + flags += "-exit "; + } - if (deleteCharacters.Count == 0) - return; - if (deleteCharacters.Count == 1) - { - switch (MessageBox.Show("Are you sure you want to delete '" + deleteCharacters[0].Name + "'?", "Wait! You are about to lose a character!", MessageBoxButton.YesNo)) + if (!App.AddGame(cagpw.Game, string.Format(cagpw.GameProfile, acct.Name), App.BaseDirectory, "ISBoxerEVELauncher.exe", flags + "\"" + acct.Name + "\"")) + { + App.ReloadGameConfiguration(); + return; + + } + } + + App.ReloadGameConfiguration(); + + } + + } + + private void buttonDeleteCharacter_Click(object sender, RoutedEventArgs e) + { + List deleteCharacters = new List(); + foreach (EVECharacter a in listCharacters.SelectedItems) { - case MessageBoxResult.Yes: - break; - default: - return; + deleteCharacters.Add(a); } - } - else - { - switch (MessageBox.Show("Are you sure you want to delete " + deleteCharacters.Count + " characters?", "Wait! You are about to lose some characters!", MessageBoxButton.YesNo)) + + if (deleteCharacters.Count == 0) + return; + + if (deleteCharacters.Count == 1) + { + switch (MessageBox.Show("Are you sure you want to delete '" + deleteCharacters[0].Name + "'?", "Wait! You are about to lose a character!", MessageBoxButton.YesNo)) + { + case MessageBoxResult.Yes: + break; + default: + return; + } + } + else { - case MessageBoxResult.Yes: - break; - default: - return; + switch (MessageBox.Show("Are you sure you want to delete " + deleteCharacters.Count + " characters?", "Wait! You are about to lose some characters!", MessageBoxButton.YesNo)) + { + case MessageBoxResult.Yes: + break; + default: + return; + } } - } - foreach (EVECharacter toDelete in deleteCharacters) - { - Characters.Remove(toDelete); - } + foreach (EVECharacter toDelete in deleteCharacters) + { + Characters.Remove(toDelete); + } - } + } - } + } } diff --git a/Windows/MasterKeyEntryWindow.xaml.cs b/Windows/MasterKeyEntryWindow.xaml.cs index 218c3ca..53720dd 100644 --- a/Windows/MasterKeyEntryWindow.xaml.cs +++ b/Windows/MasterKeyEntryWindow.xaml.cs @@ -1,16 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; +using System.Windows; namespace ISBoxerEVELauncher.Windows { diff --git a/Windows/SecurityWarningWindow.xaml.cs b/Windows/SecurityWarningWindow.xaml.cs index c5d6907..167b994 100644 --- a/Windows/SecurityWarningWindow.xaml.cs +++ b/Windows/SecurityWarningWindow.xaml.cs @@ -1,16 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; +using System.Windows; namespace ISBoxerEVELauncher.Windows { @@ -19,7 +7,10 @@ namespace ISBoxerEVELauncher.Windows /// public partial class SecurityWarningWindow : Window { - public string URI { get; set; } + public string URI + { + get; set; + } public SecurityWarningWindow(string responseBody) { diff --git a/Windows/SetMasterKeyWindow.xaml.cs b/Windows/SetMasterKeyWindow.xaml.cs index b25ce2e..5a64c88 100644 --- a/Windows/SetMasterKeyWindow.xaml.cs +++ b/Windows/SetMasterKeyWindow.xaml.cs @@ -1,19 +1,8 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace ISBoxerEVELauncher.Windows { @@ -80,14 +69,14 @@ static bool SecureStringEqual(SecureString s1, SecureString s2) Marshal.ZeroFreeBSTR(bstr2); } } - } + } private void buttonGo_Click(object sender, RoutedEventArgs e) { SecureString s1 = textPassword.SecurePassword; SecureString s2 = textPasswordVerify.SecurePassword; e.Handled = true; - if (s1==null || s1.Length<1) + if (s1 == null || s1.Length < 1) { MessageBox.Show("Password is required. Please try again!"); return; @@ -99,7 +88,7 @@ private void buttonGo_Click(object sender, RoutedEventArgs e) return; } - if (!SecureStringEqual(s1,s2)) + if (!SecureStringEqual(s1, s2)) { MessageBox.Show("Passwords do not match. Please try again!"); return; @@ -117,6 +106,6 @@ private void buttonCancel_Click(object sender, RoutedEventArgs e) this.Close(); } - + } } diff --git a/Windows/UnhandledResponseWindow.xaml.cs b/Windows/UnhandledResponseWindow.xaml.cs index fd92642..aa412cf 100644 --- a/Windows/UnhandledResponseWindow.xaml.cs +++ b/Windows/UnhandledResponseWindow.xaml.cs @@ -1,16 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; +using System.Windows; namespace ISBoxerEVELauncher.Windows { @@ -25,7 +13,10 @@ public UnhandledResponseWindow(string responseBody) InitializeComponent(); } - public string ResponseBody { get; set; } + public string ResponseBody + { + get; set; + } private void buttonGo_Click(object sender, RoutedEventArgs e) { diff --git a/Windows/VerificationCodeChallengeWindow.xaml.cs b/Windows/VerificationCodeChallengeWindow.xaml.cs index b1ccddc..284037f 100644 --- a/Windows/VerificationCodeChallengeWindow.xaml.cs +++ b/Windows/VerificationCodeChallengeWindow.xaml.cs @@ -1,17 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using ISBoxerEVELauncher.Games.EVE; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -using ISBoxerEVELauncher.Games.EVE; namespace ISBoxerEVELauncher.Windows { @@ -33,7 +21,9 @@ public string AccountName { return Account.Username; } - set { } + set + { + } } string _VerificationCode; diff --git a/app.manifest b/app.manifest index 90915b2..074a6c5 100644 --- a/app.manifest +++ b/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + diff --git a/packages.config b/packages.config index 442c28b..7ce8222 100644 --- a/packages.config +++ b/packages.config @@ -1,21 +1,22 @@  - - - - - - - + + + + + + + - - + + + - + - + @@ -27,31 +28,34 @@ - - + + + + - - + + + - - + + - + - + - + \ No newline at end of file