Пример #1
0
        private int ensureSpace(int aiType, int aiReqSize)
        {
            int num = 0;

            if (this.m_eDefaultMode == 0)
            {
                num = (aiReqSize + 4) + 4;
            }
            else if (this.m_eDefaultMode == 1)
            {
                int    apuValue  = 0;
                byte[] apcBuffer = new byte[6];
                int    num3      = TLVUtil.DecodeVByte32(ref apuValue, apcBuffer, 0);
                aiType = apuValue;
                int num4 = TLVUtil.DecodeVByte32(ref apuValue, apcBuffer, 0);
                num = (num3 + num4) + aiReqSize;
            }
            else
            {
                return(-8);
            }
            if ((this.m_pcBuf == null) || (this.m_iUsedSize <= 0))
            {
                num += this.m_ptHeader.getSize();
            }
            if ((num < 0) || ((num + this.m_iUsedSize) < 0))
            {
                return(-3);
            }
            if (num > (this.m_iAllocSize - this.m_iUsedSize))
            {
                int num5 = this.m_iAllocSize + 0x400;
                while (num5 < (num + this.m_iUsedSize))
                {
                    num5 *= 2;
                }
                if (num5 < 0)
                {
                    num5 = num + this.m_iUsedSize;
                }
                byte[] dst  = new byte[num5];
                bool   flag = false;
                if ((this.m_pcBuf != null) || (this.m_iUsedSize > 0))
                {
                    Buffer.BlockCopy(this.m_pcBuf, 0, dst, 0, this.m_iUsedSize);
                }
                else
                {
                    flag = true;
                }
                this.m_iAllocSize       = num5;
                this.m_pcBuf            = dst;
                this.m_ptHeader.h_pcBuf = this.m_pcBuf;
                if (flag)
                {
                    this.clear();
                }
            }
            return(0);
        }
Пример #2
0
 public static void getIntFrombuf(byte[] srcBuf, ref int srcOffset, ref int dstInt)
 {
     if (srcOffset < srcBuf.Length)
     {
         int num = TLVUtil.DecodeVByte32(ref dstInt, srcBuf, srcOffset);
         srcOffset += num;
     }
 }
Пример #3
0
            public override bool MapTo(byte[] apcSrc, int aiSrcSize, int aiOffset)
            {
                if (((apcSrc == null) || (aiSrcSize <= 0)) || ((aiOffset < 0) || (aiOffset >= aiSrcSize)))
                {
                    return(false);
                }
                int apuValue = 0;
                int num2     = TLVUtil.DecodeVByte32(ref apuValue, apcSrc, aiOffset);
                int num3     = apuValue;
                int num4     = TLVUtil.DecodeVByte32(ref apuValue, apcSrc, aiOffset + num2);
                int num5     = apuValue;

                base.pcValPtrOffset = (aiOffset + num2) + num4;
                int num6 = ((aiOffset + num2) + num4) + num5;

                if (num5 < 0)
                {
                    return(false);
                }
                if (base.pcValPtrOffset > aiSrcSize)
                {
                    return(false);
                }
                if (num6 > aiSrcSize)
                {
                    return(false);
                }
                if (num6 == aiSrcSize)
                {
                    base.iNextOffset = 0;
                }
                else
                {
                    base.iNextOffset = num6;
                }
                base.iType    = num3;
                base.iLength  = num5;
                base.pcValPtr = apcSrc;
                return(true);
            }