コード例 #1
0
        /// <summary>
        /// Moves the client parent directory.
        /// </summary>
        /// <param name="destination">Destination directory of the clients.</param>
        public void MoveClientParentDirectory(string destination)
        {
            // Create the parent directory.
            var existingParentDirectory = this.systemInfo.SystemFileLocation;

            Directory.CreateDirectory(destination);
            foreach (var manifestEntry in this.Patcher.Manifest.Manifest)
            {
                manifestEntry.EntryDirectory = manifestEntry.EntryDirectory.Replace(existingParentDirectory.Replace("\\", "/"), destination.Replace("\\", "/"));
            }
            this.Patcher.Manifest.Save();

            // Set the parent directory.
            this.systemInfo.Settings.ClientParentLocation = destination;
            this.systemInfo.SaveSettings();

            // Move the clients.
            foreach (var clientDirectory in Directory.GetDirectories(existingParentDirectory))
            {
                var clientDirectoryName = new DirectoryInfo(clientDirectory).Name;
                if (File.Exists(Path.Combine(clientDirectory, "legouniverse.exe")))
                {
                    DirectoryExtensions.Move(clientDirectory, Path.Combine(destination, clientDirectoryName));
                }
            }

            // Reload the patches.
            this.Patcher = new ClientPatcher(systemInfo);
        }
コード例 #2
0
 void scPatcher_Checked(object sender, RoutedEventArgs e)
 {
     txtFunction.Text = txtGhostText.Text = ((TextVariables)this.DataContext).ClientPatcher.ToUpper();
     grdControls.Children.Clear();
     myClientPatcher          = new ClientPatcher(myUserPrefs);
     myClientPatcher.OnError += new EventHandler <ErrorMessageEventArgs>(myClientLauncher_OnError);
     grdControls.Children.Add(myClientPatcher);
     myClientPatcher.PatchStarted   += new EventHandler(myClientPatcher_PatchStarted);
     myClientPatcher.PatchCompleted += new EventHandler(myClientPatcher_PatchCompleted);
 }
コード例 #3
0
 /// <summary>
 /// Creates a Client instance.
 /// </summary>
 /// <param name="systemInfo">Information of the system.</param>
 public ClientRunner(SystemInfo systemInfo)
 {
     this.systemInfo = systemInfo;
     this.Patcher    = new ClientPatcher(systemInfo);
     this.Runtime    = new ClientRuntime(systemInfo);
 }
コード例 #4
0
        public string Start(string path)
        {
            Process clientProcess = null;

            try {
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.WorkingDirectory = path;
                startInfo.FileName         = Path.Combine(path, "client.exe");

                UOMachine.NativeMethods.SafeProcessHandle hProcess;
                UOMachine.NativeMethods.SafeThreadHandle  hThread;
                uint pid, tid;

                if (UOMachine.NativeMethods.CreateProcess(startInfo, true, out hProcess, out hThread, out pid, out tid))
                {
                    ClientPatcher.MultiPatch(hProcess.DangerousGetHandle());
                    bool result = false;
                    m_AddressLock = new object();
                    clientProcess = Process.GetProcessById((int)pid);

                    UOMachine.IPC.Network.Initialize();
                    UOMachine.Utility.Log.Initialize("UnitTests" + DateTime.Now.ToString("[MM - dd - yyyy HH.mm.ss] ") + ".txt");
                    InternalEventHandler.IPCHandler.Initialize();

                    UOMachine.NativeMethods.ResumeThread(hThread.DangerousGetHandle());

                    ClientInfo ci = new ClientInfo(clientProcess);

                    int instance = 0;
                    ClientInfoCollection.ClientList[instance] = ci;
                    ClientInfoCollection.Count = 1;

                    ulong len = (ulong)ci.EntryPoint - (ulong)ci.BaseAddress;
                    UOMachine.NativeMethods.GainMemoryAccessEx(ci.Handle, ci.BaseAddress, len);

                    string channelName = null;
                    RemoteHooking.IpcCreateServer <LoginServerTest>(ref channelName, System.Runtime.Remoting.WellKnownObjectMode.SingleCall);
                    RemoteHooking.Inject(clientProcess.Id, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UnitTests.dll"), null, channelName);

                    ci.InstallMacroHook();
                    Macro.ChangeServer(instance, "127.0.0.1", 2593);

                    Thread.Sleep(10000);

                    lock (m_AddressLock)
                    {
                        GumpInfo[] gi = Macro.GetGumpList(instance);
                        foreach (GumpInfo g in gi)
                        {
                            if (g.Type == "MainMenu gump")
                            {
                                foreach (GumpInfo g2 in g.SubGumps)
                                {
                                    if (g2.Type == "AcctLogin gump")
                                    {
                                        if (ci.DateStamp > 0x43A06A35)
                                        {
                                            g2.CallFunction(26);
                                        }
                                        else
                                        {
                                            g2.CallFunction(23);
                                        }
                                    }
                                }
                            }
                        }
                        result = Monitor.Wait(m_AddressLock, 60000);
                    }

                    UOMachine.IPC.Network.Dispose();
                    Log.Dispose();
                    UOMachine.NativeMethods.TerminateProcess(Process.GetProcessById(clientProcess.Id).Handle, 0);

                    return(m_Address);
                }
            } catch (Exception)
            {
                UOMachine.IPC.Network.Dispose();
                Log.Dispose();
                UOMachine.NativeMethods.TerminateProcess(Process.GetProcessById(clientProcess.Id).Handle, 0);
                throw;
            }
            return(null);
        }