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); }
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); }
public static bool Attach(uint pid, OptionsData options, bool isRazor, out int index) { lock (myLock) { Process p = null; index = -1; try { Thread.Sleep(2000); p = Process.GetProcessById((int)pid); p.EnableRaisingEvents = true; p.Exited += new EventHandler(UOM.OnClientExit); ClientInfo ci = new ClientInfo(p); Memory.MemoryInit(ci); if (ci.IsValid) { ci.InstallMacroHook(); } else { return(false); } if (!isRazor && options.PatchClientEncryptionUOM) { if (!ClientPatcher.PatchEncryption(p.Handle)) { MessageBox.Show(Strings.Errorpatchingclientencryption, Strings.Error); } } if (ci.DateStamp < 0x4AA52CC4 && options.PatchStaminaCheck) { if (!ClientPatcher.PatchStaminaCheck(p.Handle)) { MessageBox.Show(Strings.Errorpatchingstaminacheck, Strings.Error); } } if (options.PatchAlwaysLight) { if (!ClientPatcher.PatchLight(p.Handle)) { MessageBox.Show(Strings.Errorwithalwayslightpatch, Strings.Error); } } if (options.PatchGameSize) { if (!ClientPatcher.SetGameSize(p.Handle, options.PatchGameSizeWidth, options.PatchGameSizeHeight)) { //Silently fail for now as this will fail on UOSteam. //MessageBox.Show(Strings.Errorsettinggamewindowsize); } } int instance; if (!ClientInfoCollection.AddClient(ci, out instance)) { throw new ApplicationException(String.Concat(Strings.Unknownerror, ": ClientInfoCollection.Add.")); } ci.Instance = instance; index = instance; Macros.Macro.ChangeServer(instance, options.Server, options.Port); Thread.Sleep(500); RemoteHooking.Inject(p.Id, Path.Combine(UOM.StartupPath, "clienthook.dll"), Path.Combine(UOM.StartupPath, "clienthook.dll"), UOM.ServerName); } catch (Exception e) { Utility.Log.LogMessage(e); MessageBox.Show(Strings.Errorinjectingdll, Strings.Error); try { if (p != null) { p.Kill(); } } catch (Win32Exception) { } catch (InvalidOperationException) { } return(false); } UOM.SetStatusLabel(Strings.Attachedtoclient); return(true); } }
public static bool Attach(uint pid, OptionsData options, bool isRazor, out int index) { lock (myLock) { Process p = null; index = -1; try { Thread.Sleep(2000); p = Process.GetProcessById((int)pid); p.EnableRaisingEvents = true; p.Exited += new EventHandler(UOM.OnClientExit); ClientInfo ci = new ClientInfo(p); Memory.MemoryInit(ci); if (ci.IsValid) { ci.InstallMacroHook(); } else { return(false); } if (!isRazor && options.PatchClientEncryptionUOM) { if (!ClientPatcher.PatchEncryption(p.Handle)) { MessageBox.Show("Error patching client encryption!", "Error"); } } if (ci.DateStamp < 0x4AA52CC4 && options.PatchStaminaCheck) { if (!ClientPatcher.PatchStaminaCheck(p.Handle)) { MessageBox.Show("Error patching stamina check!", "Error"); } } if (options.PatchAlwaysLight) { if (!ClientPatcher.PatchLight(p.Handle)) { MessageBox.Show("Error with always light patch!", "Error"); } } int instance; if (!ClientInfoCollection.AddClient(ci, out instance)) { throw new ApplicationException("Unknown error at ClientInfoCollection.Add."); } ci.Instance = instance; index = instance; Macros.Macro.ChangeServer(instance, options.Server, options.Port); Thread.Sleep(500); RemoteHooking.Inject(p.Id, Path.Combine(UOM.StartupPath, "clienthook.dll"), Path.Combine(UOM.StartupPath, "clienthook.dll"), UOM.ServerName); } catch (Exception e) { Utility.Log.LogMessage(e); MessageBox.Show("Error injecting ClientHook.dll into target process. Please try again.", "Error"); try { if (p != null) { p.Kill(); } } catch (Win32Exception) { } catch (InvalidOperationException) { } return(false); } UOM.SetStatusLabel("Status: Attached to client"); return(true); } }