コード例 #1
0
        /// <summary>
        /// Reads the header from the file stream
        /// </summary>
        private void ReadHeader()
        {
            InputHandler fileHandler = ((InputHandler)_ioHandler);

            // Determine endian
            byte[] byteArray16 = new byte[2];
            fileHandler.ReadPosition(byteArray16, 0x1C);
            if (byteArray16[0] == 0xFE && byteArray16[1] == 0xFF)
            {
                fileHandler.InitBitConverter(true);
            }
            else
            {
                fileHandler.InitBitConverter(false);
            }

            // Check for Magic Number
            if (fileHandler.ReadUInt64(0x0) != MAGIC_NUMBER)
            {
                throw new MagicNumberException();
            }

            SectorShift     = fileHandler.ReadUInt16(0x1E);
            MiniSectorShift = fileHandler.ReadUInt16();

            NoSectorsInDirectoryChain4KB = fileHandler.ReadUInt32(0x28);
            NoSectorsInFatChain          = fileHandler.ReadUInt32();
            DirectoryStartSector         = fileHandler.ReadUInt32();

            MiniSectorCutoff        = fileHandler.ReadUInt32(0x38);
            MiniFatStartSector      = fileHandler.ReadUInt32();
            NoSectorsInMiniFatChain = fileHandler.ReadUInt32();
            DiFatStartSector        = fileHandler.ReadUInt32();
            NoSectorsInDiFatChain   = fileHandler.ReadUInt32();
        }
コード例 #2
0
        /// <summary>
        /// Reads the values of the directory entry. The position of the file handler must be at the start of a directory entry.
        /// </summary>
        private void ReadDirectoryEntry()
        {
            Name = _fileHandler.ReadString(64);

            // Name length check: lengthOfName = length of the element in bytes including Unicode NULL
            UInt16 lengthOfName = _fileHandler.ReadUInt16();

            // Commented out due to trouble with odd unicode-named streams in PowerPoint -- flgr

            /*if (lengthOfName != (_name.Length + 1) * 2)
             * {
             *  throw new InvalidValueInDirectoryEntryException("_cb");
             * }*/
            // Added warning - math
            if (lengthOfName != (_name.Length + 1) * 2)
            {
                TraceLogger.Warning("Length of the name (_cb) of stream '" + Name + "' is not correct.");
            }


            Type            = (DirectoryEntryType)_fileHandler.ReadByte();
            Color           = (DirectoryEntryColor)_fileHandler.ReadByte();
            LeftSiblingSid  = _fileHandler.ReadUInt32();
            RightSiblingSid = _fileHandler.ReadUInt32();
            ChildSiblingSid = _fileHandler.ReadUInt32();

            byte[] array = new byte[16];
            _fileHandler.Read(array);
            ClsId = new Guid(array);

            UserFlags = _fileHandler.ReadUInt32();
            // Omit creation time
            _fileHandler.ReadUInt64();
            // Omit modification time
            _fileHandler.ReadUInt64();
            StartSector = _fileHandler.ReadUInt32();

            UInt32 sizeLow  = _fileHandler.ReadUInt32();
            UInt32 sizeHigh = _fileHandler.ReadUInt32();

            if (_header.SectorSize == 512 && sizeHigh != 0x0)
            {
                // Must be zero according to the specification. However, this requirement can be ommited.
                TraceLogger.Warning("ul_SizeHigh of stream '" + Name + "' should be zero as sector size is 512.");
                sizeHigh = 0x0;
            }
            SizeOfStream = ((UInt64)sizeHigh << 32) + sizeLow;
        }