Beispiel #1
0
        private static VolHeader BuildHeader(string directory)
        {
            VolHeader      header       = new VolHeader();
            MemoryStream   stringStream = new MemoryStream();
            BinaryWriter   nameString   = new BinaryWriter(stringStream);
            VolHeaderEntry root         = new VolHeaderEntry();

            root.entryOffset = 0x14;
            root.parent      = null;
            AppendVolHeaderFileName(nameString, ".", out root.nameOffset);
            uint runningFileDataOffset = 0;
            uint dirEntryIter          = 0x14;
            uint fileInfoSize          = 0;

            root.dataOffset  = 0x14;
            root.entryOffset = 0x14;
            root.children    = DirectoryToHeaderEntries(directory, nameString, ref dirEntryIter, ref runningFileDataOffset, ref fileInfoSize);
            nameString.Flush();
#if DEBUG
            Console.WriteLine(
                "Sizes: fileInfoOffset = {0:x}, fileInfoSize = {1:x}, runningFDO = {2:x}, nameString Length {3:x}",
                dirEntryIter,
                fileInfoSize,
                runningFileDataOffset,
                stringStream.Position
                );
#endif
            header.nameString     = stringStream.ToArray();
            header.fileInfoOffset = dirEntryIter;
            header.volEntries     = root;
            header.nameOffset     = header.fileInfoOffset + fileInfoSize;
            header.headerSize     = header.nameOffset + (uint)header.nameString.Length;
            return(header);
        }
Beispiel #2
0
        private static void WriteHeader(BinaryWriter volWriter, VolHeader volHead)
        {
            MemoryStream fileInfo       = new MemoryStream();
            BinaryWriter fileInfoWriter = new BinaryWriter(fileInfo);

            WriteDirectory(
                volWriter,
                fileInfoWriter,
                volHead.fileInfoOffset,
                volHead.nameOffset,
                (uint)((volHead.headerSize + 0x7FF) & ~0x7FF),
                volHead.volEntries
                );
            volWriter.Flush();
            fileInfoWriter.Flush();
            fileInfoWriter.BaseStream.Position = 0;
            byte[] buffer = new byte[8192];
            StreamUtils.Copy(fileInfoWriter.BaseStream, volWriter.BaseStream, buffer);
        }