import os, struct, sys import lz4.block class SegmentHeader: fileOffset = 0 memoryOffset = 0 decompressedSize = 0 def __init__(self, fileOffset, memoryOffset, decompressedSize): self.fileOffset = fileOffset self.memoryOffset = memoryOffset self.decompressedSize = decompressedSize class SegmentHeaderRelative: offset = 0 size = 0 def __init__(self, offset, size): self.offset = offset self.size = size class NSO: textSegmentHeader = None textData = [] rawData = None def __init__(self, nsoBinary): self.rawData = nsoBinary nsoStr = struct.unpack_from("4s", self.rawData, 0)[0].decode('latin-1') if nsoStr != "NSO0": print("Invalid NSO.") sys.exit(1) # we only need two things out of the header # 1) the offset and size of the text data within the binary (and its compressed size) # 2) whether or not we need to decompress the data flags = struct.unpack_from("