internal void ExtractAllLimited0(PkgEntry pkgListEntry) { if (pkgListEntry.FileType != "Image" && pkgListEntry.FileType != "Audio" && pkgListEntry.FileType != "Text") { this.PkgEx.Extract(pkgListEntry.EntryNumber, this.OutputDir); } }
internal void GetFiles0(PkgEntry pkgListEntry) { PkgFile pkgFile = new PkgFile(this.PkgStream, pkgListEntry.EntryNumber); if (pkgFile.PkgFileType == PkgFileType.Text) { List <PkgFile> d2Files = this.TextInstance._d2Files; lock (d2Files) { this.TextInstance._d2Files.Add(pkgFile); } } }
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 static PkgFileType SetD2Filetype(PkgEntry pkgEntry) { PkgFileType result = PkgFileType.None; if (pkgEntry.FileType == FileClassification.ImageType) { result = PkgFileType.Image; } else if (pkgEntry.FileType == FileClassification.TextType) { result = PkgFileType.Text; } else if (pkgEntry.FileType == FileClassification.AudioType) { result = PkgFileType.Audio; } else if (pkgEntry.FileType == FileClassification.ModelType) { result = PkgFileType.Model; } return(result); }
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); } }
public byte[] ToBuffer(PkgFile pkgFile) { PkgEntry pkgEntry = pkgFile.PkgEntry; byte[] array = new byte[pkgEntry.BlockCount * 0x40000U]; using (FileStream fileStream = File.OpenRead(Form1.RecD2PkgDir() + pkgEntry.StartBlockPkg)) { foreach (BlockEntry blockEntry in pkgFile.BlockEntries) { 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, pkgFile.Nonce, blockEntry.GcmTag, 1); } else { array2 = this.DecryptBuffer(array2, pkgFile.Nonce, blockEntry.GcmTag, 2); } } uint num = blockEntry.Size; if (blockEntry.Compressed) { array2 = this.DecompressBuffer(array2); num = 0x40000U; } Array.Copy(array2, 0L, array, (long)((ulong)((blockEntry.BlockNumber - pkgEntry.StartBlock) * 0x40000U)), (long)((ulong)num)); } fileStream.Close(); } byte[] array3 = new byte[pkgEntry.EntrySize]; Array.Copy(array, (long)((ulong)pkgEntry.InBlockOffset), array3, 0L, (long)((ulong)pkgEntry.EntrySize)); return(array3); }
internal void ExtractAll0(PkgEntry pkgListEntry) { this.Pkgex.Extract(pkgListEntry.EntryNumber, this.OutputDir); }