- Decompression: MPQ zlib blocks (DecompressData_WithOptions, 0x661A80) decoded with libdeflate 1.26 (vendored, decompression only), one decompressor per thread. Like the original, reports the produced size through outSize (verified in the client at +0x174). - MPQ file-lookup cache for File_FindInArchive (0x6549a0), re-implemented from WeirdUtils with an SRW lock (lookups also happen on loading threads) and stricter archive re-validation on hits. - Lua strings: table-driven matchclass (built lazily from the original on first use), a literal prefilter for string.find / gsub / the gfind iterator, and luaS_newlstr with a hash check before comparing bytes. - Claims WeirdUtils' "weirdperformance" mutex so an old weirdutils.dll never runs its custom Lua GC alongside. Prefilter fix over WeirdUtils: string.gfind does not treat a leading '^' as an anchor (Lua 5.0 gfind_aux calls match() directly), so '^' is an ordinary, quantifiable character there. Treating it as an anchor made patterns like "^*abab" wrongly report no match. Tests: tests/test_prefilter checks the prefilter against the real Lua 5.0.3 string library (vendored in tests/lua50): 4.7M fuzz checks plus 10M checks of 531 real addon patterns against combat-log and chat lines, 0 violations; the matcher is skipped in about half of real-world calls. Decompression verified through the hook in the offline harness. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
57 lines
1.7 KiB
C
57 lines
1.7 KiB
C
/*
|
|
* deflate_constants.h - constants for the DEFLATE compression format
|
|
*/
|
|
|
|
#ifndef LIB_DEFLATE_CONSTANTS_H
|
|
#define LIB_DEFLATE_CONSTANTS_H
|
|
|
|
/* Valid block types */
|
|
#define DEFLATE_BLOCKTYPE_UNCOMPRESSED 0
|
|
#define DEFLATE_BLOCKTYPE_STATIC_HUFFMAN 1
|
|
#define DEFLATE_BLOCKTYPE_DYNAMIC_HUFFMAN 2
|
|
|
|
/* Minimum and maximum supported match lengths (in bytes) */
|
|
#define DEFLATE_MIN_MATCH_LEN 3
|
|
#define DEFLATE_MAX_MATCH_LEN 258
|
|
|
|
/* Maximum supported match offset (in bytes) */
|
|
#define DEFLATE_MAX_MATCH_OFFSET 32768
|
|
|
|
/* log2 of DEFLATE_MAX_MATCH_OFFSET */
|
|
#define DEFLATE_WINDOW_ORDER 15
|
|
|
|
/* Number of symbols in each Huffman code. Note: for the literal/length
|
|
* and offset codes, these are actually the maximum values; a given block
|
|
* might use fewer symbols. */
|
|
#define DEFLATE_NUM_PRECODE_SYMS 19
|
|
#define DEFLATE_NUM_LITLEN_SYMS 288
|
|
#define DEFLATE_NUM_OFFSET_SYMS 32
|
|
|
|
/* The maximum number of symbols across all codes */
|
|
#define DEFLATE_MAX_NUM_SYMS 288
|
|
|
|
/* Division of symbols in the literal/length code */
|
|
#define DEFLATE_NUM_LITERALS 256
|
|
#define DEFLATE_END_OF_BLOCK 256
|
|
#define DEFLATE_FIRST_LEN_SYM 257
|
|
|
|
/* Maximum codeword length, in bits, within each Huffman code */
|
|
#define DEFLATE_MAX_PRE_CODEWORD_LEN 7
|
|
#define DEFLATE_MAX_LITLEN_CODEWORD_LEN 15
|
|
#define DEFLATE_MAX_OFFSET_CODEWORD_LEN 15
|
|
|
|
/* The maximum codeword length across all codes */
|
|
#define DEFLATE_MAX_CODEWORD_LEN 15
|
|
|
|
/* Maximum possible overrun when decoding codeword lengths */
|
|
#define DEFLATE_MAX_LENS_OVERRUN 137
|
|
|
|
/*
|
|
* Maximum number of extra bits that may be required to represent a match
|
|
* length or offset.
|
|
*/
|
|
#define DEFLATE_MAX_EXTRA_LENGTH_BITS 5
|
|
#define DEFLATE_MAX_EXTRA_OFFSET_BITS 13
|
|
|
|
#endif /* LIB_DEFLATE_CONSTANTS_H */
|