6 IDL structures defining Cabinet files
8 more info can be found at:
9 https://msdn.microsoft.com/en-us/library/bb267310.aspx#cabinet_format
13 pointer_default(unique),
14 helper
("../librpc/ndr/ndr_cab.h"),
15 helpstring("Cabinet structure"),
16 uuid("12345678-0000-0000-0000-00000000")
22 * flags.cfhdrPREV_CABINET is set if this cabinet file is not the first in
23 * a set of cabinet files. When this bit is set, the szCabinetPrev and
24 * szDiskPrev fields are present in this CFHEADER.
26 * flags.cfhdrNEXT_CABINET is set if this cabinet file is not the last in a
27 * set of cabinet files. When this bit is set, the szCabinetNext and
28 * szDiskNext fields are present in this CFHEADER.
30 * flags.cfhdrRESERVE_PRESENT is set if this cabinet file contains any
31 * reserved fields. When this bit is set, the cbCFHeader, cbCFFolder, and
32 * cbCFData fields are present in this CFHEADER.
35 typedef [bitmap16bit
] bitmap
{
36 cfhdrPREV_CABINET
= 0x0001,
37 cfhdrNEXT_CABINET
= 0x0002,
38 cfhdrRESERVE_PRESENT
= 0x0004
41 typedef [public,flag
(NDR_PAHEX|NDR_LITTLE_ENDIAN|NDR_NOALIGN
)] struct {
42 [charset
(DOS
),value
("MSCF")] uint8 signature
[4];
43 [value
(0)] uint32 reserved1
; /* reserved */
44 uint32 cbCabinet
; /* size of this cabinet file in bytes */
45 [value
(0)] uint32 reserved2
; /* reserved */
46 [value
(cFolders
*8+36)] uint32 coffFiles
; /* offset of the first CFFILE entry */
47 [value
(0)] uint32 reserved3
; /* reserved */
48 [value
(3)] uint8 versionMinor
; /* cabinet file format version, minor */
49 [value
(1)] uint8 versionMajor
; /* cabinet file format version, major */
50 uint16 cFolders
; /* number of CFFOLDER entries in this cabinet */
51 uint16 cFiles
; /* number of CFFILE entries in this cabinet */
52 cf_flags flags
; /* cabinet file option indicators */
53 uint16 setID
; /* must be the same for all cabinets in a set */
54 uint16 iCabinet
; /* number of this cabinet file in a set */
56 [range(0,60000)] uint16 cbCFHeader
; /* (optional) size of per-cabinet reserved area */
57 [range(0,255)] uint8 cbCFFolder
; /* (optional) size of per-folder reserved area */
58 [range(0,255)] uint8 cbCFData
; /* (optional) size of per-datablock reserved area */
59 uint8 abReserve
[]; /* (optional) per-cabinet reserved area */
60 uint8 szCabinetPrev
[]; /* (optional) name of previous cabinet file */
61 uint8 szDiskPrev
[]; /* (optional) name of previous disk */
62 uint8 szCabinetNext
[]; /* (optional) name of next cabinet file */
63 uint8 szDiskNext
[]; /* (optional) name of next disk */
69 CF_COMPRESS_MSZIP
= 1,
70 CF_COMPRESS_LZX
= 4611
73 typedef [public,flag
(NDR_PAHEX|NDR_LITTLE_ENDIAN|NDR_NOALIGN
)] struct {
74 uint32 coffCabStart
; /* offset of the first CFDATA block in this folder */
75 uint16 cCFData
; /* number of CFDATA blocks in this folder */
76 cf_compress_type typeCompress
; /* compression type indicator */
78 uint8 abReserve
[]; /* (optional) per-folder reserved area */
82 const int ifoldCONTINUED_FROM_PREV
= 0xFFFD;
83 const int ifoldCONTINUED_TO_NEXT
= 0xFFFE;
84 const int ifoldCONTINUED_PREV_AND_NEXT
= 0xFFFF;
86 typedef [bitmap16bit
] bitmap
{
87 _A_RDONLY
= 0x01, /* file is read-only */
88 _A_HIDDEN
= 0x02, /* file is hidden */
89 _A_SYSTEM
= 0x04, /* file is a system file */
90 _A_ARCH
= 0x20, /* file modified since last backup */
91 _A_EXEC
= 0x40, /* run after extraction */
92 _A_NAME_IS_UTF
= 0x80 /* szName[] contains UTF */
95 typedef [noprint
,flag
(NDR_NOALIGN
)] struct {
99 typedef [noprint
,flag
(NDR_NOALIGN
)] struct {
103 typedef [public,flag
(NDR_PAHEX|NDR_LITTLE_ENDIAN|NDR_NOALIGN
),gensize
] struct {
104 uint32 cbFile
; /* uncompressed size of this file in bytes */
105 uint32 uoffFolderStart
; /* uncompressed offset of this file in the folder */
106 uint16 iFolder
; /* index into the CFFOLDER area */
107 cf_date date
; /* date stamp for this file */
108 cf_time time
; /* time stamp for this file */
109 cf_attributes attribs
; /* attribute flags for this file */
110 [flag
(r
->attribs
& _A_NAME_IS_UTF ? STR_UTF8|STR_NULLTERM
: STR_ASCII|STR_NULLTERM
)] string szName
;
113 typedef [public,flag
(NDR_PAHEX|NDR_LITTLE_ENDIAN|NDR_NOALIGN
)] struct {
114 [value
(ndr_cab_generate_checksum
(r
))] uint32 csum
; /* checksum of this CFDATA entry */
115 uint16 cbData
; /* number of compressed bytes in this block */
116 uint16 cbUncomp
; /* number of uncompressed bytes in this block */
118 uint8 abReserve
[]; /* (optional) per-datablock reserved area */
120 DATA_BLOB ab
; /* compressed data bytes */
123 typedef [nopush
,nopull
,public,flag
(NDR_PAHEX|NDR_LITTLE_ENDIAN|NDR_NOALIGN
)] struct {
125 CFFOLDER cffolders
[cfheader.cFolders
];
126 CFFILE cffiles
[cfheader.cFiles
];
127 [noprint
,value
(ndr_count_cfdata
(r
))] uint32 cfdata_count
;
128 CFDATA cfdata
[cfdata_count
];
131 void decode_cab_file
(