Ejemplo n.º 1
0
        // Token: 0x06000641 RID: 1601 RVA: 0x0002342C File Offset: 0x0002162C
        internal byte[] GetBytes()
        {
            int num = 0;

            byte[] array = new byte[128];
            array[num++] = 0;
            array[num++] = (byte)this.fileNameLength;
            byte[] src = this.FileNameAsByteArray();
            Buffer.BlockCopy(src, 0, array, num, this.fileNameLength);
            num            = 65;
            num           += BinHexUtils.MarshalInt32(array, num, (long)this.fileType);
            num           += BinHexUtils.MarshalInt32(array, num, (long)this.fileCreator);
            array[num++]   = (byte)((65280 & this.finderFlags) >> 8);
            array[num++]   = 0;
            num           += BinHexUtils.MarshalUInt16(array, num, (ushort)this.iconXOffset);
            num           += BinHexUtils.MarshalUInt16(array, num, (ushort)this.iconYOffset);
            num           += BinHexUtils.MarshalUInt16(array, num, 0);
            array[num++]   = (this.fileProtected ? 1 : 0);
            array[num++]   = 0;
            num           += BinHexUtils.MarshalInt32(array, num, this.dataForkLength);
            num           += BinHexUtils.MarshalInt32(array, num, this.resourceForkLength);
            num           += BinHexUtils.MarshalInt32(array, num, 0L);
            num           += BinHexUtils.MarshalInt32(array, num, 0L);
            num           += BinHexUtils.MarshalUInt16(array, num, (ushort)this.commentLength);
            array[num++]   = (byte)(255 & this.finderFlags);
            num           += 18;
            num           += BinHexUtils.MarshalUInt16(array, num, (ushort)this.secondaryHeaderLength);
            array[num++]   = (byte)this.version;
            array[num++]   = (byte)this.minimumVersion;
            this.headerCRC = BinHexUtils.CalculateHeaderCrc(array, 124);
            num           += BinHexUtils.MarshalUInt16(array, num, this.headerCRC);
            array[num++]   = 0;
            array[num++]   = 0;
            return(array);
        }
Ejemplo n.º 2
0
        public byte[] GetBytes()
        {
            int num  = 0;
            int num2 = 1 + this.FileNameLength + 1 + 4 + 4 + 2 + 4 + 4 + 2;

            byte[] array = new byte[num2];
            array[num++] = (byte)this.fileNameLength;
            Buffer.BlockCopy(this.fileName, 0, array, num, this.fileNameLength);
            num           += this.FileNameLength;
            array[num++]   = (byte)this.version;
            num           += BinHexUtils.MarshalInt32(array, num, (long)this.fileType);
            num           += BinHexUtils.MarshalInt32(array, num, (long)this.fileCreator);
            num           += BinHexUtils.MarshalUInt16(array, num, (ushort)this.finderFlags);
            num           += BinHexUtils.MarshalInt32(array, num, this.dataForkLength);
            num           += BinHexUtils.MarshalInt32(array, num, this.resourceForkLength);
            this.headerCRC = BinHexUtils.CalculateHeaderCrc(array, num);
            num           += BinHexUtils.MarshalUInt16(array, num, this.headerCRC);
            return(array);
        }
Ejemplo n.º 3
0
        public BinHexHeader(byte[] header)
        {
            if (header.Length < 23)
            {
                throw new ArgumentException(EncodersStrings.BinHexHeaderTooSmall, "header");
            }
            int num = (int)header[0];

            if (header.Length - 22 < num)
            {
                throw new ByteEncoderException(EncodersStrings.BinHexHeaderIncomplete);
            }
            if (63 < num || 1 > num)
            {
                throw new ByteEncoderException(EncodersStrings.BinHexHeaderInvalidNameLength);
            }
            int    num2 = 2 + num;
            ushort num3 = BinHexUtils.CalculateHeaderCrc(header, num2 + 18);
            ushort num4 = BinHexUtils.UnmarshalUInt16(header, num2 + 18);

            if (num3 != num4)
            {
                throw new ByteEncoderException(EncodersStrings.BinHexHeaderInvalidCrc);
            }
            if (header[1 + num] != 0)
            {
                throw new ByteEncoderException(EncodersStrings.BinHexHeaderUnsupportedVersion);
            }
            this.fileNameLength = num;
            this.fileName       = new byte[num];
            Buffer.BlockCopy(header, 1, this.fileName, 0, this.fileNameLength);
            this.version            = (int)header[this.fileNameLength + 1];
            this.fileType           = BinHexUtils.UnmarshalInt32(header, num2);
            this.fileCreator        = BinHexUtils.UnmarshalInt32(header, num2 + 4);
            this.finderFlags        = (int)BinHexUtils.UnmarshalUInt16(header, num2 + 8);
            this.dataForkLength     = (long)BinHexUtils.UnmarshalInt32(header, num2 + 10);
            this.resourceForkLength = (long)BinHexUtils.UnmarshalInt32(header, num2 + 14);
            this.headerCRC          = num4;
        }