示例#1
0
 private void stopButton_Click(object sender, RoutedEventArgs e)
 {
     UOM.SetStatusLabel(Strings.Stoppingscript);
     ScriptCompiler.StopScript();
     Events.General.ClearEvents();
     Events.IncomingPackets.ClearEvents();
     Events.OutgoingPackets.ClearEvents();
     Events.LowLevel.ClearEvents();
     UpdateButtonStatus(startButton, true);
     UpdateButtonStatus(stopButton, false);
     UOM.SetStatusLabel(Strings.Ready);
 }
示例#2
0
        private void checkUpdate_Click(object sender, RoutedEventArgs e)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            startInfo.FileName         = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Updater.exe");
            NativeMethods.SafeProcessHandle hProcess;
            NativeMethods.SafeThreadHandle  hThread;
            uint pid, tid;

            UOM.SetStatusLabel("Launching Updater");
            NativeMethods.CreateProcess(startInfo, false, out hProcess, out hThread, out pid, out tid);
        }
示例#3
0
 private void startButton_Click(object sender, RoutedEventArgs e)
 {
     if (ScriptCompiler.Compile(Assembly.GetExecutingAssembly().Location, scriptTextBox.Text))
     {
         UOM.SetStatusLabel(Strings.Scriptrunning);
         UpdateButtonStatus(startButton, false);
         UpdateButtonStatus(stopButton, true);
     }
     else
     {
         UOM.SetStatusLabel(Strings.Compilererror);
     }
 }
示例#4
0
        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            int index;

            if (ClientLauncher.Launch(MainWindow.CurrentOptions, out index))
            {
                UOM.SetStatusLabel(Strings.Clientstarted);
            }
            else
            {
                UOM.SetStatusLabel(Strings.Errorstartingclient);
                MessageBox.Show(Strings.Errorstartingclient, Strings.Error);
            }
        }
示例#5
0
 private void MainWindow_Closing(object sender, CancelEventArgs e)
 {
     UOM.SetStatusLabel(Strings.Closing);
     UOM.Dispose();
     aboutWindow.CancelEnabled   = false;
     optionsWindow.CancelEnabled = false;
     aboutWindow.Close();
     optionsWindow.Close();
     if (assemblyPicker != null)
     {
         assemblyPicker.CancelEnabled = false;
         assemblyPicker.Close();
     }
     App.Current.Shutdown();
 }
示例#6
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);
        }
示例#7
0
 private void process_Exited(object sender, EventArgs e)
 {
     UOM.SetStatusLabel(Strings.Clientexited);
 }
示例#8
0
 private void ScriptCompiler_ScriptFinished()
 {
     UpdateButtonStatus(startButton, true);
     UpdateButtonStatus(stopButton, false);
     UOM.SetStatusLabel(Strings.Scriptstopped);
 }
示例#9
0
        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);
        }
示例#10
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);
            }
        }
示例#11
0
        public static bool Launch(OptionsData options, out int index)
        {
            NativeMethods.SafeProcessHandle   hProcess           = new NativeMethods.SafeProcessHandle();
            NativeMethods.SafeThreadHandle    hThread            = new NativeMethods.SafeThreadHandle();
            NativeMethods.PROCESS_INFORMATION processInformation = new NativeMethods.PROCESS_INFORMATION();
            NativeMethods.STARTUPINFO         startInfo          = new NativeMethods.STARTUPINFO();

            Environment.SetEnvironmentVariable("QT_QPA_PLATFORM_PLUGIN_PATH", Path.Combine(options.UOSFolder, "Platforms"));
            Environment.SetEnvironmentVariable("PATH", options.UOSFolder);

            StringBuilder param = new StringBuilder();

            param.Append(String.Format("-uo \"{0}\" ", options.UOFolder));
            param.Append(String.Format("-core \"{0}\" ", options.UOSFolder));
            param.Append(String.Format("-shard \"{0}\" ", options.Server));
            param.Append(String.Format("-port \"{0}\" ", options.Port));
            param.Append("-encryption \"Yes\"");
            if (!options.PatchClientEncryptionUOM)
            {
                param.Append("-useEncryption \"Yes\"");
            }

            index = -1;

            UOM.SetStatusLabel(Strings.Launchingclient);

            if (NativeMethods.CreateProcess(options.UOClientPath, param, null, null, false, NativeMethods.CREATE_SUSPENDED, IntPtr.Zero, options.UOFolder, startInfo, processInformation))
            {
                hThread.InitialSetHandle(processInformation.hThread);
                hProcess.InitialSetHandle(processInformation.hProcess);

                IntPtr hModule        = NativeMethods.LoadLibrary("kernel32.dll");
                IntPtr loadLibrary    = NativeMethods.GetProcAddress(hModule, "LoadLibraryA");
                IntPtr getProcAddress = NativeMethods.GetProcAddress(hModule, "GetProcAddress");

                NativeMethods.CONTEXT context = new NativeMethods.CONTEXT();
                context.ContextFlags = 0x10000 | 0x01 | 0x02 | 0x04;
                NativeMethods.GetThreadContext(hThread.DangerousGetHandle(), ref context);

                uint origEip = context.Eip;

                IntPtr dataAlloc = NativeMethods.VirtualAllocEx(hProcess.DangerousGetHandle(), IntPtr.Zero, (UIntPtr)256, NativeMethods.AllocationType.Commit | NativeMethods.AllocationType.Reserve, NativeMethods.MemoryProtection.ExecuteReadWrite);
                if (dataAlloc == null)
                {
                    UOM.SetStatusLabel(Strings.Memoryallocationfailed);
                    return(false);
                }

                int    codePosition   = 0;
                IntPtr dllPathAddress = dataAlloc + codePosition;
                string dllPath        = Path.Combine(options.UOSFolder, "UOS.dll") + '\0';
                codePosition += dllPath.Length;

                Memory.Write(hProcess.DangerousGetHandle(), dllPathAddress, Encoding.ASCII.GetBytes(dllPath), false);

                IntPtr dllFunctionAddress = dataAlloc + codePosition;
                string dllFunction        = "Install\0";
                Memory.Write(hProcess.DangerousGetHandle(), dllFunctionAddress, Encoding.ASCII.GetBytes(dllFunction), false);
                codePosition += dllFunction.Length;

                codePosition += 5;
                IntPtr codeStart = dataAlloc + codePosition;

                byte[] code =
                {
                    0x9C /* 00:00 PUSHFD */,
                    0x60 /* 01:01 PUSHAD */,
                    0x68,                                           0x00, 0x00, 0x00,              0x00 /* 2:6 PUSH dllName */,
                    0xB8,                                           0x00, 0x00, 0x00,    0x00 /* 7:11 MOV eax, LoadLibraryA */,
                    0xFF,                      0xD0 /* 12:13 CALL eax */,
                    0xBB,                                           0x00, 0x00, 0x00,        0x00 /* 14:18 MOV ebx, dllFunc */,
                    0x53 /* 19:19 PUSH ebx */,
                    0x50 /* 20:20 PUSH eax */,
                    0xB9,                                           0x00, 0x00, 0x00, 0x00 /* 21:25 MOV ecx, GetProcAddress */,
                    0xFF,                      0xD1 /* 26:27 CALL ecx */,
                    0xFF,                      0xD0 /* 28:29 CALL eax */,
                    0x61 /* 30:30 POPAD */,
                    0x9D /* 31:31 POPFD */,
                    0xE9,                                           0x00, 0x00, 0x00, 0x00 /* 32:36 JMP origEip */
                };

                IntPtr eipPtr = (IntPtr)origEip - ((int)dataAlloc + codePosition + code.Length);

                Buffer.BlockCopy(BitConverter.GetBytes((int)dllPathAddress), 0, code, 3, 4);
                Buffer.BlockCopy(BitConverter.GetBytes((int)loadLibrary), 0, code, 8, 4);
                Buffer.BlockCopy(BitConverter.GetBytes((int)dllFunctionAddress), 0, code, 15, 4);
                Buffer.BlockCopy(BitConverter.GetBytes((int)getProcAddress), 0, code, 22, 4);
                Buffer.BlockCopy(BitConverter.GetBytes((int)eipPtr), 0, code, 33, 4);

                Memory.Write(hProcess.DangerousGetHandle(), codeStart, code, false);

                context.Eip = (uint)codeStart;
                NativeMethods.SetThreadContext(hThread.DangerousGetHandle(), ref context);
                NativeMethods.ResumeThread(hThread.DangerousGetHandle());

                hProcess.Dispose();
                hThread.Dispose();

                return(ClientLauncher.Attach(processInformation.dwProcessId, options, true, out index));
            }
            UOM.SetStatusLabel(Strings.Errorstartingclient);
            return(false);
        }
示例#12
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);
            }
        }