コード例 #1
0
        public static bool Launch(OptionsData options, out int index)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.WorkingDirectory = MainWindow.CurrentOptions.UOFolder;
            startInfo.FileName         = MainWindow.CurrentOptions.UOClientPath;
            index = -1;
            NativeMethods.SafeProcessHandle hProcess;
            NativeMethods.SafeThreadHandle  hThread;
            uint pid, tid;

            UOM.SetStatusLabel(Strings.Launchingclient);
            if (NativeMethods.CreateProcess(startInfo, true, out hProcess, out hThread, out pid, out tid))
            {
                UOM.SetStatusLabel(Strings.Patchingclient);
                if (!ClientPatcher.MultiPatch(hProcess.DangerousGetHandle()))
                {
                    UOM.SetStatusLabel(Strings.MultiUOpatchfailed);
                    hProcess.Dispose();
                    hThread.Dispose();
                    return(false);
                }

                if (NativeMethods.ResumeThread(hThread.DangerousGetHandle()) == -1)
                {
                    UOM.SetStatusLabel(Strings.ResumeThreadfailed);
                    hProcess.Dispose();
                    hThread.Dispose();
                    return(false);
                }

                hProcess.Close();
                hThread.Close();
                return(Attach(pid, options, false, out index));
            }
            UOM.SetStatusLabel(Strings.Processcreationfailed);
            return(false);
        }
コード例 #2
0
ファイル: RazorLauncher.cs プロジェクト: markdwags/UOMachine
        public static bool Launch(OptionsData options, out int index)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.WorkingDirectory = MainWindow.CurrentOptions.UOFolder;
            startInfo.FileName         = MainWindow.CurrentOptions.UOClientPath;
            NativeMethods.SafeProcessHandle hProcess;
            NativeMethods.SafeThreadHandle  hThread;
            uint pid, tid;

            UOM.SetStatusLabel(Strings.Launchingclient);
            index = -1;
            if (NativeMethods.CreateProcess(startInfo, true, out hProcess, out hThread, out pid, out tid))
            {
                UOM.SetStatusLabel(Strings.Patchingclient);

                if (!ClientPatcher.MultiPatch(hProcess.DangerousGetHandle()))
                {
                    UOM.SetStatusLabel(Strings.MultiUOpatchfailed);
                    hProcess.Dispose();
                    hThread.Dispose();
                    return(false);
                }

                if (NativeMethods.ResumeThread(hThread.DangerousGetHandle()) == -1)
                {
                    UOM.SetStatusLabel(Strings.ResumeThreadfailed);
                    hProcess.Dispose();
                    hThread.Dispose();
                    return(false);
                }

                hProcess.Close();
                hThread.Close();
                startInfo = new ProcessStartInfo();
                startInfo.WorkingDirectory = options.RazorFolder;
                startInfo.UseShellExecute  = false;
                startInfo.CreateNoWindow   = true;
                startInfo.WindowStyle      = ProcessWindowStyle.Hidden;
                startInfo.FileName         = Path.Combine(UOM.StartupPath, "RazorLoader.exe");
                string args = "--server " + options.Server + "," + options.Port.ToString();
                args += " --path " + options.RazorFolder;
                if (!options.PatchClientEncryption)
                {
                    args += " --clientenc";
                }
                if (options.EncryptedServer)
                {
                    args += " --serverenc";
                }
                args += " --pid " + pid.ToString();
                startInfo.Arguments = args;
                Process p = new Process();
                p.StartInfo = startInfo;
                p.Start();

                if (ClientLauncher.Attach(pid, options, true, out index))
                {
                    UOM.SetStatusLabel(Strings.Razorsuccessfullylaunched);
                    return(true);
                }
                else
                {
                    UOM.SetStatusLabel(Strings.ErrorattachingtoRazorclient);
                    MessageBox.Show(Strings.ErrorattachingtoRazorclient, Strings.Error);
                }
            }
            return(false);
        }