From db2fa1ef68138d8c93379377d704ff09834cf072 Mon Sep 17 00:00:00 2001 From: highvoltz Date: Thu, 8 Oct 2015 17:53:11 -0400 Subject: [PATCH 01/77] Added the ability to launch renamed WoW.exe --- WoW/WowLockToken.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/WoW/WowLockToken.cs b/WoW/WowLockToken.cs index cf95cba..6035e8b 100644 --- a/WoW/WowLockToken.cs +++ b/WoW/WowLockToken.cs @@ -108,9 +108,7 @@ public void StartWoW() _lockOwner.StartupSequenceIsComplete = false; _lockOwner.Memory = null; - bool lanchingWoW = _lockOwner.Settings.WowPath.IndexOf("WoW.exe", StringComparison.InvariantCultureIgnoreCase) != -1 - || _lockOwner.Settings.WowPath.IndexOf("WoWB.exe", StringComparison.InvariantCultureIgnoreCase) != -1 // Beta WoW - || _lockOwner.Settings.WowPath.IndexOf("WoWT.exe", StringComparison.InvariantCultureIgnoreCase) != -1;// PTR WoW + bool lanchingWoW = IsWoWPath(_lockOwner.Settings.WowPath); // force 32 bit client to start. if (lanchingWoW && _lockOwner.Settings.WowArgs.IndexOf("-noautolaunch64bit", StringComparison.InvariantCultureIgnoreCase) == -1) @@ -158,6 +156,14 @@ public void StartWoW() } } + private bool IsWoWPath(string path) + { + var originalExeFileName = FileVersionInfo.GetVersionInfo(path).OriginalFilename; + return originalExeFileName == "WoW.exe" + || originalExeFileName == "WoWB.exe" // Beta WoW + || originalExeFileName == "WoWT.exe" ;// PTR WoW + } + bool IsWoWProcess(Process proc) { return proc.ProcessName.Equals("Wow", StringComparison.CurrentCultureIgnoreCase); From 7ac5f76e8ae4697f18762b30a64af357594c9fd5 Mon Sep 17 00:00:00 2001 From: highvoltz Date: Thu, 8 Oct 2015 21:46:13 -0400 Subject: [PATCH 02/77] * Fixed issue with starting renamed WoW process --- Properties/AssemblyInfo.cs | 4 ++-- Utility.cs | 29 ++++++++++++++++++++++++++++- WoW/WowLockToken.cs | 4 +++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 1065be0..930bf94 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -55,5 +55,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.3")] -[assembly: AssemblyFileVersion("1.1.3")] +[assembly: AssemblyVersion("1.1.4")] +[assembly: AssemblyFileVersion("1.1.4")] diff --git a/Utility.cs b/Utility.cs index c6872c3..f2774bc 100644 --- a/Utility.cs +++ b/Utility.cs @@ -97,9 +97,36 @@ public static NativeMethods.WindowInfo GetWindowInfo(IntPtr hWnd) public static Process GetChildProcessByName(int parentPid, string processName) { var processes = Process.GetProcessesByName(processName); - return processes.FirstOrDefault(process => IsChildProcessOf(parentPid, process)); + var result = processes.FirstOrDefault(process => IsChildProcessOf(parentPid, process)); + + if (result != null) + return result; + + // search for a process whose exe was renamed. + return (from proc in Process.GetProcesses() + let procPath = GetProcessPath(proc) + where !string.IsNullOrEmpty(procPath) && File.Exists(procPath) + let exeOriginalNameWithExtention = FileVersionInfo.GetVersionInfo(procPath).OriginalFilename + where !string.IsNullOrEmpty(exeOriginalNameWithExtention) + let exeOriginalName = Path.GetFileNameWithoutExtension(exeOriginalNameWithExtention) + where exeOriginalName != null && exeOriginalName.Equals(processName, StringComparison.OrdinalIgnoreCase) + select proc).FirstOrDefault(); } + private static string GetProcessPath(Process proc) + { + // Wrapped in a try/catch since some processes, such as those that are started in suspend state, + // will throw exceptions when MainModule is accessed. + try + { + return proc.MainModule.FileName; + } + catch (Exception) + { + return null; + } + } + public static bool IsChildProcessOf(int parentPid, Process child) { var childPid = child.Id; diff --git a/WoW/WowLockToken.cs b/WoW/WowLockToken.cs index 6035e8b..9711450 100644 --- a/WoW/WowLockToken.cs +++ b/WoW/WowLockToken.cs @@ -76,9 +76,11 @@ public void StartWoW() if (_launcherPid > 0) { + var executablePath = Path.GetFileNameWithoutExtension(_lockOwner.Profile.Settings.WowSettings.WowPath); Process wowProcess = Utility.GetChildProcessByName(_launcherPid, "Wow") ?? Utility.GetChildProcessByName(_launcherPid, "WowB") // Beta - ?? Utility.GetChildProcessByName(_launcherPid, "WowT"); // PTR + ?? Utility.GetChildProcessByName(_launcherPid, "WowT") // PTR + ?? Utility.GetChildProcessByName(_launcherPid, executablePath); // Renamed executables if (wowProcess != null) { _launcherPid = 0; From 1138968bddda696b80c03c2cb331a62dbcfbed0e Mon Sep 17 00:00:00 2001 From: highvoltz Date: Wed, 28 Oct 2015 15:54:17 -0400 Subject: [PATCH 03/77] * Launcher exit codes greater than 0 is now assumed to be the game process ID and a negative exit code indicates an error occurred. --- Utility.cs | 4 ++-- WoW/WowLockToken.cs | 51 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/Utility.cs b/Utility.cs index f2774bc..b8fefee 100644 --- a/Utility.cs +++ b/Utility.cs @@ -109,8 +109,8 @@ public static Process GetChildProcessByName(int parentPid, string processName) let exeOriginalNameWithExtention = FileVersionInfo.GetVersionInfo(procPath).OriginalFilename where !string.IsNullOrEmpty(exeOriginalNameWithExtention) let exeOriginalName = Path.GetFileNameWithoutExtension(exeOriginalNameWithExtention) - where exeOriginalName != null && exeOriginalName.Equals(processName, StringComparison.OrdinalIgnoreCase) - select proc).FirstOrDefault(); + where exeOriginalName != null && exeOriginalName.Equals(processName, StringComparison.OrdinalIgnoreCase) && IsChildProcessOf(parentPid, proc) + select proc).FirstOrDefault(); } private static string GetProcessPath(Process proc) diff --git a/WoW/WowLockToken.cs b/WoW/WowLockToken.cs index 9711450..abe8da7 100644 --- a/WoW/WowLockToken.cs +++ b/WoW/WowLockToken.cs @@ -15,7 +15,7 @@ public class WowLockToken : IDisposable private WowManager _lockOwner; private readonly string _key; private Process _wowProcess; - private int _launcherPid; + private Process _launcherProc; private WowLockToken(string key, DateTime startTime, WowManager lockOwner) { @@ -49,7 +49,7 @@ public void Dispose() _wowProcess.Kill(); } _wowProcess = null; - _launcherPid = 0; + _launcherProc = null; _lockOwner = null; } } @@ -74,17 +74,34 @@ public void StartWoW() // check if a batch file or any .exe besides WoW.exe is used and try to get the child WoW process started by this process. - if (_launcherPid > 0) + if (_launcherProc != null) { - var executablePath = Path.GetFileNameWithoutExtension(_lockOwner.Profile.Settings.WowSettings.WowPath); - Process wowProcess = Utility.GetChildProcessByName(_launcherPid, "Wow") - ?? Utility.GetChildProcessByName(_launcherPid, "WowB") // Beta - ?? Utility.GetChildProcessByName(_launcherPid, "WowT") // PTR - ?? Utility.GetChildProcessByName(_launcherPid, executablePath); // Renamed executables + Process wowProcess; + // Two methods are used to find the WoW process if a launcher is used; + // Method one: launcher exit code return the WoW process ID or a negative if an error occured. + // If launcher does not use return the expected return values then a batch file or console app + // must be used to start the launcher and return the expected return codes. + // Method two: Find a child WoW process of the launcher process. + + if (_launcherProc.HasExited && _launcherProc.ExitCode < 0) + { + _lockOwner.Profile.Log("Pausing profile because launcher exited with error code: {0}", _launcherProc.ExitCode); + _lockOwner.Profile.Pause(); + return; + } + + if (!_launcherProc.HasExited || _launcherProc.ExitCode == 0 || (wowProcess = TryGetProcessById(_launcherProc.ExitCode)) == null) + { + var executablePath = Path.GetFileNameWithoutExtension(_lockOwner.Profile.Settings.WowSettings.WowPath); + wowProcess = Utility.GetChildProcessByName(_launcherProc.Id, "Wow") + ?? Utility.GetChildProcessByName(_launcherProc.Id, "WowB") // Beta + ?? Utility.GetChildProcessByName(_launcherProc.Id, "WowT") // PTR + ?? Utility.GetChildProcessByName(_launcherProc.Id, executablePath); // Renamed executables + } if (wowProcess != null) { - _launcherPid = 0; - Helpers.ResumeProcess(wowProcess.Id); + _launcherProc = null; + Helpers.ResumeProcess(wowProcess.Id); _wowProcess = wowProcess; } else @@ -136,7 +153,7 @@ public void StartWoW() pi.Arguments = _lockOwner.Settings.WowArgs; } - _launcherPid = Process.Start(pi).Id; + _launcherProc = Process.Start(pi); _lockOwner.ProcessIsReadyForInput = false; _lockOwner.LoginTimer.Reset(); } @@ -158,6 +175,18 @@ public void StartWoW() } } + private Process TryGetProcessById(int procId) + { + try + { + return Process.GetProcessById(procId); + } + catch (Exception) + { + return null; + } + } + private bool IsWoWPath(string path) { var originalExeFileName = FileVersionInfo.GetVersionInfo(path).OriginalFilename; From c9e8cb466e4e55282e76b85970f4e55601b90ab1 Mon Sep 17 00:00:00 2001 From: highvoltz Date: Wed, 4 Nov 2015 15:14:01 -0500 Subject: [PATCH 04/77] * Added an option to disable encrypting sensitive settings * Fixed a bug where account wasn't getting logged in when Idle task was skipped. --- Controls/OptionsUserControl.xaml | 17 +- Controls/OptionsUserControl.xaml.cs | 2 +- HBRelogManager.cs | 5 +- Honorbuddy/HonorbuddyManager.cs | 15 +- NativeMethods.cs | 25 +- Settings/GlobalSettings.cs | 440 ++++++++++++++-------------- Settings/HonorbuddySettings.cs | 75 ++--- Settings/WowSettings.cs | 152 +++++----- Tasks/IdleTask.cs | 13 +- Utility.cs | 11 - WoW/States/LoginWowState.cs | 10 +- WoW/WowLockToken.cs | 8 + 12 files changed, 408 insertions(+), 365 deletions(-) diff --git a/Controls/OptionsUserControl.xaml b/Controls/OptionsUserControl.xaml index b87e767..a95b55b 100644 --- a/Controls/OptionsUserControl.xaml +++ b/Controls/OptionsUserControl.xaml @@ -31,6 +31,7 @@ + - - + + + - - + -