public long ReadLong()
 {
     CheckRecordPosition(LittleEndianConsts.LONG_SIZE);
     _currentDataOffset += LittleEndianConsts.LONG_SIZE;
     pos += LittleEndianConsts.LONG_SIZE;
     return(_dataInput.ReadLong());
 }
Beispiel #2
0
        private static object ReadAConstantValue(ILittleEndianInput in1)
        {
            byte grbit = (byte)in1.ReadByte();

            switch (grbit)
            {
            case TYPE_EMPTY:
                in1.ReadLong();     // 8 byte 'not used' field
                return(EMPTY_REPRESENTATION);

            case TYPE_NUMBER:
                return(in1.ReadDouble());

            case TYPE_STRING:
                return(StringUtil.ReadUnicodeString(in1));

            case TYPE_BOOLEAN:
                return(ReadBoolean(in1));

            case TYPE_ERROR_CODE:
                int errCode = in1.ReadUShort();
                // next 6 bytes are Unused
                in1.ReadUShort();
                in1.ReadInt();
                return(ErrorConstant.ValueOf(errCode));
            }
            throw new Exception("Unknown grbit value (" + grbit + ")");
        }
Beispiel #3
0
        /**
         * @param ris the RecordInputstream to read the record from
         */
        public NameCommentRecord(RecordInputStream ris)
        {
            ILittleEndianInput in1 = ris;

            field_1_record_type       = in1.ReadShort();
            field_2_frt_cell_ref_flag = in1.ReadShort();
            field_3_reserved          = in1.ReadLong();
            int field_4_name_length    = in1.ReadShort();
            int field_5_comment_length = in1.ReadShort();

            if (in1.ReadByte() == 0)
            {
                field_6_name_text = StringUtil.ReadCompressedUnicode(in1, field_4_name_length);
            }
            else
            {
                field_6_name_text = StringUtil.ReadUnicodeLE(in1, field_4_name_length);
            }
            if (in1.ReadByte() == 0)
            {
                field_7_comment_text = StringUtil.ReadCompressedUnicode(in1, field_5_comment_length);
            }
            else
            {
                field_7_comment_text = StringUtil.ReadUnicodeLE(in1, field_5_comment_length);
            }
        }
 private static Object ReadBoolean(ILittleEndianInput in1)
 {
     byte val = (byte)in1.ReadLong(); // 7 bytes 'not used'
     switch (val)
     {
         case FALSE_ENCODING:
             return false;
         case TRUE_ENCODING:
             return true;
     }
     // Don't tolerate Unusual bool encoded values (unless it becomes evident that they occur)
     throw new Exception("unexpected bool encoding (" + val + ")");
 }
Beispiel #5
0
        internal StandardEncryptionHeader(ILittleEndianInput is1)
        {
            Flags           = (is1.ReadInt());
            SizeExtra       = (is1.ReadInt());
            CipherAlgorithm = (CipherAlgorithm.FromEcmaId(is1.ReadInt()));
            HashAlgorithm   = (HashAlgorithm.FromEcmaId(is1.ReadInt()));
            int keySize = is1.ReadInt();

            if (keySize == 0)
            {
                // for the sake of inheritance of the cryptoAPI classes
                // see 2.3.5.1 RC4 CryptoAPI Encryption Header
                // If Set to 0x00000000, it MUST be interpreted as 0x00000028 bits.
                keySize = 0x28;
            }
            KeySize        = (keySize);
            BlockSize      = (keySize);
            CipherProvider = (CipherProvider.FromEcmaId(is1.ReadInt()));

            is1.ReadLong(); // skip reserved

            // CSPName may not always be specified
            // In some cases, the salt value of the EncryptionVerifier is the next chunk of data
            ((ByteArrayInputStream)is1).Mark(LittleEndianConsts.INT_SIZE + 1);
            int CheckForSalt = is1.ReadInt();

            ((ByteArrayInputStream)is1).Reset();

            if (CheckForSalt == 16)
            {
                CspName = ("");
            }
            else
            {
                StringBuilder builder = new StringBuilder();
                while (true)
                {
                    char c = (char)is1.ReadShort();
                    if (c == 0)
                    {
                        break;
                    }
                    builder.Append(c);
                }
                CspName = (builder.ToString());
            }

            ChainingMode = (ChainingMode.ecb);
            KeySalt      = (null);
        }
Beispiel #6
0
        private static Object ReadBoolean(ILittleEndianInput in1)
        {
            byte val = (byte)in1.ReadLong(); // 7 bytes 'not used'

            switch (val)
            {
            case FALSE_ENCODING:
                return(false);

            case TRUE_ENCODING:
                return(true);
            }
            // Don't tolerate Unusual bool encoded values (unless it becomes evident that they occur)
            throw new Exception("unexpected bool encoding (" + val + ")");
        }
Beispiel #7
0
 private static object ReadAConstantValue(ILittleEndianInput in1)
 {
     byte grbit = (byte)in1.ReadByte();
     switch (grbit)
     {
         case TYPE_EMPTY:
             in1.ReadLong(); // 8 byte 'not used' field
             return EMPTY_REPRESENTATION;
         case TYPE_NUMBER:
             return in1.ReadDouble();
         case TYPE_STRING:
             return StringUtil.ReadUnicodeString(in1);
         case TYPE_BOOLEAN:
             return ReadBoolean(in1);
         case TYPE_ERROR_CODE:
             int errCode = in1.ReadUShort();
             // next 6 bytes are Unused
             in1.ReadUShort();
             in1.ReadInt();
             return ErrorConstant.ValueOf(errCode);
     }
     throw new Exception("Unknown grbit value (" + grbit + ")");
 }
Beispiel #8
0
		public GUID(ILittleEndianInput in1) 
            :this(in1.ReadInt(), in1.ReadUShort(), in1.ReadUShort(), in1.ReadLong())
        {
			
		}
Beispiel #9
0
 public GUID(ILittleEndianInput in1)
     : this(in1.ReadInt(), in1.ReadUShort(), in1.ReadUShort(), in1.ReadLong())
 {
 }
Beispiel #10
0
 public long ReadLong()
 {
     return(_rc4.XorLong(_le.ReadLong()));
 }