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>
        /// 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]);
            }
        }