示例#1
0
        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);
            }
        }
示例#2
0
        private void CharSelector_Load(object sender, EventArgs e)
        {
            Process[] check_procs = Process.GetProcessesByName("Gw");
            procs = new Process[check_procs.Length];

            int validProcs = 0;

            for (int i = 0; i < check_procs.Length; i++)
            {
                GWCAMemory mem = new GWCAMemory(check_procs[i]);
                if (mem.HaveModule("GWToolbox.dll"))
                {
                    continue;
                }
                Tuple <IntPtr, int> imagebase = mem.GetImageBase();
                mem.InitScanner(imagebase.Item1, imagebase.Item2);
                IntPtr charnameAddr = mem.ScanForPtr(new byte[] { 0x8B, 0xF8, 0x6A, 0x03, 0x68, 0x0F, 0x00, 0x00, 0xC0, 0x8B, 0xCF, 0xE8 }, -0x42, true);
                mem.TerminateScanner();
                procs[validProcs] = check_procs[i];
                validProcs++;
                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);
            }
        }
示例#3
0
        private void loaderForm_Load(object sender, EventArgs e)
        {
            IntPtr pCharname = (IntPtr)0x00A2AE80;

            clients = new Dictionary <string, GWCAMemory>();

            Process[] procs = Process.GetProcessesByName("Gw");
            if (procs.Length == 0)
            {
                MessageBox.Show("No Guild Wars clients found. Please start the client before running this.");
                Application.Exit();
            }
            foreach (Process proc in procs)
            {
                GWCAMemory mem  = new GWCAMemory(proc);
                string     name = mem.ReadWString(pCharname, 30);

                if (name == "")
                {
                    continue;
                }

                clients.Add(name, mem);
            }
            comboBoxCharnames.DataSource    = new BindingSource(clients, null);
            comboBoxCharnames.DisplayMember = "Key";
            comboBoxCharnames.ValueMember   = "Value";
        }
示例#4
0
        static public Process LaunchClient(string path, string args, bool datfix, bool nologin = false)
        {
            try
            {
                if (Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Src", null) != null)
                {
                    Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Src", Path.GetFullPath(path));
                    Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Path", Path.GetFullPath(path));
                }

                if (Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Src", null) != null)
                {
                    Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Src", Path.GetFullPath(path));
                    Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Path", Path.GetFullPath(path));
                }
            }
            catch (System.UnauthorizedAccessException)
            {
                MessageBox.Show("Insufficient access rights.\nPlease restart the launcher as admin.", "GWMC - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            IntPtr     hThread = IntPtr.Zero;
            uint       dwPID   = LaunchClient(path, args, (GWML_FLAGS)((datfix ? 2 : 3) | (nologin ? 4 : 0)), out hThread);
            Process    proc    = Process.GetProcessById((int)dwPID);
            GWCAMemory mem     = new GWCAMemory(proc);

            if (!GWMem.scanned)
            {
                GWMem.FindAddresses(mem);
            }
            string dllpath = Directory.GetCurrentDirectory() + "\\plugins";

            if (Directory.Exists(dllpath))
            {
                string[] files = Directory.GetFiles(dllpath, "*.dll");
                foreach (string file in files)
                {
                    mem.LoadModule(file);
                }
            }

            dllpath = Path.GetDirectoryName(path) + "\\plugins";
            if (Directory.Exists(dllpath))
            {
                string[] files = Directory.GetFiles(dllpath, "*.dll");
                foreach (string file in files)
                {
                    mem.LoadModule(file);
                }
            }

            ResumeThread(hThread);
            CloseHandle(hThread);

            return(proc);
        }
示例#5
0
        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);
        }
示例#6
0
        private IntPtr GetCharnameAddress(Process process)
        {
            var firstprocmems = new GWCAMemory(process);

            firstprocmems.InitScanner(new IntPtr(0x401000), 0x49A000);
            var charnameAddr = firstprocmems.ScanForPtr(new byte[] { 0x6A, 0x14, 0x8D, 0x96, 0xBC }, 0x9, true);

            firstprocmems.TerminateScanner();

            return(charnameAddr);
        }
示例#7
0
        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);

            procs = new Process[check_procs.Length];
            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.HaveModule("GWToolbox.dll"))
                {
                    continue;
                }
                Tuple <IntPtr, int> imagebase = mem.GetImageBase();
                mem.InitScanner(imagebase.Item1, imagebase.Item2);
                charnameAddr = mem.ScanForPtr(new byte[] { 0x8B, 0xF8, 0x6A, 0x03, 0x68, 0x0F, 0x00, 0x00, 0xC0, 0x8B, 0xCF, 0xE8 }, -0x42, true);
                mem.TerminateScanner();
                if (charnameAddr == IntPtr.Zero)
                {
                    continue;
                }
                tmp_procs[validProcs]     = check_procs[i];
                tmp_charnames[validProcs] = mem.ReadWString(charnameAddr, 40);
                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);
        }
示例#8
0
        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();
        }
示例#9
0
        private void RefreshUI()
        {
            if (Program.accounts.Length > 4)
            {
                heightofgui = 143 + 17 * (Program.accounts.Length - 4);
                this.SetBounds(Location.X, Location.Y, Size.Width, heightofgui);
            }
            this.listViewAccounts.Items.Clear();

            // Run through already open GW clients to see if accounts are already active.
            foreach (Process p in Process.GetProcessesByName("Gw"))
            {
                if (p.Threads.Count == 1)
                {
                    continue;
                }
                GWCAMemory m = new GWCAMemory(p);
                GWMem.FindAddressesIfNeeded(m);
                string str = m.ReadWString(GWMem.EmailAddPtr, 64);
                for (int i = 0; i < Program.accounts.Length; ++i)
                {
                    if (str == Program.accounts[i].email)
                    {
                        Program.accounts[i].active  = true;
                        Program.accounts[i].process = m;
                        break;
                    }
                }
            }

            // Fill out data.
            for (int i = 0; i < Program.accounts.Length; ++i)
            {
                listViewAccounts.Items.Add(new ListViewItem(
                                               new string[] {
                    Program.accounts[i].character,
                    Program.accounts[i].active ? "Active" : "Inactive"
                },
                                               "gw-icon"
                                               ));
            }
        }
示例#10
0
        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);
                string     charname = mem.ReadWString(charnameAddr, 30);
                comboBox1.Items.Add(charname);
            }
            comboBox1.SelectedIndex = 0;
        }
示例#11
0
        //public static IntPtr DATInfo     = new IntPtr(0x00A35300);


        public static void FindAddresses(GWCAMemory cli)
        {
            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 = new IntPtr(tmp.ToInt32() - 0x9);
                CharnamePtr = new IntPtr(tmp.ToInt32() + 0x9);
            }

            cli.FreeScanner();
            scanned = true;
        }
示例#12
0
        private void Form1_Load(object sender, EventArgs e)
        {
            procs = Process.GetProcessesByName("Gw");
            if (procs.Length > 0)
            {
                var charnameAddr = GetCharnameAddress(procs[0]);

                var list = procs
                           .Select(proc =>
                {
                    var mem = new GWCAMemory(proc);
                    return(new GwProcess {
                        Process = proc, Name = mem.ReadWString(charnameAddr, 30)
                    });
                })
                           .ToList();

                listBox1.DataSource    = list;
                listBox1.DisplayMember = "Name";
                listBox1.ValueMember   = "Process";
            }
        }
示例#13
0
        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();
        }
示例#14
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            heightofgui = 143;
            ImageList imglist = new ImageList();

            imglist.Images.Add("gw-icon", Properties.Resources.gw_icon);

            listViewAccounts.SmallImageList = imglist;

            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);

            file.Close();

            procs = new Process[accounts.Length];
            bool[] alreadyonline = new bool[accounts.Length];

            Process[] gwprocs = Process.GetProcessesByName("Gw");
            foreach (Process proc in gwprocs)
            {
                GWCAMemory mem = new GWCAMemory(proc);

                string curaddr = mem.ReadWString(GWMem.EmailAddPtr, 100);
                for (int i = 0; i < accounts.Length; ++i)
                {
                    if (accounts[i].email == curaddr)
                    {
                        procs[i]         = proc;
                        alreadyonline[i] = true;
                    }
                }
            }

            if (first)
            {
                StatusUpdater.Interval = 1000;
                StatusUpdater.Tick    += new EventHandler(TimerEventProcessor);
                StatusUpdater.Start();

                BatchLoader.Interval = 7000;
                BatchLoader.Tick    += new EventHandler(TimerBatchLoadAccounts);
            }

            if (accounts.Length > 4)
            {
                heightofgui += 17 * (accounts.Length - 4);
                this.SetBounds(Location.X, Location.Y, Size.Width, heightofgui);
            }

            for (int i = 0; i < accounts.Length; ++i)
            {
                listViewAccounts.Items.Add(new ListViewItem(new string[] { accounts[i].character, alreadyonline[i] ? "Active" : "Inactive" }, "gw-icon"));
            }
            first = false;
        }
示例#15
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();

            // Check for admin rights.
            WindowsIdentity  identity   = WindowsIdentity.GetCurrent();
            WindowsPrincipal principal  = new WindowsPrincipal(identity);
            bool             isElevated = principal.IsInRole(WindowsBuiltInRole.Administrator);

            if (!isElevated)
            {
                MessageBox.Show("Please run the launcher as Admin.",
                                "GWToolbox++ Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }

            // names and paths
            string localappdata   = Environment.GetEnvironmentVariable("LocalAppData");
            string settingsfolder = localappdata + "\\GWToolboxpp\\";
            string inifile        = settingsfolder + "GWToolbox.ini";

            // Install resources
            ResInstaller installer = new ResInstaller();

            installer.Install();

#if DEBUG
            // do nothing, we'll use GWToolbox.dll in /Debug
            string dllfile = "GWToolbox.dll"; // same folder where the launcher is built
#else
            // Download or update if needed
            string dllfile = settingsfolder + "GWToolbox.dll";
            if (!File.Exists(dllfile))
            {
                string    toolboxdir    = Environment.GetEnvironmentVariable("LocalAppData") + "\\GWToolboxpp\\";
                WebClient host          = new WebClient();
                string    remoteversion = host.DownloadString(
                    "https://raw.githubusercontent.com/HasKha/GWToolboxpp/master/resources/toolboxversion.txt");
                string dllurl = "https://github.com/HasKha/GWToolboxpp/releases/download/"
                                + remoteversion + "_Release/GWToolbox.dll";
                host.DownloadFile(dllurl, toolboxdir + "GWToolbox.dll");
            }
#endif
            // check again after download/update/build
            if (!File.Exists(dllfile))
            {
                MessageBox.Show("Cannot find GWToolbox.dll", "GWToolbox++ Launcher Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Look for gw processes.
            Process[] gwprocs = Process.GetProcessesByName("Gw");

            switch (gwprocs.Length)
            {
            case 0:     // No gw processes found.
                MessageBox.Show("No Guild Wars clients found.\n" +
                                "Please log into Guild Wars first.",
                                "GWToolbox++ Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                break;

            case 1:     // Only one process found, injecting.
                proctoinject = gwprocs[0];
                break;

            default:     // More than one found, make user select client.

                CharSelector chargui = new CharSelector();

                Application.Run(chargui);

                proctoinject = chargui.SelectedProcess;
                break;
            }

            if (proctoinject == null)
            {
                return;
            }

            IntPtr     dll_return;
            GWCAMemory mem = new GWCAMemory(proctoinject);
            GWCAMemory.LOADMODULERESULT result = mem.LoadModule(dllfile, out dll_return);
            if (result == GWCAMemory.LOADMODULERESULT.SUCCESSFUL && dll_return != IntPtr.Zero)
            {
                return;
            }
            if (result == GWCAMemory.LOADMODULERESULT.SUCCESSFUL)
            {
                MessageBox.Show("Error loading DLL: ExitCode " + dll_return,
                                "GWToolbox++ Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("Module Load Error.\n" +
                                LOADMODULE_RESULT_MESSAGES[(uint)result] + "\n",
                                "GWToolbox++ Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
示例#16
0
        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();
        }
示例#17
0
        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();
        }
示例#18
0
        static void Main()
        {
            INI_Reader settings = new INI_Reader(Environment.CurrentDirectory + "\\GWMC.ini");

            if (!File.Exists(Environment.CurrentDirectory + "\\GWMC.ini"))
            {
                GenerateINI(settings);
            }

            string gwpath = settings.IniReadValue("MCPatch", "gwpath");


            if (gwpath == "Gw.exe")
            {
                gwpath = Environment.CurrentDirectory + "\\Gw.exe";
            }

/*            try
 *          {
 *              if (Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Src", null) != null)
 *              {
 *                  Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Src", Path.GetFullPath(gwpath));
 *                  Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Path", Path.GetFullPath(gwpath));
 *              }
 *
 *              if (Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Src", null) != null)
 *              {
 *                  Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Src", Path.GetFullPath(gwpath));
 *                  Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Path", Path.GetFullPath(gwpath));
 *              }
 *          }
 *          catch (System.UnauthorizedAccessException)
 *          {
 *              MessageBox.Show("Insufficient access rights.\nPlease restart the launcher as admin.", "GWMC - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
 *              return;
 *          }*/


            if (!File.Exists(Environment.CurrentDirectory + "\\GWMC.ini"))
            {
                GenerateINI(settings);
            }

            STARTUPINFO         startup = new STARTUPINFO();
            PROCESS_INFORMATION procinfo;

            bool createprocessresult = CreateProcess(
                gwpath,
                Environment.CommandLine,
                IntPtr.Zero,
                IntPtr.Zero,
                false,
                ProcessCreationFlags.CREATE_SUSPENDED,
                IntPtr.Zero,
                null,
                ref startup,
                out procinfo);

            if (createprocessresult == false)
            {
                MessageBox.Show("Unable to launch Gw.exe.\nIs the path correct in the ini file?", "GWMC - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Process gwproc = Process.GetProcessById((int)procinfo.dwProcessId);

            GWCAMemory memmgr = new GWCAMemory(gwproc);

            MulticlientPatch patcher = new MulticlientPatch(memmgr);

            if (settings.IniReadValue("MCPatch", "enabled") == "1")
            {
                patcher.ApplyMulticlientPatch();
            }

            if (settings.IniReadValue("MCPatch", "datfix") == "1")
            {
                patcher.ApplyDatFix();
            }

            if (settings.IniReadValue("LoadDLL", "enabled") == "1")
            {
                memmgr.LoadModule(settings.IniReadValue("LoadDLL", "dllpath"));
            }

            ResumeThread(procinfo.hThread);
        }
示例#19
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();

            // Check for admin rights.
            WindowsIdentity  identity   = WindowsIdentity.GetCurrent();
            WindowsPrincipal principal  = new WindowsPrincipal(identity);
            bool             isElevated = principal.IsInRole(WindowsBuiltInRole.Administrator);

            // names and paths
            string toolboxdir = Environment.GetEnvironmentVariable("LocalAppData") + Path.DirectorySeparatorChar + "GWToolboxpp" + Path.DirectorySeparatorChar;
            string inifile    = toolboxdir + "GWToolbox.ini";
            string dllfile    = Path.GetDirectoryName(Application.ExecutablePath) + Path.DirectorySeparatorChar + DLL_NAME;

            // Install resources
            ResInstaller installer = new ResInstaller();

            installer.Install();

            // Download or update if needed. If dll file exists in current directory, use it.
            if (!File.Exists(dllfile))
            {
                dllfile = toolboxdir + DLL_NAME;
            }
            if (File.Exists(dllfile) && (new FileInfo(dllfile).Length) < 1)
            {
                File.Delete(dllfile); // Delete file if exists with 0 length
            }
            if (!File.Exists(dllfile))
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                WebClient host = new WebClient();
                host.Headers.Add(HttpRequestHeader.UserAgent, "GWToolboxpp Launcher");
                string remoteversion = GetLatestVersion();
                if (remoteversion.Length == 0)
                {
                    MessageBox.Show("Failed to fetch latest GWToolbox++ version.\n Check your internet connection and try again",
                                    "GWToolbox++ Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
                string dllurl = "https://github.com/" + GITHUB_USER + "/GWToolboxpp/releases/download/" + remoteversion + "_Release/" + DLL_NAME;
                int    tries  = 0;
                // This bit will take a while...
                while (tries < 3 && dllurl.Length > 0 && !File.Exists(dllfile))
                {
                    try
                    {
                        host.DownloadFile(dllurl, dllfile);
                        if (File.Exists(dllfile) && (new System.IO.FileInfo(dllfile).Length) < 1)
                        {
                            File.Delete(dllfile); // Delete file if exists with 0 length
                        }
                    }
                    catch (Exception)
                    {
                        // todo
                    }
                    tries++;
                }
                if (!File.Exists(dllfile))
                {
                    MessageBox.Show("Failed to download GWToolbox++ dll.\n Check your internet connection and try again",
                                    "GWToolbox++ Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
            }
            // check again after download/update/build
            if (!File.Exists(dllfile))
            {
                MessageBox.Show("Cannot find " + DLL_NAME, "GWToolbox++ Launcher Error",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Look for gw processes.
            List <Process> processesToInject = new List <Process>();

            CharSelector chargui = new CharSelector();

            Process[] gwprocs = chargui.GetValidProcesses();
            switch (gwprocs.Length)
            {
            case 0:     // No gw processes found.
                if (!isElevated && hasElevatedGWProcesses())
                {
                    MessageBox.Show("Guild Wars is running as Admin.\n" +
                                    "Restart Guild Wars without Admin, or run this launcher as Admin to run GWToolbox++",
                                    "GWToolbox++ Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
                MessageBox.Show("No Guild Wars clients found.\n" +
                                "Please log into Guild Wars first.",
                                "GWToolbox++ Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                break;

            case 1:     // Only one process found, injecting.
                processesToInject.Add(gwprocs[0]);
                break;

            default:     // More than one found, make user select client.
                Application.Run(chargui);
                processesToInject.AddRange(chargui.SelectedProcesses);
                break;
            }

            if (processesToInject.Count == 0)
            {
                return;
            }

            for (int i = 0; i < processesToInject.Count; ++i)
            {
                IntPtr     dll_return;
                GWCAMemory mem = new GWCAMemory(processesToInject[i]);
                GWCAMemory.LOADMODULERESULT result = mem.LoadModule(dllfile, out dll_return);
                if (result == GWCAMemory.LOADMODULERESULT.SUCCESSFUL && dll_return != IntPtr.Zero)
                {
                    // continue
                }
                else if (result == GWCAMemory.LOADMODULERESULT.SUCCESSFUL)
                {
                    MessageBox.Show("Error loading DLL: ExitCode " + dll_return,
                                    "GWToolbox++ Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Module Load Error.\n" +
                                    LOADMODULE_RESULT_MESSAGES[(uint)result] + "\n",
                                    "GWToolbox++ Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }
            }
        }
示例#20
0
        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();
            }
        }
示例#21
0
        static public GWCAMemory LaunchClient(string path, string args, bool datfix, bool nologin = false, List <Mod> mods = null)
        {
            try
            {
                if (Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Src", null) != null)
                {
                    Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Src", Path.GetFullPath(path));
                    Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Path", Path.GetFullPath(path));
                }

                if (Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Src", null) != null)
                {
                    Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Src", Path.GetFullPath(path));
                    Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Path", Path.GetFullPath(path));
                }
            }
            catch (System.UnauthorizedAccessException)
            {
                MessageBox.Show("Insufficient access rights.\nPlease restart the launcher as admin.", "GWMC - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            IntPtr     hThread = IntPtr.Zero;
            uint       dwPID   = LaunchClient(path, args, (GWML_FLAGS)((datfix ? 2 : 3) | (nologin ? 4 : 0)), out hThread);
            Process    proc    = Process.GetProcessById((int)dwPID);
            GWCAMemory mem     = new GWCAMemory(proc);

            if (mem.process.Threads[0].ThreadState == ThreadState.Wait && mem.process.Threads[0].WaitReason == ThreadWaitReason.Suspended)
            {
                try
                {
                    mem.process.Kill();
                    dwPID = LaunchClient(path, args, (GWML_FLAGS)((datfix ? 2 : 3) | (nologin ? 4 : 0)), out hThread);
                    proc  = Process.GetProcessById((int)dwPID);
                    mem   = new GWCAMemory(proc);
                }
                catch (Exception)
                {
                    MessageBox.Show("This Guild Wars executable is in a suspended state.\nPlease restart the launcher as admin.", "GWMC - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ResumeThread(hThread);
                    CloseHandle(hThread);
                    return(null);
                }
            }
            string dllpath = Directory.GetCurrentDirectory() + "\\plugins";

            if (Directory.Exists(dllpath))
            {
                string[] files = Directory.GetFiles(dllpath, "*.dll");
                foreach (string file in files)
                {
                    mem.LoadModule(file);
                }
            }

            dllpath = Path.GetDirectoryName(path) + "\\plugins";
            if (Directory.Exists(dllpath))
            {
                string[] files = Directory.GetFiles(dllpath, "*.dll");
                foreach (string file in files)
                {
                    mem.LoadModule(file);
                }
            }

            if (mods != null)
            {
                foreach (var mod in mods)
                {
                    if (mod.type == ModType.kModTypeDLL && File.Exists(mod.fileName))
                    {
                        mem.LoadModule(mod.fileName);
                    }
                }
            }

            ResumeThread(hThread);
            CloseHandle(hThread);

            return(mem);
        }
        public static GWCAMemory LaunchClient(string path, string args, bool datfix, bool nologin = false, bool elevated = false, List <Mod> mods = null)
        {
            try
            {
                var regSrc = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Src", null);
                if (regSrc != null && (string)regSrc != Path.GetFullPath(path))
                {
                    Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Src", Path.GetFullPath(path));
                    Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\ArenaNet\\Guild Wars", "Path", Path.GetFullPath(path));
                }

                regSrc = Registry.GetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Src", null);
                if (regSrc != null && (string)regSrc != Path.GetFullPath(path))
                {
                    Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Src", Path.GetFullPath(path));
                    Registry.SetValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\ArenaNet\\Guild Wars", "Path", Path.GetFullPath(path));
                }
            }
            catch (System.UnauthorizedAccessException)
            {
                if (elevated)
                {
                    MessageBox.Show("Insufficient access rights.\nPlease restart the launcher as admin.",
                                    "GWMC - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(null);
                }
            }

            var  hThread = IntPtr.Zero;
            uint dwPid   = NativeMethods.LaunchClient(path, args, ((int)GWML_FLAGS.KEEP_SUSPENDED | (datfix ? 0 : (int)GWML_FLAGS.NO_DATFIX) | (nologin ? (int)GWML_FLAGS.NO_LOGIN : 0) | (elevated ? (int)GWML_FLAGS.ELEVATED : 0)), out hThread);
            var  proc    = Process.GetProcessById((int)dwPid);
            var  mem     = new GWCAMemory(proc);

            if (mem.process.Threads[0].ThreadState == ThreadState.Wait && mem.process.Threads[0].WaitReason == ThreadWaitReason.Suspended)
            {
                try
                {
                    mem.process.Kill();
                    dwPid = NativeMethods.LaunchClient(path, args, ((int)GWML_FLAGS.KEEP_SUSPENDED | (datfix ? 0 : (int)GWML_FLAGS.NO_DATFIX) | (nologin ? (int)GWML_FLAGS.NO_LOGIN : 0) | (elevated ? (int)GWML_FLAGS.ELEVATED : 0)), out hThread);
                    proc  = Process.GetProcessById((int)dwPid);
                    mem   = new GWCAMemory(proc);
                }
                catch (Exception)
                {
                    MessageBox.Show("This Guild Wars executable is in a suspended state.\nPlease restart the launcher as admin.", "GWMC - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    NativeMethods.ResumeThread(hThread);
                    NativeMethods.CloseHandle(hThread);
                    return(null);
                }
            }
            string dllpath = Directory.GetCurrentDirectory() + "\\plugins";

            if (Directory.Exists(dllpath))
            {
                string[] links = Directory.GetFiles(dllpath, "*.lnk");
                string[] files = Directory.GetFiles(dllpath, "*.dll");
                foreach (string link in links)
                {
                    var shell = new WshShell();
                    var lnk   = (IWshShortcut)shell.CreateShortcut(link);

                    if (lnk.TargetPath.EndsWith(".dll"))
                    {
                        mem.LoadModule(lnk.TargetPath);
                    }
                }
                foreach (string file in files)
                {
                    mem.LoadModule(file);
                }
            }

            dllpath = Path.GetDirectoryName(path) + "\\plugins";
            if (Directory.Exists(dllpath))
            {
                string[] links = Directory.GetFiles(dllpath, "*.lnk");
                string[] files = Directory.GetFiles(dllpath, "*.dll");
                foreach (string link in links)
                {
                    var shell = new WshShell();
                    var lnk   = (IWshShortcut)shell.CreateShortcut(link);

                    if (lnk.TargetPath.EndsWith(".dll"))
                    {
                        mem.LoadModule(lnk.TargetPath);
                    }
                }
                foreach (string file in files)
                {
                    mem.LoadModule(file);
                }
            }

            if (mods != null)
            {
                foreach (Mod mod in mods.Where(mod => mod.type == ModType.kModTypeDLL && File.Exists(mod.fileName)))
                {
                    mem.LoadModule(mod.fileName);
                }
            }

            NativeMethods.ResumeThread(hThread);
            NativeMethods.CloseHandle(hThread);

            return(mem);
        }