public static void UpdateLocalDat(LocalDatFile file) { try { if (!file.IsUpToDate) { Apply(file); Process pro = new Process { StartInfo = new ProcessStartInfo { FileName = EnviromentManager.GwClientExePath } }; pro.Start(); pro.WaitForInputIdle(); Action waitforlaunch = () => ModuleReader.WaitForModule("WINNSI.DLL", pro); Helpers.BlockerInfo.Run("Loginfile Update", "Launchbuddy is updating an outdated Loginfile", waitforlaunch); pro.Kill(); Action waitforlock = () => WaitForLoginfileRelease(file); Helpers.BlockerInfo.Run("Loginfile Update", "Launchbuddy is waiting for Gw2 to save the updated loginfile.", waitforlock); WaitForFileAccess(); ToDefault(); file.gw2build = Api.ClientBuild; } } catch (Exception e) { throw new Exception("An error occured when Updating the Login file. " + e.Message); } }
public static void UpdateLocalDat(LocalDatFile file, bool forced = false) { if (!file.IsUpToDate || forced) { string oldhash = file.MD5HASH; Apply(file); Process pro = new Process { StartInfo = new ProcessStartInfo { FileName = EnviromentManager.GwClientExePath, Arguments = "-image" } }; // -image???? pro.Start(); pro.Refresh(); Action waitforlaunch = () => pro.WaitForExit(); Helpers.BlockerInfo.Run("Loginfile Update", "Launchbuddy is updating an outdated Loginfile", waitforlaunch); Action waitforlock = () => WaitForLoginfileRelease(file); Helpers.BlockerInfo.Run("Loginfile Update", "Launchbuddy is waiting for Gw2 to save the updated loginfile.", waitforlock); if (oldhash == file.MD5HASH) { MessageBox.Show($"INFO: Loginfile for {file.Name} did not change between the updates. If this error persist pls reenter Login data."); } #if !DEBUG file.gw2build = Api.ClientBuild; #endif ToDefault(); } }
private static void WaitForLoginfileRelease(LocalDatFile file) { int i = 0; while (LoginFileIsLocked(file) && i < 5) { i++; Thread.Sleep(1000); } }
private static void WaitForLoginfileRelease(LocalDatFile file) { int i = 0; while (LoginFileIsLocked(file) && i < 50) { i++; Thread.Sleep(50); #if DEBUG Console.WriteLine("WaitForLoginfileRelease Try: " + i.ToString()); #endif } }
public static void Remove(LocalDatFile file) { if (datacollection.Any <LocalDatFile>(d => d.Path == file.Path)) { datacollection.Remove(file); if (File.Exists(file.Path)) { File.Delete(file.Path); } } else { MessageBox.Show("Local dat not registered"); } }
public static void Apply(LocalDatFile file) { Repair(); //Is Valid? if (!file.Valid) { MessageBox.Show("Invalid Login file " + file.Name + " please recreate this file in the account Manager."); } WaitForFileAccess(); //Create Backup of Local dat if (!IsSymbolic(EnviromentManager.GwLocaldatPath)) { try { if (File.Exists(EnviromentManager.GwLocaldatBakPath)) { File.Delete(EnviromentManager.GwLocaldatBakPath); } } catch (Exception e) { throw new Exception("Could not delete Bakup Local.dat.\n" + e.Message, e); } try { File.Copy(EnviromentManager.GwLocaldatPath, EnviromentManager.GwLocaldatBakPath); } catch (Exception e) { throw new Exception("Could not create Bakup Local.dat.\n" + e.Message, e); } } //Delete Local.dat if (File.Exists(EnviromentManager.GwLocaldatPath)) { File.Delete(EnviromentManager.GwLocaldatPath); } //Create Symlink Replacer WaitForFileAccess(); WaitForLoginfileRelease(file); CreateSymbolLink(file.Path); //Remember last used file for ToDefault() CurrentFile = file; }
private static bool LoginFileIsLocked(LocalDatFile file) { FileStream stream = null; try { stream = File.Open(file.Path, FileMode.Open, FileAccess.Read, FileShare.None); } catch (IOException) { return(true); } finally { if (stream != null) { stream.Close(); } } return(false); }
public static void Apply(LocalDatFile file) { try { Repair(); //Is Valid? if (!file.Valid) { MessageBox.Show("Invalid Login file " + file.Name + " please recreate this file in the account Manager."); } //Create Backup of Local dat if (!IsSymbolic(EnviromentManager.GwLocaldatPath)) { if (File.Exists(EnviromentManager.GwLocaldatBakPath)) { File.Delete(EnviromentManager.GwLocaldatBakPath); } File.Copy(EnviromentManager.GwLocaldatPath, EnviromentManager.GwLocaldatBakPath); } //Delete Local.dat if (File.Exists(EnviromentManager.GwLocaldatPath)) { File.Delete(EnviromentManager.GwLocaldatPath); } //Create Symlink Replacer CreateSymbolLink(file.Path); //Remember last used file for ToDefault() CurrentFile = file; } catch (Exception e) { Repair(); throw new Exception("An error occured while swaping the Login file." + e.Message); } }
public static LocalDatFile CreateNewFile(string filename) { LocalDatFile datfile = new LocalDatFile(); string filepath = EnviromentManager.LBLocaldatsPath + filename + ".dat"; datfile.gw2build = Api.ClientBuild; datfile.Path = filepath; Process pro = new Process { StartInfo = new ProcessStartInfo(EnviromentManager.GwClientExePath) }; pro.Start(); Action blockefunc = () => ModuleReader.WaitForModule("DPAPI.dll", pro, null); Helpers.BlockerInfo.Run("Loginfile Creation", "Please check remember email/password and press the login and play button. This window will be closed automatically on success.", blockefunc); if (!Helpers.BlockerInfo.Done) { MessageBox.Show("No Clean Login. Loginfile might be not set correctly! Proceed with caution."); } Thread.Sleep(100); int ct = 0; bool exists = true; while (exists && ct < 100) { try { pro.CloseMainWindow(); Process.GetProcessById(pro.Id); exists = true; Thread.Sleep(100); ct++; } catch { exists = false; } } try { pro.Kill(); } catch { } try { #if DEBUG Console.WriteLine("Login data Hash: " + filename + ": " + datfile.MD5HASH); #endif if (File.Exists(filepath)) { File.Delete(filepath); } File.Copy(EnviromentManager.GwLocaldatPath, filepath); datfile.Valid = true; return(datfile); } catch (Exception e) { MessageBox.Show("Error: The Gameclient did not create a valid Login data file. " + e.Message); datfile.Valid = false; return(datfile); } }
public static LocalDatFile CreateNewFileAutomated(string filename, string email, string passwd) { LocalDatFile datfile = new LocalDatFile(); string filepath = EnviromentManager.LBLocaldatsPath + filename + ".dat"; datfile.gw2build = Api.ClientBuild; datfile.Path = filepath; Process pro = new Process { StartInfo = new ProcessStartInfo(EnviromentManager.GwClientExePath) }; pro.Start(); Action blockefunc = () => ModuleReader.WaitForModule("WINNSI.DLL", pro, null); Helpers.BlockerInfo.Run("Loginfile Creation", "LB is recreating your loginfile", blockefunc); if (!Helpers.BlockerInfo.Done) { MessageBox.Show("No Clean Login. Loginfile might be not set correctly! Proceed with caution."); } Thread.Sleep(100); Loginfiller.Login(email, passwd, pro, true); Thread.Sleep(250); blockefunc = () => ModuleReader.WaitForModule("DPAPI.dll", pro, null); Helpers.BlockerInfo.Run("Loginfile Creation", "Please add additional Information if needed.", blockefunc); if (!Helpers.BlockerInfo.Done) { MessageBox.Show("No Clean Login. Loginfile might be not set correctly! Proceed with caution."); } int ct = 0; bool exists = true; while (exists && ct < 100) { try { pro.CloseMainWindow(); Process.GetProcessById(pro.Id); exists = true; Thread.Sleep(100); ct++; } catch { exists = false; } } try { pro.Kill(); } catch { } try { Console.WriteLine("Login data Hash: " + filename + ": " + datfile.MD5HASH); if (File.Exists(filepath)) { File.Delete(filepath); } File.Copy(EnviromentManager.GwLocaldatPath, filepath); datfile.Valid = true; return(datfile); } catch (Exception e) { MessageBox.Show("Error: The Gameclient did not create a valid Login data file. " + e.Message); datfile.Valid = false; return(datfile); } }
public static void Add(LocalDatFile newfile) { datacollection.Add(newfile); }