public void readIn(BinaryReader br, IO.ByteOrder endian) { blankMagic = IO.ReadUInt32(br, endian); dTOC_ptr = IO.ReadUInt32(br, endian); dTOC_entryCount = IO.ReadUInt32(br, endian); unkVarA = IO.ReadUInt32(br, endian); unkVarB = IO.ReadUInt32(br, endian); unkVarC = IO.ReadUInt32(br, endian); unkVarD = IO.ReadUInt32(br, endian); unkVarE = IO.ReadUInt32(br, endian); }
public void readIn(BinaryReader br, IO.ByteOrder endian) { _offset = (uint32)br.BaseStream.Position; size = IO.ReadUInt32(br, endian); zsize = IO.ReadUInt32(br, endian); if (size == 0) { //align n return br.BaseStream.Position += IO.PaddingAlign(br.BaseStream.Position, 2); return; } byte[] zbuffer = br.ReadBytes((int)zsize); cdata = LZ4Codec.Decode(zbuffer, 0, zbuffer.Length, (int)size); if (cdata.Length != (int)size) { throw new Exception("Error"); } }
public void readIn(BinaryReader br, IO.ByteOrder endian) { toc_entryPtr = IO.ReadUInt32(br, endian); }
public void DebugExport() { //fire up the stream and reader Program.VText("Initalizing PKG Export.."); fs = new FileStream(In_FilePath, FileMode.Open, FileAccess.Read); br = new BinaryReader(fs); IO.ByteOrder byteSex = IO.ByteOrder.BigEndian; header.magic = IO.ReadBytes(br, 4, byteSex); if (this.checkFOURCC(header.magic) != true) { Program.PError("ERROR: INCORRECT MAGIC BYTES - looking for 00 18 00 XX"); return; } Program.VText("Detected Platform: " + this.consoleType.ToString()); header.nElementCount = IO.ReadUInt16(br, byteSex); header.version = IO.ReadUInt16(br, byteSex); header.unknownA = IO.ReadUInt32(br, byteSex); header.unknownB = IO.ReadUInt32(br, byteSex); header.blankA = IO.ReadUInt32(br, byteSex); header.flagA = IO.ReadUInt32(br, byteSex); header.constValA = IO.ReadUInt32(br, byteSex); header.constValB = IO.ReadUInt32(br, byteSex); header.stampText = IO.ReadBytes(br, 132, byteSex); pkgSigInfo.unknownA = IO.ReadUInt32(br, byteSex); pkgSigInfo.unknownB = IO.ReadUInt32(br, byteSex); pkgSigInfo.unknownC = IO.ReadUInt32(br, byteSex); pkgSigInfo.dataPointer = IO.ReadUInt32(br, byteSex); pkgSigInfo.unkParA = IO.ReadUInt32(br, byteSex); pkgSigInfo.unkParB = IO.ReadUInt32(br, byteSex); pkgSigInfo.chunk = IO.ReadBytes(br, 20, byteSex); entryDescriptor.entryBlockCount = IO.ReadUInt32(br, byteSex); entryDescriptor.entryBlockLocation = IO.ReadUInt32(br, byteSex); entryDescriptor.chunk = IO.ReadBytes(br, 20, byteSex); //seek to the start of the entries fs.Seek(entryDescriptor.entryBlockLocation, SeekOrigin.Begin); //Read each entry and process Program.VText("Reading Package entries.."); for (uint i = 0; i < entryDescriptor.entryBlockCount; i++) { PK_Entry curEntry; curEntry.FileOffset = IO.ReadUInt32(br, byteSex); curEntry.CompressedFileSize = IO.ReadUInt32(br, byteSex); curEntry.flag = IO.ReadBytes(br, 4, byteSex); curEntry.Sha1FileHash = IO.ReadBytes(br, 20, byteSex); //append entries.Add(curEntry); } //now export those entries Program.VText("Exporting Package entries.."); foreach (PK_Entry pkFile in this.entries) { fs.Seek(pkFile.FileOffset, SeekOrigin.Begin); if (pkFile.flag[1] == 0x1) { if (this.ignoreCompressed != true) { Program.VText(String.Format("Entry: " + "0x{0}", pkFile.FileOffset.ToString("x")) + " compressed"); } else { Program.VText(String.Format("Entry: " + "0x{0}", pkFile.FileOffset.ToString("x")) + " is compressed will ignore"); } } else { Program.VText(String.Format("Entry: " + "0x{0}", pkFile.FileOffset.ToString("x")) + " uncompressed"); } if (this.ignoreCompressed != true) { string outFilePath = Path.Combine(Out_FolderPath, String.Format("0x{0}", pkFile.FileOffset.ToString("x")) + ".dat"); using (FileStream fw = new FileStream(outFilePath, FileMode.Create, FileAccess.Write)) { bw = new BinaryWriter(fw); bw.Write(br.ReadBytes((int)pkFile.CompressedFileSize)); } Program.VText("-->Saved: " + Path.GetFileName(outFilePath)); Program.VText(""); } } //close reader and underlying stream br.Close(); Program.VText(""); Program.VText("Done!"); }