Esempio n. 1
0
 private void InitConfigArgs()
 {
     ConfigArgs.Add(new ConfigArg()
     {
         Key       = "TransferOfAxes.Zero",
         Value     = "1372.066,0,1013.352",
         ValueType = "Vector3",
         Name      = "坐标转换原点",
         Describe  = "坐标转换原点(偏移)",
         Classify  = "Axes"
     });
     ConfigArgs.Add(new ConfigArg()
     {
         Key       = "TransferOfAxes.Scale",
         Value     = "1.685735,0,1.686961",
         ValueType = "Vector3",
         Name      = "坐标转换比例",
         Describe  = "坐标转换比例",
         Classify  = "Axes"
     });
     ConfigArgs.Add(new ConfigArg()
     {
         Key       = "TransferOfAxes.Direction",
         Value     = "-1,1,-1",
         ValueType = "Vector3",
         Name      = "坐标转换方向",
         Describe  = "坐标转换方向",
         Classify  = "Axes"
     });
 }
        private ConfigArgs ParseConfig()
        {
            if (nudPort.Value <= 0 || nudPort.Value > 65535)
            {
                MessageBox.Show("Invalid port: " + nudPort.Value.ToString() + " !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            IPHostEntry host;

            try
            {
                host = Dns.GetHostEntry(txtIptopatch.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid ip: " + txtIptopatch.Text + " !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            IPAddress ip = null;

            for (int iAddr = 0; iAddr <= host.AddressList.Length; iAddr++)
            {
                if (host.AddressList[iAddr].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                {
                    ip = host.AddressList[iAddr];
                    break;
                }
            }

            if (ip == null)
            {
                MessageBox.Show("Cannot find a valid IPV4 ip for: " + txtIptopatch.Text + " !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }

            if (this.ckbRemind.Checked)
            {
                if (this.txtIptopatch.Text.Length > 0)
                {
                    using (StreamWriter srRead = File.CreateText(StaticData.LAUNCH_CFG))
                    {
                        srRead.Write(this.txtIptopatch.Text.Trim() + "," + this.nudPort.Value.ToString() + "," + this.cmbEncryption.SelectedIndex.ToString());
                    }
                }
            }

            ConfigArgs caTouse = new ConfigArgs();

            caTouse.uPort   = (uint)this.nudPort.Value;
            caTouse.ipHost  = ip;
            caTouse.encType = (ENCRYPTION_PATCH_TYPE)this.cmbEncryption.SelectedIndex;

            return(caTouse);
        }
Esempio n. 3
0
        public override object Convert(object value, object parameter)
        {
            var fe = value as FrameworkElement;

            if (fe == null)
            {
                return(null);
            }

            if (_configArgs == null)
            {
                _configArgs = new ConfigArgs(fe);
            }

            return(_configArgs);
        }
Esempio n. 4
0
        static int Main(string[] args)
        {
            try
            {
                Console.WriteLine("开始执行IISTools工具");
                int iisVersion = IISBaseConfig.GetIISVersion();

                ConfigArgs      argsObj   = new ConfigArgs(args);
                CommandType     exType    = argsObj.GetExecuteType();
                ConfigArgsModel argsModel = argsObj.Parse();
                argsModel.ExecuteType = exType;
                if (exType == CommandType.PrintHelper)
                {
                    Console.WriteLine(PrintHelper.Text());
                    return(0);
                }

                if (iisVersion < 7)
                {
                    argsModel.User32Pool = false;
                }


                IISBaseConfig iis = iisVersion >= 7 ? (IISBaseConfig) new IISConfigEx(argsModel) : (IISBaseConfig) new IISConfig(argsModel);
                iis.CheckParams();
                if (exType == CommandType.CreateWebSite)
                {
                    iis.CreateWebSite();
                }
                if (exType == CommandType.CreateVirtualDir)
                {
                    iis.CreateVirtualDir();
                }
                if (exType == CommandType.Del)
                {
                    iis.RemoveDir();
                }
            }
            catch (CustomException e)
            {
                Console.WriteLine(e.Msg);
                return(e.Code);
            }
            Console.WriteLine("命令执行成功");
            return(1);
        }
Esempio n. 5
0
 public static void Config(ConfigArgs args)
 {
     InvokeCount++;
 }
Esempio n. 6
0
        private void PathOrLaunch(bool bPatch, ConfigArgs caTouse)
        {
            if (caTouse == null)
                return;

            int iResultEncLogin = 0;
            int iResultEncLoginId = 0;
            // ----------------------
            int iResultEncGame = 0;
            // ----------------------
            List<int> iResultIP = new List<int>();
            int iResultIPId = 0;
            // ----------------------
            ENCRYPTION_PATCH_TYPE encType = caTouse.encType;

            // !bPatch
            Process prcTostart = null;
            // bPatch
            FileStream fsToPatch = null;

            if (!bPatch)
            {
                prcTostart = new Process();
                prcTostart.StartInfo.FileName = this.txtUokrPath.Text + @"\" + StaticData.UOKR_CLIENT;
                prcTostart.StartInfo.WorkingDirectory = this.txtUokrPath.Text;

                if (!prcTostart.Start())
                {
                    MessageBox.Show("Cannot start the client !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                try
                {
                    File.Copy(this.txtUokrPath.Text + @"\" + StaticData.UOKR_CLIENT, this.txtUokrPath.Text + @"\" + StaticData.UOKR_PATCHCLIENT, true);
                }
                catch (Exception)
                {
                    MessageBox.Show("Cannot create file " + this.txtUokrPath.Text + @"\" + StaticData.UOKR_PATCHCLIENT + " !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                try
                {
                    fsToPatch = File.Open(this.txtUokrPath.Text + @"\" + StaticData.UOKR_PATCHCLIENT, FileMode.Open, FileAccess.ReadWrite);
                }
                catch (Exception)
                {
                    MessageBox.Show("Cannot open file " + this.txtUokrPath.Text + @"\" + StaticData.UOKR_PATCHCLIENT + " !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            Stream strGeneric;
            if (bPatch)
            {
                strGeneric = fsToPatch;
            }
            else
            {
                strGeneric = new ProcessStream((IntPtr)prcTostart.Id);
            }

            for (iResultIPId = 0; iResultIPId < StaticData.UOKR_IPDATA_VERSION; iResultIPId++)
            {
                List<byte[]> listBytes = StaticData.GetIPData(iResultIPId);
                foreach (byte[] bIpData in listBytes)
                {
                    iResultIP.Add(Utility.Search(strGeneric, bIpData, bPatch));
                }

                if (ListValidValues(iResultIP))
                {
                    break;
                }
                else
                {
                    iResultIP.Clear();
                }
            }

            if (!ListValidValues(iResultIP))
            {
                strGeneric.Close();
                if (!bPatch)
                    prcTostart.Kill();

                MessageBox.Show("Cannot patch IP on the client !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if ((encType == ENCRYPTION_PATCH_TYPE.Login) || (encType == ENCRYPTION_PATCH_TYPE.Both))
            {
                for (iResultEncLoginId = 0; iResultEncLoginId < StaticData.UOKR_LOGDATA_VERSION; iResultEncLoginId++)
                {
                    iResultEncLogin = Utility.Search(strGeneric, StaticData.GetLoginData(iResultEncLoginId), bPatch);
                    if (iResultEncLogin != 0)
                        break;
                }

                if (iResultEncLogin == 0)
                {
                    strGeneric.Close();
                    if (!bPatch)
                        prcTostart.Kill();

                    MessageBox.Show("Cannot patch Login Encryption on the client !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if ((encType == ENCRYPTION_PATCH_TYPE.Game) || (encType == ENCRYPTION_PATCH_TYPE.Both))
            {
                iResultEncGame = Utility.Search(strGeneric, StaticData.UOKR_ENCDATA, bPatch);
                if (iResultEncGame == 0)
                {
                    strGeneric.Close();
                    if (!bPatch)
                        prcTostart.Kill();

                    MessageBox.Show("Cannot patch Game Encryption on the client !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if (bPatch)
            {
                strGeneric.Seek(0, SeekOrigin.Begin);
            }

            List<byte[]> newDataIp = StaticData.GetPatchedIPData(iResultIPId, caTouse.ipHost, caTouse.uPort);
            for(int i = 0; i < newDataIp.Count; i++)
            {
                strGeneric.Seek(iResultIP[i], SeekOrigin.Begin);
                strGeneric.Write(newDataIp[i], 0, newDataIp[i].Length);
            }

            if ((encType == ENCRYPTION_PATCH_TYPE.Login) || (encType == ENCRYPTION_PATCH_TYPE.Both))
            {
                byte[] encLoginToPatch = StaticData.GetPatchedLoginData(iResultEncLoginId);
                strGeneric.Seek(iResultEncLogin, SeekOrigin.Begin);
                strGeneric.Write(encLoginToPatch, 0, encLoginToPatch.Length);
            }

            if ((encType == ENCRYPTION_PATCH_TYPE.Game) || (encType == ENCRYPTION_PATCH_TYPE.Both))
            {

                strGeneric.Seek(iResultEncGame, SeekOrigin.Begin);
                strGeneric.Write(StaticData.UOKR_ENCPATCHDATA, 0, StaticData.UOKR_ENCPATCHDATA.Length);
            }

            strGeneric.Close();

            if (!bPatch)
            {
                System.Threading.Thread.Sleep(10);
                Close();
            }
            else
            {
                this.ckbRemind.Checked = false;
                MessageBox.Show("Client " + this.txtUokrPath.Text + @"\" + StaticData.UOKR_PATCHCLIENT + " succesfully patched.", "Patch Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 7
0
        private ConfigArgs ParseConfig()
        {
            if (nudPort.Value <= 0 || nudPort.Value > 65535)
            {
                MessageBox.Show("Invalid port: " + nudPort.Value.ToString() + " !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }

            IPHostEntry host;

            try
            {
                host = Dns.GetHostEntry(txtIptopatch.Text.Trim());
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid ip: " + txtIptopatch.Text + " !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }

            IPAddress ip = null;
            for (int iAddr = 0; iAddr <= host.AddressList.Length; iAddr++)
            {
                if ( host.AddressList[iAddr].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork )
                {
                    ip = host.AddressList[iAddr];
                    break;
                }
            }

            if (ip == null)
            {
                MessageBox.Show("Cannot find a valid IPV4 ip for: " + txtIptopatch.Text + " !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }

            if (this.ckbRemind.Checked)
            {
                if (this.txtIptopatch.Text.Length > 0)
                {
                    using (StreamWriter srRead = File.CreateText(StaticData.LAUNCH_CFG))
                    {
                        srRead.Write(this.txtIptopatch.Text.Trim() + "," + this.nudPort.Value.ToString() + "," + this.cmbEncryption.SelectedIndex.ToString());
                    }
                }
            }

            ConfigArgs caTouse = new ConfigArgs();
            caTouse.uPort = (uint)this.nudPort.Value;
            caTouse.ipHost = ip;
            caTouse.encType = (ENCRYPTION_PATCH_TYPE)this.cmbEncryption.SelectedIndex;

            return caTouse;
        }
 public static void Config(ConfigArgs args)
 {
     InvokeCount++;
 }
        private void PathOrLaunch(bool bPatch, ConfigArgs caTouse)
        {
            if (caTouse == null)
            {
                return;
            }

            int iResultEncLogin   = 0;
            int iResultEncLoginId = 0;
            // ----------------------
            int iResultEncGame = 0;
            // ----------------------
            List <int> iResultIP   = new List <int>();
            int        iResultIPId = 0;
            // ----------------------
            ENCRYPTION_PATCH_TYPE encType = caTouse.encType;

            // !bPatch
            Process prcTostart = null;
            // bPatch
            FileStream fsToPatch = null;

            if (!bPatch)
            {
                prcTostart = new Process();
                prcTostart.StartInfo.FileName         = this.txtUokrPath.Text + @"\" + StaticData.UOKR_CLIENT;
                prcTostart.StartInfo.WorkingDirectory = this.txtUokrPath.Text;

                if (!prcTostart.Start())
                {
                    MessageBox.Show("Cannot start the client !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                try
                {
                    File.Copy(this.txtUokrPath.Text + @"\" + StaticData.UOKR_CLIENT, this.txtUokrPath.Text + @"\" + StaticData.UOKR_PATCHCLIENT, true);
                }
                catch (Exception)
                {
                    MessageBox.Show("Cannot create file " + this.txtUokrPath.Text + @"\" + StaticData.UOKR_PATCHCLIENT + " !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                try
                {
                    fsToPatch = File.Open(this.txtUokrPath.Text + @"\" + StaticData.UOKR_PATCHCLIENT, FileMode.Open, FileAccess.ReadWrite);
                }
                catch (Exception)
                {
                    MessageBox.Show("Cannot open file " + this.txtUokrPath.Text + @"\" + StaticData.UOKR_PATCHCLIENT + " !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            Stream strGeneric;

            if (bPatch)
            {
                strGeneric = fsToPatch;
            }
            else
            {
                strGeneric = new ProcessStream((IntPtr)prcTostart.Id);
            }

            for (iResultIPId = 0; iResultIPId < StaticData.UOKR_IPDATA_VERSION; iResultIPId++)
            {
                List <byte[]> listBytes = StaticData.GetIPData(iResultIPId);
                foreach (byte[] bIpData in listBytes)
                {
                    iResultIP.Add(Utility.Search(strGeneric, bIpData, bPatch));
                }

                if (ListValidValues(iResultIP))
                {
                    break;
                }
                else
                {
                    iResultIP.Clear();
                }
            }

            if (!ListValidValues(iResultIP))
            {
                strGeneric.Close();
                if (!bPatch)
                {
                    prcTostart.Kill();
                }

                MessageBox.Show("Cannot patch IP on the client !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if ((encType == ENCRYPTION_PATCH_TYPE.Login) || (encType == ENCRYPTION_PATCH_TYPE.Both))
            {
                for (iResultEncLoginId = 0; iResultEncLoginId < StaticData.UOKR_LOGDATA_VERSION; iResultEncLoginId++)
                {
                    iResultEncLogin = Utility.Search(strGeneric, StaticData.GetLoginData(iResultEncLoginId), bPatch);
                    if (iResultEncLogin != 0)
                    {
                        break;
                    }
                }

                if (iResultEncLogin == 0)
                {
                    strGeneric.Close();
                    if (!bPatch)
                    {
                        prcTostart.Kill();
                    }

                    MessageBox.Show("Cannot patch Login Encryption on the client !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if ((encType == ENCRYPTION_PATCH_TYPE.Game) || (encType == ENCRYPTION_PATCH_TYPE.Both))
            {
                iResultEncGame = Utility.Search(strGeneric, StaticData.UOKR_ENCDATA, bPatch);
                if (iResultEncGame == 0)
                {
                    strGeneric.Close();
                    if (!bPatch)
                    {
                        prcTostart.Kill();
                    }

                    MessageBox.Show("Cannot patch Game Encryption on the client !", Application.ProductName + " Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            if (bPatch)
            {
                strGeneric.Seek(0, SeekOrigin.Begin);
            }

            List <byte[]> newDataIp = StaticData.GetPatchedIPData(iResultIPId, caTouse.ipHost, caTouse.uPort);

            for (int i = 0; i < newDataIp.Count; i++)
            {
                strGeneric.Seek(iResultIP[i], SeekOrigin.Begin);
                strGeneric.Write(newDataIp[i], 0, newDataIp[i].Length);
            }

            if ((encType == ENCRYPTION_PATCH_TYPE.Login) || (encType == ENCRYPTION_PATCH_TYPE.Both))
            {
                byte[] encLoginToPatch = StaticData.GetPatchedLoginData(iResultEncLoginId);
                strGeneric.Seek(iResultEncLogin, SeekOrigin.Begin);
                strGeneric.Write(encLoginToPatch, 0, encLoginToPatch.Length);
            }

            if ((encType == ENCRYPTION_PATCH_TYPE.Game) || (encType == ENCRYPTION_PATCH_TYPE.Both))
            {
                strGeneric.Seek(iResultEncGame, SeekOrigin.Begin);
                strGeneric.Write(StaticData.UOKR_ENCPATCHDATA, 0, StaticData.UOKR_ENCPATCHDATA.Length);
            }

            strGeneric.Close();

            if (!bPatch)
            {
                System.Threading.Thread.Sleep(10);
                Close();
            }
            else
            {
                this.ckbRemind.Checked = false;
                MessageBox.Show("Client " + this.txtUokrPath.Text + @"\" + StaticData.UOKR_PATCHCLIENT + " succesfully patched.", "Patch Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }