示例#1
0
 private static UnPackage DoReadPackage(BinaryReader reader)
 {
     var signature = reader.ReadInt32();
     var packageVersion = reader.ReadInt32();
     var firstExportOffset = reader.ReadInt32();
     var folderNameLength = reader.ReadInt32();
     var folderName = reader.ReadBytes(folderNameLength);
     var packageFlags = reader.ReadInt32();
     var namesCount = reader.ReadInt32();
     var namesOffset = reader.ReadInt32();
     var exportsCount = reader.ReadInt32();
     var exportsOffset = reader.ReadInt32();
     var importsCount = reader.ReadInt32();
     var importsOffset = reader.ReadInt32();
     reader.ReadInt32();  // unknown
     var guid = reader.ReadBytes(16);
     var generationsCount = reader.ReadInt32();
     for (int i = 0; i < generationsCount; i++)
     {
         reader.ReadBytes(12);
     }
     var engineVersion = reader.ReadInt32();
     var cookerVersion = reader.ReadInt32();
     if (engineVersion == 3240)
     {
         reader.ReadBytes(28);
     }
     Stream dataStream;
     if ((packageFlags & 0x00800000) != 0)
     {
         var compressionFlag = reader.ReadInt32();
         var chunkedStream = new ChunkedStream(reader.BaseStream);
         var chunkCount = reader.ReadInt32();
         for(int i=0; i<chunkCount; i++)
         {
             var uncompressedOffset = reader.ReadInt32();
             var uncompressedSize = reader.ReadInt32();
             var compressedOffset = reader.ReadInt32();
             var compressedSize = reader.ReadInt32();
             chunkedStream.AddChunk(uncompressedOffset, uncompressedSize, compressedOffset, compressedSize);
         }
         dataStream = chunkedStream;
     }
     else
     {
         dataStream = reader.BaseStream;
     }
     UnPackage package = new UnPackage(dataStream);
     RegisterInstanceReaders(package);
     ReadNames(package, dataStream, namesOffset, namesCount);
     ReadImports(package, dataStream, importsOffset, importsCount);
     ReadExports(package, dataStream, exportsOffset, exportsCount);
     return package;
 }