21#ifndef __WINE_CABINET_H
22#define __WINE_CABINET_H
33#define _S_IWRITE 0x0080
34#define _S_IREAD 0x0100
40#define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR)
41#define _O_APPEND 0x0008
42#define _O_RANDOM 0x0010
43#define _O_SEQUENTIAL 0x0020
44#define _O_TEMPORARY 0x0040
45#define _O_NOINHERIT 0x0080
46#define _O_CREAT 0x0100
47#define _O_TRUNC 0x0200
49#define _O_SHORT_LIVED 0x1000
51#define _O_BINARY 0x8000
53#define CAB_SPLITMAX (10)
55#define CAB_SEARCH_SIZE (32*1024)
65#define CAB_ULONG_BITS (sizeof(cab_ULONG) * 8)
68#define cfhead_Signature (0x00)
69#define cfhead_CabinetSize (0x08)
70#define cfhead_FileOffset (0x10)
71#define cfhead_MinorVersion (0x18)
72#define cfhead_MajorVersion (0x19)
73#define cfhead_NumFolders (0x1A)
74#define cfhead_NumFiles (0x1C)
75#define cfhead_Flags (0x1E)
76#define cfhead_SetID (0x20)
77#define cfhead_CabinetIndex (0x22)
78#define cfhead_SIZEOF (0x24)
79#define cfheadext_HeaderReserved (0x00)
80#define cfheadext_FolderReserved (0x02)
81#define cfheadext_DataReserved (0x03)
82#define cfheadext_SIZEOF (0x04)
83#define cffold_DataOffset (0x00)
84#define cffold_NumBlocks (0x04)
85#define cffold_CompType (0x06)
86#define cffold_SIZEOF (0x08)
87#define cffile_UncompressedSize (0x00)
88#define cffile_FolderOffset (0x04)
89#define cffile_FolderIndex (0x08)
90#define cffile_Date (0x0A)
91#define cffile_Time (0x0C)
92#define cffile_Attribs (0x0E)
93#define cffile_SIZEOF (0x10)
94#define cfdata_CheckSum (0x00)
95#define cfdata_CompressedSize (0x04)
96#define cfdata_UncompressedSize (0x06)
97#define cfdata_SIZEOF (0x08)
100#define cffoldCOMPTYPE_MASK (0x000f)
101#define cffoldCOMPTYPE_NONE (0x0000)
102#define cffoldCOMPTYPE_MSZIP (0x0001)
103#define cffoldCOMPTYPE_QUANTUM (0x0002)
104#define cffoldCOMPTYPE_LZX (0x0003)
105#define cfheadPREV_CABINET (0x0001)
106#define cfheadNEXT_CABINET (0x0002)
107#define cfheadRESERVE_PRESENT (0x0004)
108#define cffileCONTINUED_FROM_PREV (0xFFFD)
109#define cffileCONTINUED_TO_NEXT (0xFFFE)
110#define cffileCONTINUED_PREV_AND_NEXT (0xFFFF)
111#define cffile_A_RDONLY (0x01)
112#define cffile_A_HIDDEN (0x02)
113#define cffile_A_SYSTEM (0x04)
114#define cffile_A_ARCH (0x20)
115#define cffile_A_EXEC (0x40)
116#define cffile_A_NAME_IS_UTF (0x80)
122#define ZIPWSIZE 0x8000
184#define LZX_MIN_MATCH (2)
185#define LZX_MAX_MATCH (257)
186#define LZX_NUM_CHARS (256)
187#define LZX_BLOCKTYPE_INVALID (0)
188#define LZX_BLOCKTYPE_VERBATIM (1)
189#define LZX_BLOCKTYPE_ALIGNED (2)
190#define LZX_BLOCKTYPE_UNCOMPRESSED (3)
191#define LZX_PRETREE_NUM_ELEMENTS (20)
192#define LZX_ALIGNED_NUM_ELEMENTS (8)
193#define LZX_NUM_PRIMARY_LENGTHS (7)
194#define LZX_NUM_SECONDARY_LENGTHS (249)
197#define LZX_PRETREE_MAXSYMBOLS (LZX_PRETREE_NUM_ELEMENTS)
198#define LZX_PRETREE_TABLEBITS (6)
199#define LZX_MAINTREE_MAXSYMBOLS (LZX_NUM_CHARS + 50*8)
200#define LZX_MAINTREE_TABLEBITS (12)
201#define LZX_LENGTH_MAXSYMBOLS (LZX_NUM_SECONDARY_LENGTHS+1)
202#define LZX_LENGTH_TABLEBITS (12)
203#define LZX_ALIGNED_MAXSYMBOLS (LZX_ALIGNED_NUM_ELEMENTS)
204#define LZX_ALIGNED_TABLEBITS (7)
206#define LZX_LENTABLE_SAFETY (64)
208#define LZX_DECLARE_TABLE(tbl) \
209 cab_UWORD tbl##_table[(1<<LZX_##tbl##_TABLEBITS) + (LZX_##tbl##_MAXSYMBOLS<<1)];\
210 cab_UBYTE tbl##_len [LZX_##tbl##_MAXSYMBOLS + LZX_LENTABLE_SAFETY]
245#define CAB_BLOCKMAX (32768)
246#define CAB_INPUTMAX (CAB_BLOCKMAX+6144)
338#define Q_INIT_BITSTREAM do { bitsleft = 0; bitbuf = 0; } while (0)
340#define Q_FILL_BUFFER do { \
341 if (bitsleft <= (CAB_ULONG_BITS - 16)) { \
342 bitbuf |= ((inpos[0]<<8)|inpos[1]) << (CAB_ULONG_BITS-16 - bitsleft); \
343 bitsleft += 16; inpos += 2; \
347#define Q_PEEK_BITS(n) (bitbuf >> (CAB_ULONG_BITS - (n)))
348#define Q_REMOVE_BITS(n) ((bitbuf <<= (n)), (bitsleft -= (n)))
350#define Q_READ_BITS(v,n) do { \
352 for (bitsneed = (n); bitsneed; bitsneed -= bitrun) { \
354 bitrun = (bitsneed > bitsleft) ? bitsleft : bitsneed; \
355 (v) = ((v) << bitrun) | Q_PEEK_BITS(bitrun); \
356 Q_REMOVE_BITS(bitrun); \
360#define Q_MENTRIES(model) (QTM(model).entries)
361#define Q_MSYM(model,symidx) (QTM(model).syms[(symidx)].sym)
362#define Q_MSYMFREQ(model,symidx) (QTM(model).syms[(symidx)].cumfreq)
367#define GET_SYMBOL(m, var) do { \
368 range = ((H - L) & 0xFFFF) + 1; \
369 symf = ((((C - L + 1) * Q_MSYMFREQ(m,0)) - 1) / range) & 0xFFFF; \
371 for (i=1; i < Q_MENTRIES(m); i++) { \
372 if (Q_MSYMFREQ(m,i) <= symf) break; \
374 (var) = Q_MSYM(m,i-1); \
376 range = (H - L) + 1; \
377 H = L + ((Q_MSYMFREQ(m,i-1) * range) / Q_MSYMFREQ(m,0)) - 1; \
378 L = L + ((Q_MSYMFREQ(m,i) * range) / Q_MSYMFREQ(m,0)); \
380 if ((L & 0x8000) != (H & 0x8000)) { \
381 if ((L & 0x4000) && !(H & 0x4000)) { \
383 C ^= 0x4000; L &= 0x3FFF; H |= 0x4000; \
387 L <<= 1; H = (H << 1) | 1; \
389 C = (C << 1) | Q_PEEK_BITS(1); \
393 QTMupdatemodel(&(QTM(m)), i); \
414#define INIT_BITSTREAM do { bitsleft = 0; bitbuf = 0; } while (0)
417#define ENSURE_BITS(n) \
418 while (bitsleft < (n)) { \
419 bitbuf |= ((inpos[1]<<8)|inpos[0]) << (CAB_ULONG_BITS-16 - bitsleft); \
420 bitsleft += 16; inpos+=2; \
423#define PEEK_BITS(n) (bitbuf >> (CAB_ULONG_BITS - (n)))
424#define REMOVE_BITS(n) ((bitbuf <<= (n)), (bitsleft -= (n)))
426#define READ_BITS(v,n) do { \
429 (v) = PEEK_BITS(n); \
439#define TABLEBITS(tbl) (LZX_##tbl##_TABLEBITS)
440#define MAXSYMBOLS(tbl) (LZX_##tbl##_MAXSYMBOLS)
441#define SYMTABLE(tbl) (LZX(tbl##_table))
442#define LENTABLE(tbl) (LZX(tbl##_len))
449#define BUILD_TABLE(tbl) \
450 if (make_decode_table( \
451 MAXSYMBOLS(tbl), TABLEBITS(tbl), LENTABLE(tbl), SYMTABLE(tbl) \
452 )) { return DECR_ILLEGALDATA; }
457#define READ_HUFFSYM(tbl,var) do { \
459 hufftbl = SYMTABLE(tbl); \
460 if ((i = hufftbl[PEEK_BITS(TABLEBITS(tbl))]) >= MAXSYMBOLS(tbl)) { \
461 j = 1 << (CAB_ULONG_BITS - TABLEBITS(tbl)); \
463 j >>= 1; i <<= 1; i |= (bitbuf & j) ? 1 : 0; \
464 if (!j) { return DECR_ILLEGALDATA; } \
465 } while ((i = hufftbl[i]) >= MAXSYMBOLS(tbl)); \
467 j = LENTABLE(tbl)[(var) = i]; \
475#define READ_LENGTHS(tbl,first,last,fn) do { \
476 lb.bb = bitbuf; lb.bl = bitsleft; lb.ip = inpos; \
477 if (fn(LENTABLE(tbl),(first),(last),&lb,decomp_state)) { \
478 return DECR_ILLEGALDATA; \
480 bitbuf = lb.bb; bitsleft = lb.bl; inpos = lb.ip; \
485#define THOSE_ZIP_CONSTS \
486static const cab_UBYTE Zipborder[] = \
487{ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; \
488static const cab_UWORD Zipcplens[] = \
489{ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, \
490 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; \
491static const cab_UWORD Zipcplext[] = \
492{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, \
493 4, 5, 5, 5, 5, 0, 99, 99}; \
494static const cab_UWORD Zipcpdist[] = \
495{ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, \
496513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; \
497static const cab_UWORD Zipcpdext[] = \
498{ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, \
49910, 11, 11, 12, 12, 13, 13}; \
501static const cab_UWORD Zipmask[17] = { \
502 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, \
503 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff \
507#define EXTRACT_FILLFILELIST 0x00000001
508#define EXTRACT_EXTRACTFILES 0x00000002
vector< FileInfo > FileList
struct cds_forward cab_decomp_state
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
GLint GLint GLint GLint GLint x
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
LZX_DECLARE_TABLE(MAINTREE)
cab_ULONG block_remaining
LZX_DECLARE_TABLE(PRETREE)
LZX_DECLARE_TABLE(ALIGNED)
LZX_DECLARE_TABLE(LENGTH)
struct QTMmodelsym * syms
struct QTMmodel model4 model5 model6pos model6len
struct QTMmodelsym m40sym[0x40+1]
struct QTMmodelsym m4sym[0x18+1]
struct QTMmodel model00 model40 model80 modelC0
struct QTMmodelsym m5sym[0x24+1]
struct QTMmodelsym mC0sym[0x40+1]
struct QTMmodelsym m7sym[7+1]
struct QTMmodelsym m00sym[0x40+1]
struct QTMmodelsym m6psym[0x2a+1]
struct QTMmodelsym m6lsym[0x1b+1]
struct QTMmodelsym m80sym[0x40+1]
struct Ziphuft * u[ZIPBMAX]
struct cab_folder * folder
struct cabinet * cab[CAB_SPLITMAX]
struct cab_file * contfile
struct cab_folder * folders
union cds_forward::@330 methods
struct cab_folder * current
cab_UBYTE outbuf[CAB_BLOCKMAX]
cab_UBYTE q_extra_bits[42]
cab_UBYTE q_length_base[27]
cab_ULONG q_position_base[42]
int(* decompress)(int, int, struct cds_forward *)
cab_UBYTE q_length_extra[27]
cab_UBYTE inbuf[CAB_INPUTMAX+2]
cab_ULONG lzx_position_base[51]
_Reserved_ PVOID Reserved