Beispiel #1
0
        /// <summary>
        /// Reads in a NetCliConnect message from the stream
        /// </summary>
        /// <param name="s">Stream to read the message from</param>
        /// <returns>Connection YData (an array of 64 bytes) or NULL if the message is malformed</returns>
        protected byte[] IReadNetCliConnect(hsStream s)
        {
            byte[] y_data = null;
            try {
                if (s.ReadByte() != plNetCore.kNetCliConnect) return null;
                int size = (int)s.ReadByte() - 2;
                y_data = s.ReadBytes(size);
            } catch (Exception e) {
            #if DEBUG
                throw e;
            #else
                return null;
            #endif
            }

            // Truncate the YData if it's too large
            if (y_data.Length > 64) {
                byte[] old = y_data;
                y_data = new byte[64];
                Buffer.BlockCopy(old, 0, y_data, 0, 64);
            }

            // The client sends us the YData in Little Endian, but
            // BigNum wants Big Endian (because OpenSSL). Let's fix that.
            Array.Reverse(y_data);

            return y_data;
        }
Beispiel #2
0
 public override void Read(hsStream s)
 {
     fTransID = s.ReadUInt();
     fAccount = pnHelpers.ReadString(s, 64);
     fHash = s.ReadBytes(20);
     fSrvChg = s.ReadUInt();
     fCliChg = s.ReadUInt();
 }
Beispiel #3
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            fFlags = (BitVectorFlags)s.ReadInt();

            if (HasVersion) {
                fVerMajor = s.ReadByte();
                fVerMinor = s.ReadByte();
            }

            if (HasTimeSent)
                fTimeSent = plUnifiedTime.Read(s);
            if (HasContext)
                fContext = s.ReadUInt();
            if (HasTransID)
                fTransID = s.ReadUInt();
            if (HasPlayerID)
                fPlayerID = s.ReadUInt();
            if (HasAccount)
                fAcctUUID = new Guid(s.ReadBytes(16));
        }
Beispiel #4
0
 public void Read(hsStream s)
 {
     pnVaultNodeFields f = (pnVaultNodeFields)s.ReadULong();
     for (ulong bit = 1; bit != 0 && bit <= (ulong)f; bit <<= 1) {
         switch (f & (pnVaultNodeFields)bit) {
             case pnVaultNodeFields.Blob_1:
                 fBlob[0] = s.ReadBytes(s.ReadInt());
                 break;
             case pnVaultNodeFields.Blob_2:
                 fBlob[1] = s.ReadBytes(s.ReadInt());
                 break;
             case pnVaultNodeFields.CreateAgeName:
                 fCreateAgeName = pnHelpers.ReadString(s);
                 break;
             case pnVaultNodeFields.CreateAgeUuid:
                 fCreateAgeGuid = pnHelpers.ReadUuid(s);
                 break;
             case pnVaultNodeFields.CreateTime:
                 fCreateTime = plUnifiedTime.Epoch.AddSeconds((double)s.ReadInt());
                 break;
             case pnVaultNodeFields.CreatorIdx:
                 fCreatorID = s.ReadUInt();
                 break;
             case pnVaultNodeFields.CreatorUuid:
                 fCreatorGuid = pnHelpers.ReadUuid(s);
                 break;
             case pnVaultNodeFields.Int32_1:
                 fInt32[0] = s.ReadInt();
                 break;
             case pnVaultNodeFields.Int32_2:
                 fInt32[1] = s.ReadInt();
                 break;
             case pnVaultNodeFields.Int32_3:
                 fInt32[2] = s.ReadInt();
                 break;
             case pnVaultNodeFields.Int32_4:
                 fInt32[3] = s.ReadInt();
                 break;
             case pnVaultNodeFields.IString64_1:
                 fIString64[0] = pnHelpers.ReadString(s);
                 break;
             case pnVaultNodeFields.IString64_2:
                 fIString64[1] = pnHelpers.ReadString(s);
                 break;
             case pnVaultNodeFields.ModifyTime:
                 fModifyTime = plUnifiedTime.Epoch.AddSeconds((double)s.ReadInt());
                 break;
             case pnVaultNodeFields.NodeIdx:
                 fNodeID = s.ReadUInt();
                 break;
             case pnVaultNodeFields.NodeType:
                 fNodeType = (ENodeType)s.ReadUInt();
                 break;
             case pnVaultNodeFields.String64_1:
                 fString64[0] = pnHelpers.ReadString(s);
                 break;
             case pnVaultNodeFields.String64_2:
                 fString64[1] = pnHelpers.ReadString(s);
                 break;
             case pnVaultNodeFields.String64_3:
                 fString64[2] = pnHelpers.ReadString(s);
                 break;
             case pnVaultNodeFields.String64_4:
                 fString64[3] = pnHelpers.ReadString(s);
                 break;
             case pnVaultNodeFields.String64_5:
                 fString64[4] = pnHelpers.ReadString(s);
                 break;
             case pnVaultNodeFields.String64_6:
                 fString64[5] = pnHelpers.ReadString(s);
                 break;
             case pnVaultNodeFields.Text_1:
                 fText[0] = pnHelpers.ReadString(s);
                 break;
             case pnVaultNodeFields.Text_2:
                 fText[1] = pnHelpers.ReadString(s);
                 break;
             case pnVaultNodeFields.UInt32_1:
                 fUInt32[0] = s.ReadUInt();
                 break;
             case pnVaultNodeFields.UInt32_2:
                 fUInt32[1] = s.ReadUInt();
                 break;
             case pnVaultNodeFields.UInt32_3:
                 fUInt32[2] = s.ReadUInt();
                 break;
             case pnVaultNodeFields.UInt32_4:
                 fUInt32[3] = s.ReadUInt();
                 break;
             case pnVaultNodeFields.Uuid_1:
                 fGuid[0] = pnHelpers.ReadUuid(s);
                 break;
             case pnVaultNodeFields.Uuid_2:
                 fGuid[1] = pnHelpers.ReadUuid(s);
                 break;
             case pnVaultNodeFields.Uuid_3:
                 fGuid[2] = pnHelpers.ReadUuid(s);
                 break;
             case pnVaultNodeFields.Uuid_4:
                 fGuid[3] = pnHelpers.ReadUuid(s);
                 break;
         }
     }
 }
Beispiel #5
0
 public override void Read(hsStream s)
 {
     fTransID = s.ReadUInt();
     fPingTimeMs = s.ReadUInt();
     fPayload = s.ReadBytes(s.ReadInt());
 }
Beispiel #6
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            base.Read(s, mgr);

            // Cache it.
            fVersion = mgr.Version;

            // Cyan stores these values, but we're just going to
            //     save the stream and have fun with it...
            fBuffer = new byte[s.ReadInt()];
            Compression type = (Compression)s.ReadByte();
            uint len = s.ReadUInt();

            if (type == Compression.kZlib) {
                short streamType = s.ReadShort();
                byte[] buf = s.ReadBytes((int)len - 2);

                // Create a zlib-compatible inflator
                // Note: incoming has no zlib header/footer
                //       System.IO.Compression sucks.
                Inflater zlib = new Inflater(true);
                zlib.Inflate(buf);

                Buffer.BlockCopy(BitConverter.GetBytes(streamType), 0, fBuffer, 0, 2);
                Buffer.BlockCopy(buf, 0, fBuffer, 2, buf.Length);
            } else
                fBuffer = s.ReadBytes((int)len);
        }
Beispiel #7
0
 public override void Read(hsStream s, hsResMgr mgr)
 {
     base.Read(s, mgr);
     fBuffer = s.ReadBytes((int)(s.BaseStream.Length - s.BaseStream.Position));
 }
Beispiel #8
0
 public static Guid ReadUuid(hsStream s)
 {
     return new Guid(s.ReadBytes(16));
 }
Beispiel #9
0
 /// <summary>
 /// Reads in a UTF-16 string with an int16 size and a predefined maximum size
 /// </summary>
 /// <param name="s">Stream to read from</param>
 /// <param name="maxSize">Maximum string size</param>
 /// <returns>Resulting string</returns>
 public static string ReadString(hsStream s, int maxSize)
 {
     int size = (int)s.ReadShort();
     string data = Encoding.Unicode.GetString(s.ReadBytes(size * 2));
     if (data.Length > maxSize)
         return data.Remove(maxSize);
     return data;
 }
Beispiel #10
0
 /// <summary>
 /// Reads in a UTF-16 string with an int32 size
 /// </summary>
 /// <param name="s">Stream to read from</param>
 /// <returns>Resulting string</returns>
 public static string ReadString(hsStream s)
 {
     byte[] data = s.ReadBytes(s.ReadInt());
     return Encoding.Unicode.GetString(data).Replace("\0", null);
 }
Beispiel #11
0
 private byte[] IReadHashUInt(hsStream s)
 {
     byte[] buf = s.ReadBytes(4);
     Array.Reverse(buf);
     return buf;
 }
Beispiel #12
0
        public override void Read(hsStream s, hsResMgr mgr)
        {
            fFlags = (Flags)s.ReadShort();

            if (HasAccount)
                fAcctUUID = new Guid(s.ReadBytes(16));
            if (HasPlayerID)
                fPlayerID = s.ReadUInt();
            if (HasPlayerName)
                fPlayerName = s.ReadStdString();
            if (HasCCRLevel)
                fCCRLevel = s.ReadByte();
            if (HasProtectedLogin)
                fProtectedLogin = s.ReadBool();
            if (HasBuildType)
                fBuildType = s.ReadByte();
            if (HasSrcAddr)
                fSrcAddr = s.ReadUInt();
            if (HasSrcPort)
                fSrcPort = s.ReadUShort();
            if (HasReserved)
                fReserved = s.ReadUShort();
            if (HasClientKey)
                fClientKey = s.ReadStdString();
        }