Example #1
0
        public uint Unserialize(byte[] buff, uint offset, uint buffLen)
        {
            CreateInstance();
            uint buffPos = offset;
            uint copyLen = 0;

            copyLen  = ss.Unserialize(buff, buffPos, buffLen - (buffPos - offset));
            buffPos += copyLen;

            return(buffPos);
        }
Example #2
0
        public uint Unserialize(byte[] buff, uint offset, uint buffLen)
        {
            CreateInstance();
            uint buffPos = offset;
            uint copyLen = 0;

            copyLen  = ss.Unserialize(buff, buffPos, buffLen - (buffPos - offset));
            buffPos += copyLen;

            copyLen = 2;
            if (copyLen > buffLen - buffPos)
            {
                return(0);
            }
            byte[] tempBytes = new byte[8];
            SerializeUtil.LEMemcpy(tempBytes, 0, buff, buffPos, copyLen);
            uint nameLen = (uint)BitConverter.ToUInt16(tempBytes, 0);

            buffPos += copyLen;

            if (nameLen > 1000)
            {
                return(0);
            }
            if (nameLen > 0)
            {
                if (nameLen > buffLen - buffPos)
                {
                    return(0);
                }
                for (int i = 0; i < nameLen; ++i)
                {
                    name.Add(buff[buffPos + i]);
                }
                buffPos += nameLen;
            }

            return(buffPos);
        }
Example #3
0
        public uint Unserialize(byte[] buff, uint offset, uint buffLen)
        {
            CreateInstance();
            uint buffPos = offset;
            uint copyLen = 0;

            copyLen = 2;
            if (copyLen > buffLen - buffPos)
            {
                return(0);
            }
            byte[] tempBytes = new byte[8];
            SerializeUtil.LEMemcpy(tempBytes, 0, buff, buffPos, copyLen);
            uint listLen = (uint)BitConverter.ToUInt16(tempBytes, 0);

            buffPos += copyLen;

            if (listLen > 1000)
            {
                return(0);
            }
            if (listLen > 0)
            {
                for (int i = 0; i < listLen; ++i)
                {
                    SampleStruct item = new SampleStruct();
                    copyLen = item.Unserialize(buff, buffPos, buffLen - (buffPos - offset));
                    list.Add(item);
                    buffPos += copyLen;
                }
            }

            copyLen  = stru.Unserialize(buff, buffPos, buffLen - (buffPos - offset));
            buffPos += copyLen;

            copyLen = 2;
            if (copyLen > buffLen - buffPos)
            {
                return(0);
            }
            SerializeUtil.LEMemcpy(tempBytes, 0, buff, buffPos, copyLen);
            uint numListLen = (uint)BitConverter.ToUInt16(tempBytes, 0);

            buffPos += copyLen;

            if (numListLen > 1000)
            {
                return(0);
            }
            if (numListLen > 0)
            {
                copyLen = sizeof(int);
                if (numListLen * copyLen > buffLen - buffPos)
                {
                    return(0);
                }
                for (int i = 0; i < numListLen; ++i)
                {
                    SerializeUtil.LEMemcpy(tempBytes, 0, buff, buffPos, copyLen);
                    int item = BitConverter.ToInt32(tempBytes, 0);
                    numList.Add(item);
                    buffPos += copyLen;
                }
            }

            return(buffPos);
        }