示例#1
0
        public void LoadOptions(OptionsData options)
        {
            switch (options.CacheLevel)
            {
                case 0:
                    radioButtonNone.IsChecked = true;
                    radioButtonIndices.IsChecked = false;
                    radioButtonFull.IsChecked = false;
                    break;
                case 1:
                    radioButtonNone.IsChecked = false;
                    radioButtonIndices.IsChecked = true;
                    radioButtonFull.IsChecked = false;
                    break;
                case 2:
                    radioButtonNone.IsChecked = false;
                    radioButtonIndices.IsChecked = false;
                    radioButtonFull.IsChecked = true;
                    break;

            }
            textBoxUO.Text = options.UOFolder;
            textBoxRazor.Text = options.RazorFolder;
            textBoxUOS.Text = options.UOSFolder;
            textBoxUOSExe.Text = options.UOSExePath;
            textBoxSize.Text = options.TextEditorOptions.IndentationSize.ToString();
            textBoxServer.Text = options.Server;
            textBoxPort.Text = options.Port.ToString();
            textBoxClient.Text = options.UOClientPath;

            checkBoxEncryptedServer.IsChecked = options.EncryptedServer;
            checkBoxPatchClient.IsChecked = options.PatchClientEncryption;
            checkBoxEncryption.IsChecked = options.PatchClientEncryptionUOM;
            checkBoxStamina.IsChecked = options.PatchStaminaCheck;
            checkBoxLight.IsChecked = options.PatchAlwaysLight;
            checkBoxGameSize.IsChecked = options.PatchGameSize;
            if (options.PatchGameSizeWidth < 800)
                options.PatchGameSizeWidth = 800;
            if (options.PatchGameSizeHeight < 600)
                options.PatchGameSizeHeight = 600;
            gameWidth.Text = options.PatchGameSizeWidth.ToString();
            gameHeight.Text = options.PatchGameSizeHeight.ToString();

            if (options.TextEditorOptions.ConvertTabsToSpaces)
                checkBoxConvert.IsChecked = true;
            else checkBoxConvert.IsChecked = false;
            if (options.TextEditorOptions.CutCopyWholeLine)
                checkBoxCopy.IsChecked = true;
            else checkBoxCopy.IsChecked = false;
            if (options.TextEditorOptions.ShowBoxForControlCharacters)
                checkBoxControl.IsChecked = true;
            else checkBoxControl.IsChecked = false;
            if (options.TextEditorOptions.ShowSpaces)
                checkBoxSpace.IsChecked = true;
            else checkBoxSpace.IsChecked = false;
            if (options.TextEditorOptions.ShowTabs)
                checkBoxTab.IsChecked = true;
            else checkBoxTab.IsChecked = false;
        }
示例#2
0
 private void OptionsWindow_OptionsChangedEvent(OptionsData optionsData)
 {
     if (waitingForOptions)
     {
         if (optionsData.IsValid())
         {
             waitingForOptions = false;
         }
         else
         {
             MessageBox.Show("Invalid value(s) present in options.xml, please fix.", "Error");
             optionsWindow.Show();
         }
     }
     if (optionsData.CacheLevel != myCurrentOptions.CacheLevel)
     {
         Map.Initialize(optionsData.UOFolder, optionsData.CacheLevel);
     }
     myCurrentOptions      = optionsData;
     scriptTextBox.Options = optionsData.TextEditorOptions;
 }
示例#3
0
 private void Initialize()
 {
     myDropShadow             = new DropShadowEffect();
     myDropShadow.ShadowDepth = 0;
     myDropShadow.BlurRadius  = 8;
     myDropShadow.Color       = Colors.Black;
     myStartButtonWidth       = startButton.Width;
     myStopButtonWidth        = stopButton.Width;
     myAddButtonWidth         = addButton.Width;
     myRazorButtonWidth       = razorButton.Width;
     myStartButtonMargin      = startButton.Margin;
     myStopButtonMargin       = stopButton.Margin;
     myAddButtonMargin        = addButton.Margin;
     myRazorButtonMargin      = razorButton.Margin;
     mySteamButtonWidth       = steamButton.Width;
     mySteamButtonMargin      = steamButton.Margin;
     stopButton.IsEnabled     = false;
     razorButton.IsEnabled    = false;
     addButton.IsEnabled      = false;
     stopButton.Opacity       = myDisabledOpacity;
     Closing += new CancelEventHandler(MainWindow_Closing);
     TreeViewUpdater.Initialize(clientTreeView);
     OptionsWindow.OptionsChangedEvent   += new OptionsWindow.dOptionsChanged(OptionsWindow_OptionsChangedEvent);
     OptionsWindow.OptionsCancelledEvent += new OptionsWindow.dOptionsCancelled(OptionsWindow_OptionsCancelledEvent);
     ScriptCompiler.ScriptFinishedEvent  += new ScriptCompiler.dScriptFinished(ScriptCompiler_ScriptFinished);
     aboutWindow      = new About();
     optionsWindow    = new OptionsWindow();
     myCurrentOptions = OptionsData.Deserialize("options.xml");
     CheckOptions(myCurrentOptions);
     if (!UOM.Initialize(this))
     {
         MessageBox.Show("Error initializing UO Machine, please try again.", "Error");
         UOM.Dispose();
         UOM.ShutDown();
         return;
     }
     PrepareTextEditor();
     razorButton.IsEnabled = true;
     addButton.IsEnabled   = true;
 }
示例#4
0
 private void OptionsWindow_OptionsChangedEvent(OptionsData optionsData)
 {
     if (waitingForOptions)
     {
         if (optionsData.IsValid())
         {
             waitingForOptions = false;
         }
         else
         {
             MessageBox.Show(Strings.Invalidvaluepresentinoptions, Strings.Error);
             optionsWindow.Show();
         }
     }
     if (optionsData.CacheLevel != myCurrentOptions.CacheLevel)
     {
         Map.Initialize(optionsData.UOFolder, optionsData.CacheLevel);
     }
     myCurrentOptions = optionsData;
     CheckOptions(optionsData);
     scriptTextBox.Options = optionsData.TextEditorOptions;
 }
示例#5
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);
        }
示例#6
0
        public static OptionsData CreateDefault()
        {
            OptionsData od = new OptionsData();

            od.UOFolder = RegistryHelper.GetUOPath();
            if (od.UOFolder == null)
            {
                od.UOFolder = @"C:\";
            }
            od.UOClientPath             = Path.Combine(od.UOFolder, "client.exe");
            od.Server                   = "localhost";
            od.PatchAlwaysLight         = true;
            od.Port                     = 2593;
            od.PatchClientEncryption    = true;
            od.RazorFolder              = RegistryHelper.GetRazorPath();
            od.CacheLevel               = 0;
            od.TextEditorOptions        = new TextEditorOptions();
            od.PatchStaminaCheck        = true;
            od.PatchClientEncryptionUOM = false;
            od.PatchGameSize            = false;
            Serialize("options.xml", od);
            return(od);
        }
示例#7
0
 private void OptionsWindow_OptionsChangedEvent( OptionsData optionsData )
 {
     if (waitingForOptions)
     {
         if (optionsData.IsValid())
         {
             waitingForOptions = false;
         }
         else
         {
             MessageBox.Show( Strings.Invalidvaluepresentinoptions, Strings.Error );
             optionsWindow.Show();
         }
     }
     if (optionsData.CacheLevel != myCurrentOptions.CacheLevel)
         Map.Initialize( optionsData.UOFolder, optionsData.CacheLevel );
     myCurrentOptions = optionsData;
     CheckOptions( optionsData );
     scriptTextBox.Options = optionsData.TextEditorOptions;
 }
示例#8
0
        private void Initialize()
        {
            UpdateButtonStatus( stopButton, false );
            UpdateButtonStatus( razorButton, false );
            UpdateButtonStatus( addButton, false );

            Closing += new CancelEventHandler( MainWindow_Closing );
            TreeViewUpdater.Initialize( clientTreeView );
            OptionsWindow.OptionsChangedEvent += new OptionsWindow.dOptionsChanged( OptionsWindow_OptionsChangedEvent );
            OptionsWindow.OptionsCancelledEvent += new OptionsWindow.dOptionsCancelled( OptionsWindow_OptionsCancelledEvent );
            ScriptCompiler.ScriptFinishedEvent += new ScriptCompiler.dScriptFinished( ScriptCompiler_ScriptFinished );
            aboutWindow = new About();
            optionsWindow = new OptionsWindow();
            myCurrentOptions = OptionsData.Deserialize( "options.xml" );
            CheckOptions( myCurrentOptions );
            if (!UOM.Initialize( this ))
            {
                MessageBox.Show( Strings.Errorinitializing, Strings.Error );
                UOM.Dispose();
                UOM.ShutDown();
                return;
            }
            PrepareTextEditor();
            UpdateButtonStatus( addButton, true );
        }
示例#9
0
        private void CheckOptions( OptionsData optionsData )
        {
            if (!optionsData.IsValid())
            {
                waitingForOptions = true;
                MessageBox.Show( Strings.Invalidvaluepresentinoptions, Strings.Error );
                optionsWindow.LoadOptions( OptionsData.CreateDefault() );
                optionsWindow.Show();
                while (waitingForOptions)
                {
                    try { Application.Current.Dispatcher.Invoke( DispatcherPriority.Background, new ThreadStart( delegate { } ) ); }
                    catch { }
                    Thread.Sleep( 50 );
                }
            }

            UpdateButtonStatus( razorButton, false );
            UpdateButtonStatus( steamButton, false );

            if (optionsData.IsRazorValid())
            {
                UpdateButtonStatus( razorButton, true );
            }

            if (optionsData.IsSteamValid())
            {
                UpdateButtonStatus( steamButton, true );
            }
        }
示例#10
0
 private static void OnOptionsChanged(OptionsData optionsData)
 {
     dOptionsChanged handler = OptionsChangedEvent;
     if (handler != null) handler(optionsData);
 }
示例#11
0
        public void LoadOptions(OptionsData options)
        {
            switch (options.CacheLevel)
            {
            case 0:
                radioButtonNone.IsChecked    = true;
                radioButtonIndices.IsChecked = false;
                radioButtonFull.IsChecked    = false;
                break;

            case 1:
                radioButtonNone.IsChecked    = false;
                radioButtonIndices.IsChecked = true;
                radioButtonFull.IsChecked    = false;
                break;

            case 2:
                radioButtonNone.IsChecked    = false;
                radioButtonIndices.IsChecked = false;
                radioButtonFull.IsChecked    = true;
                break;
            }
            textBoxUO.Text     = options.UOFolder;
            textBoxRazor.Text  = options.RazorFolder;
            textBoxUOS.Text    = options.UOSFolder;
            textBoxSize.Text   = options.TextEditorOptions.IndentationSize.ToString();
            textBoxServer.Text = options.Server;
            textBoxPort.Text   = options.Port.ToString();
            textBoxClient.Text = options.UOClientPath;

            checkBoxEncryptedServer.IsChecked = options.EncryptedServer;
            checkBoxPatchClient.IsChecked     = options.PatchClientEncryption;
            checkBoxEncryption.IsChecked      = options.PatchClientEncryptionUOM;
            checkBoxStamina.IsChecked         = options.PatchStaminaCheck;
            checkBoxLight.IsChecked           = options.PatchAlwaysLight;

            if (options.TextEditorOptions.ConvertTabsToSpaces)
            {
                checkBoxConvert.IsChecked = true;
            }
            else
            {
                checkBoxConvert.IsChecked = false;
            }
            if (options.TextEditorOptions.CutCopyWholeLine)
            {
                checkBoxCopy.IsChecked = true;
            }
            else
            {
                checkBoxCopy.IsChecked = false;
            }
            if (options.TextEditorOptions.ShowBoxForControlCharacters)
            {
                checkBoxControl.IsChecked = true;
            }
            else
            {
                checkBoxControl.IsChecked = false;
            }
            if (options.TextEditorOptions.ShowSpaces)
            {
                checkBoxSpace.IsChecked = true;
            }
            else
            {
                checkBoxSpace.IsChecked = false;
            }
            if (options.TextEditorOptions.ShowTabs)
            {
                checkBoxTab.IsChecked = true;
            }
            else
            {
                checkBoxTab.IsChecked = false;
            }
        }
示例#12
0
 public static OptionsData CreateDefault()
 {
     OptionsData od = new OptionsData();
     od.UOFolder = RegistryHelper.GetUOPath();
     if (od.UOFolder == null)
         od.UOFolder = @"C:\";
     od.UOClientPath = Path.Combine( od.UOFolder, "client.exe" );
     od.Server = "localhost";
     od.PatchAlwaysLight = true;
     od.Port = 2593;
     od.PatchClientEncryption = true;
     od.RazorFolder = RegistryHelper.GetRazorPath();
     od.CacheLevel = 0;
     od.TextEditorOptions = new TextEditorOptions();
     od.PatchStaminaCheck = true;
     od.PatchClientEncryptionUOM = false;
     od.PatchGameSize = false;
     Serialize( "options.xml", od );
     return od;
 }
示例#13
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;
            }
        }
示例#14
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;
        }
示例#15
0
        private bool SaveOptions()
        {
            OptionsData od = new OptionsData();
            ushort port;
            if (ushort.TryParse(textBoxPort.Text, out port))
                od.Port = port;
            else
            {
                System.Windows.MessageBox.Show( Strings.Invalidvalueforport, Strings.Error );
                textBoxPort.Text = "";
                return false;
            }
            od.Server = textBoxServer.Text;
            if ((bool)radioButtonNone.IsChecked) od.CacheLevel = 0;
            else if ((bool)radioButtonIndices.IsChecked) od.CacheLevel = 1;
            else if ((bool)radioButtonFull.IsChecked) od.CacheLevel = 2;
            od.PatchClientEncryption = (bool)checkBoxPatchClient.IsChecked;
            od.EncryptedServer = (bool)checkBoxEncryptedServer.IsChecked;
            od.PatchClientEncryptionUOM = (bool)checkBoxEncryption.IsChecked;
            od.PatchStaminaCheck = (bool)checkBoxStamina.IsChecked;
            od.PatchAlwaysLight = (bool)checkBoxLight.IsChecked;
            od.PatchGameSize = (bool)checkBoxGameSize.IsChecked;
            od.PatchGameSizeWidth = int.Parse(gameWidth.Text);
            od.PatchGameSizeHeight = int.Parse(gameHeight.Text);
            if (od.PatchGameSizeWidth < 800)
                od.PatchGameSizeWidth = 800;
            if (od.PatchGameSizeHeight < 600)
                od.PatchGameSizeHeight = 600;
            od.UOFolder = textBoxUO.Text;
            od.UOClientPath = textBoxClient.Text;
            od.RazorFolder = textBoxRazor.Text;
            od.UOSFolder = textBoxUOS.Text;
            od.UOSExePath = textBoxUOSExe.Text;
            od.TextEditorOptions.ConvertTabsToSpaces = (bool)checkBoxConvert.IsChecked;
            od.TextEditorOptions.CutCopyWholeLine = (bool)checkBoxCopy.IsChecked;
            od.TextEditorOptions.ShowBoxForControlCharacters = (bool)checkBoxControl.IsChecked;
            od.TextEditorOptions.ShowSpaces = (bool)checkBoxSpace.IsChecked;
            od.TextEditorOptions.ShowTabs = (bool)checkBoxTab.IsChecked;

            int tabSize;
            try { tabSize = Convert.ToInt32(textBoxSize.Text); }
            catch { tabSize = od.TextEditorOptions.IndentationSize; }
            od.TextEditorOptions.IndentationSize = tabSize;

            if (!od.IsValid())
            {
                System.Windows.MessageBox.Show( Strings.Invalidvaluepresentinoptions, Strings.Error );
                return false;
            }
            OnOptionsChanged(od);
            OptionsData.Serialize("options.xml", od);
            return true;
        }
示例#16
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);
            }
        }
示例#17
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);
        }
示例#18
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);
            }
        }
示例#19
0
        public static void Serialize( string fileName, OptionsData optionsData )
        {
            XmlWriter xw = null;
            try
            {
                XmlWriterSettings xws = new XmlWriterSettings();
                xws.Encoding = Encoding.Unicode;
                xws.CloseOutput = true;
                xws.Indent = true;
                xws.NewLineOnAttributes = true;
                xw = XmlWriter.Create( fileName, xws );
                XmlSerializer xs = new XmlSerializer( typeof( OptionsData ) );
                xs.Serialize( xw, optionsData );
                xw.Flush();
                xw.Close();
            }
            catch (Exception ex)
            {
                if (xw != null)
                {
                    try
                    {

                        xw.Flush();
                        xw.Close();
                    }
                    catch { }
                }
                ShowErrorMessage( "saving options to file", ex );
            }
        }
示例#20
0
        private bool SaveOptions()
        {
            OptionsData od = new OptionsData();
            ushort      port;

            if (ushort.TryParse(textBoxPort.Text, out port))
            {
                od.Port = port;
            }
            else
            {
                System.Windows.MessageBox.Show(Strings.Invalidvalueforport, Strings.Error);
                textBoxPort.Text = "";
                return(false);
            }
            od.Server = textBoxServer.Text;
            if ((bool)radioButtonNone.IsChecked)
            {
                od.CacheLevel = 0;
            }
            else if ((bool)radioButtonIndices.IsChecked)
            {
                od.CacheLevel = 1;
            }
            else if ((bool)radioButtonFull.IsChecked)
            {
                od.CacheLevel = 2;
            }
            od.PatchClientEncryption    = (bool)checkBoxPatchClient.IsChecked;
            od.EncryptedServer          = (bool)checkBoxEncryptedServer.IsChecked;
            od.PatchClientEncryptionUOM = (bool)checkBoxEncryption.IsChecked;
            od.PatchStaminaCheck        = (bool)checkBoxStamina.IsChecked;
            od.PatchAlwaysLight         = (bool)checkBoxLight.IsChecked;
            od.PatchGameSize            = (bool)checkBoxGameSize.IsChecked;
            od.PatchGameSizeWidth       = int.Parse(gameWidth.Text);
            od.PatchGameSizeHeight      = int.Parse(gameHeight.Text);
            if (od.PatchGameSizeWidth < 800)
            {
                od.PatchGameSizeWidth = 800;
            }
            if (od.PatchGameSizeHeight < 600)
            {
                od.PatchGameSizeHeight = 600;
            }
            od.UOFolder     = textBoxUO.Text;
            od.UOClientPath = textBoxClient.Text;
            od.RazorFolder  = textBoxRazor.Text;
            od.UOSFolder    = textBoxUOS.Text;
            od.UOSExePath   = textBoxUOSExe.Text;
            od.TextEditorOptions.ConvertTabsToSpaces         = (bool)checkBoxConvert.IsChecked;
            od.TextEditorOptions.CutCopyWholeLine            = (bool)checkBoxCopy.IsChecked;
            od.TextEditorOptions.ShowBoxForControlCharacters = (bool)checkBoxControl.IsChecked;
            od.TextEditorOptions.ShowSpaces = (bool)checkBoxSpace.IsChecked;
            od.TextEditorOptions.ShowTabs   = (bool)checkBoxTab.IsChecked;

            int tabSize;

            try { tabSize = Convert.ToInt32(textBoxSize.Text); }
            catch { tabSize = od.TextEditorOptions.IndentationSize; }
            od.TextEditorOptions.IndentationSize = tabSize;

            if (!od.IsValid())
            {
                System.Windows.MessageBox.Show(Strings.Invalidvaluepresentinoptions, Strings.Error);
                return(false);
            }
            OnOptionsChanged(od);
            OptionsData.Serialize("options.xml", od);
            return(true);
        }
示例#21
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);
        }
示例#22
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;
        }