private void CharSelector_Load(object sender, EventArgs e) { procs = Process.GetProcessesByName("Gw"); IntPtr charnameAddr; { GWCAMemory firstprocmems = new GWCAMemory(procs[0]); firstprocmems.InitScanner(new IntPtr(0x401000), 0x49A000); charnameAddr = firstprocmems.ScanForPtr(new byte[] { 0x6A, 0x14, 0x8D, 0x96, 0xBC }, 0x9, true); firstprocmems.TerminateScanner(); } foreach (Process proc in procs) { GWCAMemory mem = new GWCAMemory(proc); if (mem.Read <Int32>(new IntPtr(0x00DE0000)) != 0) { continue; } if (mem.HaveModule("GWToolbox.dll")) { continue; } string charname = mem.ReadWString(charnameAddr, 30); comboBox.Items.Add(charname); checkedListBox.Items.Add(charname, CheckState.Unchecked); } comboBox.SelectedIndex = 0; if (checkedListBox.Items.Count > 0) { checkedListBox.SetItemCheckState(0, CheckState.Checked); } }
public static void FindAddressesIfNeeded(GWCAMemory cli) { IntPtr tmp; Tuple <IntPtr, int> imagebase = cli.GetImageBase(); cli.InitScanner(imagebase.Item1, imagebase.Item2); tmp = cli.ScanForPtr(new byte[] { 0x55, 0x8B, 0xEC, 0x83, 0xEC, 0x10, 0x56, 0x6A }, 0x22, true); if (tmp != IntPtr.Zero) { WinTitle = tmp; } tmp = cli.ScanForPtr(new byte[] { 0x83, 0xC4, 0x40, 0x5F, 0x5E, 0x5B, 0x8B, 0x4D }); if (tmp != IntPtr.Zero) { EmailAddPtr = cli.Read <IntPtr>(new IntPtr(tmp.ToInt32() - 0x48)); CharnamePtr = cli.Read <IntPtr>(new IntPtr(tmp.ToInt32() - 0x2E)); } cli.TerminateScanner(); }
public Process[] GetValidProcesses() { Process[] check_procs = Process.GetProcessesByName("Gw"); Process[] tmp_procs = new Process[check_procs.Length]; string[] tmp_charnames = new string[check_procs.Length]; IntPtr charnameAddr = IntPtr.Zero; if (check_procs.Length < 1) { return(check_procs); } int validProcs = 0; // Check for admin rights. WindowsIdentity identity = WindowsIdentity.GetCurrent(); WindowsPrincipal principal = new WindowsPrincipal(identity); bool isElevated = principal.IsInRole(WindowsBuiltInRole.Administrator); for (int i = 0; i < check_procs.Length; i++) { if (!isElevated && ProcessHelper.IsProcessOwnerAdmin(check_procs[i])) { continue; // Guild wars has higher privileges } GWCAMemory mem = new GWCAMemory(check_procs[i]); if (mem.Read <Int32>(new IntPtr(0x00DE0000)) != 0) { continue; } if (mem.HaveModule("GWToolbox.dll")) { continue; } if (charnameAddr == IntPtr.Zero) { mem.InitScanner(new IntPtr(0x401000), 0x49A000); charnameAddr = mem.ScanForPtr(new byte[] { 0x6A, 0x14, 0x8D, 0x96, 0xBC }, 0x9, true); mem.TerminateScanner(); } if (charnameAddr == IntPtr.Zero) { continue; } tmp_procs[validProcs] = check_procs[i]; tmp_charnames[validProcs] = mem.ReadWString(charnameAddr, 60); validProcs++; } charnames = new string[validProcs]; procs = new Process[validProcs]; for (int i = 0; i < validProcs; i++) { procs[i] = tmp_procs[i]; charnames[i] = tmp_charnames[i]; } return(procs); }
public static IntPtr CharnamePtr = IntPtr.Zero; // = new IntPtr(0x00A2AE80); //public static IntPtr DATInfo = new IntPtr(0x00A35300); public static void FindAddressesIfNeeded(GWCAMemory cli) { if (WinTitle == IntPtr.Zero || EmailAddPtr == IntPtr.Zero || CharnamePtr == IntPtr.Zero) { IntPtr tmp; cli.InitScanner(new IntPtr(0x00401000), 0x0049A000); tmp = cli.ScanForPtr(new byte[] { 0x33, 0xD2, 0x8B, 0xCE, 0x57, 0x6A, 0x0C }, 0x0D, true); if (tmp != IntPtr.Zero) { WinTitle = tmp; } tmp = cli.ScanForPtr(new byte[] { 0x6A, 0x14, 0x8D, 0x96, 0xBC }); if (tmp != IntPtr.Zero) { EmailAddPtr = cli.Read <IntPtr>(new IntPtr(tmp.ToInt32() - 0x9)); CharnamePtr = cli.Read <IntPtr>(new IntPtr(tmp.ToInt32() + 0x9)); } cli.FreeScanner(); } }
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); //uModTexClient client = new uModTexClient(); //TexBundle bundle = new TexBundle("C:\\Users\\m\\OneDrive\\Desktop\\programs\\gw1\\Minimalus_Dub.tpf"); //client.AddBundle(bundle); 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() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (Mutex.TryOpenExisting(gwlMutexName, out gwlMutex)) { return; } else { gwlMutex = new Mutex(true, gwlMutexName); } settings = GlobalSettings.Load(); accounts = new AccountManager("Accounts.json"); for (int i = 0; i < accounts.Length; ++i) { accounts[i].active = false; } MainForm mf = new MainForm(); mf.Location = new System.Drawing.Point(-1000, -1000); mf.FormClosing += (object sender, FormClosingEventArgs e) => { Program.settings.Save(); }; 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(); bool 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.mods); uint timelock = 0; while (ok && m.process.MainWindowHandle == IntPtr.Zero) { Thread.Sleep(1000); timelock += 1; if (timelock > 10) { ok = false; break; } } if (!ok) { continue; } a.process = m; //m.WriteWString(GWMem.WinTitle, a.character + '\0'); mf.SetActive(i, true); timelock = 0; GWMem.FindAddressesIfNeeded(m); while (ok && m.Read <ushort>(GWMem.CharnamePtr) == 0 && timelock < 60) { Thread.Sleep(1000); timelock += 1; } 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(); }
static void Main() { Process[] p = Process.GetProcessesByName("GW Launcher"); // if (p.Length > 0) // { // SetForegroundWindow(p[0].MainWindowHandle); // return; // } StreamReader file; try { file = new StreamReader("Accounts.json"); } catch (FileNotFoundException) { StreamWriter writerfile = File.CreateText("Accounts.json"); writerfile.Write("[]"); writerfile.Close(); file = new StreamReader("Accounts.json"); } JsonTextReader reader = new JsonTextReader(file); JsonSerializer serializer = new JsonSerializer(); accounts = serializer.Deserialize <Account[]>(reader); for (int i = 0; i < accounts.Length; ++i) { accounts[i].active = false; } file.Close(); 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); 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(); }
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(); }