public void ReadRawToc(byte[] rawToc) { containerCount = ByteTools.ReadUInt(rawToc, 0x10); if (containerCount > 0xFFFF) { ByteTools.bigEndian = true; containerCount = ByteTools.ReadUInt(rawToc, 0x10); } tableOffset = ByteTools.ReadUInt(rawToc, 0x14); namesOffset = ByteTools.ReadUInt(rawToc, 0x18); string[] entryNames = Encoding.ASCII.GetString(rawToc, (int)namesOffset, (int)(rawToc.Length - namesOffset)).Split(new char[] { (char)0 }); entries = new tocEntryStruct[entryNames.Length]; for (int i = 0; i < entries.Length; i++) { tocEntryStruct newTocEntry = new tocEntryStruct { nameChecksum = ByteTools.ReadUInt(rawToc, (int)(tableOffset + i * 24 + 0)), isFolder = ByteTools.ReadBoolean(rawToc, (int)(tableOffset + i * 24 + 4)), container = ByteTools.ReadUInt(rawToc, (int)(tableOffset + i * 24 + 8)), offset = ByteTools.ReadUInt(rawToc, (int)(tableOffset + i * 24 + 12)), length = ByteTools.ReadUInt(rawToc, (int)tableOffset + i * 24 + 16), name = entryNames[i] }; entries[i] = newTocEntry; } }
private void ReadRawStz(byte[] rawStz) { for (int i = 0; i < 6; i++) { uint offset = ByteTools.ReadUInt(rawStz, i * 12); uint decompressedLength = ByteTools.ReadUInt(rawStz, i * 12 + 4); uint compressedLength = ByteTools.ReadUInt(rawStz, i * 12 + 8); if (compressedLength > 0) { data[i] = Decompress(rawStz, offset, compressedLength, decompressedLength); } else { data[i] = new byte[0]; } } }
public byte[] CreateRawToc() { int nameStringLength = entries.Length - 1; foreach (tocEntryStruct tocEntry in entries) { nameStringLength += tocEntry.name.Length; } byte[] rawToc = new byte[namesOffset + nameStringLength]; ByteTools.WriteBytes(rawToc, 0, tocIdentifier); ByteTools.WriteUInt(rawToc, 0x10, containerCount); ByteTools.WriteUInt(rawToc, 0x14, tableOffset); ByteTools.WriteUInt(rawToc, 0x18, namesOffset); string namesString = ""; for (int i = 0; i < entries.Length; i++) { tocEntryStruct tocEntry = entries[i]; ByteTools.WriteUInt(rawToc, tableOffset + i * 24 + 0, tocEntry.nameChecksum); ByteTools.WriteUInt(rawToc, tableOffset + i * 24 + 4, tocEntry.isFolder ? 1u : 0u); ByteTools.WriteUInt(rawToc, tableOffset + i * 24 + 8, tocEntry.container); ByteTools.WriteUInt(rawToc, tableOffset + i * 24 + 12, tocEntry.offset); ByteTools.WriteUInt(rawToc, tableOffset + i * 24 + 16, tocEntry.length); ByteTools.WriteUInt(rawToc, tableOffset + i * 24 + 20, (uint)(namesString.Length)); namesString += tocEntry.name; if (i < entries.Length - 1) { namesString += (char)0; } ; } ByteTools.WriteString(rawToc, namesOffset, namesString); return(rawToc); }