From 86a852652706cfe53087ef839840171bed597ffd Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 13 Apr 2014 01:56:23 -0500 Subject: [PATCH] Support basic reading WIMBoot WIMs These use a new compression flag, but it's actually just XPRESS with a really small chunk size. --- include/wimlib/header.h | 3 +++ include/wimlib/xml.h | 3 +++ src/header.c | 5 ++++- src/wim.c | 5 +++-- src/xml.c | 19 +++++++++++++++++++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/include/wimlib/header.h b/include/wimlib/header.h index 34e910cb..2bbb8388 100644 --- a/include/wimlib/header.h +++ b/include/wimlib/header.h @@ -190,4 +190,7 @@ struct wim_header { * wimlib v1.6.0 and later and WIMGAPI Windows 8 and later. */ #define WIM_HDR_FLAG_COMPRESS_LZMS 0x00080000 +/* XPRESS, with small chunk size??? */ +#define WIM_HDR_FLAG_COMPRESS_XPRESS_2 0x00200000 + #endif /* _WIMLIB_HEADER_H */ diff --git a/include/wimlib/xml.h b/include/wimlib/xml.h index e9c044af..18c60b98 100644 --- a/include/wimlib/xml.h +++ b/include/wimlib/xml.h @@ -19,6 +19,9 @@ wim_info_get_image_total_bytes(const struct wim_info *info, int image); extern unsigned wim_info_get_num_images(const struct wim_info *info); +extern void +wim_info_set_wimboot(struct wim_info *info, int image, bool value); + extern int xml_export_image(const struct wim_info *old_wim_info, int image, struct wim_info **new_wim_info_p, diff --git a/src/header.c b/src/header.c index 0f955519..f52c72b7 100644 --- a/src/header.c +++ b/src/header.c @@ -226,7 +226,8 @@ set_wim_hdr_cflags(int ctype, struct wim_header *hdr) WIM_HDR_FLAG_COMPRESS_LZX | WIM_HDR_FLAG_COMPRESS_RESERVED | WIM_HDR_FLAG_COMPRESS_XPRESS | - WIM_HDR_FLAG_COMPRESS_LZMS); + WIM_HDR_FLAG_COMPRESS_LZMS | + WIM_HDR_FLAG_COMPRESS_XPRESS_2); switch (ctype) { case WIMLIB_COMPRESSION_TYPE_NONE: @@ -289,6 +290,8 @@ struct hdr_flag hdr_flags[] = { {WIM_HDR_FLAG_COMPRESS_RESERVED,"COMPRESS_RESERVED"}, {WIM_HDR_FLAG_COMPRESS_LZX, "COMPRESS_LZX"}, {WIM_HDR_FLAG_COMPRESS_XPRESS, "COMPRESS_XPRESS"}, + {WIM_HDR_FLAG_COMPRESS_LZMS, "COMPRESS_LZMS"}, + {WIM_HDR_FLAG_COMPRESS_XPRESS_2,"COMPRESS_XPRESS_2"}, }; /* API function documented in wimlib.h */ diff --git a/src/wim.c b/src/wim.c index 9daa8e3b..95a3cb28 100644 --- a/src/wim.c +++ b/src/wim.c @@ -130,7 +130,7 @@ wim_chunk_size_valid(u32 chunk_size, int ctype) return order >= 15 && order <= 21; case WIMLIB_COMPRESSION_TYPE_XPRESS: - return order >= 15 && order <= 26; + return order >= 12 && order <= 26; case WIMLIB_COMPRESSION_TYPE_LZMS: return order >= 15 && order <= 30; } @@ -621,7 +621,8 @@ begin_read(WIMStruct *wim, const void *wim_filename_or_fd, if (wim->hdr.flags & WIM_HDR_FLAG_COMPRESSION) { if (wim->hdr.flags & WIM_HDR_FLAG_COMPRESS_LZX) { wim->compression_type = WIMLIB_COMPRESSION_TYPE_LZX; - } else if (wim->hdr.flags & WIM_HDR_FLAG_COMPRESS_XPRESS) { + } else if (wim->hdr.flags & (WIM_HDR_FLAG_COMPRESS_XPRESS | + WIM_HDR_FLAG_COMPRESS_XPRESS_2)) { wim->compression_type = WIMLIB_COMPRESSION_TYPE_XPRESS; } else if (wim->hdr.flags & WIM_HDR_FLAG_COMPRESS_LZMS) { wim->compression_type = WIMLIB_COMPRESSION_TYPE_LZMS; diff --git a/src/xml.c b/src/xml.c index 142c1a91..dd7de12e 100644 --- a/src/xml.c +++ b/src/xml.c @@ -89,6 +89,7 @@ struct image_info { tchar *display_name; tchar *display_description; tchar *flags; + bool wimboot; struct wim_lookup_table *lookup_table; /* temporary field */ }; @@ -167,6 +168,12 @@ wim_info_get_num_images(const struct wim_info *info) return 0; } +void +wim_info_set_wimboot(struct wim_info *info, int image, bool value) +{ + info->images[image - 1].wimboot = value; +} + /* Architecture constants are from w64 mingw winnt.h */ #define PROCESSOR_ARCHITECTURE_INTEL 0 #define PROCESSOR_ARCHITECTURE_MIPS 1 @@ -520,6 +527,10 @@ xml_read_image_info(xmlNode *image_node, struct image_info *image_info) ret = node_get_string(child, &image_info->display_name); } else if (node_name_is(child, "DISPLAYDESCRIPTION")) { ret = node_get_string(child, &image_info->display_description); + } else if (node_name_is(child, "WIMBOOT")) { + if (node_get_u64(child) == 1) { + image_info->wimboot = true; + } } if (ret != 0) return ret; @@ -944,6 +955,12 @@ xml_write_image_info(xmlTextWriter *writer, const struct image_info *image_info) if (rc) return rc; + if (image_info->wimboot) { + rc = xmlTextWriterWriteFormatElement(writer, "WIMBOOT", "%d", 1); + if (rc < 0) + return rc; + } + rc = xmlTextWriterEndElement(writer); /* */ if (rc < 0) return rc; @@ -1336,6 +1353,8 @@ print_image_info(const struct wim_info *wim_info, int image) print_windows_info(&image_info->windows_info); if (image_info->flags) tprintf(T("Flags: %"TS"\n"), image_info->flags); + tprintf(T("WIMBoot compatible: %"TS"\n"), + image_info->wimboot ? T("yes") : T("no")); tputchar('\n'); } -- 2.43.0