Ejemplo n.º 1
0
 public FIoStoreTocHeader(FArchive Ar)
 {
     TocMagic = Ar.ReadBytes(16);
     if (!TOC_MAGIC.SequenceEqual(TocMagic))
     {
         throw new ParserException(Ar, "Invalid utoc magic");
     }
     Version       = Ar.Read <EIoStoreTocVersion>();
     _reserved0    = Ar.Read <byte>();
     _reserved1    = Ar.Read <ushort>();
     TocHeaderSize = Ar.Read <uint>();
     TocEntryCount = Ar.Read <uint>();
     TocCompressedBlockEntryCount = Ar.Read <uint>();
     TocCompressedBlockEntrySize  = Ar.Read <uint>();
     CompressionMethodNameCount   = Ar.Read <uint>();
     CompressionMethodNameLength  = Ar.Read <uint>();
     CompressionBlockSize         = Ar.Read <uint>();
     DirectoryIndexSize           = Ar.Read <uint>();
     PartitionCount    = Ar.Read <uint>();
     ContainerId       = Ar.Read <FIoContainerId>();
     EncryptionKeyGuid = Ar.Read <FGuid>();
     ContainerFlags    = Ar.Read <EIoContainerFlags>();
     _reserved3        = Ar.Read <byte>();
     _reserved4        = Ar.Read <ushort>();
     _reserved5        = Ar.Read <uint>();
     PartitionSize     = Ar.Read <ulong>();
     _reserved6        = Ar.ReadArray <ulong>(6);
 }
Ejemplo n.º 2
0
        public FIoContainerHeader(FArchive Ar)
        {
            var version = Ar.Game >= EGame.GAME_UE5_0 ? EIoContainerHeaderVersion.Initial : EIoContainerHeaderVersion.BeforeVersionWasAdded;

            if (version == EIoContainerHeaderVersion.Initial)
            {
                var signature = Ar.Read <uint>();
                if (signature != Signature)
                {
                    throw new ParserException(Ar, $"Invalid container header signature: 0x{signature:X8} != 0x{Signature:X8}");
                }

                version = Ar.Read <EIoContainerHeaderVersion>();
            }

            ContainerId  = Ar.Read <FIoContainerId>();
            PackageCount = Ar.Read <uint>();
            if (version == EIoContainerHeaderVersion.BeforeVersionWasAdded)
            {
                var namesSize      = Ar.Read <int>();
                var namesPos       = Ar.Position;
                var nameHashesSize = Ar.Read <int>();
                var continuePos    = Ar.Position + nameHashesSize;
                Ar.Position      = namesPos;
                ContainerNameMap = FNameEntrySerialized.LoadNameBatch(Ar, nameHashesSize / sizeof(ulong) - 1);
                Ar.Position      = continuePos;
            }

            PackageIds = Ar.ReadArray <FPackageId>();
            var storeEntriesSize = Ar.Read <int>();
            var storeEntriesEnd  = Ar.Position + storeEntriesSize;

            StoreEntries = Ar.ReadArray((int)PackageCount, () => new FFilePackageStoreEntry(Ar));
            Ar.Position  = storeEntriesEnd;
            if (version >= EIoContainerHeaderVersion.Initial)
            {
                ContainerNameMap = FNameEntrySerialized.LoadNameBatch(Ar); // Actual name is RedirectsNameMap
            }

            // Skip CulturePackageMap and PackageRedirects
        }