public void ReadBlock(Stream s) { s.Seek((long)((ulong)this.Blocks.Offset), SeekOrigin.Begin); for (uint num = 0U; num < this.Blocks.Size; num += 1U) { BlockEntry blockEntry = new BlockEntry { BlockNumber = num, Offset = Helpers.ReadUInt(s), Size = Helpers.ReadUInt(s), PatchId = Helpers.ReadUShort(s), Flag = Helpers.ReadUShort(s) }; if ((blockEntry.Flag & 1) != 0) { blockEntry.Encrypted = true; } if ((blockEntry.Flag & 2) != 0) { blockEntry.Compressed = true; } if ((blockEntry.Flag & 4) != 0) { blockEntry.AltKey = true; } blockEntry.Md5Hash = Helpers.ReadByteArray(s, 0x14U); blockEntry.GcmTag = Helpers.ReadByteArray(s, 0x10U); this.BlockEntryList.Add(blockEntry); } }
private void GetBlockEntries() { for (uint num = this.PkgEntry.StartBlock; num < this.PkgEntry.StartBlock + this.PkgEntry.BlockCount; num += 1U) { BlockEntry item = this._pkgStream.BlockEntryList[(int)num]; this.BlockEntries.Add(item); } }
public byte[] ToBuffer(uint fnumber) { PkgEntry pkgEntry = default(PkgEntry); pkgEntry = this.GetPkgEntryInfo(fnumber); byte[] array = new byte[pkgEntry.BlockCount * 0x40000U]; using (FileStream fileStream = File.OpenRead(Form1.RecD2PkgDir() + pkgEntry.StartBlockPkg)) { for (uint num = pkgEntry.StartBlock; num < pkgEntry.StartBlock + pkgEntry.BlockCount; num += 1U) { BlockEntry blockEntry = this._pkgStream.BlockEntryList[(int)num]; byte[] array2 = new byte[blockEntry.Size]; fileStream.Seek((long)((ulong)blockEntry.Offset), SeekOrigin.Begin); fileStream.Read(array2, 0, (int)blockEntry.Size); if (blockEntry.Encrypted) { if (!blockEntry.AltKey) { array2 = this.DecryptBuffer(array2, this._pkgStream.Nonce, blockEntry.GcmTag, 1); } else { array2 = this.DecryptBuffer(array2, this._pkgStream.Nonce, blockEntry.GcmTag, 2); } } uint num2 = blockEntry.Size; if (blockEntry.Compressed) { array2 = this.DecompressBuffer(array2); num2 = 0x40000U; } Array.Copy(array2, 0L, array, (long)((ulong)((num - pkgEntry.StartBlock) * 0x40000U)), (long)((ulong)num2)); } fileStream.Close(); } byte[] array3 = new byte[pkgEntry.EntrySize]; Array.Copy(array, (long)((ulong)pkgEntry.InBlockOffset), array3, 0L, (long)((ulong)pkgEntry.EntrySize)); return(array3); }
public void ReadEntries(Stream s) { s.Seek((long)((ulong)this.Entries.Offset), SeekOrigin.Begin); for (uint num = 0U; num < this.Entries.Size; num += 1U) { PkgEntry pkgEntry = default(PkgEntry); pkgEntry.EntryNumber = num; pkgEntry.EntryA = Helpers.ReadUInt(s); pkgEntry.TypeA = Helpers.ReadUInt(s); pkgEntry.EntryB = Helpers.ReadULong(s); pkgEntry.StartBlock = (uint)(pkgEntry.EntryB & 0x3FFFUL); pkgEntry.StartBlockOffset = this.Blocks.Offset + pkgEntry.StartBlock * 0x30U; int index = this._pkgListEntries.FindIndex(new Predicate <PkgListEntry>(this.ReadEntries19)); PkgListEntry pkgListEntry = this._pkgListEntries[index]; BlockEntry blockEntry = this.BlockEntryList[(int)pkgEntry.StartBlock]; pkgEntry.StartBlockPkg = string.Concat(new object[] { pkgListEntry.Basename, "_", blockEntry.PatchId, ".pkg" }); pkgEntry.InBlockOffset = (uint)((pkgEntry.EntryB >> 0xE & 0x3FFFUL) * 0x10UL); pkgEntry.EntrySize = (uint)(pkgEntry.EntryB >> 0x1C & 0x3FFFFFFFUL); pkgEntry.BlockCount = this.CalcBlockCount(pkgEntry.InBlockOffset, pkgEntry.EntrySize); pkgEntry.UnkEntryInfo = (uint)(pkgEntry.EntryB >> 0x3A & 0x3FUL); pkgEntry.Filename = string.Concat(new string[] { this.Header.PackageId.ToString("X4"), "_", pkgEntry.EntryNumber.ToString("X4"), "_", this.Header.LangId.ToString("X2") }); pkgEntry.FileType = FileClassification.FileClassify(pkgEntry.EntryA, pkgEntry.TypeA); this.PkgEntryList.Add(pkgEntry); } }