Exemplo n.º 1
0
        private Stream BuildVltStream()
        {
            MemoryStream ms = new MemoryStream(8192);
            BinaryWriter bw = new BinaryWriter(ms);
            ChunkWriter  cw = new ChunkWriter(bw, Vault);

            var versionChunk = new VltVersionChunk();

            cw.WriteChunk(versionChunk);

            var startChunk = new VltStartChunk();

            cw.WriteChunk(startChunk);

            var dependencyChunk = new VltDependencyChunk(new List <string>
            {
                $"{Vault.Name}.vlt",
                $"{Vault.Name}.bin"
            });

            cw.WriteChunk(dependencyChunk);

            var dataChunk = new VltDataChunk(ExportManager.GetExports());

            cw.WriteChunk(dataChunk);

            var exportChunk = new VltExportChunk(dataChunk.ExportEntries);

            cw.WriteChunk(exportChunk);
            var binWriter = new BinaryWriter(BinStream);

            foreach (var pointerObject in ExportManager.GetExports().OfType <IPointerObject>())
            {
                pointerObject.WritePointerData(Vault, binWriter);
            }

            // after writing exports, we can build pointers
            BuildPointers();

            var pointersChunk = new VltPointersChunk();

            cw.WriteChunk(pointersChunk);
            var endChunk = new EndChunk();

            cw.WriteChunk(endChunk);

            return(ms);
        }
Exemplo n.º 2
0
        public ChunkBase NextChunk(Vault vault)
        {
            var header = new ChunkBlockHeader();

            header.Read(vault, Reader);
            ChunkBase chunk = null;

            switch (header.ID)
            {
            case 0x53747245:
                chunk = new BinStringsChunk();
                break;

            case 0x5374724E:
                chunk = new VltStartChunk();
                break;

            case 0x456E6443:
                chunk = new EndChunk();
                break;

            case 0x56657273:
                chunk = new VltVersionChunk();
                break;

            case 0x4465704E:
                chunk = new VltDependencyChunk();
                break;

            case 0x4578704E:
                chunk = new VltExportChunk();
                break;

            case 0x5074724E:
                chunk = new VltPointersChunk();
                break;

            default:
                chunk = new GenericChunk(header.ID);
                break;
            }

            chunk.Offset = header.Offset;
            chunk.Size   = header.Size + 8;

            return(chunk);
        }