Exemple #1
0
        public static Client OpenMC(string path, string arguments)
        {
            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,
                                 System.IO.Path.GetDirectoryName(path), ref si, out pi);

            IntPtr  handle = WinApi.OpenProcess(WinApi.PROCESS_ALL_ACCESS, 0, pi.dwProcessId);
            Memory  memory = new Memory(handle);
            Process p      = Process.GetProcessById(Convert.ToInt32(pi.dwProcessId));

            memory.WriteByte((long)Addresses.MultiClient, Addresses.MultiClientJMP);
            WinApi.ResumeThread(pi.hThread);
            p.WaitForInputIdle();
            WinApi.CloseHandle(handle);
            WinApi.CloseHandle(pi.hProcess);
            WinApi.CloseHandle(pi.hThread);

            return(new Client(p));
        }