예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
            }
        }