Exemplo n.º 1
0
 internal static void Dispose()
 {
     ScriptCompiler.StopScript();
     ClientInfoCollection.Dispose();
     Log.Dispose();
     InternalEventHandler.IPCHandler.Dispose();
     IPC.Network.Dispose();
 }
Exemplo n.º 2
0
 internal static void OnClientExit(object sender, EventArgs e)
 {
     try
     {
         Process exiting = (Process)sender;
         ClientInfoCollection.RemoveByPid(exiting.Id);
         dClientListChanged handler = null;
         lock (myClientListChangedLock) { handler = myClientListChangedEvent; }
         if (handler != null)
         {
             ThreadPool.QueueUserWorkItem(delegate { handler(); });
         }
         SetStatusLabel(Strings.Clientexited);
     }
     catch { }
 }
Exemplo n.º 3
0
        public Item[] GetEquippedItems()
        {
            List <Item> itemList = new List <Item>(29);

            int[] layerArray = this.GetAllLayers();
            Item  i;

            for (int x = 0; x < layerArray.Length; x++)
            {
                if (layerArray[x] != 0)
                {
                    if (ClientInfoCollection.GetItem(myClient, layerArray[x], out i) && i.Layer != Layer.Invalid)
                    {
                        itemList.Add(i);
                    }
                }
            }
            return(itemList.ToArray());
        }
Exemplo n.º 4
0
 public bool GetEquippedItem(Layer layer, out Item item)
 {
     return(ClientInfoCollection.GetItem(myClient, GetLayer((int)layer), out item));
 }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Get number of running UO clients currently managed by UO Machine.
 /// </summary>
 public static int ActiveClients()
 {
     return(ClientInfoCollection.ActiveClients());
 }
Exemplo n.º 7
0
 /// <summary>
 /// Get array of indices corresponding to active clients.
 /// </summary>
 public static int[] ActiveClientIndices()
 {
     return(ClientInfoCollection.ActiveClientIndices());
 }
Exemplo n.º 8
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);
            }
        }