Skip to content

CSTR compressed streams

Robomodo RMEArchives and filesApplies toSHRED

A PAK entry whose attribute value is 2 is a CSTR stream: a 16-byte header followed by blocks, each a raw deflate stream of at most 65,531 decoded bytes, or the same bytes stored as they are. The stream is compressed_size bytes long in the PAK and decodes to the entry’s size. Proven · all 31,227 streams of the 336 PAKs

Big-endian throughout.

CSTR header16 bytesSHRED100% known

Followed by the blocks to the end of the stream.

ProvenObservedSourcedInferredUnknownNot described
OffsetSizeTypeFieldConfidenceNotes
0x04char[4] = CSTRmagicProven
0x42u16 = 0xFEEDbyte_order_markProven
0x62u16 = 1versionProven
0x82u16block_countProvenexactly the number of blocks in every stream
0xA2u16 = 0xF32FthresholdProven62,255; the compression-selection threshold the loader compares with
0xC4u32uncompressed_sizeProven
CSTR block4 + stored_sizeSHRED100% known

Blocks follow one another with no padding.

ProvenObservedSourcedInferredUnknownNot described
OffsetSizeTypeFieldConfidenceNotes
0x02u16stored_sizeProvenbytes of payload
0x22u16decoded_sizeProvenbytes the block decodes to; at most 65,531
0x4stored_sizeu8[]payloadProvenraw deflate (no zlib header) when stored_size differs from decoded_size, otherwise the bytes themselves

Across the disc there are 111,391 blocks: 107,170 are deflate and 4,221 are stored (equal sizes). The decoded sizes of a stream’s blocks sum to its header size, and the stored sizes plus headers fill its range in the PAK. Proven · all 31,227 streams The threshold is 0xF32F and the largest decoded block is 65,531 bytes (0xFFFB). Proven · all 31,227 streams

The executable reads the block header, then inflates the block when the stored size is at most the threshold and the decoded size is above 0xFFFB − threshold (3,276 bytes); otherwise it copies the stored bytes. Observed · static reading of the executable That rule and “inflate when the two sizes differ” give the same answer on every one of the 111,391 blocks of the disc and on the 260 blocks of the script archive. Proven · all blocks Its working buffers are 0xFFFB bytes each, which would explain why no block decodes to more. Inferred How the writer picks stored or deflate is not shown by the data, and the threshold’s meaning on the writing side is not established. Unknown

The script archive (SCRIPTS.SDAT decrypted) holds 252 streams in 260 blocks, all compressed, with the same threshold. Observed

Why are some blocks stored?

4,221 blocks are stored. Small blocks and data that deflate cannot shrink are both possible reasons; the split between them was not measured.