Esempio n. 1
0
        /// <summary>
        /// Writes the directory entry to the directory stream of the current context
        /// </summary>
        internal void write()
        {
            OutputHandler directoryStream = _context.DirectoryStream;

            char[] unicodeName    = _name.ToCharArray();
            int    paddingCounter = 0;

            foreach (UInt16 unicodeChar in  unicodeName)
            {
                directoryStream.writeUInt16(unicodeChar);
                paddingCounter++;
            }
            while (paddingCounter < 32)
            {
                directoryStream.writeUInt16(0x0);
                paddingCounter++;
            }
            directoryStream.writeUInt16(this.LengthOfName);
            directoryStream.writeByte((byte)this.Type);
            directoryStream.writeByte((byte)this.Color);
            directoryStream.writeUInt32(this.LeftSiblingSid);
            directoryStream.writeUInt32(this.RightSiblingSid);
            directoryStream.writeUInt32(this.ChildSiblingSid);
            directoryStream.write(this.ClsId.ToByteArray());
            directoryStream.writeUInt32(this.UserFlags);
            //FILETIME set to 0x0
            directoryStream.write(new byte[16]);

            directoryStream.writeUInt32(this.StartSector);
            directoryStream.writeUInt64(this.SizeOfStream);
        }
Esempio n. 2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="stream">The input stream.</param>
 /// <param name="fat">The fat which is used by this stream.</param>
 /// <param name="sectorSize">The sector size.</param>
 /// <param name="outputHander"></param>
 internal VirtualStream(Stream stream, AbstractFat fat, UInt16 sectorSize, OutputHandler outputHander)
 {
     _stream       = stream;
     _fat          = fat;
     _sectorSize   = sectorSize;
     _outputHander = outputHander;
     _sectorCount  = (UInt32)Math.Ceiling((double)_stream.Length / (double)_sectorSize);
 }
Esempio n. 3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="context">the current context</param>
 internal Header(StructuredStorageContext context)
 {
     _ioHandler = new OutputHandler(new MemoryStream());
     _ioHandler.SetHeaderReference(this);
     _ioHandler.InitBitConverter(true);
     _context = context;
     setHeaderDefaults();
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 internal StructuredStorageContext()
 {
     _tempOutputStream     = new OutputHandler(new MemoryStream());
     _directoryStream      = new OutputHandler(new MemoryStream());
     _header               = new Header(this);
     _internalBitConverter = new InternalBitConverter(true);
     _fat                = new Fat(this);
     _miniFat            = new MiniFat(this);
     _rootDirectoryEntry = new RootDirectoryEntry(this);
 }
Esempio n. 5
0
        /// <summary>
        /// Writes the header to the internal stream.
        /// </summary>
        internal void write()
        {
            OutputHandler outputHandler = ((OutputHandler)_ioHandler);

            // Magic number
            outputHandler.write(BitConverter.GetBytes(MAGIC_NUMBER));

            // CLSID
            outputHandler.write(new byte[16]);

            // Minor version
            outputHandler.writeUInt16(0x3E);

            // Major version: 512 KB sectors
            outputHandler.writeUInt16(0x03);

            // Byte ordering: little Endian
            outputHandler.writeUInt16(0xFFFE);

            outputHandler.writeUInt16(SectorShift);
            outputHandler.writeUInt16(MiniSectorShift);

            // reserved
            outputHandler.writeUInt16(0x0);
            outputHandler.writeUInt32(0x0);

            // cSectDir: 0x0 for 512 KB
            outputHandler.writeUInt32(NoSectorsInDirectoryChain4KB);

            outputHandler.writeUInt32(NoSectorsInFatChain);
            outputHandler.writeUInt32(DirectoryStartSector);

            // reserved
            outputHandler.writeUInt32(0x0);

            outputHandler.writeUInt32(MiniSectorCutoff);
            outputHandler.writeUInt32(MiniFatStartSector);
            outputHandler.writeUInt32(NoSectorsInMiniFatChain);
            outputHandler.writeUInt32(DiFatStartSector);
            outputHandler.writeUInt32(NoSectorsInDiFatChain);

            // First 109 FAT Sectors
            outputHandler.write(_diFatSectors.ToArray());

            // Pad the rest
            if (SectorSize == 4096)
            {
                outputHandler.write(new byte[4096 - 512]);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Writes the internal header stream to the given stream.
        /// </summary>
        /// <param name="stream">The stream to which is written to.</param>
        internal void writeToStream(Stream stream)
        {
            OutputHandler outputHandler = ((OutputHandler)_ioHandler);

            outputHandler.writeToStream(stream);
        }