internal static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (Mutex.TryOpenExisting(GwlMutexName, out gwlMutex)) { return; } gwlMutex = new Mutex(true, GwlMutexName); settings = GlobalSettings.Load(); accounts = new AccountManager("Accounts.json"); foreach (Account t in accounts) { t.active = false; } using (var mf = new MainForm()) { mf.Location = new System.Drawing.Point(-1000, -1000); mf.FormClosing += (object sender, FormClosingEventArgs e) => { Program.settings.Save(); }; mainthread = new Thread(() => { var mainClosed = false; mf.FormClosed += (s, a) => { mainClosed = true; }; while (!mainClosed) { var sleep = 5000; while (mf.needtolaunch.Count > 0) { int i = mf.needtolaunch.Dequeue(); var ok = true; Account a = accounts[i]; GWCAMemory m = MulticlientPatch.LaunchClient(a.gwpath, " -email \"" + a.email + "\" -password \"" + a.password + "\" -character \"" + a.character + "\" " + a.extraargs, a.datfix, false, a.elevated, a.mods); uint timelock = 0; while (m.process.MainWindowHandle == IntPtr.Zero) { Thread.Sleep(1000); timelock += 1; if (timelock <= 10) { continue; } ok = false; break; } if (!ok) { continue; } a.process = m; mf.SetActive(i, true); timelock = 0; GWMem.FindAddressesIfNeeded(m); while (m.Read <ushort>(GWMem.CharnamePtr) == 0 && timelock < 60) { Thread.Sleep(1000); timelock += 1; } Thread.Sleep(sleep); sleep += 5000; } mutex.WaitOne(); for (var i = 0; i < accounts.Length; ++i) { if (!accounts[i].active) { continue; } if (accounts[i].process.process.HasExited) { mf.SetActive(i, false); } } mutex.ReleaseMutex(); Thread.Sleep(150); } }); Application.Run(mf); mainthread.Abort(); } }
static void Main() { if (Mutex.TryOpenExisting(gwlMutexName, out gwlMutex)) { return; } else { gwlMutex = new Mutex(true, gwlMutexName); } accounts = new AccountManager("Accounts.json"); for (int i = 0; i < accounts.Length; ++i) { accounts[i].active = false; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm mf = new MainForm(); mf.Location = new System.Drawing.Point(-1000, -1000); mainthread = new Thread(() => { bool main_closed = false; mf.FormClosed += (s, a) => { main_closed = true; }; while (!main_closed) { int sleep = 5000; while (mf.needtolaunch.Count > 0) { int i = mf.needtolaunch.Dequeue(); Account a = accounts[i]; GWCAMemory m = MulticlientPatch.LaunchClient(a.gwpath, " -email \"" + a.email + "\" -password \"" + a.password + "\" -character \"" + a.character + "\" " + a.extraargs, a.datfix, false, a.mods); GWMem.FindAddressesIfNeeded(m); a.process = m; m.WriteWString(GWMem.WinTitle, a.character + '\0'); mf.SetActive(i, true); while (m.Read <ushort>(GWMem.CharnamePtr) == 0) { Thread.Sleep(1000); } Thread.Sleep(sleep); sleep += 5000; } mutex.WaitOne(); for (int i = 0; i < accounts.Length; ++i) { if (accounts[i].active) { if (accounts[i].process.process.HasExited) { mf.SetActive(i, false); } } } mutex.ReleaseMutex(); Thread.Sleep(150); } }); Application.Run(mf); mainthread.Abort(); }