public TextualServerControl(ServerInfo theServerInfo, UserPreferences thePreferences, bool blnAllowCustomServerUpdate, TextVariables theTextVariables)
 {
     TheServerInfo = theServerInfo;
     TheUserPreferences = thePreferences;
     AllowCustomServerUpdate = blnAllowCustomServerUpdate;
     TheTextVariables = theTextVariables;
 }
 public ServerSelector(ServerInfo theServerInfo, UserPreferences thePreferences, bool blnAllowCustomServerUpdate, TextVariables theTextVariables)
 {
     TheServerInfo = theServerInfo;
     TheUserPreferences = thePreferences;
     AllowCustomServerUpdate = blnAllowCustomServerUpdate;
     TheTextVariables = theTextVariables;
 }
Ejemplo n.º 3
0
        private void CopyRequiredFiles(ServerInfo theServer)
        {
            //copy the files require to run the game

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.CreatingDirectory + " " + SWGANHPAth + theServer.SafeFolderName, true));
            }
            //make the directory
            if (!Directory.Exists(SWGANHPAth + theServer.SafeFolderName))
            {
                Directory.CreateDirectory(SWGANHPAth + theServer.SafeFolderName);
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Created, false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CopyingSoundSystem, true));
            }

            //copy the miles directory across
            Directory.CreateDirectory(SWGANHPAth + theServer.SafeFolderName + "\\miles");

            if (Directory.Exists(SWGANHPAth + "\\miles"))
            {
                foreach (string theFileName in Directory.GetFiles(SWGANHPAth + "\\miles"))
                {
                    File.Copy(theFileName, SWGANHPAth + theServer.SafeFolderName + "\\miles\\" + Path.GetFileName(theFileName));
                }
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CopyingBinaries, true));
            }

            //copy the raw files in there

            //main executable
            File.Copy(SWGANHPAth + "swganh.exe", SWGANHPAth + theServer.SafeFolderName+ "\\swganh.exe");

            //related DLLS
            File.Copy(SWGANHPAth + "dpvs.dll", SWGANHPAth + theServer.SafeFolderName + "\\dpvs.dll");
            File.Copy(SWGANHPAth + "Mss32.dll", SWGANHPAth + theServer.SafeFolderName + "\\Mss32.dll");
            File.Copy(SWGANHPAth + "s205_r.dll", SWGANHPAth + theServer.SafeFolderName + "\\s205_r.dll");
            File.Copy(SWGANHPAth + "s206_r.dll", SWGANHPAth + theServer.SafeFolderName + "\\s206_r.dll");
            File.Copy(SWGANHPAth + "s207_r.dll", SWGANHPAth + theServer.SafeFolderName + "\\s207_r.dll");

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
                PatchStepFired(this, new PatchingEventArgs(myVariables.CopyConfigFiles, true));
            }

            try
            {

                if (File.Exists(SWGANHPAth + "swg2uu_machineoptions.iff"))
                {
                    //one IFF
                    File.Copy(SWGANHPAth + "swg2uu_machineoptions.iff", SWGANHPAth + theServer.SafeFolderName + "\\swg2uu_machineoptions.iff");
                }
                //the pre-load CFG
                //File.Copy(SWGANHPAth + "preload.cfg", SWGANHPAth + theServer.ServerId.ToString() + "\\preload.cfg");

                //craft the login one to match
                File.Copy(SWGANHPAth + "swg2uu_login.cfg", SWGANHPAth + theServer.SafeFolderName + "\\swg2uu_login.cfg");

                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
                    PatchStepFired(this, new PatchingEventArgs(myVariables.SettingServerAddress, true));
                }

                IniFiles myFiles = new IniFiles(SWGANHPAth + theServer.SafeFolderName + "\\swg2uu_login.cfg");
                myFiles.WriteValue("ClientGame", "loginServerPort0", theServer.Port);
                myFiles.WriteValue("ClientGame", "loginServerAddress0", theServer.Address);

                if (PatchStepFired != null)
                {
                    PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
                    PatchStepFired(this, new PatchingEventArgs(myVariables.SetupLocalConfig, true));
                }

                //and make a main cfg which points to the central config files
                //and our local login
                TextWriter twOut = new StreamWriter(SWGANHPAth + theServer.SafeFolderName + "\\swg2uu.cfg");
                twOut.WriteLine(".include \"swg2uu_login.cfg\"");
                twOut.WriteLine(".include \"..\\swg2uu_live.cfg\"");
                twOut.WriteLine(".include \"..\\swg2uu_preload.cfg\"");
                twOut.WriteLine(".include \"..\\swg2uu_opt.cfg\"");
                twOut.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.Complete, false));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Asynnchronously checks the files and compares them against the set of standard MD5 checksums
        /// </summary>
        /// <param name="theServerInfo">ServerInfo onject of the server to patch for</param>
        public void PatchClient(ServerInfo theServerInfo)
        {
            //cache the ol' server info
            cachedServerInfo = theServerInfo;

            if (string.IsNullOrEmpty(SWGANHPAth))
            {
                return;
            }
            //get a list of the custom TRE's
            ServiceMaker myServiceMaker = new ServiceMaker();
            LauncherData.LauncherDataClient myClient = myServiceMaker.GetServiceClient();
            CustomeTreCallObject theObject = new CustomeTreCallObject
            {
                TheClient = myClient,
                Server = theServerInfo
            };
            myClient.BeginGetCustomTre(theServerInfo.ServerId, new AsyncCallback(FinishedGettingTRE), theObject);

            if (PatchStepFired != null)
            {
                PatchStepFired(this, new PatchingEventArgs(myVariables.GettingCustomTre, true));
            }
        }
        public bool CreateSessionKey(ServerInfo theServerInfo, string strUsername, string strPassword)
        {
            bool blnSuccess = false;
            //open a memory stream to hold our session packet
            MemoryStream msSessionOpen = new MemoryStream();
            msSessionOpen.Write(new byte[] { 0x00, 0x01, 0x00, 0x00, 0x00, 0x02 }, 0, 6);

            //take 4 random digits from a guid
            Random myRandom = new Random((int)DateTime.Now.Ticks);
            byte[] arRandom = Guid.NewGuid().ToByteArray();
            for (int i = 0; i < 4; i++)
            {
                msSessionOpen.WriteByte(arRandom[myRandom.Next(0, 31)]);
            }

            //finish it off
            msSessionOpen.Write(new byte[] { 0x00, 0x00, 0x01, 0xf0 }, 0, 4);

            //and extract it's bytey goodness
            byte[] arSessionOpen = msSessionOpen.ToArray();
            msSessionOpen.Flush();
            msSessionOpen.Close();

            //make the client and connect it to the server
            UdpClient myClient = new UdpClient();
            //give it a ten second timeout
            myClient.Client.SendTimeout = 1000;
            myClient.Client.ReceiveTimeout = 1000;
            myClient.Connect(theServerInfo.Address, theServerInfo.Port);

            //and send it out session creation packet
            myClient.Send(arSessionOpen, arSessionOpen.Length);

            try
            {
                //what's the server saying?
                IPEndPoint rec = new IPEndPoint(IPAddress.Any, 0);
                byte[] arReceivedBytes = myClient.Receive(ref rec);

                //craft our special launcher packet

                //get the ol' CRC seed
                arCRCSeed = new byte[] { arReceivedBytes[6], arReceivedBytes[7], arReceivedBytes[8], arReceivedBytes[9] };
                Array.Reverse(arCRCSeed);
                uint myCRCSeed = BitConverter.ToUInt32(arCRCSeed, 0);

                //and use the luancher session opcode - Hoon :¬)
                byte[] arOpCode = new byte[] { 0x48, 0x6f, 0x6f, 0x6e };
                Array.Reverse(arOpCode);

                //make arrays for our login details
                byte[] arUserName = Encoding.ASCII.GetBytes(strUsername);
                byte[] arPassword = Encoding.ASCII.GetBytes(strPassword);

                //Aubrey's birthday
                byte[] arStationId = Encoding.ASCII.GetBytes("20090610-18:00");

                //and construct our luancher session packet
                MemoryStream msPacket = new MemoryStream();
                msPacket.Write(new byte[] { 0x00, 0x00, 0x04, 0x00 }, 0, 4);
                msPacket.Write(arOpCode, 0, arOpCode.Length);
                byte[] arUsernameLength = BitConverter.GetBytes((short)arUserName.Length);
                msPacket.Write(arUsernameLength, 0, arUsernameLength.Length);
                msPacket.Write(arUserName, 0, arUserName.Length);
                byte[] arPasswordLength = BitConverter.GetBytes((short)arPassword.Length);
                msPacket.Write(arPasswordLength, 0, arPasswordLength.Length);
                msPacket.Write(arPassword, 0, arPassword.Length);
                byte[] arStartionIdLength = BitConverter.GetBytes((short)arStationId.Length);
                msPacket.Write(arStartionIdLength, 0, arStartionIdLength.Length);
                msPacket.Write(arStationId, 0, arStationId.Length);
                msPacket.WriteByte(0x00);
                byte[] arCompressMe = msPacket.ToArray();
                msPacket.Close();

                //encrypt it
                Encrypt(ref arCompressMe, arCRCSeed);

                //and put it all together
                MemoryStream msFinalPacket = new MemoryStream();
                msFinalPacket.Write(new byte[] { 0x00, 0x09 }, 0, 2);
                msFinalPacket.Write(arCompressMe, 0, arCompressMe.Length);
                //msFinalPacket.WriteByte(0x00);

                //now to generate the CRC for the packet
                byte[] arFinalPacket = msFinalPacket.ToArray();
                UInt32 myCRC = GenerateCrc(arFinalPacket, (ushort)arFinalPacket.Length, myCRCSeed);
                byte[] arCRC = BitConverter.GetBytes(myCRC);
                Array.Reverse(arCRC);

                //and add this on to the end
                msFinalPacket.Write(arCRC, 2, arCRC.Length - 2);
                arFinalPacket = msFinalPacket.ToArray();
                msFinalPacket.Close();

                //send it all up the wire
                myClient.Send(arFinalPacket, arFinalPacket.Length);

                //and wait to recieve
                myClient.BeginReceive(new AsyncCallback(PacketRecieve), myClient);

                blnSuccess = true;

            }
            catch (SocketException exSocket)
            {
                //Session Times out
                if (exSocket.ErrorCode == 10060)
                {
                    Message = myTextVariables.ConnectionTimeout;
                }
                else
                {
                    Message = exSocket.Message;
                }

                blnSuccess = false;

                myClient.Close();
            }
            catch (Exception ex)
            {
                Message = ex.Message;
                blnSuccess = false;
                myClient.Close();
            }

            return blnSuccess;
        }