Beispiel #1
0
 public UnknownSubRecord(ILittleEndianInput in1, int sid, int size)
 {
     _sid = sid;
     byte[] buf = new byte[size];
     in1.ReadFully(buf);
     _data = buf;
 }
Beispiel #2
0
        public static String ReadUtf8LPP4(ILittleEndianInput is1)
        {
            int length = is1.ReadInt();

            if (length == 0 || length == 4)
            {
                //@SuppressWarnings("unused")
                int skip = is1.ReadInt(); // ignore
                return(length == 0 ? null : "");
            }

            byte[] data = new byte[length];
            is1.ReadFully(data);

            // Padding (variable): A set of bytes that MUST be of correct size such that the size of the UTF-8-LP-P4
            // structure is a multiple of 4 bytes. If PAdding is present, each byte MUST be 0x00. If
            // the length is exactly 0x00000000, this specifies a null string, and the entire structure uses
            // exactly 4 bytes. If the length is exactly 0x00000004, this specifies an empty string, and the
            // entire structure also uses exactly 4 bytes
            int scratchedBytes = length % 4;

            if (scratchedBytes > 0)
            {
                for (int i = 0; i < (4 - scratchedBytes); i++)
                {
                    is1.ReadByte();
                }
            }

            return(Encoding.UTF8.GetString(data, 0, data.Length));
            //return new String(data, 0, data.length, Charset.forName("UTF-8"));
        }
Beispiel #3
0
        /// <summary>
        /// Returns <see cref="size"/> bytes from the <see cref="input"/> stream
        /// </summary>
        /// <param name="input"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        private static byte[] Read(ILittleEndianInput input, int size)
        {
            var result = new byte[size];

            input.ReadFully(result);
            return(result);
        }
 public void ReadFully(byte[] buf, int off, int len)
 {
     CheckRecordPosition(len);
     _dataInput.ReadFully(buf, off, len);
     _currentDataOffset += len;
     pos += len;
 }
 protected internal BinaryRC4EncryptionVerifier(ILittleEndianInput is1)
 {
     byte[] salt = new byte[16];
     is1.ReadFully(salt);
     SetSalt(salt);
     byte[] encryptedVerifier = new byte[16];
     is1.ReadFully(encryptedVerifier);
     EncryptedVerifier = (encryptedVerifier);
     byte[] encryptedVerifierHash = new byte[16];
     is1.ReadFully(encryptedVerifierHash);
     EncryptedVerifierHash = (encryptedVerifierHash);
     SpinCount             = (-1);
     CipherAlgorithm       = (CipherAlgorithm.rc4);
     ChainingMode          = (null);
     EncryptedKey          = (null);
     HashAlgorithm         = (HashAlgorithm.md5);
 }
 /**
  * Constructs a NoteStructureSubRecord and Sets its fields appropriately.
  *
  */
 public NoteStructureSubRecord(ILittleEndianInput in1, int size)
 {
     if (size != ENCODED_SIZE) {
         throw new RecordFormatException("Unexpected size (" + size + ")");
     }
     //just grab the raw data
     byte[] buf = new byte[size];
     in1.ReadFully(buf);
     reserved = buf;
 }
Beispiel #7
0
 public FtCblsSubRecord(ILittleEndianInput in1, int size)
 {
     if (size != ENCODED_SIZE)
     {
         throw new RecordFormatException("Unexpected size (" + size + ")");
     }
     //just grab the raw data
     byte[] buf = new byte[size];
     in1.ReadFully(buf);
     reserved = buf;
 }
Beispiel #8
0
 private static byte[] ReadRawData(ILittleEndianInput in1, int size)
 {
     if (size < 0)
     {
         throw new ArgumentException("Negative size (" + size + ")");
     }
     if (size == 0)
     {
         return(EMPTY_BYTE_ARRAY);
     }
     byte[] result = new byte[size];
     in1.ReadFully(result);
     return(result);
 }
Beispiel #9
0
 private static byte[] ReadTail(byte[] expectedTail, ILittleEndianInput in1)
 {
     byte[] result = new byte[TAIL_SIZE];
     in1.ReadFully(result);
     //if (false)
     //{ // Quite a few examples in the unit tests which don't have the exact expected tail
     //    for (int i = 0; i < expectedTail.Length; i++)
     //    {
     //        if (expectedTail[i] != result[i])
     //        {
     //           logger.Log( POILogger.ERROR, "Mismatch in tail byte [" + i + "]"
     //                    + "expected " + (expectedTail[i] & 0xFF) + " but got " + (result[i] & 0xFF));
     //        }
     //    }
     //}
     return(result);
 }
        public void ReadFully(byte[] buf, int off, int len)
        {
            /*CheckRecordPosition(len);
             * _dataInput.ReadFully(buf, off, len);
             * _currentDataOffset += len;
             * pos += len;*/

            int origLen = len;

            if (buf == null)
            {
                throw new ArgumentNullException();
            }
            else if (off < 0 || len < 0 || len > buf.Length - off)
            {
                throw new IndexOutOfRangeException();
            }

            while (len > 0)
            {
                int nextChunk = Math.Min(Available(), len);
                if (nextChunk == 0)
                {
                    if (!HasNextRecord)
                    {
                        throw new RecordFormatException("Can't read the remaining " + len + " bytes of the requested " + origLen + " bytes. No further record exists.");
                    }
                    else
                    {
                        NextRecord();
                        nextChunk = Math.Min(Available(), len);
                        Debug.Assert(nextChunk > 0);
                    }
                }
                CheckRecordPosition(nextChunk);
                _dataInput.ReadFully(buf, off, nextChunk);
                _currentDataOffset += nextChunk;
                off += nextChunk;
                len -= nextChunk;

                pos += nextChunk;
            }
        }
Beispiel #11
0
 public ExtendedColor(ILittleEndianInput in1)
 {
     type = in1.ReadInt();
     if (type == TYPE_INDEXED)
     {
         colorIndex = in1.ReadInt();
     }
     else if (type == TYPE_RGB)
     {
         rgba = new byte[4];
         in1.ReadFully(rgba);
     }
     else if (type == TYPE_THEMED)
     {
         themeIndex = in1.ReadInt();
     }
     else
     {
         // Ignored
         in1.ReadInt();
     }
     tint = in1.ReadDouble();
 }
Beispiel #12
0
        /**
         * Constructs a Group marker record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public GroupMarkerSubRecord(ILittleEndianInput in1, int size)
        {
            byte[] buf = new byte[size];
            in1.ReadFully(buf);
            reserved = buf;
        }
Beispiel #13
0
 public static String ReadUnicodeLE(ILittleEndianInput in1, int nChars)
 {
     byte[] bytes = new byte[nChars * 2];
     in1.ReadFully(bytes);
     return(UTF16LE.GetString(bytes));
 }
Beispiel #14
0
 public static String ReadCompressedUnicode(ILittleEndianInput in1, int nChars)
 {
     byte[] buf = new byte[nChars];
     in1.ReadFully(buf);
     return(ISO_8859_1.GetString(buf));
 }
 private static byte[] ReadRawData(ILittleEndianInput in1, int size)
 {
     if (size < 0)
     {
         throw new ArgumentException("Negative size (" + size + ")");
     }
     if (size == 0)
     {
         return EMPTY_BYTE_ARRAY;
     }
     byte[] result = new byte[size];
     in1.ReadFully(result);
     return result;
 }
Beispiel #16
0
 public static String ReadCompressedUnicode(ILittleEndianInput in1, int nChars)
 {
     byte[] buf = new byte[nChars];
     in1.ReadFully(buf);
     return ISO_8859_1.GetString(buf);
 }
        /**
         * Constructs a Group marker record and Sets its fields appropriately.
         *
         * @param in the RecordInputstream to Read the record from
         */

        public GroupMarkerSubRecord(ILittleEndianInput in1, int size)
        {
            byte[] buf = new byte[size];
            in1.ReadFully(buf);
            reserved = buf;
        }
Beispiel #18
0
 public void ReadFully(byte[] buf, int off, int len)
 {
     _le.ReadFully(buf, off, len);
     _rc4.Xor(buf, off, len);
 }
Beispiel #19
0
 /**
  * When there are no array constants present, <c>encodedTokenLen</c>==<c>totalEncodedLen</c>
  * @param encodedTokenLen number of bytes in the stream taken by the plain formula tokens
  * @param totalEncodedLen the total number of bytes in the formula (includes trailing encoding
  * for array constants, but does not include 2 bytes for initial <c>ushort encodedTokenLen</c> field.
  * @return A new formula object as read from the stream.  Possibly empty, never <code>null</code>.
  */
 public static Formula Read(int encodedTokenLen, ILittleEndianInput in1, int totalEncodedLen)
 {
     byte[] byteEncoding = new byte[totalEncodedLen];
     in1.ReadFully(byteEncoding);
     return(new Formula(byteEncoding, encodedTokenLen));
 }
Beispiel #20
0
 public static String ReadUnicodeLE(ILittleEndianInput in1, int nChars)
 {
     byte[] bytes = new byte[nChars * 2];
     in1.ReadFully(bytes);
     return UTF16LE.GetString(bytes);
 }
Beispiel #21
0
 /**
  * When there are no array constants present, <c>encodedTokenLen</c>==<c>totalEncodedLen</c>
  * @param encodedTokenLen number of bytes in the stream taken by the plain formula tokens
  * @param totalEncodedLen the total number of bytes in the formula (includes trailing encoding
  * for array constants, but does not include 2 bytes for initial <c>ushort encodedTokenLen</c> field.
  * @return A new formula object as read from the stream.  Possibly empty, never <code>null</code>.
  */
 public static Formula Read(int encodedTokenLen, ILittleEndianInput in1, int totalEncodedLen)
 {
     byte[] byteEncoding = new byte[totalEncodedLen];
     in1.ReadFully(byteEncoding);
     return new Formula(byteEncoding, encodedTokenLen);
 }
 private static byte[] ReadTail(byte[] expectedTail, ILittleEndianInput in1)
 {
     byte[] result = new byte[TAIL_SIZE];
     in1.ReadFully(result);
     //if (false)
     //{ // Quite a few examples in the unit tests which don't have the exact expected tail
     //    for (int i = 0; i < expectedTail.Length; i++)
     //    {
     //        if (expectedTail[i] != result[i])
     //        {
     //           logger.Log( POILogger.ERROR, "Mismatch in tail byte [" + i + "]"
     //                    + "expected " + (expectedTail[i] & 0xFF) + " but got " + (result[i] & 0xFF));
     //        }
     //    }
     //}
     return result;
 }
Beispiel #23
0
 public UnknownSubRecord(ILittleEndianInput in1, int sid, int size)
 {
     _sid = sid;
     byte[] buf = new byte[size];
     in1.ReadFully(buf);
     _data = buf;
 }
 /// <summary>
 /// Returns <see cref="size"/> bytes from the <see cref="input"/> stream
 /// </summary>
 /// <param name="input"></param>
 /// <param name="size"></param>
 /// <returns></returns>
 private static byte[] Read(ILittleEndianInput input, int size)
 {
     var result = new byte[size];
     input.ReadFully(result);
     return result;
 }