1 #ifndef _WIMLIB_HEADER_H
2 #define _WIMLIB_HEADER_H
4 #include "wimlib/resource.h"
5 #include "wimlib/types.h"
7 #define WIM_MAGIC_LEN 8
9 #define WIM_UNUSED_LEN 60
11 /* Length of the WIM header on disk. */
12 #define WIM_HEADER_DISK_SIZE (148 + WIM_UNUSED_LEN)
14 /* Compressed resources in the WIM are divided into separated compressed chunks
16 #define WIM_CHUNK_SIZE 32768
18 /* Version of the WIM file. There is an older version, but we don't support it
19 * yet. The differences between the versions are undocumented. */
20 #define WIM_VERSION 0x10d00
22 /* Header at the very beginning of the WIM file. */
24 /* Identifies the file as WIM file. Must be exactly
25 * {'M', 'S', 'W', 'I', 'M', 0, 0, 0} */
26 //u8 magic[WIM_MAGIC_LEN];
28 /* size of WIM header in bytes. */
31 /* Version of the WIM file. Microsoft provides no documentation about
32 * exactly what this field affects about the file format, other than the
33 * fact that more recent versions have a higher value. */
36 /* Bitwise OR of one or more of the WIM_HDR_FLAG_* defined below. */
39 /* The size of the pieces that the uncompressed files were split up into
40 * when they were compressed. This should be the same as
41 * WIM_CHUNK_SIZE. Microsoft incorrectly documents this as "the size of
42 * the compressed .wim file in bytes".*/
45 /* A unique identifier for the WIM file. */
48 /* Part number of the WIM file in a spanned set. */
51 /* Total number of parts in a spanned set. */
54 /* Number of images in the WIM file. */
57 /* Location, size, and flags of the lookup table of the WIM. */
58 struct resource_entry lookup_table_res_entry;
60 /* Location, size, and flags for the XML data of the WIM. */
61 struct resource_entry xml_res_entry;
63 /* Location, size, and flags for the boot metadata. This means the
64 * metadata resource for the image specified by boot_idx below. Should
65 * be zeroed out if boot_idx is 0. */
66 struct resource_entry boot_metadata_res_entry;
68 /* The index of the bootable image in the WIM file. If 0, there are no
69 * bootable images available. */
72 /* The location of the optional integrity table used to verify the
73 * integrity WIM. Zeroed out if there is no integrity table.*/
74 struct resource_entry integrity;
76 /* Reserved for future disuse */
77 //u8 unused[WIM_UNUSED_LEN];
80 /* Flags for the `flags' field of the struct wim_header: */
82 /* Reserved for future use */
83 #define WIM_HDR_FLAG_RESERVED 0x00000001
85 /* Files and metadata in the WIM are compressed. */
86 #define WIM_HDR_FLAG_COMPRESSION 0x00000002
88 /* WIM is read-only (wimlib ignores this because it's pretty much pointless) */
89 #define WIM_HDR_FLAG_READONLY 0x00000004
91 /* Resource data specified by images in this WIM may be contained in a different
92 * WIM. Or in other words, this WIM is part of a split WIM. */
93 #define WIM_HDR_FLAG_SPANNED 0x00000008
95 /* The WIM contains resources only; no filesystem metadata. wimlib ignores this
96 * flag, as it looks for resources in all the WIMs anyway. */
97 #define WIM_HDR_FLAG_RESOURCE_ONLY 0x00000010
99 /* The WIM contains metadata only. wimlib ignores this flag. Note that all the
100 * metadata resources for a split WIM should be in the first part. */
101 #define WIM_HDR_FLAG_METADATA_ONLY 0x00000020
103 /* Lock field to prevent multiple writers from writing the WIM concurrently.
104 * wimlib ignores this flag as it uses flock() to acquire a real lock on the
105 * file (if supported by the underlying filesystem). */
106 #define WIM_HDR_FLAG_WRITE_IN_PROGRESS 0x00000040
108 /* Reparse point fixup flag. See docs for --rpfix and --norpfix in imagex, or
109 * WIMLIB_ADD_FLAG_{RPFIX,NORPFIX} in wimlib.h. Note that
110 * WIM_HDR_FLAG_RP_FIX is a header flag and just sets the default behavior for
111 * the WIM; it can still be overridder on a per-image basis. But there is no
112 * flag to set the default behavior for a specific image. */
113 #define WIM_HDR_FLAG_RP_FIX 0x00000080
115 /* Unused, reserved flag for another compression type */
116 #define WIM_HDR_FLAG_COMPRESS_RESERVED 0x00010000
118 /* Resources within the WIM are compressed using "XPRESS" compression, which is
119 * a LZ77-based compression algorithm. */
120 #define WIM_HDR_FLAG_COMPRESS_XPRESS 0x00020000
122 /* Resources within the WIM are compressed using "LZX" compression. This is also
123 * a LZ77-based algorithm. */
124 #define WIM_HDR_FLAG_COMPRESS_LZX 0x00040000
126 #endif /* _WIMLIB_HEADER_H */