public string ExtractString()
        {
            ushort num  = this.ExtractUInt16();
            int    num2 = this.Length - this.Position;

            if ((int)num > num2)
            {
                NetworkChannel.StaticTraceError("ExtractString: {0} exceeds max string len: {1}", new object[]
                {
                    num,
                    num2
                });
                throw new NetworkCorruptDataGenericException();
            }
            string result;

            if (num > 0)
            {
                result           = NetworkChannelPacket.DecodeString(this.m_buf, this.Position, (int)num);
                this.m_position += (int)num;
            }
            else
            {
                result = string.Empty;
            }
            return(result);
        }
 private static int CheckByteArrayLen(int expectedLen)
 {
     if (expectedLen > 2097152)
     {
         NetworkChannel.StaticTraceError("CheckByteArrayLen: {0} exceeds max byteArray len: {1}", new object[]
         {
             expectedLen,
             2097152
         });
         throw new NetworkDataOverflowGenericException();
     }
     return(expectedLen);
 }
 private static ushort CheckStringLen(int expectedLen)
 {
     if (expectedLen > 65535)
     {
         NetworkChannel.StaticTraceError("CheckStringLen: {0} exceeds max string len: {1}", new object[]
         {
             expectedLen,
             65535
         });
         throw new NetworkDataOverflowGenericException();
     }
     return((ushort)expectedLen);
 }
        public byte[] ExtractByteArray()
        {
            int num  = this.ExtractInt32();
            int num2 = this.Length - this.Position;

            if (num > num2 || num < 0)
            {
                NetworkChannel.StaticTraceError("ExtractByteArray: {0} exceeds max byte len: {1}", new object[]
                {
                    num,
                    num2
                });
                throw new NetworkCorruptDataGenericException();
            }
            return(this.ExtractBytes(num));
        }