Ejemplo n.º 1
0
 // Token: 0x0600061B RID: 1563 RVA: 0x0002312C File Offset: 0x0002132C
 public MacBinaryHeader(byte[] bytes)
 {
     if (bytes == null)
     {
         throw new ArgumentNullException("bytes");
     }
     if (bytes.Length != 128)
     {
         throw new ArgumentException(EncodersStrings.MacBinHeaderMustBe128Long, "bytes");
     }
     if (bytes[0] != 0 || bytes[74] != 0 || bytes[82] != 0)
     {
         throw new ByteEncoderException(EncodersStrings.MacBinInvalidData);
     }
     if (bytes[1] > 63)
     {
         throw new ByteEncoderException(EncodersStrings.MacBinInvalidData);
     }
     this.fileNameLength     = (int)bytes[1];
     this.fileName           = CTSGlobals.AsciiEncoding.GetString(bytes, 2, this.fileNameLength);
     this.fileType           = BinHexUtils.UnmarshalInt32(bytes, 65);
     this.fileCreator        = BinHexUtils.UnmarshalInt32(bytes, 69);
     this.finderFlags        = (int)bytes[73];
     this.iconXOffset        = (int)BinHexUtils.UnmarshalUInt16(bytes, 75);
     this.iconYOffset        = (int)BinHexUtils.UnmarshalUInt16(bytes, 77);
     this.fileProtected      = (1 == bytes[81]);
     this.dataForkLength     = (long)BinHexUtils.UnmarshalInt32(bytes, 83);
     this.resourceForkLength = (long)BinHexUtils.UnmarshalInt32(bytes, 87);
     this.version            = (int)bytes[122];
     this.minimumVersion     = (int)bytes[123];
 }
Ejemplo n.º 2
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;
        }