コード例 #1
0
ファイル: DLCPackage.cs プロジェクト: henbagle/ME3Explorer
        public void Serialize(SerializingFile con)
        {
            if (con.isLoading)
            {
                Header = new HeaderStruct();
            }
            Header.Serialize(con);
            con.Seek((int)Header.EntryOffset, SeekOrigin.Begin);
            for (int i = 0; i < Header.FileCount; i++)
            {
                //Debug.WriteLine($"Serialize sfar file {i} at 0x{con.Memory.Position:X8}");
                var feStruct = new FileEntryStruct();
                feStruct.Serialize(con, Header);
                Files.Add(feStruct);
                //Debug.WriteLine($"Data offset for {i}: 0x{Files[i].DataOffset:X8} (0x{Files[i].RealDataOffset:X8}), header at 0x{pos:X8}");
            }

            //var ordered = Files.OrderBy(x => x.DataOffset).ToList();
            //foreach (var f in ordered)
            //{
            //    Debug.WriteLine($"0x{f.DataOffset:X8} (0x{f.RealDataOffset:X8}), header at {f.MyOffset:X8}");
            //}
            //var firstfile = Files.MinBy(x => x.RealDataOffset);

            if (con.isLoading)
            {
                ReadFileNames();
            }
        }
コード例 #2
0
ファイル: DLCPackage.cs プロジェクト: henbagle/ME3Explorer
 public void Serialize(SerializingFile con)
 {
     //Magic = magic;
     Version          = con + Version;
     DataOffset       = con + DataOffset;
     EntryOffset      = con + EntryOffset;
     FileCount        = con + FileCount;
     BlockTableOffset = con + BlockTableOffset;
     MaxBlockSize     = con + MaxBlockSize;
     if (con.isLoading)
     {
         CompressionScheme = con.Memory.BaseStream.ReadStringASCII(4).Trim();
     }
     if (//Magic != 0x53464152 ||
         Version != 0x00010000 ||
         MaxBlockSize != 0x00010000)
     {
         throw new Exception("Not supported DLC file!");
     }
 }
コード例 #3
0
ファイル: DLCPackage.cs プロジェクト: henbagle/ME3Explorer
            public void Serialize(SerializingFile con, HeaderStruct header)
            {
                Header       = header;
                MyOffset     = (uint)con.GetPos();
                isActualFile = true; //default to true
                if (con.isLoading)
                {
                    Hash = new byte[16];
                }
                for (int i = 0; i < 16; i++)
                {
                    Hash[i] = con + Hash[i];
                }
                BlockSizeTableIndex = con + BlockSizeTableIndex;
                if (con.Memory.Endian == Endian.Big)
                {
                    UncompressedSizeAdder = con + UncompressedSizeAdder;
                    UncompressedSize      = con + UncompressedSize;
                    DataOffsetAdder       = con + DataOffsetAdder;
                    DataOffset            = con + DataOffset;
                }
                else
                {
                    UncompressedSize      = con + UncompressedSize;
                    UncompressedSizeAdder = con + UncompressedSizeAdder;
                    DataOffset            = con + DataOffset;
                    DataOffsetAdder       = con + DataOffsetAdder;
                }
                RealUncompressedSize = UncompressedSize + UncompressedSizeAdder; //<< 32

                RealDataOffset = DataOffset + DataOffsetAdder;                   // << 32
                if (BlockSizeTableIndex == 0xFFFFFFFF)                           //Decompressed
                {
                    BlockOffsets     = new long[1];
                    BlockOffsets[0]  = RealDataOffset;
                    BlockSizes       = new ushort[1];
                    BlockSizes[0]    = (ushort)UncompressedSize;
                    BlockTableOffset = 0;
                }
                else //Compressed
                {
                    int numBlocks = (int)Math.Ceiling(UncompressedSize / (double)header.MaxBlockSize);
                    if (con.isLoading)
                    {
                        BlockOffsets = new long[numBlocks];
                        BlockSizes   = new ushort[numBlocks];
                    }

                    if (numBlocks > 0)
                    {
                        BlockOffsets[0] = RealDataOffset;
                        long pos = con.Memory.Position;
                        con.Seek((int)getBlockOffset((int)BlockSizeTableIndex, header.EntryOffset, header.FileCount), SeekOrigin.Begin);
                        BlockTableOffset = con.Memory.Position;
                        BlockSizes[0]    = con + BlockSizes[0];
                        for (int i = 1; i < numBlocks; i++) //read any further blocks
                        {
                            BlockSizes[i]   = con + BlockSizes[i];
                            BlockOffsets[i] = BlockOffsets[i - 1] + BlockSizes[i];
                        }

                        con.Seek((int)pos, SeekOrigin.Begin);
                    }
                }
            }