nx_sevenz_lib.nx
buildroot/runtime/nx_sevenz_lib.nx
about
nx_sevenz_lib.nx -- THE 7z CONTAINER READER (/compare/modding MD29 sz_walk, 2026-09-06), written from the mirrored format
document (knowledge/fetched/cmp_modding_7zFormat.txt, pin 395ad336) and method table (cmp_modding_7z_Methods.txt, pin
418d0748), both READ first. It composes the incumbents and adds no second ruler: nx_lzma_lib (LZMA and LZMA2 coders, the
x86 BCJ branch converter), nxzip_crc32 from nx_zip (the reflected CRC-32 the 7z digests use), and nx_bundle_ingest_lib's
record table, so a 7z walks to the SAME typed rows the zip walker fills and the texture binder and the partition run
unchanged over both.
WHAT IT READS: the 32-byte signature header (its own CRC verified), the next header (CRC verified), an ENCODED header
(decoded through the folder that carries it, then parsed as the plain header), pack info, coders info (folders with
their coder ids, properties, bind pairs and unpack sizes), substreams info (sizes and digests), and files info (empty-stream
and empty-file bit vectors, UTF-16LE names converted to UTF-8). Directories are counted and left out of the table; empty
files are rows with no bytes. Every member's bytes are CRC-checked against the archive's OWN digest -- the container is
the oracle for the decoder. Coders: Copy (00), LZMA (03 01 01), LZMA2 (21), and the two-coder folder 7-Zip writes for
executables, x86 BCJ (03 03 01 03) over LZMA or LZMA2 with the one bind pair in0 <- out1; any other coder or chain is
REPORTED unsupported by name on every member it holds, never guessed at. Solid folders decode once into one buffer sized
from the folder's declared unpack size and every member is a window into it.
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 3 imports · 4 importers
imports: nx_syscalls.nxnx_lzma_lib.nxnx_bundle_ingest_lib.nx
imported by: nx_bundle_ingest.nxnx_pushback_lib.nxnx_sevenz.nxnx_sevenz_gate.nx
structs
| none |
consts
| 21 | const SZ_SIG_LEN: i64 = 32 |
| 22 | const SZ_START_HDR_OFF: i64 = 12 |
| 23 | const SZ_START_HDR_LEN: i64 = 20 |
| 24 | const SZ_NID_END: i64 = 0 |
| 25 | const SZ_NID_HEADER: i64 = 1 |
| 26 | const SZ_NID_ARCHIVE_PROPS: i64 = 2 |
| 27 | const SZ_NID_ADDITIONAL: i64 = 3 |
| 28 | const SZ_NID_MAIN: i64 = 4 |
| 29 | const SZ_NID_FILES: i64 = 5 |
| 30 | const SZ_NID_PACK: i64 = 6 |
| 31 | const SZ_NID_UNPACK: i64 = 7 |
| 32 | const SZ_NID_SUBSTREAMS: i64 = 8 |
| 33 | const SZ_NID_SIZE: i64 = 9 |
| 34 | const SZ_NID_CRC: i64 = 10 |
| 35 | const SZ_NID_FOLDER: i64 = 11 |
| 36 | const SZ_NID_CODERS_UNPACK: i64 = 12 |
| 37 | const SZ_NID_NUM_UNPACK: i64 = 13 |
| 38 | const SZ_NID_EMPTY_STREAM: i64 = 14 |
| 39 | const SZ_NID_EMPTY_FILE: i64 = 15 |
| 40 | const SZ_NID_NAME: i64 = 17 |
| 41 | const SZ_NID_ENCODED: i64 = 23 |
| 42 | const SZ_CODER_COPY: i64 = 0 |
| 43 | const SZ_CODER_LZMA: i64 = 196865 // 03 01 01 = 3*65536 + 1*256 + 1 (the first cut wrote 197121 = 03 02 01 and read every LZMA header as unsupported) |
| 44 | const SZ_CODER_LZMA2: i64 = 33 // 21 |
| 45 | const SZ_CODER_BCJ_X86: i64 = 50528515 // 03 03 01 03 = 3*16777216 + 3*65536 + 256 + 3; as a CLASS it means BCJ x86 over an LZMA-family second coder |
| 46 | const SZ_CODER_UNSUPPORTED: i64 = 0 - 1 |
| 47 | const SZ_CODER_CHAIN: i64 = 0 - 2 |
| 48 | const SZ_MAX_FOLDERS_PER_BYTES: i64 = 8 // derived caps: a folder or a file costs at least this many header bytes |
| 49 | const SZ_MAX_FILES_PER_BYTES: i64 = 2 |
| 51 | const SZ_OK: i64 = 0 |
| 52 | const SZ_ERR_NOT_7Z: i64 = 0 - 1 |
| 53 | const SZ_ERR_START_CRC: i64 = 0 - 2 |
| 54 | const SZ_ERR_TRUNCATED: i64 = 0 - 3 |
| 55 | const SZ_ERR_HEADER_CRC: i64 = 0 - 4 |
| 56 | const SZ_ERR_HEADER_CODER: i64 = 0 - 5 |
| 57 | const SZ_ERR_SYNTAX: i64 = 0 - 6 |
| 58 | const SZ_ERR_EXTERNAL: i64 = 0 - 7 |
| 59 | const SZ_ERR_HEADER_DECODE: i64 = 0 - 8 |
| 61 | const SZ_M_ERR: i64 = 0 |
| 62 | const SZ_M_NPACK: i64 = 1 |
| 63 | const SZ_M_PACKPOS: i64 = 2 |
| 64 | const SZ_M_PACKSIZES: i64 = 3 |
| 65 | const SZ_M_NFOLD: i64 = 4 |
| 66 | const SZ_M_FCODER: i64 = 5 |
| 67 | const SZ_M_FPROPS_OFF: i64 = 6 |
| 68 | const SZ_M_FPROPS_LEN: i64 = 7 |
| 69 | const SZ_M_FUNPACK: i64 = 8 |
| 70 | const SZ_M_FCRC: i64 = 9 |
| 71 | const SZ_M_FCRCDEF: i64 = 10 |
| 72 | const SZ_M_FNSUB: i64 = 11 |
| 73 | const SZ_M_FPACKIDX: i64 = 12 |
| 74 | const SZ_M_FNCODERS: i64 = 13 |
| 75 | const SZ_M_NSUB: i64 = 14 |
| 76 | const SZ_M_SUBSIZE: i64 = 15 |
| 77 | const SZ_M_SUBCRC: i64 = 16 |
| 78 | const SZ_M_SUBCRCDEF: i64 = 17 |
| 79 | const SZ_M_NFILES: i64 = 18 |
| 80 | const SZ_M_FILE_EMPTYSTREAM: i64 = 19 |
| 81 | const SZ_M_FILE_EMPTYFILE: i64 = 20 |
| 82 | const SZ_M_NAMES: i64 = 21 |
| 83 | const SZ_M_NAMEOFF: i64 = 22 |
| 84 | const SZ_M_NAMELEN: i64 = 23 |
| 85 | const SZ_M_ENCODED: i64 = 24 |
| 86 | const SZ_M_DIRS: i64 = 25 |
| 87 | const SZ_M_EMPTYFILES: i64 = 26 |
| 88 | const SZ_M_DATAFILES: i64 = 27 |
| 89 | const SZ_M_HDRBUF: i64 = 28 |
| 90 | const SZ_M_HDRLEN: i64 = 29 |
| 91 | const SZ_M_BASE: i64 = 30 |
| 92 | const SZ_M_NEMPTYSTREAMS: i64 = 31 |
| 93 | const SZ_M_HDR_CODERID: i64 = 32 |
| 94 | const SZ_M_HDR_NCODERS: i64 = 33 |
| 95 | const SZ_M_FCODER0RAW: i64 = 34 |
| 96 | const SZ_M_FCODER1RAW: i64 = 35 |
| 97 | const SZ_M_FPROPS2_OFF: i64 = 36 |
| 98 | const SZ_M_FPROPS2_LEN: i64 = 37 |
| 99 | const SZ_M_FUNPACK2: i64 = 38 |
| 100 | const SZ_M_FBIND_IN: i64 = 39 |
| 101 | const SZ_M_FBIND_OUT: i64 = 40 |
| 102 | const SZ_M_N: i64 = 48 |
functions
| 104 | func sz_is_7z(b: *u8, n: i64) -> i64 |
| 114 | func sz_u32(b: *u8, o: i64) -> i64 { return ((b[o] & 0xff) as i64) | (((b[o + 1] & 0xff) as i64) * 256) | (((b[o + 2] & 0xff) as i64) * 65536) | (((b[o + 3] & 0xff) as i64) * 16777216) } |
| 115 | func sz_u64(b: *u8, o: i64) -> i64 { return sz_u32(b, o) + sz_u32(b, o + 4) * 4294967296 } |
| 117 | func sz_rd8(b: *u8, p: *i64, end: i64, m: *i64) -> i64 |
| 124 | func sz_num(b: *u8, p: *i64, end: i64, m: *i64) -> i64 |
| 137 | func sz_skip(p: *i64, end: i64, n: i64, m: *i64) -> i64 called by 1: sz_header |
| 143 | func sz_bit(v: *u8, i: i64) -> i64 { return (((v[i / 8] & 0xff) as i64) / lz_pow2(7 - (i % 8))) & 1 } |
| 145 | func sz_digests(b: *u8, p: *i64, end: i64, m: *i64, n: i64, def: *i64, crc: *i64) -> i64 |
| 162 | func sz_streams_info(b: *u8, p: *i64, end: i64, m: *i64) -> i64 |
| 393 | func sz_utf16_to_utf8(b: *u8, off: i64, units: i64, out: *u8, o0: i64, cap: i64) -> i64 called by 1: sz_header |
| 411 | func sz_header(b: *u8, p: *i64, end: i64, m: *i64) -> i64 |
| 489 | func sz_decode_folder(b: *u8, n: i64, m: *i64, f: i64, rc: *i64) -> *u8 |
| 547 | func sz_parse(b: *u8, n: i64, m: *i64) -> i64 |
| 609 | func sz_err_name(e: i64) -> *u8 |
| 620 | func sz_coder_name(c: i64) -> *u8 |
| 629 | func sz_count(b: *u8, n: i64) -> i64 |
| 639 | func sz_walk(b: *u8, n: i64, tbl: *i64, maxm: i64, names: *u8, ncap: i64, st: *i64) -> i64 called by 3: mainszc_walkzg_walk calls 7: sys_mmapsz_parsebi_recsz_decode_folderap_claimap_identify+1 |
| 739 | func sz_put8(o: *u8, p: *i64, v: i64) -> i64 { o[p[0]] = (v & 255) as u8; p[0] = p[0] + 1; return 1 } |
| 740 | func sz_put32(o: *u8, p: *i64, v: i64) -> i64 { var i: i64 = 0; var x: i64 = v; while i < 4 { sz_put8(o, p, x & 255); x = x / 256; i = i + 1 } return 4 } |
| 741 | func sz_put64(o: *u8, p: *i64, v: i64) -> i64 { var i: i64 = 0; var x: i64 = v; while i < 8 { sz_put8(o, p, x & 255); x = x / 256; i = i + 1 } return 8 } |
| 743 | func sz_putnum(o: *u8, p: *i64, v: i64) -> i64 |
| 764 | func sz_write_copy(names: *i64, datas: *i64, lens: *i64, nfiles: i64, out: *u8, outcap: i64) -> i64 |