#!/usr/bin/env python3 """ unpack_upk.py — decompress a fully-compressed, LZO-compressed Unreal Engine 3 .upk. Many UE3 games ship "fully compressed" (LZO) packages that some tools can't read: UELib's package decompressor is a stub, and UPKUtils' DecompressLZO only accepts XCOM and Batman package versions (Dishonored, build 801/30, is rejected). Gildor's decompress (from UE Viewer) is the community tool for these; this is a small Python fallback for LZO packages, meant for reading the result with UELib. Only LZO (CompressionFlags 2) is handled. Usage (minilzo is a C extension built from source, so it needs a C compiler): uv run --python 3.12 --with minilzo python unpack_upk.py Then, to read the contents with UELib, clear ONLY the CompressionFlags dword in the output (keep the chunk count/table) so UnrealPackage.Deserialize stops returning early. Pass the output file and the CompressionFlags offset the script printed (0x79 in this example): python - DishonoredGame.fixed.upk 0x79 <<'PY' import struct,sys p=sys.argv[1]; off=int(sys.argv[2],0); d=bytearray(open(p,'rb').read()) struct.pack_into(' len(d): break flags = struct.unpack_from(' len(d): continue recs = [struct.unpack_from('