public static List <Client> GetClients(string version, bool offline)
        {
            List <Client> clients = new List <Client>();

            foreach (Process process in Process.GetProcesses())
            {
                StringBuilder classname = new StringBuilder();
                WinApi.GetClassName(process.MainWindowHandle, classname, 12);

                if (classname.ToString().Equals("TibiaClient", StringComparison.CurrentCultureIgnoreCase))
                {
                    var clientVersion = ClientVersion.GetFromFileVersion(process.MainModule.FileVersionInfo.FileVersion);

                    //Version not supported.
                    if (clientVersion == null)
                    {
                        continue;
                    }

                    if (version == null || clientVersion.FileVersion == version)
                    {
                        var client = new Client(process, clientVersion);
                        if (!offline || !client.LoggedIn)
                        {
                            clients.Add(client);
                        }
                    }
                }
            }
            return(clients);
        }
        public static Client Open(ProcessStartInfo psi)
        {
            var fileVersion = FileVersionInfo.GetVersionInfo(psi.FileName).FileVersion;
            var version     = ClientVersion.GetFromFileVersion(fileVersion);

            if (version == null)
            {
                throw new Exception("The version " + fileVersion + " is not supported.");
            }

            Process p = Process.Start(psi);

            return(new Client(p, version));
        }
        public static Client OpenMC(string path, string arguments)
        {
            var fileVersion = FileVersionInfo.GetVersionInfo(path).FileVersion;
            var version     = ClientVersion.GetFromFileVersion(fileVersion);

            if (version == null)
            {
                throw new Exception("The version " + fileVersion + " is not supported.");
            }

            WinApi.PROCESS_INFORMATION pi = new WinApi.PROCESS_INFORMATION();
            WinApi.STARTUPINFO         si = new WinApi.STARTUPINFO();

            if (arguments == null)
            {
                arguments = "";
            }

            WinApi.CreateProcess(path, " " + arguments, IntPtr.Zero, IntPtr.Zero, false, WinApi.CREATE_SUSPENDED, IntPtr.Zero, Path.GetDirectoryName(path), ref si, out pi);

            Process p = Process.GetProcessById(Convert.ToInt32(pi.dwProcessId));

            var client = new Client(p, version, Path.GetDirectoryName(path));

            Memory.WriteByte(client.ProcessHandle, client.MemoryAddresses.ClientMultiClient, client.MemoryAddresses.ClientMultiClientJMP);

            WinApi.ResumeThread(pi.hThread);
            p.WaitForInputIdle();

            Memory.WriteByte(client.ProcessHandle, client.MemoryAddresses.ClientMultiClient, client.MemoryAddresses.ClientMultiClientJNZ);

            WinApi.CloseHandle(pi.hProcess);
            WinApi.CloseHandle(pi.hThread);

            return(client);
        }