From a1ae78eb303d9969f96d3c14768acdad53d484a7 Mon Sep 17 00:00:00 2001 From: Administrator Date: Wed, 14 Feb 2024 14:42:52 +0800 Subject: [PATCH 1/2] Add MSVC and MSYS2 UCRT64 Build --- .gitignore | 18 + include/msvc/unistd.h | 42 + include/wimlib.h | 13 +- include/wimlib/compiler.h | 131 ++- include/wimlib/decompress_common.h | 9 +- include/wimlib/header.h | 6 + include/wimlib/inode.h | 13 +- include/wimlib/list.h | 78 +- include/wimlib/metadata.h | 16 +- include/wimlib/reparse.h | 6 + include/wimlib/resource.h | 20 +- include/wimlib/security_descriptor.h | 7 +- include/wimlib/timestamp.h | 3 + include/wimlib/win32.h | 5 +- include/wimlib/win32_common.h | 1233 ++++++++++++++++++++++++++ include/wimlib/wof.h | 7 +- include/wimlib/xattr.h | 11 +- include/wimlib/xmlproc.h | 4 +- include/wimlib_tchar.h | 6 +- programs/imagex.c | 96 +- programs/wgetopt.c | 4 +- programs/wimlib-imagex.vcxproj | 647 ++++++++++++++ src/blob_table.c | 28 +- src/decompress_common.c | 2 +- src/dentry.c | 11 +- src/divsufsort.c | 64 +- src/export_image.c | 2 +- src/extract.c | 68 +- src/file_io.c | 16 +- src/header.c | 18 +- src/inode_fixup.c | 4 +- src/inode_table.c | 10 +- src/integrity.c | 6 + src/libwim.vcxproj | 862 ++++++++++++++++++ src/libwim.vcxproj.filters | 303 +++++++ src/lzms_compress.c | 6 + src/lzms_decompress.c | 6 +- src/lzx_compress.c | 25 +- src/lzx_decompress.c | 6 + src/metadata_resource.c | 2 +- src/registry.c | 6 + src/resource.c | 6 +- src/security.c | 6 + src/sha1.c | 8 +- src/solid.c | 10 +- src/tagged_items.c | 6 + src/template.c | 2 +- src/textfile.c | 4 + src/threads.c | 2 +- src/util.c | 6 +- src/verify.c | 4 +- src/wim.c | 8 +- src/win32_apply.c | 74 +- src/win32_capture.c | 85 +- src/win32_common.c | 1 - src/win32_replacements.c | 4 +- src/win32_vss.c | 3 +- src/write.c | 46 +- src/xml.c | 16 +- src/xml_windows.c | 2 +- src/xmlproc.c | 14 +- src/xpress_compress.c | 6 +- src/xpress_decompress.c | 6 + tests/set_reparse_point.c | 6 +- tests/set_reparse_point.vcxproj | 300 +++++++ tests/win32-tree-cmp.c | 5 +- tests/win32-tree-cmp.vcxproj | 300 +++++++ tools/get-version-number.cmd | 5 + tools/windows-after-build-msvc.cmd | 51 ++ tools/windows-build.sh | 6 +- wimlib-imagex.sln | 177 ++++ 71 files changed, 4728 insertions(+), 261 deletions(-) create mode 100644 include/msvc/unistd.h create mode 100644 programs/wimlib-imagex.vcxproj create mode 100644 src/libwim.vcxproj create mode 100644 src/libwim.vcxproj.filters create mode 100644 tests/set_reparse_point.vcxproj create mode 100644 tests/win32-tree-cmp.vcxproj create mode 100644 tools/get-version-number.cmd create mode 100644 tools/windows-after-build-msvc.cmd create mode 100644 wimlib-imagex.sln diff --git a/.gitignore b/.gitignore index 908421a5..e7e21bd8 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,21 @@ /wimlib-imagex /wimlib-imagex.exe /wimlib.pc +.vs +/x86 +/win32 +/x64 +/arm +/arm32 +/arm64 +/Debug +/Release +*/x86 +*/win32 +*/x64 +*/arm +*/arm32 +*/arm64 +*/Debug +*/Release +*.vcxproj.user diff --git a/include/msvc/unistd.h b/include/msvc/unistd.h new file mode 100644 index 00000000..c801e4b1 --- /dev/null +++ b/include/msvc/unistd.h @@ -0,0 +1,42 @@ +#ifndef _UNISTD_H +#define _UNISTD_H 1 + +/* This file intended to serve as a drop-in replacement for + * unistd.h on Windows + * Please add functionality as neeeded + */ + +#include +#include +#include /* for getpid() and the exec..() family */ +#include /* for _getcwd() and _chdir() */ + +#define srandom srand +#define random rand + + /* Values for the second argument to access. + These may be OR'd together. */ +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ + //#define X_OK 1 /* execute permission - unsupported in windows*/ +#define F_OK 0 /* Test for existence. */ + +#define access _access +#define dup2 _dup2 +#define execve _execve +#define ftruncate _chsize +#define unlink _unlink +#define fileno _fileno +#define getcwd _getcwd +#define chdir _chdir +#define isatty _isatty +#define lseek _lseek +/* read, write, and close are NOT being #defined here, because while there are file handle specific versions for Windows, they probably don't work for sockets. You need to look at your app and consider whether to call e.g. closesocket(). */ + +#define ssize_t int + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +#endif /* unistd.h */ \ No newline at end of file diff --git a/include/wimlib.h b/include/wimlib.h index 55ed0f45..80fe9646 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -391,16 +391,15 @@ #include #include #ifndef __cplusplus -# if defined(_MSC_VER) && _MSC_VER < 1800 /* VS pre-2013? */ - typedef unsigned char bool; -# else -# include -# endif +#if defined(_MSC_VER) +#include "msvc/unistd.h" +#endif +# include #endif #include #include -#ifdef BUILDING_WIMLIB +#if defined BUILDING_WIMLIB || defined LIBWIM_EXPORTS /* * On i386, gcc assumes that the stack is 16-byte aligned at function entry. * However, some compilers (e.g. MSVC) and programming languages (e.g. Delphi) @@ -414,7 +413,7 @@ # else # define WIMLIB_ALIGN_STACK # endif -# ifdef _WIN32 +#if defined _WIN32 || defined LIBWIM_EXPORTS # define WIMLIBAPI __declspec(dllexport) WIMLIB_ALIGN_STACK # else # define WIMLIBAPI __attribute__((visibility("default"))) WIMLIB_ALIGN_STACK diff --git a/include/wimlib/compiler.h b/include/wimlib/compiler.h index 77cd27f8..d16c4ebc 100644 --- a/include/wimlib/compiler.h +++ b/include/wimlib/compiler.h @@ -87,6 +87,10 @@ * evaluates to 1. The other evaluates to 0. Note that newer gcc supports * __BYTE_ORDER__ for easily determining the endianness; older gcc doesn't. In * the latter case we fall back to a configure-time check. */ +#ifdef _MSC_VER +#define CPU_IS_BIG_ENDIAN() 0 +#include +#endif #ifdef __BYTE_ORDER__ # define CPU_IS_BIG_ENDIAN() (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) #elif defined(HAVE_CONFIG_H) @@ -110,15 +114,23 @@ /* Get the minimum of two variables, without multiple evaluation. */ #undef min +#ifdef _MSC_VER +#define min(a, b) ((a < b) ? a : b) +#else #define min(a, b) ({ typeof(a) _a = (a); typeof(b) _b = (b); \ (_a < _b) ? _a : _b; }) +#endif #undef MIN #define MIN(a, b) min((a), (b)) /* Get the maximum of two variables, without multiple evaluation. */ #undef max +#ifdef _MSC_VER +#define max(a, b) ((a > b) ? a : b) +#else #define max(a, b) ({ typeof(a) _a = (a); typeof(b) _b = (b); \ (_a > _b) ? _a : _b; }) +#endif #undef MAX #define MAX(a, b) max((a), (b)) @@ -127,10 +139,13 @@ #define max3(a, b, c) max(max((a), (b)), (c)) /* Swap the values of two variables, without multiple evaluation. */ +#ifdef _MSC_VER +# define swap(a, b, type) { type _a = (a); (a) = (b); (b) = _a; } +#endif #ifndef swap -# define swap(a, b) ({ typeof(a) _a = (a); (a) = (b); (b) = _a; }) +# define swap(a, b, type) ({ typeof(a) _a = (a); (a) = (b); (b) = _a; }) #endif -#define SWAP(a, b) swap((a), (b)) +#define SWAP(a, b ,type) swap((a), (b),type) /* Optional definitions for checking with 'sparse'. */ #ifdef __CHECKER__ @@ -142,6 +157,9 @@ #endif /* STATIC_ASSERT() - verify the truth of an expression at compilation time. */ +#ifdef _MSC_VER +#define STATIC_ASSERT(expr) assert(expr) +#else #ifdef __CHECKER__ # define STATIC_ASSERT(expr) #elif __STDC_VERSION__ >= 201112L @@ -149,14 +167,117 @@ #else # define STATIC_ASSERT(expr) ((void)sizeof(char[1 - 2 * !(expr)])) #endif - +#endif /* STATIC_ASSERT_ZERO() - verify the truth of an expression at compilation time * and also produce a result of value '0' to be used in constant expressions */ +#ifdef _MSC_VER +#pragma comment(lib, "ntdll") +#define STATIC_ASSERT_ZERO(expr) 0 +#else #define STATIC_ASSERT_ZERO(expr) ((int)sizeof(char[-!(expr)])) - +#endif #define CONCAT_IMPL(s1, s2) s1##s2 /* CONCAT() - concatenate two tokens at preprocessing time. */ #define CONCAT(s1, s2) CONCAT_IMPL(s1, s2) +#ifndef PACKAGE_VERSION +#define PACKAGE_VERSION "" +#endif +#ifndef PACKAGE_BUGREPORT +#define PACKAGE_BUGREPORT "" +#endif +#ifdef _MSC_VER +//We are using Microsoft's MSVC, gcc specific functions are not available +#include +#define __attribute__(x) +#define POINTER_FIX() (size_t) +#define smart_array(type, name, size) type * name=_alloca((size)*(sizeof(type))) +#define restrict +#define EMPTY 0 +#define FILE_SHARE_VALID_FLAGS FILE_SHARE_DELETE | FILE_SHARE_READ |FILE_SHARE_WRITE +#include +static inline wchar_t * wmempcpy(wchar_t *_S1, wchar_t const *_S2, size_t _N) +{ + return wmemcpy(_S1,_S2,_N)+_N; + +} +#define alloca _alloca + +#include +#include +uint32_t __inline __builtin_ctz(uint32_t value) +{ + unsigned long trailing_zero = 0; + if (_BitScanForward(&trailing_zero, value)) + return trailing_zero; + return 32; +} -#endif /* _WIMLIB_COMPILER_H */ +uint32_t __inline __builtin_clz(uint32_t value) +{ + unsigned long leading_zero = 0; + if (_BitScanReverse(&leading_zero, value)) + return 31 - leading_zero; + return 32; +} +#define __builtin_constant_p(x) 0 +#define __builtin_prefetch(x, y) 0 +#define __builtin_expect(x,y) (x) +#define gmtime_r(x, y) gmtime_s(y,x) +#define vsnwprintf _vsnwprintf +#define snwprintf _snwprintf +#undef PRIu64 +#define PRIu64 "I64u" +#undef PRId64 +#define PRId64 "I64d" +#undef PRIi64 +#define PRIi64 "I64i" +#undef PRIo64 +#define PRIo64 "I64o" +#undef PRIx64 +#define PRIx64 "I64x" +#if defined(_M_ARM64) || defined(_M_X64) +uint32_t __inline __builtin_clzll(uint64_t value) +{ + unsigned long leading_zero = 0; + if (_BitScanReverse64(&leading_zero, value)) + return 63 - leading_zero; + return 64; +} +uint32_t __inline __builtin_ctzll(uint32_t value) +{ + unsigned long trailing_zero = 0; + if (_BitScanForward64(&trailing_zero, value)) + return trailing_zero; + return 64; +} +#else +uint32_t __inline __builtin_clzll(uint64_t value) +{ + if (value == 0) + return 64; + uint32_t msh = (uint32_t)(value >> 32); + uint32_t lsh = (uint32_t)(value & 0xFFFFFFFF); + if (msh != 0) + return __builtin_clz(msh); + return 32 + __builtin_clz(lsh); +} +uint32_t __inline __builtin_ctzll(uint64_t value) +{ + if (value == 0) + return 64; + uint32_t msh = (uint32_t)(value >> 32); + uint32_t lsh = (uint32_t)(value & 0xFFFFFFFF); + if (msh != 0) + return __builtin_ctz(msh); + return 32 + __builtin_ctz(lsh); +} +#endif +#define __builtin_clzl __builtin_clzll +#else +#define POINTER_FIX() +#define smart_array(type, name, size) type name[size] +#define EMPTY +#endif +#endif +/* _WIMLIB_COMPILER_H */ diff --git a/include/wimlib/decompress_common.h b/include/wimlib/decompress_common.h index 46fce94f..2af51e40 100644 --- a/include/wimlib/decompress_common.h +++ b/include/wimlib/decompress_common.h @@ -400,17 +400,22 @@ read_huffsym(struct input_bitstream *is, const u16 decode_table[], * structure, then the outer structure must be allocated on a * DECODE_TABLE_ALIGNMENT-byte aligned boundary as well. */ +#ifdef _MSC_VER +#pragma pack(push, 16) +#endif #define DECODE_TABLE(name, num_syms, table_bits, max_codeword_len) \ u16 name[DECODE_TABLE_SIZE((num_syms), (table_bits), \ (max_codeword_len))] \ __attribute__((aligned(DECODE_TABLE_ALIGNMENT))) - +#ifdef _MSC_VER +#pragma pack(pop) +#endif /* * Declare the temporary "working_space" array needed for building the decode * table for a Huffman code. */ #define DECODE_TABLE_WORKING_SPACE(name, num_syms, max_codeword_len) \ - u16 name[2 * ((max_codeword_len) + 1) + (num_syms)]; + u16 name[2 * ((max_codeword_len) + 1) + (num_syms)] int make_huffman_decode_table(u16 decode_table[], unsigned num_syms, diff --git a/include/wimlib/header.h b/include/wimlib/header.h index 49ccf0b2..f5fd16ea 100644 --- a/include/wimlib/header.h +++ b/include/wimlib/header.h @@ -48,6 +48,9 @@ ((u64)'\0' << 54)) /* On-disk format of the WIM header. */ +#ifdef _MSC_VER +#pragma pack(push,1) +#endif struct wim_header_disk { /* +0x00: Magic characters WIM_MAGIC or PWM_MAGIC. */ @@ -112,6 +115,9 @@ struct wim_header_disk { /* +0xd0 (208) */ } __attribute__((packed)); +#ifdef _MSC_VER +#pragma pack(pop) +#endif /* * Arbitrarily limit the maximum number of images to 65535, to prevent huge * memory allocations when processing fuzzed files. This can be increased if diff --git a/include/wimlib/inode.h b/include/wimlib/inode.h index bdf2ad18..52fbe7c2 100644 --- a/include/wimlib/inode.h +++ b/include/wimlib/inode.h @@ -225,13 +225,17 @@ struct wim_inode { struct wim_inode *i_corresponding; #endif }; - +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif /* Optional extra data for a WIM inode */ struct wim_inode_extra { size_t size; /* Size of the extra data in bytes */ u8 data[] __attribute__((aligned(8))); /* The extra data */ }; - +#ifdef _MSC_VER +#pragma pack(pop) +#endif /* * The available reparse tags are documented at * https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/c8e77b37-3909-4fe6-a4ea-2b9d423b1ee4 @@ -268,8 +272,9 @@ struct wim_inode * new_inode(struct wim_dentry *dentry, bool set_timestamps); /* Iterate through each alias of the specified inode. */ -#define inode_for_each_dentry(dentry, inode) \ - hlist_for_each_entry((dentry), &(inode)->i_alias_list, d_alias_node) + +#define inode_for_each_dentry(dentry, inode, type) \ + hlist_for_each_entry((dentry), &(inode)->i_alias_list, d_alias_node, type) /* Return an alias of the specified inode. */ #define inode_any_dentry(inode) \ diff --git a/include/wimlib/list.h b/include/wimlib/list.h index d556a56c..db2eb5b9 100644 --- a/include/wimlib/list.h +++ b/include/wimlib/list.h @@ -212,17 +212,25 @@ list_splice_tail(struct list_head *list, struct list_head *head) * @pos: the type * to cursor * @member: the name of the list_struct within the struct. */ -#define list_next_entry(pos, member) \ +#ifdef _MSC_VER +#define list_next_entry(pos, member,type) \ + list_entry((pos)->member.next, type, member) +#else +#define list_next_entry(pos, member,type) \ list_entry((pos)->member.next, typeof(*(pos)), member) - +#endif /** * list_prev_entry - get the prev element in list * @pos: the type * to cursor * @member: the name of the list_struct within the struct. */ -#define list_prev_entry(pos, member) \ +#ifdef _MSC_VER +#define list_prev_entry(pos, member,type) \ + list_entry((pos)->member.prev, type, member) +#else +#define list_prev_entry(pos, member, type) \ list_entry((pos)->member.prev, typeof(*(pos)), member) - +#endif /** * list_for_each - iterate over a list @@ -238,22 +246,33 @@ list_splice_tail(struct list_head *list, struct list_head *head) * @head: the head for your list. * @member: the name of the list_struct within the struct. */ -#define list_for_each_entry(pos, head, member) \ +#ifdef _MSC_VER +#define list_for_each_entry(pos, head, member, type) \ + for (pos = list_first_entry(head, type, member); \ + &pos->member != (head); pos = list_next_entry(pos, member,type)) +#else +#define list_for_each_entry(pos, head, member,type) \ for (pos = list_first_entry(head, typeof(*pos), member); \ &pos->member != (head); \ - pos = list_next_entry(pos, member)) - + pos = list_next_entry(pos, member, type)) +#endif /** * list_for_each_entry_reverse - iterate backwards over list of given type. * @pos: the type * to use as a loop cursor. * @head: the head for your list. * @member: the name of the list_struct within the struct. */ -#define list_for_each_entry_reverse(pos, head, member) \ +#ifdef _MSC_VER +#define list_for_each_entry_reverse(pos, head, member, type) \ + for (pos = list_last_entry(head, type, member); \ + &pos->member != (head); \ + pos = list_prev_entry(pos, member, type)) +#else +#define list_for_each_entry_reverse(pos, head, member, type) \ for (pos = list_last_entry(head, typeof(*pos), member); \ &pos->member != (head); \ - pos = list_prev_entry(pos, member)) - + pos = list_prev_entry(pos, member, type)) +#endif /** * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry * @pos: the type * to use as a loop cursor. @@ -261,12 +280,19 @@ list_splice_tail(struct list_head *list, struct list_head *head) * @head: the head for your list. * @member: the name of the list_struct within the struct. */ -#define list_for_each_entry_safe(pos, n, head, member) \ +#ifdef _MSC_VER +#define list_for_each_entry_safe(pos, n, head, member,type) \ + for (pos = list_entry((head)->next, type, member), \ + n = list_entry(pos->member.next, type, member); \ + &pos->member != (head); \ + pos = n, n = list_entry(n->member.next, type, member)) +#else +#define list_for_each_entry_safe(pos, n, head, member, type) \ for (pos = list_entry((head)->next, typeof(*pos), member), \ n = list_entry(pos->member.next, typeof(*pos), member); \ &pos->member != (head); \ pos = n, n = list_entry(n->member.next, typeof(*n), member)) - +#endif /* * Double linked lists with a single pointer list head. * Mostly useful for hash tables where the two pointer list head is @@ -323,23 +349,34 @@ hlist_add_head(struct hlist_node *n, struct hlist_head *h) } #define hlist_entry(ptr, type, member) container_of(ptr,type,member) - +#ifdef _MSC_VER +#define hlist_entry_safe(ptr, type, member) \ + ptr ? hlist_entry(ptr, type, member) : NULL +#else #define hlist_entry_safe(ptr, type, member) \ ({ typeof(ptr) ____ptr = (ptr); \ ____ptr ? hlist_entry(____ptr, type, member) : NULL; \ }) - +#endif /** * hlist_for_each_entry - iterate over list of given type * @pos: the type * to use as a loop cursor. * @head: the head for your list. * @member: the name of the hlist_node within the struct. */ -#define hlist_for_each_entry(pos, head, member) \ +#ifdef _MSC_VER + +#define hlist_for_each_entry(pos, head, member,type) \ + for (pos = hlist_entry_safe((head)->first, type, member); \ + pos; pos = hlist_entry_safe((pos)->member.next, type, \ + member)) +#else + +#define hlist_for_each_entry(pos, head, member, type) \ for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member);\ pos; \ pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) - +#endif /** * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry * @pos: the type * to use as a loop cursor. @@ -347,9 +384,16 @@ hlist_add_head(struct hlist_node *n, struct hlist_head *h) * @head: the head for your list. * @member: the name of the hlist_node within the struct. */ -#define hlist_for_each_entry_safe(pos, n, head, member) \ +#ifdef _MSC_VER +#define hlist_for_each_entry_safe(pos, n, head, member, type) \ + for (pos = hlist_entry_safe((head)->first, type, member); \ + (unsigned long long)pos && ((unsigned long long)(n = pos->member.next) || 1 ); \ + pos = hlist_entry_safe(n, type, member)) +#else +#define hlist_for_each_entry_safe(pos, n, head, member,type) \ for (pos = hlist_entry_safe((head)->first, typeof(*pos), member);\ pos && ({ n = pos->member.next; 1; }); \ pos = hlist_entry_safe(n, typeof(*pos), member)) +#endif #endif /* _WIMLIB_LIST_H */ diff --git a/include/wimlib/metadata.h b/include/wimlib/metadata.h index a3d28048..2057c7a1 100644 --- a/include/wimlib/metadata.h +++ b/include/wimlib/metadata.h @@ -134,21 +134,21 @@ can_unload_image(const struct wim_image_metadata *imd) } /* Iterate over each inode in a WIM image */ -#define image_for_each_inode(inode, imd) \ - hlist_for_each_entry(inode, &(imd)->inode_list, i_hlist_node) +#define image_for_each_inode(inode, imd, type) \ + hlist_for_each_entry(inode, &(imd)->inode_list, i_hlist_node, type) /* Iterate over each inode in a WIM image (safe against inode removal) */ -#define image_for_each_inode_safe(inode, tmp, imd) \ - hlist_for_each_entry_safe(inode, tmp, &(imd)->inode_list, i_hlist_node) +#define image_for_each_inode_safe(inode, tmp, imd, type) \ + hlist_for_each_entry_safe(inode, tmp, &(imd)->inode_list, i_hlist_node, type) /* Iterate over each blob in a WIM image that has not yet been hashed */ -#define image_for_each_unhashed_blob(blob, imd) \ - list_for_each_entry(blob, &(imd)->unhashed_blobs, unhashed_list) +#define image_for_each_unhashed_blob(blob, imd, type) \ + list_for_each_entry(blob, &(imd)->unhashed_blobs, unhashed_list, type) /* Iterate over each blob in a WIM image that has not yet been hashed (safe * against blob removal) */ -#define image_for_each_unhashed_blob_safe(blob, tmp, imd) \ - list_for_each_entry_safe(blob, tmp, &(imd)->unhashed_blobs, unhashed_list) +#define image_for_each_unhashed_blob_safe(blob, tmp, imd, type) \ + list_for_each_entry_safe(blob, tmp, &(imd)->unhashed_blobs, unhashed_list, type) void put_image_metadata(struct wim_image_metadata *imd); diff --git a/include/wimlib/reparse.h b/include/wimlib/reparse.h index 972780df..5f324fc2 100644 --- a/include/wimlib/reparse.h +++ b/include/wimlib/reparse.h @@ -17,6 +17,9 @@ struct blob_table; * Note: we are not using __attribute__((packed)) for this structure, so only * cast to this if properly aligned! */ +#ifdef _MSC_VER +#pragma pack(push, 4) +#endif struct reparse_buffer_disk { le32 rptag; le16 rpdatalen; @@ -45,6 +48,9 @@ struct reparse_buffer_disk { }; }; +#ifdef _MSC_VER +#pragma pack(pop) +#endif #define REPARSE_DATA_OFFSET ((unsigned)offsetof(struct reparse_buffer_disk, rpdata)) #define REPARSE_DATA_MAX_SIZE (REPARSE_POINT_MAX_SIZE - REPARSE_DATA_OFFSET) diff --git a/include/wimlib/resource.h b/include/wimlib/resource.h index 8924b807..61d1752e 100644 --- a/include/wimlib/resource.h +++ b/include/wimlib/resource.h @@ -58,6 +58,9 @@ struct wim_resource_descriptor { }; /* On-disk version of a WIM resource header. */ +#ifdef _MSC_VER +#pragma pack(push, 1) +#endif struct wim_reshdr_disk { /* Size of the resource as it appears in the WIM file (possibly * compressed). */ @@ -74,6 +77,9 @@ struct wim_reshdr_disk { le64 uncompressed_size; } __attribute__((packed)); +#ifdef _MSC_VER +#pragma pack(pop) +#endif /* In-memory version of a WIM resource header (`struct wim_reshdr_disk'). */ struct wim_reshdr { u64 size_in_wim : 56; @@ -138,6 +144,9 @@ put_wim_reshdr(const struct wim_reshdr *reshdr, /* Alternate chunk table format for resources with WIM_RESHDR_FLAG_SOLID set. */ +#ifdef _MSC_VER +#pragma pack(push, 1) +#endif struct alt_chunk_table_header_disk { /* Uncompressed size of the resource in bytes. */ le64 res_usize; @@ -159,7 +168,9 @@ struct alt_chunk_table_header_disk { /* This header is directly followed by a table of compressed sizes of * the chunks (4 bytes per entry). */ } __attribute__((packed)); - +#ifdef _MSC_VER +#pragma pack(pop) +#endif static inline unsigned int get_chunk_entry_size(u64 res_size, bool is_alt) { @@ -315,6 +326,9 @@ write_metadata_resource(WIMStruct *wim, int image, int write_resource_flags); #define PWM_BLOB_MAGIC 0x2b9b9ba2443db9d8ULL /* Header that precedes each blob in a pipable WIM. */ +#ifdef _MSC_VER +#pragma pack(push, 1) +#endif struct pwm_blob_hdr { le64 magic; /* +0 */ le64 uncompressed_size; /* +8 */ @@ -328,5 +342,7 @@ struct pwm_blob_hdr { struct pwm_chunk_hdr { le32 compressed_size; } __attribute__((packed)); - +#ifdef _MSC_VER +#pragma pack(pop) +#endif #endif /* _WIMLIB_RESOURCE_H */ diff --git a/include/wimlib/security_descriptor.h b/include/wimlib/security_descriptor.h index f5c5a34c..77e0ef7e 100644 --- a/include/wimlib/security_descriptor.h +++ b/include/wimlib/security_descriptor.h @@ -35,6 +35,9 @@ * conflicts with the same types being defined in the libntfs-3g headers. */ /* Windows NT security descriptor, in self-relative format */ +#ifdef _MSC_VER +#pragma pack(push, 4) +#endif typedef struct { /* Security descriptor revision; should be 1 */ u8 revision; @@ -59,7 +62,9 @@ typedef struct { * descriptor, or 0 if no DACL is present */ le32 dacl_offset; } __attribute__((packed)) wimlib_SECURITY_DESCRIPTOR_RELATIVE; - +#ifdef _MSC_VER +#pragma pack(pop) +#endif #define wimlib_SE_OWNER_DEFAULTED 0x0001 #define wimlib_SE_GROUP_DEFAULTED 0x0002 #define wimlib_SE_DACL_PRESENT 0x0004 diff --git a/include/wimlib/timestamp.h b/include/wimlib/timestamp.h index e30e0621..90c75ec4 100644 --- a/include/wimlib/timestamp.h +++ b/include/wimlib/timestamp.h @@ -7,7 +7,10 @@ #ifndef _WIMLIB_TIMESTAMP_H #define _WIMLIB_TIMESTAMP_H +#ifdef _MSC_VER +#else #include +#endif #include #include "wimlib/types.h" diff --git a/include/wimlib/win32.h b/include/wimlib/win32.h index ed54e6f5..f100034d 100644 --- a/include/wimlib/win32.h +++ b/include/wimlib/win32.h @@ -8,7 +8,10 @@ #ifdef _WIN32 #include "wimlib/types.h" - +#ifdef _MSC_VER +#include "msvc/unistd.h" +#else +#endif struct blob_descriptor; struct consume_chunk_callback; struct windows_file; diff --git a/include/wimlib/win32_common.h b/include/wimlib/win32_common.h index 46faf6ac..e4044956 100644 --- a/include/wimlib/win32_common.h +++ b/include/wimlib/win32_common.h @@ -6,6 +6,7 @@ #ifndef _WIMLIB_WIN32_COMMON_H #define _WIMLIB_WIN32_COMMON_H +#define _WINIOCTL_ // excludes winioctl.h #include #include #include @@ -160,5 +161,1237 @@ winnt_error(NTSTATUS status, const wchar_t *format, ...); NTSTATUS winnt_fsctl(HANDLE h, u32 code, const void *in, u32 in_size, void *out, u32 out_size_avail, u32 *actual_out_size_ret); +#ifdef WIN32 +#pragma region win32_typedefs +#define DEVICE_TYPE DWORD +#define FILE_ANY_ACCESS 0 +#define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS) +#define FILE_READ_ACCESS (0x0001) // file & pipe +#define FILE_WRITE_ACCESS (0x0002) // file & pipe +#define METHOD_BUFFERED 0 +#define METHOD_IN_DIRECT 1 +#define METHOD_OUT_DIRECT 2 +#define METHOD_NEITHER 3 +#define FILE_DEVICE_BEEP 0x00000001 +#define FILE_DEVICE_CD_ROM 0x00000002 +#define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003 +#define FILE_DEVICE_CONTROLLER 0x00000004 +#define FILE_DEVICE_DATALINK 0x00000005 +#define FILE_DEVICE_DFS 0x00000006 +#define FILE_DEVICE_DISK 0x00000007 +#define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008 +#define FILE_DEVICE_FILE_SYSTEM 0x00000009 +#define FILE_DEVICE_INPORT_PORT 0x0000000a +#define FILE_DEVICE_KEYBOARD 0x0000000b +#define FILE_DEVICE_MAILSLOT 0x0000000c +#define FILE_DEVICE_MIDI_IN 0x0000000d +#define FILE_DEVICE_MIDI_OUT 0x0000000e +#define FILE_DEVICE_MOUSE 0x0000000f +#define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010 +#define FILE_DEVICE_NAMED_PIPE 0x00000011 +#define FILE_DEVICE_NETWORK 0x00000012 +#define FILE_DEVICE_NETWORK_BROWSER 0x00000013 +#define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014 +#define FILE_DEVICE_NULL 0x00000015 +#define FILE_DEVICE_PARALLEL_PORT 0x00000016 +#define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017 +#define FILE_DEVICE_PRINTER 0x00000018 +#define FILE_DEVICE_SCANNER 0x00000019 +#define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a +#define FILE_DEVICE_SERIAL_PORT 0x0000001b +#define FILE_DEVICE_SCREEN 0x0000001c +#define FILE_DEVICE_SOUND 0x0000001d +#define FILE_DEVICE_STREAMS 0x0000001e +#define FILE_DEVICE_TAPE 0x0000001f +#define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020 +#define FILE_DEVICE_TRANSPORT 0x00000021 +#define FILE_DEVICE_UNKNOWN 0x00000022 +#define FILE_DEVICE_VIDEO 0x00000023 +#define FILE_DEVICE_VIRTUAL_DISK 0x00000024 +#define FILE_DEVICE_WAVE_IN 0x00000025 +#define FILE_DEVICE_WAVE_OUT 0x00000026 +#define FILE_DEVICE_8042_PORT 0x00000027 +#define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028 +#define FILE_DEVICE_BATTERY 0x00000029 +#define FILE_DEVICE_BUS_EXTENDER 0x0000002a +#define FILE_DEVICE_MODEM 0x0000002b +#define FILE_DEVICE_VDM 0x0000002c +#define FILE_DEVICE_MASS_STORAGE 0x0000002d +#define FILE_DEVICE_SMB 0x0000002e +#define FILE_DEVICE_KS 0x0000002f +#define FILE_DEVICE_CHANGER 0x00000030 +#define FILE_DEVICE_SMARTCARD 0x00000031 +#define FILE_DEVICE_ACPI 0x00000032 +#define FILE_DEVICE_DVD 0x00000033 +#define FILE_DEVICE_FULLSCREEN_VIDEO 0x00000034 +#define FILE_DEVICE_DFS_FILE_SYSTEM 0x00000035 +#define FILE_DEVICE_DFS_VOLUME 0x00000036 +#define FILE_DEVICE_SERENUM 0x00000037 +#define FILE_DEVICE_TERMSRV 0x00000038 +#define FILE_DEVICE_KSEC 0x00000039 +#define FILE_DEVICE_FIPS 0x0000003A +#define FILE_DEVICE_INFINIBAND 0x0000003B +#define FILE_DEVICE_VMBUS 0x0000003E +#define FILE_DEVICE_CRYPT_PROVIDER 0x0000003F +#define FILE_DEVICE_WPD 0x00000040 +#define FILE_DEVICE_BLUETOOTH 0x00000041 +#define FILE_DEVICE_MT_COMPOSITE 0x00000042 +#define FILE_DEVICE_MT_TRANSPORT 0x00000043 +#define FILE_DEVICE_BIOMETRIC 0x00000044 +#define FILE_DEVICE_PMI 0x00000045 +#define FILE_DEVICE_EHSTOR 0x00000046 +#define FILE_DEVICE_DEVAPI 0x00000047 +#define FILE_DEVICE_GPIO 0x00000048 +#define FILE_DEVICE_USBEX 0x00000049 +#define FILE_DEVICE_CONSOLE 0x00000050 +#define FILE_DEVICE_NFP 0x00000051 +#define FILE_DEVICE_SYSENV 0x00000052 +#define FILE_DEVICE_VIRTUAL_BLOCK 0x00000053 +#define FILE_DEVICE_POINT_OF_SERVICE 0x00000054 +#define FILE_DEVICE_STORAGE_REPLICATION 0x00000055 +#define FILE_DEVICE_TRUST_ENV 0x00000056 +#define FILE_DEVICE_UCM 0x00000057 +#define FILE_DEVICE_UCMTCPCI 0x00000058 +#define FILE_DEVICE_PERSISTENT_MEMORY 0x00000059 +#define FILE_DEVICE_NVDIMM 0x0000005a +#define FILE_DEVICE_HOLOGRAPHIC 0x0000005b +#define FILE_DEVICE_SDFXHCI 0x0000005c +#define FILE_DEVICE_UCMUCSI 0x0000005d +#define FILE_DEVICE_PRM 0x0000005e +#define FILE_DEVICE_EVENT_COLLECTOR 0x0000005f +#define FILE_DEVICE_USB4 0x00000060 +#define FILE_DEVICE_SOUNDWIRE 0x00000061 +#define CTL_CODE(DeviceType, Function, Method, Access) \ + (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)) +#define FSCTL_REQUEST_OPLOCK_LEVEL_1 \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 0, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_REQUEST_OPLOCK_LEVEL_2 \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 1, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_REQUEST_BATCH_OPLOCK \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 2, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 3, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_OPBATCH_ACK_CLOSE_PENDING \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 4, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_OPLOCK_BREAK_NOTIFY \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 5, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_LOCK_VOLUME \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 6, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_UNLOCK_VOLUME \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 7, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_DISMOUNT_VOLUME \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 8, METHOD_BUFFERED, FILE_ANY_ACCESS) +// decommissioned fsctl value 9 +#define FSCTL_IS_VOLUME_MOUNTED \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 10, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_IS_PATHNAME_VALID \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 11, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // PATHNAME_BUFFER, +#define FSCTL_MARK_VOLUME_DIRTY \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 12, METHOD_BUFFERED, FILE_ANY_ACCESS) +// decommissioned fsctl value 13 +#define FSCTL_QUERY_RETRIEVAL_POINTERS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 14, METHOD_NEITHER, FILE_ANY_ACCESS) +#define FSCTL_GET_COMPRESSION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 15, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_SET_COMPRESSION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, \ + FILE_READ_DATA | FILE_WRITE_DATA) +// decommissioned fsctl value 17 +// decommissioned fsctl value 18 +#define FSCTL_SET_BOOTLOADER_ACCESSED \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 19, METHOD_NEITHER, FILE_ANY_ACCESS) +#define FSCTL_MARK_AS_SYSTEM_HIVE FSCTL_SET_BOOTLOADER_ACCESSED +#define FSCTL_OPLOCK_BREAK_ACK_NO_2 \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 20, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_INVALIDATE_VOLUMES \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 21, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_QUERY_FAT_BPB \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 22, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // FSCTL_QUERY_FAT_BPB_BUFFER +#define FSCTL_REQUEST_FILTER_OPLOCK \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 23, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_FILESYSTEM_GET_STATISTICS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 24, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // FILESYSTEM_STATISTICS + +#if (_WIN32_WINNT >= _WIN32_WINNT_NT4) +#define FSCTL_GET_NTFS_VOLUME_DATA \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 25, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // NTFS_VOLUME_DATA_BUFFER +#define FSCTL_GET_NTFS_FILE_RECORD \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 26, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // NTFS_FILE_RECORD_INPUT_BUFFER, + // NTFS_FILE_RECORD_OUTPUT_BUFFER +#define FSCTL_GET_VOLUME_BITMAP \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 27, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // STARTING_LCN_INPUT_BUFFER, + // VOLUME_BITMAP_BUFFER +#define FSCTL_GET_RETRIEVAL_POINTERS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 28, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // STARTING_VCN_INPUT_BUFFER, + // RETRIEVAL_POINTERS_BUFFER +#define FSCTL_MOVE_FILE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 29, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) // MOVE_FILE_DATA, +#define FSCTL_IS_VOLUME_DIRTY \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 30, METHOD_BUFFERED, FILE_ANY_ACCESS) +// decommissioned fsctl value 31 +#define FSCTL_ALLOW_EXTENDED_DASD_IO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 32, METHOD_NEITHER, FILE_ANY_ACCESS) +#endif /* _WIN32_WINNT >= _WIN32_WINNT_NT4 */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN2K) +// decommissioned fsctl value 33 +// decommissioned fsctl value 34 +#define FSCTL_FIND_FILES_BY_SID \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 35, METHOD_NEITHER, FILE_ANY_ACCESS) +// decommissioned fsctl value 36 +// decommissioned fsctl value 37 +#define FSCTL_SET_OBJECT_ID \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 38, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) // FILE_OBJECTID_BUFFER +#define FSCTL_GET_OBJECT_ID \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 39, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // FILE_OBJECTID_BUFFER +#define FSCTL_DELETE_OBJECT_ID \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 40, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) +#define FSCTL_SET_REPARSE_POINT \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) // REPARSE_DATA_BUFFER, +#define FSCTL_GET_REPARSE_POINT \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // REPARSE_DATA_BUFFER +#define FSCTL_DELETE_REPARSE_POINT \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) // REPARSE_DATA_BUFFER, +#define FSCTL_ENUM_USN_DATA \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 44, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // MFT_ENUM_DATA, +#define FSCTL_SECURITY_ID_CHECK \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 45, METHOD_NEITHER, \ + FILE_READ_DATA) // BULK_SECURITY_TEST_DATA, +#define FSCTL_READ_USN_JOURNAL \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // READ_USN_JOURNAL_DATA, USN +#define FSCTL_SET_OBJECT_ID_EXTENDED \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 47, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) +#define FSCTL_CREATE_OR_GET_OBJECT_ID \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 48, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // FILE_OBJECTID_BUFFER +#define FSCTL_SET_SPARSE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) +#define FSCTL_SET_ZERO_DATA \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 50, METHOD_BUFFERED, \ + FILE_WRITE_DATA) // FILE_ZERO_DATA_INFORMATION, +#define FSCTL_QUERY_ALLOCATED_RANGES \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 51, METHOD_NEITHER, \ + FILE_READ_DATA) // FILE_ALLOCATED_RANGE_BUFFER, + // FILE_ALLOCATED_RANGE_BUFFER +#define FSCTL_ENABLE_UPGRADE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 52, METHOD_BUFFERED, FILE_WRITE_DATA) +#define FSCTL_SET_ENCRYPTION \ + CTL_CODE( \ + FILE_DEVICE_FILE_SYSTEM, 53, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // ENCRYPTION_BUFFER, DECRYPTION_STATUS_BUFFER +#define FSCTL_ENCRYPTION_FSCTL_IO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 54, METHOD_NEITHER, FILE_ANY_ACCESS) +#define FSCTL_WRITE_RAW_ENCRYPTED \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 55, METHOD_NEITHER, \ + FILE_SPECIAL_ACCESS) // ENCRYPTED_DATA_INFO, + // EXTENDED_ENCRYPTED_DATA_INFO +#define FSCTL_READ_RAW_ENCRYPTED \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 56, METHOD_NEITHER, \ + FILE_SPECIAL_ACCESS) // REQUEST_RAW_ENCRYPTED_DATA, + // ENCRYPTED_DATA_INFO, + // EXTENDED_ENCRYPTED_DATA_INFO +#define FSCTL_CREATE_USN_JOURNAL \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 57, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // CREATE_USN_JOURNAL_DATA, +#define FSCTL_READ_FILE_USN_DATA \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 58, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // Read the Usn Record for a file +#define FSCTL_WRITE_USN_CLOSE_RECORD \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 59, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // Generate Close Usn Record +#define FSCTL_EXTEND_VOLUME \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_QUERY_USN_JOURNAL \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 61, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_DELETE_USN_JOURNAL \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 62, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_MARK_HANDLE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 63, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_SIS_COPYFILE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 64, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_SIS_LINK_FILES \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 65, METHOD_BUFFERED, \ + FILE_READ_DATA | FILE_WRITE_DATA) +// decommissioned fsctl value 66 +// decommissioned fsctl value 67 +// decommissioned fsctl value 68 +#define FSCTL_RECALL_FILE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 69, METHOD_NEITHER, FILE_ANY_ACCESS) +// decommissioned fsctl value 70 +#define FSCTL_READ_FROM_PLEX \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 71, METHOD_OUT_DIRECT, FILE_READ_DATA) +#define FSCTL_FILE_PREFETCH \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 72, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) // FILE_PREFETCH +#endif /* _WIN32_WINNT >= _WIN32_WINNT_WIN2K */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) +#define FSCTL_MAKE_MEDIA_COMPATIBLE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 76, METHOD_BUFFERED, \ + FILE_WRITE_DATA) // UDFS R/W +#define FSCTL_SET_DEFECT_MANAGEMENT \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 77, METHOD_BUFFERED, \ + FILE_WRITE_DATA) // UDFS R/W +#define FSCTL_QUERY_SPARING_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 78, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // UDFS R/W +#define FSCTL_QUERY_ON_DISK_VOLUME_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 79, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // C/UDFS +#define FSCTL_SET_VOLUME_COMPRESSION_STATE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 80, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) // VOLUME_COMPRESSION_STATE +// decommissioned fsctl value 80 +#define FSCTL_TXFS_MODIFY_RM \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 81, METHOD_BUFFERED, \ + FILE_WRITE_DATA) // TxF +#define FSCTL_TXFS_QUERY_RM_INFORMATION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 82, METHOD_BUFFERED, \ + FILE_READ_DATA) // TxF +// decommissioned fsctl value 83 +#define FSCTL_TXFS_ROLLFORWARD_REDO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 84, METHOD_BUFFERED, \ + FILE_WRITE_DATA) // TxF +#define FSCTL_TXFS_ROLLFORWARD_UNDO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 85, METHOD_BUFFERED, \ + FILE_WRITE_DATA) // TxF +#define FSCTL_TXFS_START_RM \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 86, METHOD_BUFFERED, \ + FILE_WRITE_DATA) // TxF +#define FSCTL_TXFS_SHUTDOWN_RM \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 87, METHOD_BUFFERED, \ + FILE_WRITE_DATA) // TxF +#define FSCTL_TXFS_READ_BACKUP_INFORMATION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 88, METHOD_BUFFERED, \ + FILE_READ_DATA) // TxF +#define FSCTL_TXFS_WRITE_BACKUP_INFORMATION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 89, METHOD_BUFFERED, \ + FILE_WRITE_DATA) // TxF +#define FSCTL_TXFS_CREATE_SECONDARY_RM \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 90, METHOD_BUFFERED, \ + FILE_WRITE_DATA) // TxF +#define FSCTL_TXFS_GET_METADATA_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 91, METHOD_BUFFERED, \ + FILE_READ_DATA) // TxF +#define FSCTL_TXFS_GET_TRANSACTED_VERSION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 92, METHOD_BUFFERED, \ + FILE_READ_DATA) // TxF +// decommissioned fsctl value 93 +#define FSCTL_TXFS_SAVEPOINT_INFORMATION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 94, METHOD_BUFFERED, \ + FILE_WRITE_DATA) // TxF +#define FSCTL_TXFS_CREATE_MINIVERSION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 95, METHOD_BUFFERED, \ + FILE_WRITE_DATA) // TxF +// decommissioned fsctl value 96 +// decommissioned fsctl value 97 +// decommissioned fsctl value 98 +#define FSCTL_TXFS_TRANSACTION_ACTIVE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 99, METHOD_BUFFERED, \ + FILE_READ_DATA) // TxF +#define FSCTL_SET_ZERO_ON_DEALLOCATION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 101, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) +#define FSCTL_SET_REPAIR \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 102, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_GET_REPAIR \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 103, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_WAIT_FOR_REPAIR \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 104, METHOD_BUFFERED, FILE_ANY_ACCESS) +// decommissioned fsctl value 105 +#define FSCTL_INITIATE_REPAIR \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 106, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_CSC_INTERNAL \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 107, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // CSC internal implementation +#define FSCTL_SHRINK_VOLUME \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 108, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) // SHRINK_VOLUME_INFORMATION +#define FSCTL_SET_SHORT_NAME_BEHAVIOR \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 109, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_DFSR_SET_GHOST_HANDLE_STATE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 110, METHOD_BUFFERED, FILE_ANY_ACCESS) + +// +// Values 111 - 119 are reserved for FSRM. +// + +#define FSCTL_TXFS_LIST_TRANSACTION_LOCKED_FILES \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 120, METHOD_BUFFERED, \ + FILE_READ_DATA) // TxF +#define FSCTL_TXFS_LIST_TRANSACTIONS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 121, METHOD_BUFFERED, \ + FILE_READ_DATA) // TxF +#define FSCTL_QUERY_PAGEFILE_ENCRYPTION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 122, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) +#define FSCTL_RESET_VOLUME_ALLOCATION_HINTS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 123, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) +#define FSCTL_QUERY_DEPENDENT_VOLUME \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 124, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // Dependency File System Filter +#define FSCTL_SD_GLOBAL_CHANGE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 125, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // Query/Change NTFS Security Descriptors +#endif /* _WIN32_WINNT >= _WIN32_WINNT_WIN7 */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) +#define FSCTL_TXFS_READ_BACKUP_INFORMATION2 \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 126, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // TxF +#endif /* _WIN32_WINNT >= _WIN32_WINNT_VISTA */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) +#define FSCTL_LOOKUP_STREAM_FROM_CLUSTER \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 127, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_TXFS_WRITE_BACKUP_INFORMATION2 \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 128, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // TxF +#define FSCTL_FILE_TYPE_NOTIFICATION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 129, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) +#define FSCTL_FILE_LEVEL_TRIM \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 130, METHOD_BUFFERED, FILE_WRITE_DATA) +#endif /*_WIN32_WINNT >= _WIN32_WINNT_WIN8 */ + +// +// Values 131 - 139 are reserved for FSRM. +// + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) +#define FSCTL_GET_BOOT_AREA_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 140, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // BOOT_AREA_INFO +#define FSCTL_GET_RETRIEVAL_POINTER_BASE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 141, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // RETRIEVAL_POINTER_BASE +#define FSCTL_SET_PERSISTENT_VOLUME_STATE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 142, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // FILE_FS_PERSISTENT_VOLUME_INFORMATION +#define FSCTL_QUERY_PERSISTENT_VOLUME_STATE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 143, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // FILE_FS_PERSISTENT_VOLUME_INFORMATION + +#define FSCTL_REQUEST_OPLOCK \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 144, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define FSCTL_CSV_TUNNEL_REQUEST \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 145, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // CSV_TUNNEL_REQUEST +#define FSCTL_IS_CSV_FILE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 146, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // IS_CSV_FILE + +#define FSCTL_QUERY_FILE_SYSTEM_RECOGNITION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 147, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // +#define FSCTL_CSV_GET_VOLUME_PATH_NAME \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 148, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_CSV_GET_VOLUME_NAME_FOR_VOLUME_MOUNT_POINT \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 149, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_CSV_GET_VOLUME_PATH_NAMES_FOR_VOLUME_NAME \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 150, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_IS_FILE_ON_CSV_VOLUME \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 151, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /* _WIN32_WINNT >= _WIN32_WINNT_WIN7 */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) +#define FSCTL_CORRUPTION_HANDLING \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 152, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_OFFLOAD_READ \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 153, METHOD_BUFFERED, \ + FILE_READ_ACCESS) +#define FSCTL_OFFLOAD_WRITE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 154, METHOD_BUFFERED, \ + FILE_WRITE_ACCESS) +#endif /*_WIN32_WINNT >= _WIN32_WINNT_WIN8 */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) +#define FSCTL_CSV_INTERNAL \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 155, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /* _WIN32_WINNT >= _WIN32_WINNT_WIN7 */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) +#define FSCTL_SET_PURGE_FAILURE_MODE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 156, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_QUERY_FILE_LAYOUT \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 157, METHOD_NEITHER, FILE_ANY_ACCESS) +#define FSCTL_IS_VOLUME_OWNED_BYCSVFS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 158, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define FSCTL_GET_INTEGRITY_INFORMATION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // FSCTL_GET_INTEGRITY_INFORMATION_BUFFER +#define FSCTL_SET_INTEGRITY_INFORMATION \ + CTL_CODE( \ + FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, \ + FILE_READ_DATA | \ + FILE_WRITE_DATA) // FSCTL_SET_INTEGRITY_INFORMATION_BUFFER + +#define FSCTL_QUERY_FILE_REGIONS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 161, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#endif /*_WIN32_WINNT >= _WIN32_WINNT_WIN8 */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) +#define FSCTL_RKF_INTERNAL \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 171, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // Resume Key Filter + +#define FSCTL_SCRUB_DATA \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 172, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_REPAIR_COPIES \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 173, METHOD_BUFFERED, \ + FILE_READ_DATA | FILE_WRITE_DATA) +#define FSCTL_DISABLE_LOCAL_BUFFERING \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 174, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_CSV_MGMT_LOCK \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 175, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_CSV_QUERY_DOWN_LEVEL_FILE_SYSTEM_CHARACTERISTICS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 176, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_ADVANCE_FILE_ID \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 177, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_CSV_SYNC_TUNNEL_REQUEST \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 178, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_CSV_QUERY_VETO_FILE_DIRECT_IO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 179, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_WRITE_USN_REASON \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 180, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_CSV_CONTROL \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 181, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_GET_REFS_VOLUME_DATA \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 182, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_CSV_H_BREAKING_SYNC_TUNNEL_REQUEST \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 185, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /*_WIN32_WINNT >= _WIN32_WINNT_WIN8 */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) +#define FSCTL_QUERY_STORAGE_CLASSES \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 187, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_QUERY_REGION_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 188, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_USN_TRACK_MODIFIED_RANGES \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 189, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // USN_TRACK_MODIFIED_RANGES +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) */ +#if (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) +#define FSCTL_QUERY_SHARED_VIRTUAL_DISK_SUPPORT \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 192, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_SVHDX_SYNC_TUNNEL_REQUEST \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 193, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_SVHDX_SET_INITIATOR_INFORMATION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 194, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) */ +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) +#define FSCTL_SET_EXTERNAL_BACKING \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 195, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) +#define FSCTL_GET_EXTERNAL_BACKING \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 196, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_DELETE_EXTERNAL_BACKING \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 197, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) +#define FSCTL_ENUM_EXTERNAL_BACKING \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 198, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_ENUM_OVERLAY \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 199, METHOD_NEITHER, FILE_ANY_ACCESS) +#define FSCTL_ADD_OVERLAY \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 204, METHOD_BUFFERED, FILE_WRITE_DATA) +#define FSCTL_REMOVE_OVERLAY \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 205, METHOD_BUFFERED, FILE_WRITE_DATA) +#define FSCTL_UPDATE_OVERLAY \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 206, METHOD_BUFFERED, FILE_WRITE_DATA) +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WIN7) */ +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) +#define FSCTL_SHUFFLE_FILE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 208, METHOD_BUFFERED, \ + FILE_READ_ACCESS | FILE_WRITE_ACCESS) // SHUFFLE_FILE_DATA +#endif /*_WIN32_WINNT >= _WIN32_WINNT_WIN8 */ +#if (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) +#define FSCTL_DUPLICATE_EXTENTS_TO_FILE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 209, METHOD_BUFFERED, FILE_WRITE_DATA) +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) */ +#if (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) +#define FSCTL_SPARSE_OVERALLOCATE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 211, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) +#define FSCTL_STORAGE_QOS_CONTROL \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 212, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) */ +#if (_WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD) +#define FSCTL_INITIATE_FILE_METADATA_OPTIMIZATION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 215, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) +#define FSCTL_QUERY_FILE_METADATA_OPTIMIZATION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 216, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD) */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) +#define FSCTL_SVHDX_ASYNC_TUNNEL_REQUEST \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 217, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WINBLUE) */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) +#define FSCTL_GET_WOF_VERSION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 218, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif + +#if (_WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD) +#define FSCTL_HCS_SYNC_TUNNEL_REQUEST \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 219, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_HCS_ASYNC_TUNNEL_REQUEST \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 220, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_QUERY_EXTENT_READ_CACHE_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 221, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // VCN_RANGE_INPUT_BUFFER, + // EXTENT_READ_CACHE_INFO_BUFFER +#define FSCTL_QUERY_REFS_VOLUME_COUNTER_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 222, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // REFS_VOLUME_COUNTER_INFO_INPUT_BUFFER, + // VOLUME_REFS_INFO_BUFFER +#define FSCTL_CLEAN_VOLUME_METADATA \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 223, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_SET_INTEGRITY_INFORMATION_EX \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 224, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // FSCTL_SET_INTEGRITY_INFORMATION_BUFFER_EX +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD) */ +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN7) +#define FSCTL_SUSPEND_OVERLAY \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 225, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif +#if (_WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD) +#define FSCTL_VIRTUAL_STORAGE_QUERY_PROPERTY \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 226, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_FILESYSTEM_GET_STATISTICS_EX \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 227, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // FILESYSTEM_STATISTICS_EX +#define FSCTL_QUERY_VOLUME_CONTAINER_STATE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 228, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_SET_LAYER_ROOT \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 229, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // CONTAINER_ROOT_INFO_INPUT + // CONTAINER_ROOT_INFO_OUTPUT +#endif + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_TH2) +#define FSCTL_QUERY_DIRECT_ACCESS_EXTENTS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 230, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // QUERY_DIRECT_ACCESS_EXTENTS +#define FSCTL_NOTIFY_STORAGE_SPACE_ALLOCATION \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 231, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_SSDI_STORAGE_REQUEST \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 232, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS1) +#define FSCTL_QUERY_DIRECT_IMAGE_ORIGINAL_BASE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 233, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_READ_UNPRIVILEGED_USN_JOURNAL \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 234, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // READ_USN_JOURNAL_DATA, USN +#endif + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_TH2) +#define FSCTL_GHOST_FILE_EXTENTS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 235, METHOD_BUFFERED, \ + FILE_WRITE_ACCESS) // FSCTL_GHOST_FILE_EXTENTS_INPUT_BUFFER +#define FSCTL_QUERY_GHOSTED_FILE_EXTENTS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 236, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_TH2) +#define FSCTL_UNMAP_SPACE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 237, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif + +#if (_WIN32_WINNT >= _WIN32_WINNT_WINTHRESHOLD) +#define FSCTL_HCS_SYNC_NO_WRITE_TUNNEL_REQUEST \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 238, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS1) +#define FSCTL_START_VIRTUALIZATION_INSTANCE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 240, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // VIRTUALIZATION_INSTANCE_INFO_INPUT, + // VIRTUALIZATION_INSTANCE_INFO_OUTPUT +#define FSCTL_GET_FILTER_FILE_IDENTIFIER \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 241, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // GET_FILTER_FILE_IDENTIFIER_INPUT, + // GET_FILTER_FILE_IDENTIFIER_OUTPUT +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS1) */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS2) +#define FSCTL_STREAMS_QUERY_PARAMETERS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 241, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_STREAMS_ASSOCIATE_ID \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 242, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_STREAMS_QUERY_ID \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 243, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#define FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 244, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // STARTING_VCN_INPUT_BUFFER, + // RETRIEVAL_POINTERS_AND_REFCOUNT_BUFFER + +#define FSCTL_QUERY_VOLUME_NUMA_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 245, METHOD_BUFFERED, FILE_ANY_ACCESS) + +#endif + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS2) + +#define FSCTL_REFS_DEALLOCATE_RANGES \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 246, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_TH2) +#define FSCTL_QUERY_REFS_SMR_VOLUME_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 247, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_SET_REFS_SMR_VOLUME_GC_PARAMETERS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 248, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_SET_REFS_FILE_STRICTLY_SEQUENTIAL \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 249, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS3) +#define FSCTL_DUPLICATE_EXTENTS_TO_FILE_EX \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 250, METHOD_BUFFERED, FILE_WRITE_DATA) +#define FSCTL_QUERY_BAD_RANGES \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 251, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_SET_DAX_ALLOC_ALIGNMENT_HINT \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 252, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_DELETE_CORRUPTED_REFS_CONTAINER \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 253, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_SCRUB_UNDISCOVERABLE_ID \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 254, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS3) */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS4) +#define FSCTL_NOTIFY_DATA_CHANGE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 255, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS4) */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS1) +#define FSCTL_START_VIRTUALIZATION_INSTANCE_EX \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 256, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS1) */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS4) +#define FSCTL_ENCRYPTION_KEY_CONTROL \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 257, METHOD_BUFFERED, \ + FILE_ANY_ACCESS) // protect/unprotect under DPL +#define FSCTL_VIRTUAL_STORAGE_SET_BEHAVIOR \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 258, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS4) */ + +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS1) +#define FSCTL_SET_REPARSE_POINT_EX \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 259, METHOD_BUFFERED, \ + FILE_SPECIAL_ACCESS) // REPARSE_DATA_BUFFER_EX +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS1) */ +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS5) +#define FSCTL_REARRANGE_FILE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 264, METHOD_BUFFERED, \ + FILE_READ_ACCESS | FILE_WRITE_ACCESS) // REARRANGE_FILE_DATA +#define FSCTL_VIRTUAL_STORAGE_PASSTHROUGH \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 265, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_GET_RETRIEVAL_POINTER_COUNT \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 266, METHOD_NEITHER, \ + FILE_ANY_ACCESS) // STARTING_VCN_INPUT_BUFFER, + // RETRIEVAL_POINTER_COUNT +#if defined(_WIN64) +#define FSCTL_ENABLE_PER_IO_FLAGS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 267, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif /* _WIN64 */ +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS5) */ +#if (NTDDI_VERSION >= NTDDI_WIN10_RS5) +#define FSCTL_QUERY_ASYNC_DUPLICATE_EXTENTS_STATUS \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 268, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif +#if (NTDDI_VERSION >= NTDDI_WIN10_MN) +#define FSCTL_SMB_SHARE_FLUSH_AND_PURGE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 271, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN10_FE) +#define FSCTL_REFS_STREAM_SNAPSHOT_MANAGEMENT \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 272, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif +#if (NTDDI_VERSION >= NTDDI_WIN10_CO) +#define FSCTL_MANAGE_BYPASS_IO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 274, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN10_FE) +#define FSCTL_REFS_DEALLOCATE_RANGES_EX \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 275, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif + +#if (NTDDI_VERSION >= NTDDI_WIN10_FE) +#define FSCTL_SET_CACHED_RUNS_STATE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 276, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif +#if (NTDDI_VERSION >= NTDDI_WIN10_NI) +#define FSCTL_REFS_SET_VOLUME_COMPRESSION_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 277, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_REFS_QUERY_VOLUME_COMPRESSION_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 278, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif +#if (NTDDI_VERSION >= NTDDI_WIN10_NI) +#define FSCTL_DUPLICATE_CLUSTER \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 279, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_CREATE_LCN_WEAK_REFERENCE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 280, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_DELETE_LCN_WEAK_REFERENCE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 281, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_QUERY_LCN_WEAK_REFERENCE \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 282, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_DELETE_LCN_WEAK_REFERENCES \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 283, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif +#if (NTDDI_VERSION >= NTDDI_WIN10_NI) +#define FSCTL_REFS_SET_VOLUME_DEDUP_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 284, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define FSCTL_REFS_QUERY_VOLUME_DEDUP_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 285, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif +#if (NTDDI_VERSION >= NTDDI_WIN10_RS5) +#define FSCTL_LMR_QUERY_INFO \ + CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 286, METHOD_BUFFERED, FILE_ANY_ACCESS) +#endif +#define IOCTL_VOLUME_BASE 0x00000056 // 'V' +#define IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS CTL_CODE(IOCTL_VOLUME_BASE, 0, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_DISK_BASE FILE_DEVICE_DISK +#define IOCTL_DISK_GET_PARTITION_INFO_EX \ + CTL_CODE(IOCTL_DISK_BASE, 0x0012, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_DISK_SET_PARTITION_INFO_EX \ + CTL_CODE(IOCTL_DISK_BASE, 0x0013, METHOD_BUFFERED, \ + FILE_READ_ACCESS | FILE_WRITE_ACCESS) +#define IOCTL_DISK_GET_DRIVE_LAYOUT_EX \ + CTL_CODE(IOCTL_DISK_BASE, 0x0014, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_DISK_SET_DRIVE_LAYOUT_EX \ + CTL_CODE(IOCTL_DISK_BASE, 0x0015, METHOD_BUFFERED, \ + FILE_READ_ACCESS | FILE_WRITE_ACCESS) +#define IOCTL_DISK_CREATE_DISK \ + CTL_CODE(IOCTL_DISK_BASE, 0x0016, METHOD_BUFFERED, \ + FILE_READ_ACCESS | FILE_WRITE_ACCESS) +#define IOCTL_DISK_GET_LENGTH_INFO \ + CTL_CODE(IOCTL_DISK_BASE, 0x0017, METHOD_BUFFERED, FILE_READ_ACCESS) +#define IOCTL_DISK_GET_DRIVE_GEOMETRY_EX \ + CTL_CODE(IOCTL_DISK_BASE, 0x0028, METHOD_BUFFERED, FILE_ANY_ACCESS) +typedef struct _FILE_OBJECTID_BUFFER { + + u8 ObjectId[16]; + + union { + struct { + u8 BirthVolumeId[16]; + u8 BirthObjectId[16]; + u8 DomainId[16]; + }; + u8 ExtendedInfo[48]; + }; + +} FILE_OBJECTID_BUFFER, *PFILE_OBJECTID_BUFFER; +typedef struct { + + LARGE_INTEGER StartingVcn; + +} STARTING_VCN_INPUT_BUFFER, *PSTARTING_VCN_INPUT_BUFFER; + +typedef enum _PARTITION_STYLE { + PARTITION_STYLE_MBR, + PARTITION_STYLE_GPT, + PARTITION_STYLE_RAW +} PARTITION_STYLE; +typedef struct _PARTITION_INFORMATION_MBR { + + BYTE PartitionType; + + BOOLEAN BootIndicator; + + BOOLEAN RecognizedPartition; + + DWORD HiddenSectors; + +#if (NTDDI_VERSION >= NTDDI_WINBLUE) /* ABRACADABRA_THRESHOLD */ + GUID PartitionId; +#endif + +} PARTITION_INFORMATION_MBR, *PPARTITION_INFORMATION_MBR; +typedef struct _PARTITION_INFORMATION_GPT { + + GUID PartitionType; // Partition type. See table 16-3. + + GUID PartitionId; // Unique GUID for this partition. + + DWORD64 Attributes; // See table 16-4. + + WCHAR Name[36]; // Partition Name in Unicode. + +} PARTITION_INFORMATION_GPT, *PPARTITION_INFORMATION_GPT; +typedef struct _PARTITION_INFORMATION_EX { + + PARTITION_STYLE PartitionStyle; + + LARGE_INTEGER StartingOffset; + + LARGE_INTEGER PartitionLength; + + DWORD PartitionNumber; + + BOOLEAN RewritePartition; + +#if (NTDDI_VERSION >= NTDDI_WIN10_RS3) /* ABRACADABRA_WIN10_RS3 */ + BOOLEAN IsServicePartition; +#endif + + union { + + PARTITION_INFORMATION_MBR Mbr; + + PARTITION_INFORMATION_GPT Gpt; + }; + +} PARTITION_INFORMATION_EX, *PPARTITION_INFORMATION_EX; +typedef struct _DRIVE_LAYOUT_INFORMATION_GPT { + + GUID DiskId; + + LARGE_INTEGER StartingUsableOffset; + + LARGE_INTEGER UsableLength; + + DWORD MaxPartitionCount; + +} DRIVE_LAYOUT_INFORMATION_GPT, *PDRIVE_LAYOUT_INFORMATION_GPT; + +typedef struct _DRIVE_LAYOUT_INFORMATION_MBR { + + DWORD Signature; + +#if (NTDDI_VERSION >= NTDDI_WIN10_RS1) /* ABRACADABRA_WIN10_RS1 */ + DWORD CheckSum; +#endif + +} DRIVE_LAYOUT_INFORMATION_MBR, *PDRIVE_LAYOUT_INFORMATION_MBR; +typedef struct _DRIVE_LAYOUT_INFORMATION_EX { + + DWORD PartitionStyle; + + DWORD PartitionCount; + + union { + + DRIVE_LAYOUT_INFORMATION_MBR Mbr; + + DRIVE_LAYOUT_INFORMATION_GPT Gpt; + }; + + PARTITION_INFORMATION_EX PartitionEntry[1]; + +} DRIVE_LAYOUT_INFORMATION_EX, *PDRIVE_LAYOUT_INFORMATION_EX; +typedef struct _DISK_EXTENT { + + // + // Specifies the storage device number of + // the disk on which this extent resides. + // + DWORD DiskNumber; + + // + // Specifies the offset and length of this + // extent relative to the beginning of the + // disk. + // + LARGE_INTEGER StartingOffset; + LARGE_INTEGER ExtentLength; + +} DISK_EXTENT, *PDISK_EXTENT; +typedef struct _VOLUME_DISK_EXTENTS { + + // + // Specifies one or more contiguous range + // of sectors that make up this volume. + // + DWORD NumberOfDiskExtents; + DISK_EXTENT Extents[ANYSIZE_ARRAY]; + +} VOLUME_DISK_EXTENTS, *PVOLUME_DISK_EXTENTS; +#endif +typedef struct RETRIEVAL_POINTERS_BUFFER { + + DWORD ExtentCount; + LARGE_INTEGER StartingVcn; + struct { + LARGE_INTEGER NextVcn; + LARGE_INTEGER Lcn; + } Extents[1]; + +} RETRIEVAL_POINTERS_BUFFER, *PRETRIEVAL_POINTERS_BUFFER; +#ifdef _MSC_VER +typedef struct _FILE_BASIC_INFORMATION { + LARGE_INTEGER CreationTime; + LARGE_INTEGER LastAccessTime; + LARGE_INTEGER LastWriteTime; + LARGE_INTEGER ChangeTime; + u32 FileAttributes; +} FILE_BASIC_INFORMATION, *PFILE_BASIC_INFORMATION; +typedef struct _FILE_NAME_INFORMATION { + u32 FileNameLength; + WCHAR FileName[1]; +} FILE_NAME_INFORMATION, *PFILE_NAME_INFORMATION; +typedef struct _FILE_DISPOSITION_INFORMATION { + u8 DoDeleteFile; +} FILE_DISPOSITION_INFORMATION, *PFILE_DISPOSITION_INFORMATION; +typedef enum _FILE_INFORMATION_CLASS2 { + FileDirectoryInformation2 = 1, + FileFullDirectoryInformation, // 2 + FileBothDirectoryInformation, // 3 + FileBasicInformation, // 4 + FileStandardInformation, // 5 + FileInternalInformation, // 6 + FileEaInformation, // 7 + FileAccessInformation, // 8 + FileNameInformation, // 9 + FileRenameInformation, // 10 + FileLinkInformation, // 11 + FileNamesInformation, // 12 + FileDispositionInformation, // 13 + FilePositionInformation, // 14 + FileFullEaInformation, // 15 + FileModeInformation, // 16 + FileAlignmentInformation, // 17 + FileAllInformation, // 18 + FileAllocationInformation, // 19 + FileEndOfFileInformation, // 20 + FileAlternateNameInformation, // 21 + FileStreamInformation, // 22 + FilePipeInformation, // 23 + FilePipeLocalInformation, // 24 + FilePipeRemoteInformation, // 25 + FileMailslotQueryInformation, // 26 + FileMailslotSetInformation, // 27 + FileCompressionInformation, // 28 + FileObjectIdInformation, // 29 + FileCompletionInformation, // 30 + FileMoveClusterInformation, // 31 + FileQuotaInformation, // 32 + FileReparsePointInformation, // 33 + FileNetworkOpenInformation, // 34 + FileAttributeTagInformation, // 35 + FileTrackingInformation, // 36 + FileIdBothDirectoryInformation, // 37 + FileIdFullDirectoryInformation, // 38 + FileValidDataLengthInformation, // 39 + FileShortNameInformation, // 40 + FileIoCompletionNotificationInformation, // 41 + FileIoStatusBlockRangeInformation, // 42 + FileIoPriorityHintInformation, // 43 + FileSfioReserveInformation, // 44 + FileSfioVolumeInformation, // 45 + FileHardLinkInformation, // 46 + FileProcessIdsUsingFileInformation, // 47 + FileNormalizedNameInformation, // 48 + FileNetworkPhysicalNameInformation, // 49 + FileIdGlobalTxDirectoryInformation, // 50 + FileIsRemoteDeviceInformation, // 51 + FileUnusedInformation, // 52 + FileNumaNodeInformation, // 53 + FileStandardLinkInformation, // 54 + FileRemoteProtocolInformation, // 55 + + // + // These are special versions of these operations (defined earlier) + // which can be used by kernel mode drivers only to bypass security + // access checks for Rename and HardLink operations. These operations + // are only recognized by the IOManager, a file system should never + // receive these. + // + + FileRenameInformationBypassAccessCheck, // 56 + FileLinkInformationBypassAccessCheck, // 57 + + // + // End of special information classes reserved for IOManager. + // + + FileVolumeNameInformation, // 58 + FileIdInformation, // 59 + FileIdExtdDirectoryInformation, // 60 + FileReplaceCompletionInformation, // 61 + FileHardLinkFullIdInformation, // 62 + FileIdExtdBothDirectoryInformation, // 63 + FileDispositionInformationEx, // 64 + FileRenameInformationEx, // 65 + FileRenameInformationExBypassAccessCheck, // 66 + FileDesiredStorageClassInformation, // 67 + FileStatInformation, // 68 + FileMemoryPartitionInformation, // 69 + FileStatLxInformation, // 70 + FileCaseSensitiveInformation, // 71 + FileLinkInformationEx, // 72 + FileLinkInformationExBypassAccessCheck, // 73 + FileStorageReserveIdInformation, // 74 + FileCaseSensitiveInformationForceAccessCheck, // 75 + FileKnownFolderInformation, // 76 + + FileMaximumInformation +} FILE_INFORMATION_CLASS, + *PFILE_INFORMATION_CLASS; +typedef enum _FSINFOCLASS { + FileFsVolumeInformation = 1, + FileFsLabelInformation = 2, + FileFsSizeInformation = 3, + FileFsDeviceInformation = 4, + FileFsAttributeInformation = 5, + FileFsControlInformation = 6, + FileFsFullSizeInformation = 7, + FileFsObjectIdInformation = 8, + FileFsDriverPathInformation = 9, + FileFsVolumeFlagsInformation = 10, + FileFsSectorSizeInformation = 11, + FileFsDataCopyInformation = 12, + FileFsMetadataSizeInformation = 13, + FileFsFullSizeInformationEx = 14, + FileFsGuidInformation, + FileFsMaximumInformation +} FS_INFORMATION_CLASS, + *PFS_INFORMATION_CLASS; +typedef struct _FILE_LINK_INFORMATION { +#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10_RS5) + union { + u8 ReplaceIfExists; // FileLinkInformation + u32 Flags; // FileLinkInformationEx + } DUMMYUNIONNAME; +#else + u8 ReplaceIfExists; +#endif + HANDLE RootDirectory; + u32 FileNameLength; + WCHAR FileName[1]; +} FILE_LINK_INFORMATION, *PFILE_LINK_INFORMATION; +typedef struct _FILE_ALLOCATION_INFORMATION { + LARGE_INTEGER AllocationSize; +} FILE_ALLOCATION_INFORMATION, *PFILE_ALLOCATION_INFORMATION; +typedef struct _FILE_END_OF_FILE_INFORMATION { + LARGE_INTEGER EndOfFile; +} FILE_END_OF_FILE_INFORMATION, *PFILE_END_OF_FILE_INFORMATION; +typedef struct _FILE_FULL_EA_INFORMATION { + u32 NextEntryOffset; + UCHAR Flags; + UCHAR EaNameLength; + USHORT EaValueLength; + CHAR EaName[1]; +} FILE_FULL_EA_INFORMATION, *PFILE_FULL_EA_INFORMATION; +typedef struct _FILE_NAMES_INFORMATION { + u32 NextEntryOffset; + u32 FileIndex; + u32 FileNameLength; + WCHAR FileName[1]; +} FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION; +typedef struct _FILE_INTERNAL_INFORMATION { + LARGE_INTEGER IndexNumber; +} FILE_INTERNAL_INFORMATION, *PFILE_INTERNAL_INFORMATION; +typedef struct _FILE_FS_VOLUME_INFORMATION { + LARGE_INTEGER VolumeCreationTime; + u32 VolumeSerialNumber; + u32 VolumeLabelLength; + u8 SupportsObjects; + WCHAR VolumeLabel[1]; +} FILE_FS_VOLUME_INFORMATION, *PFILE_FS_VOLUME_INFORMATION; +typedef struct _FILE_STREAM_INFORMATION { + u32 NextEntryOffset; + u32 StreamNameLength; + LARGE_INTEGER StreamSize; + LARGE_INTEGER StreamAllocationSize; + WCHAR StreamName[1]; +} FILE_STREAM_INFORMATION, *PFILE_STREAM_INFORMATION; +typedef struct _FILE_STANDARD_INFORMATION { + LARGE_INTEGER AllocationSize; + LARGE_INTEGER EndOfFile; + u32 NumberOfLinks; + u8 DeletePending; + u8 Directory; +} FILE_STANDARD_INFORMATION, *PFILE_STANDARD_INFORMATION; +typedef struct _FILE_EA_INFORMATION { + u32 EaSize; +} FILE_EA_INFORMATION, *PFILE_EA_INFORMATION; +typedef struct _FILE_ACCESS_INFORMATION { + ACCESS_MASK AccessFlags; +} FILE_ACCESS_INFORMATION, *PFILE_ACCESS_INFORMATION; +typedef struct _FILE_POSITION_INFORMATION { + LARGE_INTEGER CurrentByteOffset; +} FILE_POSITION_INFORMATION, *PFILE_POSITION_INFORMATION; +typedef struct _FILE_MODE_INFORMATION { + u32 Mode; +} FILE_MODE_INFORMATION, *PFILE_MODE_INFORMATION; +typedef struct _FILE_ALIGNMENT_INFORMATION { + u32 AlignmentRequirement; +} FILE_ALIGNMENT_INFORMATION, *PFILE_ALIGNMENT_INFORMATION; +typedef struct _FILE_ALL_INFORMATION { + FILE_BASIC_INFORMATION BasicInformation; + FILE_STANDARD_INFORMATION StandardInformation; + FILE_INTERNAL_INFORMATION InternalInformation; + FILE_EA_INFORMATION EaInformation; + FILE_ACCESS_INFORMATION AccessInformation; + FILE_POSITION_INFORMATION PositionInformation; + FILE_MODE_INFORMATION ModeInformation; + FILE_ALIGNMENT_INFORMATION AlignmentInformation; + FILE_NAME_INFORMATION NameInformation; +} FILE_ALL_INFORMATION, *PFILE_ALL_INFORMATION; +typedef struct _FILE_FS_ATTRIBUTE_INFORMATION { + u32 FileSystemAttributes; + s32 MaximumComponentNameLength; + u32 FileSystemNameLength; + WCHAR FileSystemName[1]; +} FILE_FS_ATTRIBUTE_INFORMATION, *PFILE_FS_ATTRIBUTE_INFORMATION; + + +#pragma endregion +NTSTATUS __stdcall NtFsControlFile(HANDLE FileHandle, HANDLE Event, + PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, + PIO_STATUS_BLOCK IoStatusBlock, + ULONG FsControlCode, PVOID InputBuffer, + ULONG InputBufferLength, PVOID OutputBuffer, + ULONG OutputBufferLength); +NTSTATUS __stdcall NtSetInformationFile( + HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation, + ULONG Length, FILE_INFORMATION_CLASS FileInformationClass); +NTSTATUS __stdcall NtQueryInformationFile( + HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FileInformation, + ULONG Length, FILE_INFORMATION_CLASS FileInformationClass); +NTSTATUS __stdcall NtQueryVolumeInformationFile( + HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, + ULONG Length, FS_INFORMATION_CLASS FsInformationClass); +BOOLEAN __stdcall RtlDosPathNameToNtPathName_U(PCWSTR DosName, PUNICODE_STRING NtName, + PCWSTR *PartName, + PRTL_RELATIVE_NAME_U RelativeName); +#endif #endif /* _WIMLIB_WIN32_COMMON_H */ diff --git a/include/wimlib/wof.h b/include/wimlib/wof.h index 6f5017be..9591be01 100644 --- a/include/wimlib/wof.h +++ b/include/wimlib/wof.h @@ -219,6 +219,9 @@ typedef struct _WIM_PROVIDER_UPDATE_OVERLAY_INPUT { * WOF, although they document the structures which must be passed into the * ioctls, which are often similar. */ +#ifdef _MSC_VER +#pragma pack(push, 4) +#endif struct wim_provider_rpdata { /* Set to 2. Uncertain meaning. */ le32 version; @@ -249,7 +252,9 @@ struct wim_provider_rpdata { /* Byte offset of the file's unnamed data stream in the WIM. */ le64 unnamed_data_stream_offset_in_wim; } __attribute__((packed)); - +#ifdef _MSC_VER +#pragma pack(pop) +#endif /* WIM-specific information about a WIM data source */ struct WimOverlay_dat_entry_1 { diff --git a/include/wimlib/xattr.h b/include/wimlib/xattr.h index 074fed9d..2fed6733 100644 --- a/include/wimlib/xattr.h +++ b/include/wimlib/xattr.h @@ -57,7 +57,7 @@ xattr_entry_size(const struct wim_xattr_entry *entry) static inline struct wim_xattr_entry * xattr_entry_next(const struct wim_xattr_entry *entry) { - return (void *)entry + xattr_entry_size(entry); + return POINTER_FIX()(void *) entry + xattr_entry_size(entry); } static inline bool @@ -80,6 +80,9 @@ valid_xattr_entry(const struct wim_xattr_entry *entry, size_t avail) * xattr support in both WIMGAPI and wimlib). Now we use TAG_XATTRS for both * Windows and Linux xattrs. */ +#ifdef _MSC_VER +#pragma pack(push, 4) +#endif struct wimlib_xattr_entry_old { /* length of xattr name in bytes, excluding a null terminator */ @@ -99,7 +102,9 @@ struct wimlib_xattr_entry_old { /* then zero-padded to a 4-byte boundary */ } __attribute__((aligned(4))); - +#ifdef _MSC_VER +#pragma pack(pop) +#endif static inline size_t old_xattr_entry_size(const struct wimlib_xattr_entry_old *entry) { @@ -116,7 +121,7 @@ old_xattr_entry_size(const struct wimlib_xattr_entry_old *entry) static inline struct wimlib_xattr_entry_old * old_xattr_entry_next(const struct wimlib_xattr_entry_old *entry) { - return (void *)entry + old_xattr_entry_size(entry); + return POINTER_FIX()(void *) entry + old_xattr_entry_size(entry); } static inline bool diff --git a/include/wimlib/xmlproc.h b/include/wimlib/xmlproc.h index c202d629..acf2c624 100644 --- a/include/wimlib/xmlproc.h +++ b/include/wimlib/xmlproc.h @@ -22,8 +22,8 @@ struct xml_node { }; /* Iterate through the children of an xml_node. Does nothing if passed NULL. */ -#define xml_node_for_each_child(parent, child) \ - if (parent) list_for_each_entry(child, &(parent)->children, sibling_link) +#define xml_node_for_each_child(parent, child,type) \ + if (parent) list_for_each_entry(child, &(parent)->children, sibling_link,type) static inline bool xml_node_is_element(const struct xml_node *node, const tchar *name) diff --git a/include/wimlib_tchar.h b/include/wimlib_tchar.h index 781f370c..8fd8f819 100644 --- a/include/wimlib_tchar.h +++ b/include/wimlib_tchar.h @@ -27,7 +27,11 @@ typedef wchar_t tchar; # define tstrcat wcscat # define tstrcpy wcscpy # define tprintf wprintf +#ifdef _MSC_VER +#define tsprintf wsprintfW +#else # define tsprintf swprintf +#endif # define tfprintf fwprintf # define tvfprintf vfwprintf # define tscanf swscanf @@ -50,7 +54,7 @@ typedef wchar_t tchar; # define tfputs fputws # define tfopen _wfopen # define topen _wopen -# define tstat _wstati64 +# define tstat _wstat # define tstrtol wcstol # define tstrtod wcstod # define tstrtoul wcstoul diff --git a/programs/imagex.c b/programs/imagex.c index 54e50bfc..395c2fbc 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -33,13 +33,93 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable:4996) +#include"msvc/unistd.h" +#define PACKAGE_VERSION "" +#define PACKAGE_BUGREPORT "" +#define alloca _alloca +#define gmtime_r(x, y) gmtime_s(y, x) +#define S_IFMT 00170000 +#define S_IFSOCK 0140000 +#define S_IFLNK 0120000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) +#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) +#ifndef LIBWIM_STATIC +#if defined _M_AMD64 +#ifdef _DEBUG +#pragma comment(lib, "../x64/Debug/libwim.lib") +#else +#pragma comment(lib, "../x64/Release/libwim.lib") +#endif +#elif defined _M_IX86 +#ifdef _DEBUG +#pragma comment(lib, "../x86/Debug/libwim.lib") +#else +#pragma comment(lib, "../x86/Release/libwim.lib") +#endif +#elif defined _M_ARM +#ifdef _DEBUG +#pragma comment(lib, "../ARM/Debug/libwim.lib") +#else +#pragma comment(lib, "../ARM/Release/libwim.lib") +#endif +#elif defined _M_ARM64 +#ifdef _DEBUG +#pragma comment(lib, "../ARM64/Debug/libwim.lib") +#else +#pragma comment(lib, "../ARM64/Release/libwim.lib") +#endif +#endif +#else +#if defined _M_AMD64 +#ifdef _DEBUG +#pragma comment(lib, "../x64/Debug Static/libwim.lib") +#else +#pragma comment(lib, "../x64/Release Static/libwim.lib") +#endif +#elif defined _M_IX86 +#ifdef _DEBUG +#pragma comment(lib, "../x86/Debug Static/libwim.lib") +#else +#pragma comment(lib, "../x86/Release Static/libwim.lib") +#endif +#elif defined _M_ARM +#ifdef _DEBUG +#pragma comment(lib, "../ARM/Debug Static/libwim.lib") +#else +#pragma comment(lib, "../ARM/Release Static/libwim.lib") +#endif +#elif defined _M_ARM64 +#ifdef _DEBUG +#pragma comment(lib, "../ARM64/Debug Static/libwim.lib") +#else +#pragma comment(lib, "../ARM64/Release Static/libwim.lib") +#endif +#endif +#endif +#else #include +#include +#endif #include #include #include #include #include -#include #include #ifdef HAVE_ALLOCA_H @@ -756,7 +836,7 @@ do_metadata_not_found_warning(const tchar *wimfile, static off_t file_get_size(const tchar *filename) { - struct stat st; + struct _stat st; if (tstat(filename, &st) == 0) return st.st_size; else @@ -942,7 +1022,7 @@ parse_source_list(tchar **source_list_contents_p, size_t source_list_nchars, /* Always allocate at least 1 slot, just in case the implementation of * calloc() returns NULL if 0 bytes are requested. */ - sources = calloc(nlines ?: 1, sizeof(*sources)); + sources = calloc(nlines ? nlines: 1, sizeof(*sources)); if (!sources) { imagex_error(T("out of memory")); return NULL; @@ -1518,7 +1598,7 @@ parse_update_command_file(tchar **cmd_file_contents_p, size_t cmd_file_nchars, /* Always allocate at least 1 slot, just in case the implementation of * calloc() returns NULL if 0 bytes are requested. */ - cmds = calloc(nlines ?: 1, sizeof(struct wimlib_update_command)); + cmds = calloc(nlines ? nlines: 1, sizeof(struct wimlib_update_command)); if (!cmds) { imagex_error(T("out of memory")); return NULL; @@ -1977,7 +2057,7 @@ imagex_capture_or_append(int argc, tchar **argv, int cmd) imagex_output_to_stderr(); set_fd_to_binary_mode(wim_fd); } else { - struct stat stbuf; + struct _stat stbuf; /* Check for 'wimappend --create' acting as wimcapture */ if (create && tstat(wimfile, &stbuf) != 0 && errno == ENOENT) { @@ -2795,7 +2875,7 @@ imagex_export(int argc, tchar **argv, int cmd) WIMStruct *dest_wim; int ret; int image; - struct stat stbuf; + struct _stat stbuf; bool wim_is_new; STRING_LIST(refglobs); unsigned num_threads = 0; @@ -3824,7 +3904,7 @@ imagex_optimize(int argc, tchar **argv, int cmd) if (old_size == -1) tputs(T("Unknown")); else - tprintf(T("%"PRIu64" KiB\n"), old_size >> 10); + tprintf(T("%"PRIu64" KiB\n"), ((unsigned long long)old_size) >> 10); ret = wimlib_overwrite(wim, write_flags, num_threads); if (ret) { @@ -3837,7 +3917,7 @@ imagex_optimize(int argc, tchar **argv, int cmd) if (new_size == -1) tputs(T("Unknown")); else - tprintf(T("%"PRIu64" KiB\n"), new_size >> 10); + tprintf(T("%"PRIu64" KiB\n"), ((unsigned long long)new_size) >> 10); tfputs(T("Space saved: "), stdout); if (new_size != -1 && old_size != -1) { diff --git a/programs/wgetopt.c b/programs/wgetopt.c index 47f34a5b..5a9c084a 100644 --- a/programs/wgetopt.c +++ b/programs/wgetopt.c @@ -23,7 +23,9 @@ #include "wgetopt.h" #include #include - +#ifdef _MSC_VER +#pragma warning(disable:4996) +#endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. diff --git a/programs/wimlib-imagex.vcxproj b/programs/wimlib-imagex.vcxproj new file mode 100644 index 00000000..84ee744f --- /dev/null +++ b/programs/wimlib-imagex.vcxproj @@ -0,0 +1,647 @@ + + + + + Debug Static + ARM + + + Debug Static + ARM64 + + + Debug Static + Win32 + + + Debug Static + x64 + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Release Static + ARM + + + Release Static + ARM64 + + + Release Static + Win32 + + + Release Static + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + 16.0 + Win32Proj + {2f969cab-005d-4c70-87fc-cb45e2fe22da} + wimlibimagex + 10.0 + + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + false + v143 + true + Unicode + + + Application + false + v143 + true + Unicode + + + Application + false + v143 + true + Unicode + + + Application + false + v143 + true + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;LIBWIM_STATIC;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;LIBWIM_STATIC;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + _DEBUG;_CONSOLE;LIBWIM_STATIC;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + _DEBUG;_CONSOLE;LIBWIM_STATIC;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + _DEBUG;_CONSOLE;LIBWIM_STATIC;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;LIBWIM_STATIC;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;LIBWIM_STATIC;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;LIBWIM_STATIC;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + $(SolutionDir)tools\windows-after-build-msvc.cmd "$(PlatformShortName)" "$(Configuration)" + + + + + + \ No newline at end of file diff --git a/src/blob_table.c b/src/blob_table.c index 38615503..dd2619f5 100644 --- a/src/blob_table.c +++ b/src/blob_table.c @@ -31,8 +31,11 @@ #include #include +#ifdef _MSC_VER +#include "msvc/unistd.h" /* for unlink() */ +#else #include /* for unlink() */ - +#endif #include "wimlib/assert.h" #include "wimlib/bitops.h" #include "wimlib/blob_table.h" @@ -325,7 +328,7 @@ enlarge_blob_table(struct blob_table *table) table->mask = new_capacity - 1; for (i = 0; i < old_capacity; i++) - hlist_for_each_entry_safe(blob, tmp, &old_array[i], hash_list) + hlist_for_each_entry_safe(blob, tmp, &old_array[i], hash_list,struct blob_descriptor) blob_table_insert_raw(table, blob); FREE(old_array); } @@ -359,7 +362,7 @@ lookup_blob(const struct blob_table *table, const u8 *hash) struct blob_descriptor *blob; i = load_size_t_unaligned(hash) & table->mask; - hlist_for_each_entry(blob, &table->array[i], hash_list) + hlist_for_each_entry(blob, &table->array[i], hash_list,struct blob_descriptor) if (hashes_equal(hash, blob->hash)) return blob; return NULL; @@ -377,7 +380,7 @@ for_blob_in_table(struct blob_table *table, for (size_t i = 0; i <= table->mask; i++) { hlist_for_each_entry_safe(blob, tmp, &table->array[i], - hash_list) + hash_list, struct blob_descriptor) { ret = visitor(blob, arg); if (ret) @@ -570,6 +573,9 @@ for_blob_in_table_sorted_by_sequential_order(struct blob_table *table, * Note: if the WIM file contains solid resource(s), then this structure is * sometimes overloaded to describe a "resource" rather than a "blob". See the * code for details. */ +#ifdef _MSC_VER +#pragma pack(push, 1) +#endif struct blob_descriptor_disk { /* Size, offset, and flags of the blob. */ @@ -586,7 +592,9 @@ struct blob_descriptor_disk { * zeroes if this blob is of zero length. */ u8 hash[SHA1_HASH_SIZE]; } __attribute__((packed)); - +#ifdef _MSC_VER +#pragma pack(pop) +#endif /* Given a nonempty run of consecutive blob descriptors with the SOLID flag set, * count how many specify resources (as opposed to blobs within those * resources). @@ -786,7 +794,7 @@ validate_resource(struct wim_resource_descriptor *rdesc) */ expected_next_offset = 0; out_of_order = false; - list_for_each_entry(blob, &rdesc->blob_list, rdesc_node) { + list_for_each_entry(blob, &rdesc->blob_list, rdesc_node,struct blob_descriptor) { if (blob->offset_in_res + blob->size < blob->size || blob->offset_in_res + blob->size > rdesc->uncompressed_size) goto invalid_due_to_overflow; @@ -809,7 +817,7 @@ validate_resource(struct wim_resource_descriptor *rdesc) return ret; expected_next_offset = 0; - list_for_each_entry(blob, &rdesc->blob_list, rdesc_node) { + list_for_each_entry(blob, &rdesc->blob_list, rdesc_node,struct blob_descriptor) { if (blob->offset_in_res >= expected_next_offset) expected_next_offset = blob->offset_in_res + blob->size; else @@ -1154,7 +1162,7 @@ write_blob_table_from_blob_list(struct list_head *blob_list, u64 logical_offset; table_size = 0; - list_for_each_entry(blob, blob_list, blob_table_list) { + list_for_each_entry(blob, blob_list, blob_table_list,struct blob_descriptor) { table_size += sizeof(struct blob_descriptor_disk); if (blob->out_reshdr.flags & WIM_RESHDR_FLAG_SOLID && @@ -1176,7 +1184,7 @@ write_blob_table_from_blob_list(struct list_head *blob_list, prev_res_offset_in_wim = ~0ULL; prev_uncompressed_size = 0; logical_offset = 0; - list_for_each_entry(blob, blob_list, blob_table_list) { + list_for_each_entry(blob, blob_list, blob_table_list,struct blob_descriptor) { if (blob->out_reshdr.flags & WIM_RESHDR_FLAG_SOLID) { struct wim_reshdr tmp_reshdr; @@ -1400,7 +1408,7 @@ wimlib_iterate_lookup_table(WIMStruct *wim, int flags, ret = do_iterate_blob(imd->metadata_blob, &ctx); if (ret) return ret; - image_for_each_unhashed_blob(blob, imd) { + image_for_each_unhashed_blob(blob, imd,struct blob_descriptor) { ret = do_iterate_blob(blob, &ctx); if (ret) return ret; diff --git a/src/decompress_common.c b/src/decompress_common.c index abdf4df4..f3178c11 100644 --- a/src/decompress_common.c +++ b/src/decompress_common.c @@ -263,7 +263,7 @@ make_huffman_decode_table(u16 decode_table[], unsigned num_syms, unsigned n = stores_per_loop; do { *(u16 *)entry_ptr = v; - entry_ptr += sizeof(v); + POINTER_FIX() entry_ptr += sizeof(v); } while (--n); } } diff --git a/src/dentry.c b/src/dentry.c index f20d7dff..1c2680cc 100644 --- a/src/dentry.c +++ b/src/dentry.c @@ -71,6 +71,9 @@ /* On-disk format of a WIM dentry (directory entry), located in the metadata * resource for a WIM image. */ +#ifdef _MSC_VER +#pragma pack(push,1) +#endif struct wim_dentry_on_disk { /* Length of this directory entry in bytes, not including any extra @@ -154,7 +157,6 @@ struct wim_dentry_on_disk { le64 hard_link_group_id; } __attribute__((packed)) nonreparse; }; - /* Number of extra stream entries that directly follow this dentry * on-disk. */ le16 num_extra_streams; @@ -222,6 +224,9 @@ struct wim_extra_stream_entry_on_disk { utf16lechar name[]; } __attribute__((packed)); +#ifdef _MSC_VER +#pragma pack(pop) +#endif static void do_dentry_set_name(struct wim_dentry *dentry, utf16lechar *name, size_t name_nbytes) @@ -488,7 +493,7 @@ calculate_dentry_full_path(struct wim_dentry *dentry) d = d->d_parent; /* assumes d == d->d_parent for root */ } while (!dentry_is_root(d)); - utf16lechar ubuf[ulen]; + smart_array(utf16lechar,ubuf,ulen); utf16lechar *p = &ubuf[ulen]; d = dentry; @@ -846,7 +851,7 @@ get_parent_dentry(WIMStruct *wim, const tchar *path, CASE_SENSITIVITY_TYPE case_type) { size_t path_len = tstrlen(path); - tchar buf[path_len + 1]; + smart_array(tchar, buf, path_len + 1); tmemcpy(buf, path, path_len + 1); to_parent_name(buf, path_len); diff --git a/src/divsufsort.c b/src/divsufsort.c index 81a13f97..5c02c094 100644 --- a/src/divsufsort.c +++ b/src/divsufsort.c @@ -261,11 +261,11 @@ ss_heapsort(const unsigned char *Td, const int *PA, int *SA, int size) { m = size; if((size % 2) == 0) { m--; - if(Td[PA[SA[m / 2]]] < Td[PA[SA[m]]]) { SWAP(SA[m], SA[m / 2]); } + if(Td[PA[SA[m / 2]]] < Td[PA[SA[m]]]) { SWAP(SA[m], SA[m / 2],int); } } for(i = m / 2 - 1; 0 <= i; --i) { ss_fixdown(Td, PA, SA, i, m); } - if((size % 2) == 0) { SWAP(SA[0], SA[m]); ss_fixdown(Td, PA, SA, 0, m); } + if((size % 2) == 0) { SWAP(SA[0], SA[m],int); ss_fixdown(Td, PA, SA, 0, m); } for(i = m - 1; 0 < i; --i) { t = SA[0], SA[0] = SA[i]; ss_fixdown(Td, PA, SA, 0, i); @@ -281,7 +281,7 @@ static forceinline int * ss_median3(const unsigned char *Td, const int *PA, int *v1, int *v2, int *v3) { - if(Td[PA[*v1]] > Td[PA[*v2]]) { SWAP(v1, v2); } + if(Td[PA[*v1]] > Td[PA[*v2]]) { SWAP(v1, v2,int*); } if(Td[PA[*v2]] > Td[PA[*v3]]) { if(Td[PA[*v1]] > Td[PA[*v3]]) { return v1; } else { return v3; } @@ -294,11 +294,11 @@ static forceinline int * ss_median5(const unsigned char *Td, const int *PA, int *v1, int *v2, int *v3, int *v4, int *v5) { - if(Td[PA[*v2]] > Td[PA[*v3]]) { SWAP(v2, v3); } - if(Td[PA[*v4]] > Td[PA[*v5]]) { SWAP(v4, v5); } - if(Td[PA[*v2]] > Td[PA[*v4]]) { SWAP(v2, v4); SWAP(v3, v5); } - if(Td[PA[*v1]] > Td[PA[*v3]]) { SWAP(v1, v3); } - if(Td[PA[*v1]] > Td[PA[*v4]]) { SWAP(v1, v4); SWAP(v3, v5); } + if(Td[PA[*v2]] > Td[PA[*v3]]) { SWAP(v2, v3,int*); } + if(Td[PA[*v4]] > Td[PA[*v5]]) { SWAP(v4, v5,int*); } + if(Td[PA[*v2]] > Td[PA[*v4]]) { SWAP(v2, v4,int*); SWAP(v3, v5,int*); } + if(Td[PA[*v1]] > Td[PA[*v3]]) { SWAP(v1, v3,int*); } + if(Td[PA[*v1]] > Td[PA[*v4]]) { SWAP(v1, v4,int*); SWAP(v3, v5,int*); } if(Td[PA[*v3]] > Td[PA[*v4]]) { return v4; } return v3; } @@ -409,28 +409,28 @@ ss_mintrosort(const unsigned char *T, const int *PA, /* choose pivot */ a = ss_pivot(Td, PA, first, last); v = Td[PA[*a]]; - SWAP(*first, *a); + SWAP(*first, *a,int); /* partition */ for(b = first; (++b < last) && ((x = Td[PA[*b]]) == v);) { } if(((a = b) < last) && (x < v)) { for(; (++b < last) && ((x = Td[PA[*b]]) <= v);) { - if(x == v) { SWAP(*b, *a); ++a; } + if(x == v) { SWAP(*b, *a,int); ++a; } } } for(c = last; (b < --c) && ((x = Td[PA[*c]]) == v);) { } if((b < (d = c)) && (x > v)) { for(; (b < --c) && ((x = Td[PA[*c]]) >= v);) { - if(x == v) { SWAP(*c, *d); --d; } + if(x == v) { SWAP(*c, *d,int); --d; } } } for(; b < c;) { - SWAP(*b, *c); + SWAP(*b, *c,int); for(; (++b < c) && ((x = Td[PA[*b]]) <= v);) { - if(x == v) { SWAP(*b, *a); ++a; } + if(x == v) { SWAP(*b, *a,int); ++a; } } for(; (b < --c) && ((x = Td[PA[*c]]) >= v);) { - if(x == v) { SWAP(*c, *d); --d; } + if(x == v) { SWAP(*c, *d,int); --d; } } } @@ -438,9 +438,9 @@ ss_mintrosort(const unsigned char *T, const int *PA, c = b - 1; if((s = a - first) > (t = b - a)) { s = t; } - for(e = first, f = b - s; 0 < s; --s, ++e, ++f) { SWAP(*e, *f); } + for(e = first, f = b - s; 0 < s; --s, ++e, ++f) { SWAP(*e, *f,int); } if((s = d - c) > (t = last - d - 1)) { s = t; } - for(e = b, f = last - s; 0 < s; --s, ++e, ++f) { SWAP(*e, *f); } + for(e = b, f = last - s; 0 < s; --s, ++e, ++f) { SWAP(*e, *f,int); } a = first + (b - a), c = last - (d - c); b = (v <= Td[PA[*a] - 1]) ? a : ss_partition(PA, a, c, depth); @@ -922,11 +922,11 @@ tr_heapsort(const int *ISAd, int *SA, int size) { m = size; if((size % 2) == 0) { m--; - if(ISAd[SA[m / 2]] < ISAd[SA[m]]) { SWAP(SA[m], SA[m / 2]); } + if(ISAd[SA[m / 2]] < ISAd[SA[m]]) { SWAP(SA[m], SA[m / 2],int); } } for(i = m / 2 - 1; 0 <= i; --i) { tr_fixdown(ISAd, SA, i, m); } - if((size % 2) == 0) { SWAP(SA[0], SA[m]); tr_fixdown(ISAd, SA, 0, m); } + if((size % 2) == 0) { SWAP(SA[0], SA[m],int); tr_fixdown(ISAd, SA, 0, m); } for(i = m - 1; 0 < i; --i) { t = SA[0], SA[0] = SA[i]; tr_fixdown(ISAd, SA, 0, i); @@ -941,7 +941,7 @@ tr_heapsort(const int *ISAd, int *SA, int size) { static forceinline int * tr_median3(const int *ISAd, int *v1, int *v2, int *v3) { - if(ISAd[*v1] > ISAd[*v2]) { SWAP(v1, v2); } + if(ISAd[*v1] > ISAd[*v2]) { SWAP(v1, v2,int*); } if(ISAd[*v2] > ISAd[*v3]) { if(ISAd[*v1] > ISAd[*v3]) { return v1; } else { return v3; } @@ -954,11 +954,11 @@ static forceinline int * tr_median5(const int *ISAd, int *v1, int *v2, int *v3, int *v4, int *v5) { - if(ISAd[*v2] > ISAd[*v3]) { SWAP(v2, v3); } - if(ISAd[*v4] > ISAd[*v5]) { SWAP(v4, v5); } - if(ISAd[*v2] > ISAd[*v4]) { SWAP(v2, v4); SWAP(v3, v5); } - if(ISAd[*v1] > ISAd[*v3]) { SWAP(v1, v3); } - if(ISAd[*v1] > ISAd[*v4]) { SWAP(v1, v4); SWAP(v3, v5); } + if(ISAd[*v2] > ISAd[*v3]) { SWAP(v2, v3,int*); } + if(ISAd[*v4] > ISAd[*v5]) { SWAP(v4, v5,int*); } + if(ISAd[*v2] > ISAd[*v4]) { SWAP(v2, v4,int*); SWAP(v3, v5,int*); } + if(ISAd[*v1] > ISAd[*v3]) { SWAP(v1, v3,int*); } + if(ISAd[*v1] > ISAd[*v4]) { SWAP(v1, v4,int*); SWAP(v3, v5,int*); } if(ISAd[*v3] > ISAd[*v4]) { return v4; } return v3; } @@ -1031,31 +1031,31 @@ tr_partition(const int *ISAd, for(b = middle - 1; (++b < last) && ((x = ISAd[*b]) == v);) { } if(((a = b) < last) && (x < v)) { for(; (++b < last) && ((x = ISAd[*b]) <= v);) { - if(x == v) { SWAP(*b, *a); ++a; } + if(x == v) { SWAP(*b, *a,int); ++a; } } } for(c = last; (b < --c) && ((x = ISAd[*c]) == v);) { } if((b < (d = c)) && (x > v)) { for(; (b < --c) && ((x = ISAd[*c]) >= v);) { - if(x == v) { SWAP(*c, *d); --d; } + if(x == v) { SWAP(*c, *d,int); --d; } } } for(; b < c;) { - SWAP(*b, *c); + SWAP(*b, *c,int); for(; (++b < c) && ((x = ISAd[*b]) <= v);) { - if(x == v) { SWAP(*b, *a); ++a; } + if(x == v) { SWAP(*b, *a,int); ++a; } } for(; (b < --c) && ((x = ISAd[*c]) >= v);) { - if(x == v) { SWAP(*c, *d); --d; } + if(x == v) { SWAP(*c, *d,int); --d; } } } if(a <= d) { c = b - 1; if((s = a - first) > (t = b - a)) { s = t; } - for(e = first, f = b - s; 0 < s; --s, ++e, ++f) { SWAP(*e, *f); } + for(e = first, f = b - s; 0 < s; --s, ++e, ++f) { SWAP(*e, *f,int); } if((s = d - c) > (t = last - d - 1)) { s = t; } - for(e = b, f = last - s; 0 < s; --s, ++e, ++f) { SWAP(*e, *f); } + for(e = b, f = last - s; 0 < s; --s, ++e, ++f) { SWAP(*e, *f,int); } first += (b - a), last -= (d - c); } *pa = first, *pb = last; @@ -1244,7 +1244,7 @@ tr_introsort(int *ISA, const int *ISAd, /* choose pivot */ a = tr_pivot(ISAd, first, last); - SWAP(*first, *a); + SWAP(*first, *a,int); v = ISAd[*first]; /* partition */ diff --git a/src/export_image.c b/src/export_image.c index 1dff266d..55f4a593 100644 --- a/src/export_image.c +++ b/src/export_image.c @@ -233,7 +233,7 @@ wimlib_export_image(WIMStruct *src_wim, /* Iterate through inodes in the source image and export their * blobs into the destination WIM. */ - image_for_each_inode(inode, src_imd) { + image_for_each_inode(inode, src_imd, struct wim_inode) { ret = inode_export_blobs(inode, src_wim->blob_table, dest_wim->blob_table, diff --git a/src/extract.c b/src/extract.c index 24b53cbe..00e769d7 100644 --- a/src/extract.c +++ b/src/extract.c @@ -43,8 +43,11 @@ #include #include #include +#ifdef _MSC_VER +#include "msvc/unistd.h" +#else #include - +#endif #include "wimlib/apply.h" #include "wimlib/assert.h" #include "wimlib/blob_table.h" @@ -188,19 +191,19 @@ bool detect_sparse_region(const void *data, size_t size, size_t *len_ret) { const void *p = data; - const void * const end = data + size; + const void * const end = POINTER_FIX()data + size; size_t len = 0; bool zeroes = false; while (p != end) { - size_t n = min(end - p, SPARSE_UNIT); + size_t n = min(POINTER_FIX()end - POINTER_FIX()p, SPARSE_UNIT); bool z = is_all_zeroes(p, n); if (len != 0 && z != zeroes) break; zeroes = z; len += n; - p += n; + POINTER_FIX()p += n; } *len_ret = len; @@ -782,7 +785,7 @@ destroy_dentry_list(struct list_head *dentry_list) struct wim_dentry *dentry, *tmp; struct wim_inode *inode; - list_for_each_entry_safe(dentry, tmp, dentry_list, d_extraction_list_node) { + list_for_each_entry_safe(dentry, tmp, dentry_list, d_extraction_list_node,struct wim_dentry) { inode = dentry->d_inode; dentry_reset_extraction_list_node(dentry); inode->i_visited = 0; @@ -799,7 +802,7 @@ destroy_blob_list(struct list_head *blob_list) { struct blob_descriptor *blob; - list_for_each_entry(blob, blob_list, extraction_list) + list_for_each_entry(blob, blob_list, extraction_list,struct blob_descriptor) if (blob->out_refcnt > ARRAY_LEN(blob->inline_blob_extraction_targets)) FREE(blob->blob_extraction_targets); } @@ -820,7 +823,38 @@ file_name_valid(utf16lechar *name, size_t num_chars, bool fix) for (i = 0; i < num_chars; i++) { switch (le16_to_cpu(name[i])) { #ifdef _WIN32 - case '\x01'...'\x1F': + + case '\x01': + case '\x02': + case '\x03': + case '\x04': + case '\x05': + case '\x06': + case '\x07': + case '\x08': + case '\x09': + case '\x0A': + case '\x0B': + case '\x0C': + case '\x0D': + case '\x0E': + case '\x0F': + case '\x10': + case '\x11': + case '\x12': + case '\x13': + case '\x14': + case '\x15': + case '\x16': + case '\x17': + case '\x18': + case '\x19': + case '\x1A': + case '\x1B': + case '\x1C': + case '\x1D': + case '\x1E': + case '\x1F': case '\\': case ':': case '*': @@ -911,7 +945,7 @@ dentry_calculate_extraction_name(struct wim_dentry *dentry, out_replace: { - utf16lechar utf16_name_copy[dentry->d_name_nbytes / 2]; + smart_array(utf16lechar,utf16_name_copy,dentry->d_name_nbytes / 2); memcpy(utf16_name_copy, dentry->d_name, dentry->d_name_nbytes); file_name_valid(utf16_name_copy, dentry->d_name_nbytes / 2, true); @@ -928,7 +962,7 @@ dentry_calculate_extraction_name(struct wim_dentry *dentry, tchar_nchars /= sizeof(tchar); size_t fixed_name_num_chars = tchar_nchars; - tchar fixed_name[tchar_nchars + 50]; + smart_array(tchar,fixed_name,tchar_nchars + 50); tmemcpy(fixed_name, tchar_name, tchar_nchars); fixed_name_num_chars += tsprintf(fixed_name + tchar_nchars, @@ -1033,7 +1067,7 @@ dentry_list_resolve_streams(struct list_head *dentry_list, struct wim_dentry *dentry; int ret; - list_for_each_entry(dentry, dentry_list, d_extraction_list_node) { + list_for_each_entry(dentry, dentry_list, d_extraction_list_node,struct wim_dentry) { ret = dentry_resolve_streams(dentry, ctx->extract_flags, ctx->wim->blob_table); @@ -1201,12 +1235,12 @@ dentry_list_ref_streams(struct list_head *dentry_list, struct apply_ctx *ctx) struct wim_dentry *dentry; int ret; - list_for_each_entry(dentry, dentry_list, d_extraction_list_node) { + list_for_each_entry(dentry, dentry_list, d_extraction_list_node,struct wim_dentry) { ret = dentry_ref_streams(dentry, ctx); if (ret) return ret; } - list_for_each_entry(dentry, dentry_list, d_extraction_list_node) + list_for_each_entry(dentry, dentry_list, d_extraction_list_node,struct wim_dentry) dentry->d_inode->i_visited = 0; return 0; } @@ -1216,10 +1250,10 @@ dentry_list_build_inode_alias_lists(struct list_head *dentry_list) { struct wim_dentry *dentry; - list_for_each_entry(dentry, dentry_list, d_extraction_list_node) + list_for_each_entry(dentry, dentry_list, d_extraction_list_node,struct wim_dentry) dentry->d_inode->i_first_extraction_alias = NULL; - list_for_each_entry(dentry, dentry_list, d_extraction_list_node) { + list_for_each_entry(dentry, dentry_list, d_extraction_list_node,struct wim_dentry) { dentry->d_next_extraction_alias = dentry->d_inode->i_first_extraction_alias; dentry->d_inode->i_first_extraction_alias = dentry; } @@ -1292,10 +1326,10 @@ dentry_list_get_features(struct list_head *dentry_list, { struct wim_dentry *dentry; - list_for_each_entry(dentry, dentry_list, d_extraction_list_node) + list_for_each_entry(dentry, dentry_list, d_extraction_list_node,struct wim_dentry) dentry_tally_features(dentry, features); - list_for_each_entry(dentry, dentry_list, d_extraction_list_node) + list_for_each_entry(dentry, dentry_list, d_extraction_list_node,struct wim_dentry) dentry->d_inode->i_visited = 0; } @@ -1895,7 +1929,7 @@ static int extract_all_images(WIMStruct *wim, const tchar *target, int extract_flags) { size_t output_path_len = tstrlen(target); - tchar buf[output_path_len + 1 + 128 + 1]; + smart_array(tchar,buf,output_path_len + 1 + 128 + 1); int ret; int image; const tchar *image_name; diff --git a/src/file_io.c b/src/file_io.c index 4cd71ec4..5b573eea 100644 --- a/src/file_io.c +++ b/src/file_io.c @@ -24,8 +24,12 @@ #endif #include -#include +#ifdef _MSC_VER +#include"msvc/unistd.h" +#else +#include +#endif #include "wimlib/error.h" #include "wimlib/file_io.h" #include "wimlib/util.h" @@ -61,7 +65,7 @@ full_read(struct filedes *fd, void *buf, size_t count) continue; return WIMLIB_ERR_READ; } - buf += ret; + POINTER_FIX()buf += ret; count -= ret; fd->offset += ret; } @@ -86,7 +90,7 @@ pipe_read(struct filedes *fd, void *buf, size_t count, off_t offset) /* Manually seek to the requested position. */ while (fd->offset != offset) { size_t bytes_to_read = min(offset - fd->offset, BUFFER_SIZE); - u8 dummy[bytes_to_read]; + smart_array(u8,dummy,bytes_to_read); ret = full_read(fd, dummy, bytes_to_read); if (ret) @@ -131,7 +135,7 @@ full_pread(struct filedes *fd, void *buf, size_t count, off_t offset) } return WIMLIB_ERR_READ; } - buf += ret; + POINTER_FIX() buf += ret; count -= ret; offset += ret; } @@ -159,7 +163,7 @@ full_write(struct filedes *fd, const void *buf, size_t count) continue; return WIMLIB_ERR_WRITE; } - buf += ret; + POINTER_FIX() buf += ret; count -= ret; fd->offset += ret; } @@ -185,7 +189,7 @@ full_pwrite(struct filedes *fd, const void *buf, size_t count, off_t offset) continue; return WIMLIB_ERR_WRITE; } - buf += ret; + POINTER_FIX() buf += ret; count -= ret; offset += ret; } diff --git a/src/header.c b/src/header.c index 1a476900..0bbe253a 100644 --- a/src/header.c +++ b/src/header.c @@ -28,8 +28,11 @@ #include #include #include +#ifdef _MSC_VER +#include "msvc/unistd.h" +#else #include - +#endif #include "wimlib.h" #include "wimlib/alloca.h" #include "wimlib/assert.h" @@ -62,7 +65,14 @@ int read_wim_header(WIMStruct *wim, struct wim_header *hdr) { + +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif struct wim_header_disk disk_hdr __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif struct filedes *in_fd = &wim->in_fd; const tchar *filename = wim->filename; int ret; @@ -170,9 +180,15 @@ int write_wim_header(const struct wim_header *hdr, struct filedes *out_fd, off_t offset) { +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif struct wim_header_disk disk_hdr __attribute__((aligned(8))); int ret; +#ifdef _MSC_VER +#pragma pack(pop) +#endif disk_hdr.magic = cpu_to_le64(hdr->magic); disk_hdr.hdr_size = cpu_to_le32(sizeof(struct wim_header_disk)); disk_hdr.wim_version = cpu_to_le32(hdr->wim_version); diff --git a/src/inode_fixup.c b/src/inode_fixup.c index f507c987..87fd06ad 100644 --- a/src/inode_fixup.c +++ b/src/inode_fixup.c @@ -73,7 +73,7 @@ inode_table_insert(struct wim_dentry *dentry, void *_params) /* Try adding this dentry to an existing inode. */ pos = hash_inode(table, d_inode->i_ino, 0); - hlist_for_each_entry(inode, &table->array[pos], i_hlist_node) { + hlist_for_each_entry(inode, &table->array[pos], i_hlist_node,struct wim_inode) { if (inode->i_ino != d_inode->i_ino) { continue; } @@ -141,7 +141,7 @@ reassign_inode_numbers(struct hlist_head *inode_list) struct wim_inode *inode; u64 cur_ino = 1; - hlist_for_each_entry(inode, inode_list, i_hlist_node) + hlist_for_each_entry(inode, inode_list, i_hlist_node, struct wim_inode) inode->i_ino = cur_ino++; } diff --git a/src/inode_table.c b/src/inode_table.c index f6842f8a..adad8b16 100644 --- a/src/inode_table.c +++ b/src/inode_table.c @@ -69,7 +69,7 @@ enlarge_inode_table(struct wim_inode_table *table) table->array = new_array; table->capacity = new_capacity; for (size_t i = 0; i < old_capacity; i++) { - hlist_for_each_entry_safe(inode, tmp, &old_array[i], i_hlist_node) { + hlist_for_each_entry_safe(inode, tmp, &old_array[i], i_hlist_node,struct wim_inode) { hlist_add_head(&inode->i_hlist_node, &new_array[hash_inode(table, inode->i_ino, inode->i_devno)]); @@ -128,7 +128,7 @@ inode_table_new_dentry(struct wim_inode_table *table, const tchar *name, } else { /* Hard link detection */ list = &table->array[hash_inode(table, ino, devno)]; - hlist_for_each_entry(inode, list, i_hlist_node) { + hlist_for_each_entry(inode, list, i_hlist_node,struct wim_inode) { if (inode->i_ino != ino || inode->i_devno != devno) continue; if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY) { @@ -174,18 +174,18 @@ inode_table_prepare_inode_list(struct wim_inode_table *table, u64 cur_ino = 1; /* Re-assign inode numbers in the existing list to avoid duplicates. */ - hlist_for_each_entry(inode, head, i_hlist_node) + hlist_for_each_entry(inode, head, i_hlist_node,struct wim_inode) inode->i_ino = cur_ino++; /* Assign inode numbers to the new inodes and move them to the image's * inode list. */ for (size_t i = 0; i < table->capacity; i++) { - hlist_for_each_entry_safe(inode, tmp, &table->array[i], i_hlist_node) { + hlist_for_each_entry_safe(inode, tmp, &table->array[i], i_hlist_node,struct wim_inode) { inode->i_ino = cur_ino++; hlist_add_head(&inode->i_hlist_node, head); } } - hlist_for_each_entry_safe(inode, tmp, &table->extra_inodes, i_hlist_node) { + hlist_for_each_entry_safe(inode, tmp, &table->extra_inodes, i_hlist_node,struct wim_inode) { inode->i_ino = cur_ino++; hlist_add_head(&inode->i_hlist_node, head); } diff --git a/src/integrity.c b/src/integrity.c index 47d3244b..2a63582d 100644 --- a/src/integrity.c +++ b/src/integrity.c @@ -47,6 +47,9 @@ #define INTEGRITY_MIN_CHUNK_SIZE 4096 #define INTEGRITY_MAX_CHUNK_SIZE 134217728 +#ifdef _MSC_VER +#pragma pack(push,1) +#endif struct integrity_table { u32 size; u32 num_entries; @@ -54,6 +57,9 @@ struct integrity_table { u8 sha1sums[][20]; } __attribute__((packed)); +#ifdef _MSC_VER +#pragma pack(pop) +#endif static int calculate_chunk_sha1(struct filedes *in_fd, size_t this_chunk_size, off_t offset, u8 sha1_md[]) diff --git a/src/libwim.vcxproj b/src/libwim.vcxproj new file mode 100644 index 00000000..59945b0d --- /dev/null +++ b/src/libwim.vcxproj @@ -0,0 +1,862 @@ + + + + + Debug Static + ARM + + + Debug Static + ARM64 + + + Debug Static + Win32 + + + Debug Static + x64 + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Release Static + ARM + + + Release Static + ARM64 + + + Release Static + Win32 + + + Release Static + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 16.0 + Win32Proj + {1218765a-b2f8-40fd-9bd6-7f5a769678cf} + libwim + 10.0 + + + + DynamicLibrary + true + v143 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + StaticLibrary + false + v143 + true + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + DynamicLibrary + true + v143 + Unicode + + + StaticLibrary + true + v143 + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + StaticLibrary + false + v143 + true + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + StaticLibrary + false + v143 + true + Unicode + + + DynamicLibrary + false + v143 + true + Unicode + + + StaticLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(ProjectDir)..\include;$(ExternalIncludePath) + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + + Level3 + WIN32;_DEBUG;LIBWIM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + false + + stdc17 + stdcpp17 + EnableFastChecks + false + MultiThreadedDebug + + + Windows + true + false + + + + + + + Level3 + WIN32;_DEBUG;LIBWIM_STATIC;_WINDOWS;%(PreprocessorDefinitions) + false + false + + + stdc17 + stdcpp17 + EnableFastChecks + false + MultiThreadedDebug + + + Windows + true + false + + + + + + + Level3 + true + true + false + WIN32;NDEBUG;LIBWIM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + Default + MultiThreaded + + + Windows + true + true + true + false + + + + + + + Level3 + true + true + false + WIN32;NDEBUG;LIBWIM_STATIC;_WINDOWS;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + Default + MultiThreaded + + + Windows + true + true + true + false + + + + + + + Level3 + false + _DEBUG;LIBWIM_EXPORTS;_WINDOWS;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + EnableFastChecks + MultiThreadedDebug + + + Windows + true + false + + + + + + + Level3 + false + _DEBUG;LIBWIM_STATIC;_WINDOWS;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + EnableFastChecks + MultiThreadedDebug + + + Windows + true + false + + + + + + + Level3 + false + _DEBUG;LIBWIM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + EnableFastChecks + MultiThreadedDebug + + + Windows + true + false + + + + + + + Level3 + false + _DEBUG;LIBWIM_STATIC;_WINDOWS;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + EnableFastChecks + MultiThreadedDebug + + + Windows + true + false + + + + + + + Level3 + false + _DEBUG;LIBWIM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + EnableFastChecks + MultiThreadedDebug + + + Windows + true + false + + + + + + + Level3 + false + _DEBUG;LIBWIM_STATIC;_WINDOWS;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + EnableFastChecks + MultiThreadedDebug + + + Windows + true + false + + + + + + + Level3 + true + true + false + NDEBUG;LIBWIM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + Default + MultiThreaded + + + Windows + true + true + true + false + + + + + + + Level3 + true + true + false + NDEBUG;LIBWIM_STATIC;_WINDOWS;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + Default + MultiThreaded + + + Windows + true + true + true + false + + + + + + + Level3 + true + true + false + NDEBUG;LIBWIM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + Default + MultiThreaded + + + Windows + true + true + true + false + + + + + + + Level3 + true + true + false + NDEBUG;LIBWIM_STATIC;_WINDOWS;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + Default + MultiThreaded + + + Windows + true + true + true + false + + + + + + + Level3 + true + true + false + NDEBUG;LIBWIM_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + Default + MultiThreaded + + + Windows + true + true + true + false + + + + + + + Level3 + true + true + false + NDEBUG;LIBWIM_STATIC;_WINDOWS;%(PreprocessorDefinitions) + false + NotUsing + + + false + stdc17 + stdcpp17 + Default + MultiThreaded + + + Windows + true + true + true + false + + + + + + + + \ No newline at end of file diff --git a/src/libwim.vcxproj.filters b/src/libwim.vcxproj.filters new file mode 100644 index 00000000..215d4fd7 --- /dev/null +++ b/src/libwim.vcxproj.filters @@ -0,0 +1,303 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {e182d838-1788-4e34-843f-c7fe9df170f4} + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/src/lzms_compress.c b/src/lzms_compress.c index e55a32b8..6dee6810 100644 --- a/src/lzms_compress.c +++ b/src/lzms_compress.c @@ -177,6 +177,9 @@ check_that_powers_fit_in_bitfield(void) /* A stripped-down version of the adaptive state in LZMS which excludes the * probability entries and Huffman codes */ +#ifdef _MSC_VER +#pragma pack(push, 64) +#endif struct lzms_adaptive_state { /* Recent offsets for LZ matches */ @@ -253,6 +256,9 @@ struct lzms_optimum_node { struct lzms_adaptive_state state; } __attribute__((aligned(64))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif /* The main compressor structure */ struct lzms_compressor { diff --git a/src/lzms_decompress.c b/src/lzms_decompress.c index c9b5c983..40fffd9a 100644 --- a/src/lzms_decompress.c +++ b/src/lzms_decompress.c @@ -721,7 +721,7 @@ lzms_decompress(const void * const restrict in, const size_t in_nbytes, { struct lzms_decompressor *d = _d; u8 *out_next = out; - u8 * const out_end = out + out_nbytes; + u8 * const out_end = POINTER_FIX()out + out_nbytes; struct lzms_range_decoder rd; struct lzms_input_bitstream is; @@ -742,8 +742,8 @@ lzms_decompress(const void * const restrict in, const size_t in_nbytes, u32 match_state = 0; u32 lz_state = 0; u32 delta_state = 0; - u32 lz_rep_states[LZMS_NUM_LZ_REP_DECISIONS] = {}; - u32 delta_rep_states[LZMS_NUM_DELTA_REP_DECISIONS] = {}; + u32 lz_rep_states[LZMS_NUM_LZ_REP_DECISIONS] = {EMPTY}; + u32 delta_rep_states[LZMS_NUM_DELTA_REP_DECISIONS] = {EMPTY}; /* * Requirements on the compressed data: diff --git a/src/lzx_compress.c b/src/lzx_compress.c index 02498bf5..e6c5df9e 100644 --- a/src/lzx_compress.c +++ b/src/lzx_compress.c @@ -260,6 +260,9 @@ struct lzx_block_split_stats { * since items cannot be written until all items for the block have been chosen * and the block's Huffman codes have been computed. */ +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif struct lzx_sequence { /* @@ -335,6 +338,9 @@ struct lzx_optimum_node { } __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif /* The cost model for near-optimal parsing */ struct lzx_costs { @@ -849,7 +855,7 @@ lzx_write_compressed_code(struct lzx_output_bitstream *os, u32 precode_freqs[LZX_PRECODE_NUM_SYMBOLS]; u8 precode_lens[LZX_PRECODE_NUM_SYMBOLS]; u32 precode_codewords[LZX_PRECODE_NUM_SYMBOLS]; - unsigned precode_items[num_lens]; + smart_array(unsigned,precode_items,num_lens); unsigned num_precode_items; unsigned precode_item; unsigned precode_sym; @@ -1313,10 +1319,16 @@ lzx_should_end_block(struct lzx_block_split_stats *stats) * This is represented as a 64-bit integer for efficiency. There are three * offsets of 21 bits each. Bit 64 is garbage. */ +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif struct lzx_lru_queue { u64 R; } __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif #define LZX_QUEUE_OFFSET_SHIFT 21 #define LZX_QUEUE_OFFSET_MASK (((u64)1 << LZX_QUEUE_OFFSET_SHIFT) - 1) @@ -1564,12 +1576,17 @@ lzx_find_min_cost_path(struct lzx_compressor * const restrict c, * 'struct lzx_optimum_node' both being 8 bytes in size and alignment. */ struct lzx_lru_queue queues[512]; + memset(queues, 0, sizeof(struct lzx_lru_queue) * 512); STATIC_ASSERT(ARRAY_LEN(queues) >= LZX_MAX_MATCH_LEN + 1); STATIC_ASSERT(sizeof(c->optimum_nodes[0]) == sizeof(queues[0])); -#define QUEUE(node) \ + #ifdef _MSC_VER + #define QUEUE(node) \ + (queues[(uintptr_t)(node) / sizeof(*(node)) % ARRAY_LEN(queues)]) + #else + #define QUEUE(node) \ (*(struct lzx_lru_queue *)((char *)queues + \ ((uintptr_t)(node) % (ARRAY_LEN(queues) * sizeof(queues[0]))))) - /*(queues[(uintptr_t)(node) / sizeof(*(node)) % ARRAY_LEN(queues)])*/ + #endif #if CONSIDER_GAP_MATCHES u32 matches_before_gap[ARRAY_LEN(queues)]; @@ -2395,7 +2412,7 @@ lzx_choose_match(struct lzx_compressor *c, unsigned length, u32 adjusted_offset, /* Update the recent offsets queue. */ if (adjusted_offset < LZX_NUM_RECENT_OFFSETS) { /* Repeat offset match. */ - swap(recent_offsets[0], recent_offsets[adjusted_offset]); + swap(recent_offsets[0], recent_offsets[adjusted_offset],u32); } else { /* Explicit offset match. */ diff --git a/src/lzx_decompress.c b/src/lzx_decompress.c index ba923fdd..0afed6f9 100644 --- a/src/lzx_decompress.c +++ b/src/lzx_decompress.c @@ -70,6 +70,9 @@ #define LZX_READ_LENS_MAX_OVERRUN 50 +#ifdef _MSC_VER +#pragma pack(push, DECODE_TABLE_ALIGNMENT) +#endif struct lzx_decompressor { DECODE_TABLE(maincode_decode_table, LZX_MAINCODE_MAX_NUM_SYMBOLS, @@ -117,6 +120,9 @@ struct lzx_decompressor { } __attribute__((aligned(DECODE_TABLE_ALIGNMENT))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif /* Read a Huffman-encoded symbol using the precode. */ static forceinline unsigned read_presym(const struct lzx_decompressor *d, struct input_bitstream *is) diff --git a/src/metadata_resource.c b/src/metadata_resource.c index 71d3d6d0..6126d60f 100644 --- a/src/metadata_resource.c +++ b/src/metadata_resource.c @@ -39,7 +39,7 @@ fix_security_ids(struct wim_image_metadata *imd, const u32 num_entries) struct wim_inode *inode; unsigned long invalid_count = 0; - image_for_each_inode(inode, imd) { + image_for_each_inode(inode, imd,struct wim_inode) { if ((u32)inode->i_security_id >= num_entries) { if (inode->i_security_id >= 0) invalid_count++; diff --git a/src/registry.c b/src/registry.c index 5672e707..3a3e3611 100644 --- a/src/registry.c +++ b/src/registry.c @@ -34,6 +34,9 @@ #include "wimlib/util.h" /* Registry hive file header */ +#ifdef _MSC_VER +#pragma pack(push, 1) +#endif struct regf { #define REGF_MAGIC cpu_to_le32(0x66676572) /* "regf" */ le32 magic; @@ -107,6 +110,9 @@ struct value_list { le32 vk_offsets[0]; } __attribute__((packed)); +#ifdef _MSC_VER +#pragma pack(pop) +#endif /* VK cell - contains a value's data, or a reference to it */ struct vk { #define VK_MAGIC cpu_to_le16(0x6B76) diff --git a/src/resource.c b/src/resource.c index a2aee42d..5c15d877 100644 --- a/src/resource.c +++ b/src/resource.c @@ -27,7 +27,11 @@ #include #include +#ifdef _MSC_VER +#include "msvc/unistd.h" +#else #include +#endif #include "wimlib/alloca.h" #include "wimlib/assert.h" @@ -1384,7 +1388,7 @@ int sha1_blob(struct blob_descriptor *blob) { static const struct read_blob_callbacks cbs = { - }; + EMPTY}; return read_blob_with_sha1(blob, &cbs, false); } diff --git a/src/security.c b/src/security.c index 617abfbd..1dc93811 100644 --- a/src/security.c +++ b/src/security.c @@ -33,12 +33,18 @@ #include "wimlib/sha1.h" #include "wimlib/util.h" +#ifdef _MSC_VER +#pragma pack(push, 1) +#endif struct wim_security_data_disk { le32 total_length; le32 num_entries; le64 sizes[]; } __attribute__((packed)); +#ifdef _MSC_VER +#pragma pack(pop) +#endif struct wim_security_data * new_wim_security_data(void) { diff --git a/src/sha1.c b/src/sha1.c index fbbfdc18..bfdbd28a 100644 --- a/src/sha1.c +++ b/src/sha1.c @@ -88,7 +88,7 @@ rol32(u32 v, int bits) #define SHA1_GENERIC_ROUND(i, a, b, c, d, e) \ FORCE_NOT_CACHED_IF_FEW_REGS(w); \ if ((i) < 16) \ - w[i] = get_unaligned_be32(data + ((i) * 4)); \ + w[i] = get_unaligned_be32(POINTER_FIX()data + ((i) * 4)); \ else \ w[(i) % 16] = rol32(w[((i) - 16) % 16] ^ \ w[((i) - 14) % 16] ^ \ @@ -132,7 +132,7 @@ sha1_blocks_generic(u32 h[5], const void *data, size_t num_blocks) h[2] += c; h[3] += d; h[4] += e; - data += SHA1_BLOCK_SIZE; + POINTER_FIX() data += SHA1_BLOCK_SIZE; } while (--num_blocks); } @@ -572,14 +572,14 @@ sha1_update(struct sha1_ctx *ctx, const void *data, size_t len) } memcpy(&ctx->buffer[buffered], data, remaining); sha1_blocks(ctx->h, ctx->buffer, 1); - data += remaining; + POINTER_FIX() data += remaining; len -= remaining; } blocks = len / SHA1_BLOCK_SIZE; if (blocks) { sha1_blocks(ctx->h, data, blocks); - data += blocks * SHA1_BLOCK_SIZE; + POINTER_FIX() data += blocks * SHA1_BLOCK_SIZE; len -= blocks * SHA1_BLOCK_SIZE; } diff --git a/src/solid.c b/src/solid.c index a6aef418..86418a4d 100644 --- a/src/solid.c +++ b/src/solid.c @@ -114,7 +114,7 @@ blob_set_solid_sort_name_from_inode(struct blob_descriptor *blob, return; /* If this file has multiple names, choose the shortest one. */ - inode_for_each_dentry(dentry, inode) { + inode_for_each_dentry(dentry, inode, struct wim_dentry) { if (dentry->d_name_nbytes < best_name_nbytes) { best_name = dentry->d_name; best_name_nbytes = dentry->d_name_nbytes; @@ -143,7 +143,7 @@ dentry_fill_in_solid_sort_names(struct wim_dentry *dentry, void *_blob_table) return 0; head = &blob_table->table[load_size_t_unaligned(hash) % blob_table->capacity]; - hlist_for_each_entry(blob, head, hash_list_2) { + hlist_for_each_entry(blob, head, hash_list_2, struct blob_descriptor) { if (hashes_equal(hash, blob->hash)) { blob_set_solid_sort_name_from_inode(blob, inode); break; @@ -171,7 +171,7 @@ sort_blob_list_for_solid_compression(struct list_head *blob_list) int ret; /* Count the number of blobs to be written. */ - list_for_each_entry(blob, blob_list, write_blobs_list) + list_for_each_entry(blob, blob_list, write_blobs_list,struct blob_descriptor) num_blobs++; /* Allocate a temporary hash table for mapping blob hash => blob */ @@ -187,7 +187,7 @@ sort_blob_list_for_solid_compression(struct list_head *blob_list) * - If it's in non-solid WIM resource, then save the WIMStruct. * - If it's in a file on disk, then set its sort name from that. */ - list_for_each_entry(blob, blob_list, write_blobs_list) { + list_for_each_entry(blob, blob_list, write_blobs_list,struct blob_descriptor) { blob->solid_sort_name = NULL; blob->solid_sort_name_nbytes = 0; switch (blob->blob_location) { @@ -235,7 +235,7 @@ sort_blob_list_for_solid_compression(struct list_head *blob_list) cmp_blobs_by_solid_sort_name); out: - list_for_each_entry(blob, blob_list, write_blobs_list) + list_for_each_entry(blob, blob_list, write_blobs_list,struct blob_descriptor) FREE(blob->solid_sort_name); FREE(blob_table.table); return ret; diff --git a/src/tagged_items.c b/src/tagged_items.c index dee06517..42e7c807 100644 --- a/src/tagged_items.c +++ b/src/tagged_items.c @@ -36,6 +36,9 @@ * Header that begins each tagged metadata item associated with a file in a WIM * metadata resource */ +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif struct tagged_item_header { /* identifies the type of metadata item (see TAG_* constants) */ @@ -50,6 +53,9 @@ struct tagged_item_header { /* then zero-padded to an 8-byte boundary */ } __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif /* * Retrieve from @inode the first metadata item that is tagged with @tag and * contains at least @min_len bytes of data. If found, return a pointer to the diff --git a/src/template.c b/src/template.c index 2cface66..ad83c141 100644 --- a/src/template.c +++ b/src/template.c @@ -180,7 +180,7 @@ wimlib_reference_template_image(WIMStruct *wim, int new_image, if (ret) return ret; - image_for_each_inode(inode, new_imd) { + image_for_each_inode(inode, new_imd, struct wim_inode) { ret = reference_template_file(inode, wim, template_wim); if (ret) return ret; diff --git a/src/textfile.c b/src/textfile.c index d41464cd..904d577a 100644 --- a/src/textfile.c +++ b/src/textfile.c @@ -28,7 +28,11 @@ #include #include #include +#ifdef _MSC_VER +#include "msvc/unistd.h" +#else #include +#endif #include "wimlib/encoding.h" #include "wimlib/error.h" diff --git a/src/threads.c b/src/threads.c index 1b1028a0..c95ea762 100644 --- a/src/threads.c +++ b/src/threads.c @@ -38,7 +38,7 @@ #ifdef _WIN32 -static WINAPI DWORD +static DWORD WINAPI win32_thrproc(LPVOID lpParameter) { struct thread *t = (struct thread *)lpParameter; diff --git a/src/util.c b/src/util.c index 52af147d..887506c0 100644 --- a/src/util.c +++ b/src/util.c @@ -36,7 +36,11 @@ #ifdef HAVE_SYS_SYSCALL_H # include #endif +#ifdef _MSC_VER +#include "msvc/unistd.h" +#else #include +#endif #include "wimlib.h" #include "wimlib/assert.h" @@ -162,7 +166,7 @@ wimlib_set_memory_allocator(void *(*malloc_func)(size_t), #ifndef HAVE_MEMPCPY void *mempcpy(void *dst, const void *src, size_t n) { - return memcpy(dst, src, n) + n; + return POINTER_FIX()memcpy(dst, src, n) + n; } #endif diff --git a/src/verify.c b/src/verify.c index 00da3970..223150e2 100644 --- a/src/verify.c +++ b/src/verify.c @@ -80,7 +80,7 @@ verify_file_data_present(struct wim_image_metadata *imd, struct wim_inode *inode; int ret; - image_for_each_inode(inode, imd) { + image_for_each_inode(inode, imd, struct wim_inode) { ret = inode_resolve_streams(inode, blob_table, false); if (ret) return ret; @@ -153,7 +153,7 @@ wimlib_verify_wim(WIMStruct *wim, int verify_flags) memset(&progress, 0, sizeof(progress)); progress.verify_streams.wimfile = wim->filename; - list_for_each_entry(blob, &blob_list, extraction_list) { + list_for_each_entry(blob, &blob_list, extraction_list, struct blob_descriptor) { progress.verify_streams.total_streams++; progress.verify_streams.total_bytes += blob->size; } diff --git a/src/wim.c b/src/wim.c index 3a2a216a..969641b2 100644 --- a/src/wim.c +++ b/src/wim.c @@ -27,7 +27,11 @@ #include #include #include +#ifdef _MSC_VER +#include "msvc/unistd.h" +#else #include +#endif #include "wimlib.h" #include "wimlib/assert.h" @@ -221,7 +225,7 @@ put_image_metadata(struct wim_image_metadata *imd) return; wimlib_assert(imd->selected_refcnt == 0); unload_image_metadata(imd); - list_for_each_entry_safe(blob, tmp, &imd->unhashed_blobs, unhashed_list) + list_for_each_entry_safe(blob, tmp, &imd->unhashed_blobs, unhashed_list, struct blob_descriptor) free_blob_descriptor(blob); free_blob_descriptor(imd->metadata_blob); FREE(imd); @@ -848,7 +852,7 @@ wim_checksum_unhashed_blobs(WIMStruct *wim) for (int i = 0; i < wim->hdr.image_count; i++) { struct blob_descriptor *blob, *tmp; struct wim_image_metadata *imd = wim->image_metadata[i]; - image_for_each_unhashed_blob_safe(blob, tmp, imd) { + image_for_each_unhashed_blob_safe(blob, tmp, imd, struct blob_descriptor) { struct blob_descriptor *new_blob; ret = hash_unhashed_blob(blob, wim->blob_table, &new_blob); if (ret) diff --git a/src/win32_apply.c b/src/win32_apply.c index e493ecfe..7d45805d 100644 --- a/src/win32_apply.c +++ b/src/win32_apply.c @@ -733,7 +733,7 @@ start_wimboot_extraction(struct list_head *dentry_list, struct win32_apply_ctx * " means it is not intended to be used to back a Windows operating\n" " system. Proceeding anyway."); - list_for_each_entry(dentry, dentry_list, d_extraction_list_node) { + list_for_each_entry(dentry, dentry_list, d_extraction_list_node, struct wim_dentry) { struct blob_descriptor *blob; ret = win32_will_back_from_wim(dentry, &ctx->common); @@ -906,7 +906,7 @@ compute_path_max(struct list_head *dentry_list) size_t max = 0; const struct wim_dentry *dentry; - list_for_each_entry(dentry, dentry_list, d_extraction_list_node) { + list_for_each_entry(dentry, dentry_list, d_extraction_list_node, struct wim_dentry) { size_t len; len = dentry_extraction_path_length(dentry); @@ -1242,9 +1242,14 @@ remove_conflicting_short_name(const struct wim_dentry *dentry, struct win32_appl wchar_t *end; NTSTATUS status; HANDLE h; - size_t bufsize = offsetof(FILE_NAME_INFORMATION, FileName) + - (13 * sizeof(wchar_t)); - u8 buf[bufsize] __attribute__((aligned(8))); + size_t bufsize = offsetof(FILE_NAME_INFORMATION, FileName) + (13 * sizeof(wchar_t)); +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif + smart_array(u8, buf, bufsize) __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif bool retried = false; FILE_NAME_INFORMATION *info = (FILE_NAME_INFORMATION *)buf; @@ -1326,7 +1331,13 @@ set_short_name(HANDLE h, const struct wim_dentry *dentry, size_t bufsize = offsetof(FILE_NAME_INFORMATION, FileName) + max(dentry->d_short_name_nbytes, sizeof(wchar_t)) + sizeof(wchar_t); - u8 buf[bufsize] __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif + smart_array(u8, buf, bufsize) __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif FILE_NAME_INFORMATION *info = (FILE_NAME_INFORMATION *)buf; NTSTATUS status; bool tried_to_remove_existing = false; @@ -1632,9 +1643,14 @@ create_empty_streams(const struct wim_dentry *dentry, continue; if (strm->stream_type == STREAM_TYPE_REPARSE_POINT && - ctx->common.supported_features.reparse_points) - { + ctx->common.supported_features.reparse_points) { +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif u8 buf[REPARSE_DATA_OFFSET] __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif struct reparse_buffer_disk *rpbuf = (struct reparse_buffer_disk *)buf; complete_reparse_point(rpbuf, inode, 0); @@ -1760,7 +1776,7 @@ create_directories(struct list_head *dentry_list, const struct wim_dentry *dentry; int ret; - list_for_each_entry(dentry, dentry_list, d_extraction_list_node) { + list_for_each_entry(dentry, dentry_list, d_extraction_list_node, struct wim_dentry) { if (!(dentry->d_inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY)) continue; @@ -1843,7 +1859,13 @@ create_link(HANDLE h, const struct wim_dentry *dentry, size_t bufsize = offsetof(FILE_LINK_INFORMATION, FileName) + ctx->pathbuf.Length + sizeof(wchar_t); - u8 buf[bufsize] __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif + smart_array(u8, buf, bufsize) __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif FILE_LINK_INFORMATION *info = (FILE_LINK_INFORMATION *)buf; NTSTATUS status; @@ -1952,7 +1974,7 @@ create_nondirectories(struct list_head *dentry_list, struct win32_apply_ctx *ctx struct wim_inode *inode; int ret; - list_for_each_entry(dentry, dentry_list, d_extraction_list_node) { + list_for_each_entry(dentry, dentry_list, d_extraction_list_node, struct wim_dentry) { inode = dentry->d_inode; if (inode->i_attributes & FILE_ATTRIBUTE_DIRECTORY) continue; @@ -2205,7 +2227,7 @@ try_rpfix(struct reparse_buffer_disk *rpbuf, u16 *rpbuflen_p, fixed_subst_name_nchars = target_ntpath_nchars + relpath_nchars; - wchar_t fixed_subst_name[fixed_subst_name_nchars]; + smart_array(wchar_t,fixed_subst_name,fixed_subst_name_nchars); wmemcpy(fixed_subst_name, ctx->target_ntpath.Buffer, target_ntpath_nchars); wmemcpy(&fixed_subst_name[target_ntpath_nchars], relpath, relpath_nchars); @@ -2370,18 +2392,18 @@ win32_begin_extract_blob(struct blob_descriptor *blob, void *_ctx) static int pwrite_to_handle(HANDLE h, const void *data, size_t size, u64 offset) { - const void * const end = data + size; + const void * const end = POINTER_FIX()data + size; const void *p; IO_STATUS_BLOCK iosb; NTSTATUS status; - for (p = data; p != end; p += iosb.Information, + for (p = data; p != end; POINTER_FIX()p += iosb.Information, offset += iosb.Information) { LARGE_INTEGER offs = { .QuadPart = offset }; status = NtWriteFile(h, NULL, NULL, NULL, &iosb, - (void *)p, min(INT32_MAX, end - p), + (void *)p, min(INT32_MAX, POINTER_FIX()end - POINTER_FIX()p), &offs, NULL); if (!NT_SUCCESS(status)) { winnt_error(status, @@ -2398,7 +2420,7 @@ win32_extract_chunk(const struct blob_descriptor *blob, u64 offset, const void *chunk, size_t size, void *_ctx) { struct win32_apply_ctx *ctx = _ctx; - const void * const end = chunk + size; + const void * const end = POINTER_FIX()chunk + size; const void *p; bool zeroes; size_t len; @@ -2409,8 +2431,8 @@ win32_extract_chunk(const struct blob_descriptor *blob, u64 offset, * For sparse streams, only write nonzero regions. This lets the * filesystem use holes to represent zero regions. */ - for (p = chunk; p != end; p += len, offset += len) { - zeroes = maybe_detect_sparse_region(p, end - p, &len, + for (p = chunk; p != end; POINTER_FIX()p += len, offset += len) { + zeroes = maybe_detect_sparse_region(p, POINTER_FIX()end - POINTER_FIX()p, &len, ctx->any_sparse_streams); for (i = 0; i < ctx->num_open_handles; i++) { if (!zeroes || !ctx->is_sparse_stream[i]) { @@ -2754,7 +2776,7 @@ win32_end_extract_blob(struct blob_descriptor *blob, int status, void *_ctx) /* Reparse data */ memcpy(ctx->rpbuf.rpdata, ctx->data_buffer, blob->size); - list_for_each_entry(dentry, &ctx->reparse_dentries, d_tmp_list) { + list_for_each_entry(dentry, &ctx->reparse_dentries, d_tmp_list, struct wim_dentry) { /* Reparse point header */ complete_reparse_point(&ctx->rpbuf, dentry->d_inode, @@ -2771,7 +2793,7 @@ win32_end_extract_blob(struct blob_descriptor *blob, int status, void *_ctx) if (!list_empty(&ctx->encrypted_dentries)) { ctx->encrypted_size = blob->size; - list_for_each_entry(dentry, &ctx->encrypted_dentries, d_tmp_list) { + list_for_each_entry(dentry, &ctx->encrypted_dentries, d_tmp_list, struct wim_dentry) { ret = extract_encrypted_file(dentry, ctx); ret = check_apply_error(dentry, ctx, ret); if (ret) @@ -2841,7 +2863,13 @@ set_xattrs(HANDLE h, const struct wim_inode *inode, struct win32_apply_ctx *ctx) u32 len; const struct wim_xattr_entry *entry; size_t bufsize = 0; +#ifdef _MSC_VER +#pragma pack(push, 4) +#endif u8 _buf[1024] __attribute__((aligned(4))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif u8 *buf = _buf; FILE_FULL_EA_INFORMATION *ea, *ea_prev; NTSTATUS status; @@ -2853,12 +2881,12 @@ set_xattrs(HANDLE h, const struct wim_inode *inode, struct win32_apply_ctx *ctx) entries = inode_get_xattrs(inode, &len); if (likely(entries == NULL || len == 0)) /* No extended attributes? */ return 0; - entries_end = entries + len; + entries_end = POINTER_FIX()entries + len; entry = entries; for (entry = entries; (void *)entry < entries_end; entry = xattr_entry_next(entry)) { - if (!valid_xattr_entry(entry, entries_end - (void *)entry)) { + if (!valid_xattr_entry(entry, POINTER_FIX()entries_end - POINTER_FIX()(void *)entry)) { ERROR("\"%"TS"\": extended attribute is corrupt or unsupported", inode_any_full_path(inode)); return WIMLIB_ERR_INVALID_XATTR; @@ -3198,7 +3226,7 @@ apply_metadata(struct list_head *dentry_list, struct win32_apply_ctx *ctx) /* We go in reverse so that metadata is set on all a directory's * children before the directory itself. This avoids any potential * problems with attributes, timestamps, or security descriptors. */ - list_for_each_entry_reverse(dentry, dentry_list, d_extraction_list_node) + list_for_each_entry_reverse(dentry, dentry_list, d_extraction_list_node, struct wim_dentry) { ret = apply_metadata_to_file(dentry, ctx); ret = check_apply_error(dentry, ctx, ret); diff --git a/src/win32_capture.c b/src/win32_capture.c index 958147e6..495e1efd 100644 --- a/src/win32_capture.c +++ b/src/win32_capture.c @@ -27,7 +27,6 @@ # include "config.h" #endif -#include "wimlib/win32_common.h" #include "wimlib/assert.h" #include "wimlib/blob_table.h" @@ -43,6 +42,10 @@ #include "wimlib/wof.h" #include "wimlib/xattr.h" +#include "wimlib/win32_common.h" +#ifndef ERROR +#define ERROR(format, ...) wimlib_error(T(format), ##__VA_ARGS__) +#endif struct winnt_scan_ctx { struct scan_params *params; bool is_ntfs; @@ -330,7 +333,13 @@ read_winnt_stream_prefix(const struct windows_file *file, }; HANDLE h; NTSTATUS status; +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif u8 buf[BUFFER_SIZE] __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif u64 bytes_remaining; int ret; @@ -512,7 +521,13 @@ winnt_get_short_name(HANDLE h, struct wim_dentry *dentry) * course has to create its own handle. */ NTSTATUS status; IO_STATUS_BLOCK iosb; +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif u8 buf[128] __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif const FILE_NAME_INFORMATION *info; status = NtQueryInformationFile(h, &iosb, buf, sizeof(buf), @@ -537,7 +552,13 @@ winnt_load_security_descriptor(HANDLE h, struct wim_inode *inode, struct winnt_scan_ctx *ctx) { SECURITY_INFORMATION requestedInformation; +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif u8 _buf[4096] __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif u8 *buf; ULONG bufsize; ULONG len_needed; @@ -705,7 +726,13 @@ winnt_load_xattrs(HANDLE h, struct wim_inode *inode, { IO_STATUS_BLOCK iosb; NTSTATUS status; +#ifdef _MSC_VER +#pragma pack(push, 4) +#endif u8 _buf[1024] __attribute__((aligned(4))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif u8 *buf = _buf; const FILE_FULL_EA_INFORMATION *ea; struct wim_xattr_entry *entry; @@ -821,7 +848,7 @@ winnt_recurse_directory(HANDLE h, const size_t bufsize = 8192; IO_STATUS_BLOCK iosb; NTSTATUS status; - int ret; + int ret=0; buf = MALLOC(bufsize); if (!buf) @@ -1013,7 +1040,7 @@ winnt_rpfix_progress(struct scan_params *params, const struct link_reparse_point *link, int scan_status) { size_t print_name_nchars = link->print_name_nbytes / sizeof(wchar_t); - wchar_t print_name0[print_name_nchars + 1]; + smart_array(wchar_t,print_name0,print_name_nchars + 1); wmemcpy(print_name0, link->print_name, print_name_nchars); print_name0[print_name_nchars] = L'\0'; @@ -1089,13 +1116,13 @@ winnt_try_rpfix(struct reparse_buffer_disk *rpbuf, u16 *rpbuflen_p, link.substitute_name_nbytes - ((const u8 *)rel_target - (const u8 *)link.substitute_name); - wchar_t tmp[(sizeof(prefix) + rel_target_nbytes) / sizeof(wchar_t)]; + smart_array(wchar_t,tmp,(sizeof(prefix) + rel_target_nbytes) / sizeof(wchar_t)); memcpy(tmp, prefix, sizeof(prefix)); memcpy(tmp + ARRAY_LEN(prefix), rel_target, rel_target_nbytes); link.substitute_name = tmp; - link.substitute_name_nbytes = sizeof(tmp); + link.substitute_name_nbytes = (sizeof(prefix) + rel_target_nbytes); link.print_name = link.substitute_name + num_unprintable_chars; link.print_name_nbytes = link.substitute_name_nbytes - @@ -1331,7 +1358,13 @@ winnt_scan_data_streams(HANDLE h, struct wim_inode *inode, u64 file_size, struct winnt_scan_ctx *ctx) { int ret; +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif u8 _buf[4096] __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif u8 *buf; size_t bufsize; IO_STATUS_BLOCK iosb; @@ -1654,8 +1687,14 @@ get_file_info(HANDLE h, struct file_info *info) static void get_volume_information(HANDLE h, struct winnt_scan_ctx *ctx) { +#ifdef _MSC_VER +#pragma pack(push, 8) +#endif u8 _attr_info[sizeof(FILE_FS_ATTRIBUTE_INFORMATION) + 128] - __attribute__((aligned(8))); + __attribute__((aligned(8))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif FILE_FS_ATTRIBUTE_INFORMATION *attr_info = (void *)_attr_info; FILE_FS_VOLUME_INFORMATION vol_info; struct file_info file_info; @@ -2137,13 +2176,13 @@ struct ntfs_inode_map { #define NTFS_INODE(node) \ avl_tree_entry((node), struct ntfs_inode, index_node) -#define SKIP_ALIGNED(p, size) ((void *)(p) + ALIGN((size), 8)) +#define SKIP_ALIGNED(p, size) (void*)(POINTER_FIX()(void *)(p) + ALIGN((size), 8)) /* Get a pointer to the first dentry of the inode. */ #define FIRST_DENTRY(ni) SKIP_ALIGNED((ni), sizeof(struct ntfs_inode)) /* Get a pointer to the first stream of the inode. */ -#define FIRST_STREAM(ni) ((const void *)ni + ni->first_stream_offset) +#define FIRST_STREAM(ni) (const void*)(POINTER_FIX()(const void *)ni + ni->first_stream_offset) /* Advance to the next dentry of the inode. */ #define NEXT_DENTRY(nd) SKIP_ALIGNED((nd), sizeof(struct ntfs_dentry) + \ @@ -2227,7 +2266,7 @@ validate_names_and_compute_total_length(const FILE_LAYOUT_ENTRY *file, size_t *total_length_ret) { const FILE_LAYOUT_NAME_ENTRY *name = - (const void *)file + file->FirstNameOffset; + POINTER_FIX()(const void *)file + file->FirstNameOffset; size_t total = 0; size_t num_long_names = 0; @@ -2251,7 +2290,7 @@ validate_names_and_compute_total_length(const FILE_LAYOUT_ENTRY *file, } if (name->NextNameOffset == 0) break; - name = (const void *)name + name->NextNameOffset; + name = POINTER_FIX()(const void *) name + name->NextNameOffset; } if (unlikely(num_long_names == 0)) { @@ -2320,7 +2359,7 @@ validate_streams_and_compute_total_length(const FILE_LAYOUT_ENTRY *file, u32 *special_streams_ret) { const STREAM_LAYOUT_ENTRY *stream = - (const void *)file + file->FirstStreamOffset; + POINTER_FIX()(const void *) file + file->FirstStreamOffset; size_t total = 0; u32 special_streams = 0; @@ -2352,7 +2391,7 @@ validate_streams_and_compute_total_length(const FILE_LAYOUT_ENTRY *file, } if (stream->NextStreamOffset == 0) break; - stream = (const void *)stream + stream->NextStreamOffset; + stream = POINTER_FIX()(const void *)stream + stream->NextStreamOffset; } *total_length_ret = total; @@ -2365,7 +2404,7 @@ load_name_information(const FILE_LAYOUT_ENTRY *file, struct ntfs_inode *ni, void *p) { const FILE_LAYOUT_NAME_ENTRY *name = - (const void *)file + file->FirstNameOffset; + POINTER_FIX()(const void *) file + file->FirstNameOffset; for (;;) { struct ntfs_dentry *nd = p; /* Note that a name may be just a short (DOS) name, just a long @@ -2386,12 +2425,12 @@ load_name_information(const FILE_LAYOUT_ENTRY *file, struct ntfs_inode *ni, nd->parent_ino = name->ParentFileReferenceNumber; memcpy(nd->name, name->FileName, name->FileNameLength); nd->name[name->FileNameLength / 2] = L'\0'; - p += ALIGN(sizeof(struct ntfs_dentry) + + POINTER_FIX()p += ALIGN(sizeof(struct ntfs_dentry) + name->FileNameLength + sizeof(wchar_t), 8); } if (name->NextNameOffset == 0) break; - name = (const void *)name + name->NextNameOffset; + name = POINTER_FIX()(const void *)name + name->NextNameOffset; } return p; } @@ -2404,7 +2443,7 @@ load_starting_lcn(const STREAM_LAYOUT_ENTRY *stream) if (stream->ExtentInformationOffset == 0) return 0; - entry = (const void *)stream + stream->ExtentInformationOffset; + entry = POINTER_FIX()(const void *)stream + stream->ExtentInformationOffset; if (!(entry->Flags & STREAM_EXTENT_ENTRY_AS_RETRIEVAL_POINTERS)) return 0; @@ -2417,7 +2456,7 @@ load_stream_information(const FILE_LAYOUT_ENTRY *file, struct ntfs_inode *ni, void *p) { const STREAM_LAYOUT_ENTRY *stream = - (const void *)file + file->FirstStreamOffset; + POINTER_FIX()(const void *) file + file->FirstStreamOffset; const u32 first_stream_offset = (const u8 *)p - (const u8 *)ni; for (;;) { struct ntfs_stream *ns = p; @@ -2432,12 +2471,12 @@ load_stream_information(const FILE_LAYOUT_ENTRY *file, struct ntfs_inode *ni, ns->size = stream->EndOfFile; wmemcpy(ns->name, name, name_nchars); ns->name[name_nchars] = L'\0'; - p += ALIGN(sizeof(struct ntfs_stream) + + POINTER_FIX()p += ALIGN(sizeof(struct ntfs_stream) + (name_nchars + 1) * sizeof(wchar_t), 8); } if (stream->NextStreamOffset == 0) break; - stream = (const void *)stream + stream->NextStreamOffset; + stream = POINTER_FIX()(const void *)stream + stream->NextStreamOffset; } return p; } @@ -2447,7 +2486,7 @@ static int load_one_file(const FILE_LAYOUT_ENTRY *file, struct ntfs_inode_map *inode_map) { const FILE_LAYOUT_INFO_ENTRY *info = - (const void *)file + file->ExtraInfoOffset; + POINTER_FIX()(const void *)file + file->ExtraInfoOffset; size_t inode_size; struct ntfs_inode *ni; size_t n; @@ -2553,14 +2592,14 @@ load_files_from_mft(const wchar_t *path, struct ntfs_inode_map *inode_map) out, outsize, NULL))) { const FILE_LAYOUT_ENTRY *file = - (const void *)out + out->FirstFileOffset; + POINTER_FIX()(const void *)out + out->FirstFileOffset; for (;;) { ret = load_one_file(file, inode_map); if (ret) goto out; if (file->NextFileOffset == 0) break; - file = (const void *)file + file->NextFileOffset; + file = POINTER_FIX()(const void *)file + file->NextFileOffset; } in.Flags &= ~QUERY_FILE_LAYOUT_RESTART; } @@ -2895,7 +2934,7 @@ generate_wim_structures_recursive(struct wim_dentry **root_ret, &child, nd->name, nd->is_primary, - (void *)nd - nd->offset_from_inode, + POINTER_FIX()(void *)nd - nd->offset_from_inode, ctx, inode_map, security_map); diff --git a/src/win32_common.c b/src/win32_common.c index 408650b0..b846ace4 100644 --- a/src/win32_common.c +++ b/src/win32_common.c @@ -31,7 +31,6 @@ #include "wimlib/error.h" #include "wimlib/util.h" #include "wimlib/win32_vss.h" - static bool win32_modify_privilege(const wchar_t *privilege, bool enable) { diff --git a/src/win32_replacements.c b/src/win32_replacements.c index 5df6c78e..4d019679 100644 --- a/src/win32_replacements.c +++ b/src/win32_replacements.c @@ -501,7 +501,7 @@ do_pread_or_pwrite(int fd, void *buf, size_t count, off_t offset, memset(&overlapped, 0, sizeof(overlapped)); overlapped.Offset = offset; - overlapped.OffsetHigh = offset >> 32; + overlapped.OffsetHigh = (unsigned long long)offset >> 32; /* Do the read or write at the specified offset */ count = min(count, MAX_IO_AMOUNT); @@ -754,7 +754,7 @@ get_random_bytes(void *p, size_t n) wimlib_assert(0); count = 0; } - p += count; + POINTER_FIX()p += count; n -= count; } } diff --git a/src/win32_vss.c b/src/win32_vss.c index 6f5a28ea..a0837949 100644 --- a/src/win32_vss.c +++ b/src/win32_vss.c @@ -374,8 +374,7 @@ request_vss_snapshot(IVssBackupComponents *vss, wchar_t *volume, (u32)res); return false; } - - res = vss->vtable->AddToSnapshotSet(vss, volume, (GUID){}, snapshot_id); + res = vss->vtable->AddToSnapshotSet(vss, volume, (GUID){EMPTY}, snapshot_id); if (FAILED(res)) { ERROR("IVssBackupComponents.AddToSnapshotSet() error: %x", (u32)res); diff --git a/src/write.c b/src/write.c index 4bf1b2be..2249ed50 100644 --- a/src/write.c +++ b/src/write.c @@ -35,7 +35,11 @@ #include #include #include +#ifdef _MSC_VER +#include "msvc/unistd.h" +#else #include +#endif #include "wimlib/alloca.h" #include "wimlib/assert.h" @@ -226,7 +230,7 @@ can_raw_copy(const struct blob_descriptor *blob, int write_resource_flags, struct blob_descriptor *res_blob; u64 write_size = 0; - list_for_each_entry(res_blob, &rdesc->blob_list, rdesc_node) + list_for_each_entry(res_blob, &rdesc->blob_list, rdesc_node, struct blob_descriptor) if (res_blob->will_be_in_output_wim) write_size += res_blob->size; @@ -1125,7 +1129,7 @@ compute_blob_list_stats(struct list_head *blob_list, WIMStruct *prev_wim_part = NULL; const struct wim_resource_descriptor *prev_rdesc = NULL; - list_for_each_entry(blob, blob_list, write_blobs_list) { + list_for_each_entry(blob, blob_list, write_blobs_list, struct blob_descriptor) { num_blobs++; total_bytes += blob->size; if (blob->blob_location == BLOB_IN_WIM) { @@ -1177,11 +1181,11 @@ find_raw_copy_blobs(struct list_head *blob_list, int write_resource_flags, INIT_LIST_HEAD(raw_copy_blobs); /* Initialize temporary raw_copy_ok flag. */ - list_for_each_entry(blob, blob_list, write_blobs_list) + list_for_each_entry(blob, blob_list, write_blobs_list, struct blob_descriptor) if (blob->blob_location == BLOB_IN_WIM) blob->rdesc->raw_copy_ok = 0; - list_for_each_entry_safe(blob, tmp, blob_list, write_blobs_list) { + list_for_each_entry_safe(blob, tmp, blob_list, write_blobs_list, struct blob_descriptor) { if (can_raw_copy(blob, write_resource_flags, out_ctype, out_chunk_size)) { @@ -1262,7 +1266,7 @@ write_raw_copy_resource(struct wim_resource_descriptor *in_rdesc, return WIMLIB_ERR_WRITE; } - list_for_each_entry(blob, &in_rdesc->blob_list, rdesc_node) { + list_for_each_entry(blob, &in_rdesc->blob_list, rdesc_node, struct blob_descriptor) { if (blob->will_be_in_output_wim) { blob_set_out_reshdr_for_reuse(blob); if (in_rdesc->flags & WIM_RESHDR_FLAG_SOLID) @@ -1285,10 +1289,10 @@ write_raw_copy_resources(struct list_head *raw_copy_blobs, struct blob_descriptor *blob; int ret; - list_for_each_entry(blob, raw_copy_blobs, write_blobs_list) + list_for_each_entry(blob, raw_copy_blobs, write_blobs_list, struct blob_descriptor) blob->rdesc->raw_copy_ok = 1; - list_for_each_entry(blob, raw_copy_blobs, write_blobs_list) { + list_for_each_entry(blob, raw_copy_blobs, write_blobs_list, struct blob_descriptor) { u64 compressed_size = 0; if (blob->rdesc->raw_copy_ok) { @@ -1339,7 +1343,7 @@ validate_blob_list(struct list_head *blob_list) { struct blob_descriptor *blob; - list_for_each_entry(blob, blob_list, write_blobs_list) { + list_for_each_entry(blob, blob_list, write_blobs_list, struct blob_descriptor) { wimlib_assert(blob->will_be_in_output_wim); wimlib_assert(blob->size != 0); } @@ -1350,7 +1354,7 @@ init_done_with_file_info(struct list_head *blob_list) { struct blob_descriptor *blob; - list_for_each_entry(blob, blob_list, write_blobs_list) { + list_for_each_entry(blob, blob_list, write_blobs_list, struct blob_descriptor) { if (blob_is_in_file(blob)) { blob->file_inode->i_num_remaining_streams = 0; blob->may_send_done_with_file = 1; @@ -1359,7 +1363,7 @@ init_done_with_file_info(struct list_head *blob_list) } } - list_for_each_entry(blob, blob_list, write_blobs_list) + list_for_each_entry(blob, blob_list, write_blobs_list, struct blob_descriptor) if (blob->may_send_done_with_file) blob->file_inode->i_num_remaining_streams++; } @@ -1636,7 +1640,7 @@ write_blob_list(struct list_head *blob_list, goto out_destroy_context; offset_in_res = 0; - list_for_each_entry(blob, &ctx.blobs_in_solid_resource, write_blobs_list) { + list_for_each_entry(blob, &ctx.blobs_in_solid_resource, write_blobs_list, struct blob_descriptor) { blob->out_reshdr.size_in_wim = blob->size; blob->out_reshdr.flags = reshdr_flags_for_blob(blob) | WIM_RESHDR_FLAG_SOLID; @@ -1785,7 +1789,7 @@ blob_size_table_insert(struct blob_descriptor *blob, void *_tab) pos = hash_u64(blob->size) % tab->capacity; blob->unique_size = 1; - hlist_for_each_entry(same_size_blob, &tab->array[pos], hash_list_2) { + hlist_for_each_entry(same_size_blob, &tab->array[pos], hash_list_2, struct blob_descriptor) { if (same_size_blob->size == blob->size) { blob->unique_size = 0; same_size_blob->unique_size = 0; @@ -1867,11 +1871,11 @@ image_find_blobs_to_reference(WIMStruct *wim) imd = wim_get_current_image_metadata(wim); - image_for_each_unhashed_blob(blob, imd) + image_for_each_unhashed_blob(blob, imd, struct blob_descriptor) blob->will_be_in_output_wim = 0; blob_list = wim->private; - image_for_each_inode(inode, imd) { + image_for_each_inode(inode, imd, struct wim_inode) { ret = inode_find_blobs_to_reference(inode, wim->blob_table, blob_list); @@ -1906,7 +1910,7 @@ prepare_unfiltered_list_of_blobs_in_output_wim(WIMStruct *wim, for (i = 0; i < wim->hdr.image_count; i++) { imd = wim->image_metadata[i]; - image_for_each_unhashed_blob(blob, imd) + image_for_each_unhashed_blob(blob, imd, struct blob_descriptor) fully_reference_blob_for_write(blob, blob_list_ret); } } else { @@ -1960,7 +1964,7 @@ determine_blob_size_uniquity(struct list_head *blob_list, for_blob_in_table(lt, insert_other_if_hard_filtered, &ctx); } - list_for_each_entry(blob, blob_list, write_blobs_list) + list_for_each_entry(blob, blob_list, write_blobs_list, struct blob_descriptor) blob_size_table_insert(blob, &tab); destroy_blob_size_table(&tab); @@ -1973,7 +1977,7 @@ filter_blob_list_for_write(struct list_head *blob_list, { struct blob_descriptor *blob, *tmp; - list_for_each_entry_safe(blob, tmp, blob_list, write_blobs_list) { + list_for_each_entry_safe(blob, tmp, blob_list, write_blobs_list, struct blob_descriptor) { int status = blob_filtered(blob, filter_ctx); if (status == 0) { @@ -2079,7 +2083,7 @@ prepare_blob_list_for_write(WIMStruct *wim, int image, return ret; INIT_LIST_HEAD(blob_table_list_ret); - list_for_each_entry(blob, blob_list_ret, write_blobs_list) + list_for_each_entry(blob, blob_list_ret, write_blobs_list, struct blob_descriptor) list_add_tail(&blob->blob_table_list, blob_table_list_ret); ret = determine_blob_size_uniquity(blob_list_ret, wim->blob_table, @@ -2124,7 +2128,7 @@ write_file_data(WIMStruct *wim, int image, int write_flags, blob_list = blob_list_override; filter_ctx = NULL; INIT_LIST_HEAD(blob_table_list_ret); - list_for_each_entry(blob, blob_list, write_blobs_list) { + list_for_each_entry(blob, blob_list, write_blobs_list, struct blob_descriptor) { blob->out_refcnt = blob->refcnt; blob->will_be_in_output_wim = 1; blob->unique_size = 0; @@ -2267,7 +2271,7 @@ write_blob_table(WIMStruct *wim, int image, int write_flags, /* Set output resource metadata for blobs already present in WIM. */ if (write_flags & WIMLIB_WRITE_FLAG_APPEND) { struct blob_descriptor *blob; - list_for_each_entry(blob, blob_table_list, blob_table_list) { + list_for_each_entry(blob, blob_table_list, blob_table_list, struct blob_descriptor) { if (blob->blob_location == BLOB_IN_WIM && blob->rdesc->wim == wim) { @@ -3247,7 +3251,7 @@ overwrite_wim_via_tmpfile(WIMStruct *wim, int write_flags, unsigned num_threads) /* Write the WIM to a temporary file in the same directory as the * original WIM. */ wim_name_len = tstrlen(wim->filename); - tchar tmpfile[wim_name_len + 10]; + smart_array(tchar,tmpfile,wim_name_len + 10); tmemcpy(tmpfile, wim->filename, wim_name_len); get_random_alnum_chars(tmpfile + wim_name_len, 9); tmpfile[wim_name_len + 9] = T('\0'); diff --git a/src/xml.c b/src/xml.c index d4400ee6..d077db24 100644 --- a/src/xml.c +++ b/src/xml.c @@ -94,7 +94,7 @@ xml_element_get_timestamp(const struct xml_node *element) u64 timestamp = 0; const struct xml_node *child; - xml_node_for_each_child(element, child) { + xml_node_for_each_child(element, child, struct xml_node) { if (xml_node_is_element(child, T("HIGHPART"))) timestamp |= xml_element_get_number(child, 16) << 32; else if (xml_node_is_element(child, T("LOWPART"))) @@ -173,7 +173,7 @@ do_xml_path_walk(struct xml_node *element, const tchar *path, bool create, struct xml_node **result_ret) { size_t n = tstrlen(path) + 1; - tchar buf[n]; + smart_array(tchar,buf,n); tchar *p; tchar c; @@ -212,7 +212,7 @@ do_xml_path_walk(struct xml_node *element, const tchar *path, bool create, *p = '\0'; /* Look for a matching child. */ - xml_node_for_each_child(element, child) + xml_node_for_each_child(element, child, struct xml_node) if (xml_node_is_element(child, name) && !--index) goto next_step; @@ -482,7 +482,7 @@ xml_update_image_info(WIMStruct *wim, int image) struct xml_node *hardlinkbytes_node; struct xml_node *lastmodificationtime_node; - image_for_each_inode(inode, imd) { + image_for_each_inode(inode, imd, struct wim_inode) { if (inode_is_directory(inode)) dir_count += inode->i_nlink; else @@ -726,7 +726,7 @@ print_windows_info(struct xml_node *image_node) struct xml_node *lang_node; tprintf(T("Languages: ")); - xml_node_for_each_child(langs_node, lang_node) { + xml_node_for_each_child(langs_node, lang_node,struct xml_node) { if (!xml_node_is_element(lang_node, T("LANGUAGE"))) continue; text = xml_element_get_text(lang_node); @@ -843,7 +843,7 @@ setup_images(struct wim_xml_info *info, struct xml_node *root) int max_index = 0; int ret; - xml_node_for_each_child(root, child) { + xml_node_for_each_child(root, child, struct xml_node) { if (!xml_node_is_element(child, T("IMAGE"))) continue; index = image_element_get_index(child); @@ -858,7 +858,7 @@ setup_images(struct wim_xml_info *info, struct xml_node *root) info->images = CALLOC(info->image_count, sizeof(info->images[0])); if (unlikely(!info->images)) goto err; - xml_node_for_each_child(root, child) { + xml_node_for_each_child(root, child, struct xml_node) { if (!xml_node_is_element(child, T("IMAGE"))) continue; index = image_element_get_index(child); @@ -1049,7 +1049,7 @@ write_wim_xml_data(WIMStruct *wim, int image, u64 total_bytes, struct wim_xml_info *info = wim->xml_info; int ret; struct xml_node *orig_totalbytes_element; - struct xml_out_buf buf = {}; + struct xml_out_buf buf = {EMPTY}; const utf16lechar *raw_doc; size_t raw_doc_size; diff --git a/src/xml_windows.c b/src/xml_windows.c index 305d2efa..6034b953 100644 --- a/src/xml_windows.c +++ b/src/xml_windows.c @@ -536,7 +536,7 @@ set_default_language(struct windows_info_ctx *ctx, const struct regf *regf) const char *language_name = language_id_to_name(language_id); if (language_name) { size_t len = strlen(language_name); - tchar tstr[len + 1]; + smart_array(tchar,tstr,len + 1); for (size_t i = 0; i <= len; i++) tstr[i] = language_name[i]; set_string_property(ctx, T("WINDOWS/LANGUAGES/DEFAULT"), diff --git a/src/xmlproc.c b/src/xmlproc.c index 8ce193e9..4768e161 100644 --- a/src/xmlproc.c +++ b/src/xmlproc.c @@ -130,7 +130,7 @@ xml_free_children(struct xml_node *parent) { struct xml_node *child, *tmp; - list_for_each_entry_safe(child, tmp, &parent->children, sibling_link) + list_for_each_entry_safe(child, tmp, &parent->children, sibling_link, struct xml_node) xml_free_node(child); } @@ -156,7 +156,7 @@ xml_element_get_text(const struct xml_node *element) { const struct xml_node *child; - xml_node_for_each_child(element, child) + xml_node_for_each_child(element, child, struct xml_node) if (child->type == XML_TEXT_NODE) return child->value; return NULL; @@ -215,7 +215,7 @@ xml_get_attrib(const struct xml_node *element, const tchar *name) { struct xml_node *child; - xml_node_for_each_child(element, child) { + xml_node_for_each_child(element, child, struct xml_node) { if (child->type == XML_ATTRIBUTE_NODE && !tstrcmp(child->name, name)) return child; @@ -247,7 +247,7 @@ xml_replace_child(struct xml_node *parent, struct xml_node *replacement) xml_unlink_node(replacement); /* Shouldn't be needed, but be safe. */ - xml_node_for_each_child(parent, child) { + xml_node_for_each_child(parent, child, struct xml_node) { if (child->type == replacement->type && !tstrcmp(child->name, replacement->name)) { list_replace(&child->sibling_link, @@ -271,7 +271,7 @@ xml_clone_tree(struct xml_node *orig) orig->value, orig->value ? tstrlen(orig->value) : 0); if (!clone) return NULL; - xml_node_for_each_child(orig, orig_child) { + xml_node_for_each_child(orig, orig_child, struct xml_node) { clone_child = xml_clone_tree(orig_child); if (!clone_child) goto oom; @@ -709,7 +709,7 @@ xml_write_element(struct xml_node *element, struct xml_out_buf *buf) /* Write the start tag. */ xml_puts(buf, T("<")); xml_puts(buf, element->name); - xml_node_for_each_child(element, child) { + xml_node_for_each_child(element, child, struct xml_node) { if (child->type == XML_ATTRIBUTE_NODE) { xml_puts(buf, T(" ")); xml_puts(buf, child->name); @@ -721,7 +721,7 @@ xml_write_element(struct xml_node *element, struct xml_out_buf *buf) xml_puts(buf, T(">")); /* Write the contents. */ - xml_node_for_each_child(element, child) { + xml_node_for_each_child(element, child, struct xml_node) { if (child->type == XML_TEXT_NODE) xml_escape_and_puts(buf, child->value); else if (child->type == XML_ELEMENT_NODE) diff --git a/src/xpress_compress.c b/src/xpress_compress.c index e192c870..39929f84 100644 --- a/src/xpress_compress.c +++ b/src/xpress_compress.c @@ -529,7 +529,7 @@ xpress_compress_greedy(struct xpress_compressor * restrict c, const u8 * const in_end = in_begin + in_nbytes; struct xpress_item *next_chosen_item = c->chosen_items; unsigned len_3_too_far; - u32 next_hashes[2] = {}; + u32 next_hashes[2] = {EMPTY}; if (in_nbytes <= 8192) len_3_too_far = 2048; @@ -592,7 +592,7 @@ xpress_compress_lazy(struct xpress_compressor * restrict c, const u8 * const in_end = in_begin + in_nbytes; struct xpress_item *next_chosen_item = c->chosen_items; unsigned len_3_too_far; - u32 next_hashes[2] = {}; + u32 next_hashes[2] = {EMPTY}; if (in_nbytes <= 8192) len_3_too_far = 2048; @@ -907,7 +907,7 @@ xpress_find_matches(struct xpress_compressor * restrict c, const u8 * const in_begin = in; const u8 *in_next = in_begin; struct lz_match *cache_ptr = c->match_cache; - u32 next_hashes[2] = {}; + u32 next_hashes[2] = {EMPTY}; u32 max_len = in_nbytes; u32 nice_len = min(max_len, c->nice_match_length); diff --git a/src/xpress_decompress.c b/src/xpress_decompress.c index 035bcfd0..b3e633e3 100644 --- a/src/xpress_decompress.c +++ b/src/xpress_decompress.c @@ -76,6 +76,9 @@ /* This value is chosen for fast decompression. */ #define XPRESS_TABLEBITS 11 +#ifdef _MSC_VER +#pragma pack(push, DECODE_TABLE_ALIGNMENT) +#endif struct xpress_decompressor { union { DECODE_TABLE(decode_table, XPRESS_NUM_SYMBOLS, @@ -86,6 +89,9 @@ struct xpress_decompressor { XPRESS_MAX_CODEWORD_LEN); } __attribute__((aligned(DECODE_TABLE_ALIGNMENT))); +#ifdef _MSC_VER +#pragma pack(pop) +#endif static int xpress_decompress(const void *restrict compressed_data, size_t compressed_size, void *restrict uncompressed_data, size_t uncompressed_size, diff --git a/tests/set_reparse_point.c b/tests/set_reparse_point.c index d22cd08a..4e7c334a 100644 --- a/tests/set_reparse_point.c +++ b/tests/set_reparse_point.c @@ -3,6 +3,9 @@ #include #include +#ifdef _MSC_VER +#include "../include/wimlib/compiler.h" +#endif static const wchar_t * win32_error_string(DWORD err) { @@ -43,8 +46,7 @@ wmain(int argc, wchar_t **argv) NULL); if (h == INVALID_HANDLE_VALUE) fail("CreateFile"); - - uint8_t in[8 + rpdatalen]; + smart_array(uint8_t, in, 8 + rpdatalen); uint8_t *p = in; *(uint32_t *)p = 0x80000000; /* rptag */ p += 4; diff --git a/tests/set_reparse_point.vcxproj b/tests/set_reparse_point.vcxproj new file mode 100644 index 00000000..7ffbec9a --- /dev/null +++ b/tests/set_reparse_point.vcxproj @@ -0,0 +1,300 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + 16.0 + Win32Proj + {c303c939-130f-5791-d8ef-f0d58e61e824} + wimlibimagex + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + false + v143 + true + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/tests/win32-tree-cmp.c b/tests/win32-tree-cmp.c index 1b6a0276..c68ea366 100644 --- a/tests/win32-tree-cmp.c +++ b/tests/win32-tree-cmp.c @@ -11,7 +11,10 @@ #include #include - +#ifdef _MSC_VER +#include "../include/wimlib/compiler.h" +#pragma warning(disable:4996) +#endif typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; diff --git a/tests/win32-tree-cmp.vcxproj b/tests/win32-tree-cmp.vcxproj new file mode 100644 index 00000000..28d64ac2 --- /dev/null +++ b/tests/win32-tree-cmp.vcxproj @@ -0,0 +1,300 @@ + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + 16.0 + Win32Proj + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B} + wimlibimagex + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + false + v143 + true + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + $(SolutionDir)$(PlatformShortName)\$(Configuration)\ + $(PlatformShortName)\$(Configuration)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreadedDebug + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + false + stdcpp17 + stdc17 + MultiThreaded + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/tools/get-version-number.cmd b/tools/get-version-number.cmd new file mode 100644 index 00000000..14ddcbdf --- /dev/null +++ b/tools/get-version-number.cmd @@ -0,0 +1,5 @@ +echo off +setlocal enabledelayedexpansion +for /f %%i in ('git describe --abbrev^=8 --dirty --always 2^>nul') do set "vers=%%i" +if not defined vers set "vers=1.14.3" +echo !vers! \ No newline at end of file diff --git a/tools/windows-after-build-msvc.cmd b/tools/windows-after-build-msvc.cmd new file mode 100644 index 00000000..5606bfea --- /dev/null +++ b/tools/windows-after-build-msvc.cmd @@ -0,0 +1,51 @@ +echo off +setlocal enabledelayedexpansion +cd /d %~dp0.. +for /f %%i in ('%~dp0get-version-number.cmd') do set "VERSION=%%i" +set "ARCH=%~1" +set "ARCH=!ARCH:ARM=arm!" +set "CONFIG=%~2" +set "CONFIGOUT=!CONFIG: =_!" +set "CONFIGOUT=!CONFIGOUT:R=r!" +set "CONFIGOUT=!CONFIGOUT:D=d!" +set "CONFIGOUT=!CONFIGOUT:S=s!" +set "DESTDIR=wimlib-!VERSION!-windows-msvc-!ARCH!-!CONFIGOUT!-bin" +mkdir "!DESTDIR!" 2>nul +mkdir "!DESTDIR!\symbols" 2>nul +:install_binaries +echo Installing binaries... +copy /y ".\!ARCH!\!CONFIG!\*wim*.dll" "!DESTDIR!" >nul 2>nul +copy /y ".\!ARCH!\!CONFIG!\*wim*.exe" "!DESTDIR!" >nul +:install_text_files +echo Installing NEWS, README, and licenses... +del /q !DESTDIR!\*.txt 2>nul +copy /y NEWS* "!DESTDIR!" >nul +copy /y README* "!DESTDIR!" >nul +copy /y COPYING* "!DESTDIR!" >nul +for %%i in (!DESTDIR!\COPYING*) do move /y %%i %%i.txt>nul +ren !DESTDIR!\*.txt.txt *. 1>nul +ren !DESTDIR!\*.md *.txt>nul +:install_symbols +echo Installing symbols... +copy /y ".\!ARCH!\!CONFIG!\*wim*.pdb" "!DESTDIR!\symbols" >nul +:install_cmd_aliases +echo Installing wim*.cmd files... +for /f %%i in ('dir /a-d /b .\doc\man1\wim*.1') do ( +set "cmd=%%i" +echo ^@echo off>"!DESTDIR!\!cmd:~0,-2!.cmd" +echo "^%%~dp0\\wimlib-imagex" !cmd:~3,-2! %%^*>>"!DESTDIR!\!cmd:~0,-2!.cmd" +) +del /q "!DESTDIR!\*mount*.cmd" +del /q "!DESTDIR!\*imagex.cmd" +:install_development_files +echo Installing development files... +mkdir "!DESTDIR!\devel" 2>nul +copy /y ".\!ARCH!\!CONFIG!\*.lib" "!DESTDIR!\devel" >nul +copy /y ".\include\wimlib.h" "!DESTDIR!\devel" >nul +:install_test_files +echo Installing test files... +mkdir "!DESTDIR!\test" 2>nul +copy /y ".\!ARCH!\!CONFIG: Static=!\*.exe" "!DESTDIR!\test" >nul +copy /y ".\!ARCH!\!CONFIG!\*.exe" "!DESTDIR!\test" >nul +copy /y ".\!ARCH!\!CONFIG!\*.dll" "!DESTDIR!\test" >nul 2>nul +copy /y ".\tests\*.bat" "!DESTDIR!\test" >nul \ No newline at end of file diff --git a/tools/windows-build.sh b/tools/windows-build.sh index 63bd58b4..0d60df42 100755 --- a/tools/windows-build.sh +++ b/tools/windows-build.sh @@ -67,6 +67,10 @@ parse_options() ARCH=x86_64 CC_PKG=mingw-w64-x86_64-gcc ;; + UCRT64) + ARCH=x86_64 + CC_PKG=mingw-w64-x86_64-ucrt-gcc + ;; CLANG32) ARCH=i686 CC_PKG=mingw-w64-clang-i686-clang @@ -88,7 +92,7 @@ parse_options() ;; *) echo 1>&2 "Unsupported MSYS2 environment: $MSYSTEM. This script supports" - echo 1>&2 "MINGW32, MINGW64, CLANG32, CLANG64, and CLANGARM64." + echo 1>&2 "MINGW32, MINGW64, UCRT64, CLANG32, CLANG64, and CLANGARM64." echo 1>&2 "See https://www.msys2.org/docs/environments/" exit 1 esac diff --git a/wimlib-imagex.sln b/wimlib-imagex.sln new file mode 100644 index 00000000..f2e21821 --- /dev/null +++ b/wimlib-imagex.sln @@ -0,0 +1,177 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33829.357 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wimlib-imagex", "programs\wimlib-imagex.vcxproj", "{2F969CAB-005D-4C70-87FC-CB45E2FE22DA}" + ProjectSection(ProjectDependencies) = postProject + {1218765A-B2F8-40FD-9BD6-7F5A769678CF} = {1218765A-B2F8-40FD-9BD6-7F5A769678CF} + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B} = {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B} + {C303C939-130F-5791-D8EF-F0D58E61E824} = {C303C939-130F-5791-D8EF-F0D58E61E824} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwim", "src\libwim.vcxproj", "{1218765A-B2F8-40FD-9BD6-7F5A769678CF}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "set_reparse_point", "tests\set_reparse_point.vcxproj", "{C303C939-130F-5791-D8EF-F0D58E61E824}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "win32-tree-cmp", "tests\win32-tree-cmp.vcxproj", "{3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}" + ProjectSection(ProjectDependencies) = postProject + {C303C939-130F-5791-D8EF-F0D58E61E824} = {C303C939-130F-5791-D8EF-F0D58E61E824} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug Static|ARM = Debug Static|ARM + Debug Static|ARM64 = Debug Static|ARM64 + Debug Static|x64 = Debug Static|x64 + Debug Static|x86 = Debug Static|x86 + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release Static|ARM = Release Static|ARM + Release Static|ARM64 = Release Static|ARM64 + Release Static|x64 = Release Static|x64 + Release Static|x86 = Release Static|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug Static|ARM.ActiveCfg = Debug Static|ARM + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug Static|ARM.Build.0 = Debug Static|ARM + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug Static|ARM64.ActiveCfg = Debug Static|ARM64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug Static|ARM64.Build.0 = Debug Static|ARM64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug Static|x64.ActiveCfg = Debug Static|x64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug Static|x64.Build.0 = Debug Static|x64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug Static|x86.ActiveCfg = Debug Static|Win32 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug Static|x86.Build.0 = Debug Static|Win32 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug|ARM.ActiveCfg = Debug|ARM + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug|ARM.Build.0 = Debug|ARM + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug|ARM64.Build.0 = Debug|ARM64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug|x64.ActiveCfg = Debug|x64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug|x64.Build.0 = Debug|x64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug|x86.ActiveCfg = Debug|Win32 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Debug|x86.Build.0 = Debug|Win32 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release Static|ARM.ActiveCfg = Release Static|ARM + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release Static|ARM.Build.0 = Release Static|ARM + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release Static|ARM64.ActiveCfg = Release Static|ARM64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release Static|ARM64.Build.0 = Release Static|ARM64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release Static|x64.ActiveCfg = Release Static|x64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release Static|x64.Build.0 = Release Static|x64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release Static|x86.ActiveCfg = Release Static|Win32 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release Static|x86.Build.0 = Release Static|Win32 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release|ARM.ActiveCfg = Release|ARM + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release|ARM.Build.0 = Release|ARM + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release|ARM64.ActiveCfg = Release|ARM64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release|ARM64.Build.0 = Release|ARM64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release|x64.ActiveCfg = Release|x64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release|x64.Build.0 = Release|x64 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release|x86.ActiveCfg = Release|Win32 + {2F969CAB-005D-4C70-87FC-CB45E2FE22DA}.Release|x86.Build.0 = Release|Win32 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug Static|ARM.ActiveCfg = Debug Static|ARM + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug Static|ARM.Build.0 = Debug Static|ARM + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug Static|ARM64.ActiveCfg = Debug Static|ARM64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug Static|ARM64.Build.0 = Debug Static|ARM64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug Static|x64.ActiveCfg = Debug Static|x64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug Static|x64.Build.0 = Debug Static|x64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug Static|x86.ActiveCfg = Debug Static|Win32 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug Static|x86.Build.0 = Debug Static|Win32 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug|ARM.ActiveCfg = Debug|ARM + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug|ARM.Build.0 = Debug|ARM + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug|ARM64.Build.0 = Debug|ARM64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug|x64.ActiveCfg = Debug|x64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug|x64.Build.0 = Debug|x64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug|x86.ActiveCfg = Debug|Win32 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Debug|x86.Build.0 = Debug|Win32 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release Static|ARM.ActiveCfg = Release Static|ARM + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release Static|ARM.Build.0 = Release Static|ARM + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release Static|ARM64.ActiveCfg = Release Static|ARM64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release Static|ARM64.Build.0 = Release Static|ARM64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release Static|x64.ActiveCfg = Release Static|x64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release Static|x64.Build.0 = Release Static|x64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release Static|x86.ActiveCfg = Release Static|Win32 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release Static|x86.Build.0 = Release Static|Win32 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release|ARM.ActiveCfg = Release|ARM + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release|ARM.Build.0 = Release|ARM + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release|ARM64.ActiveCfg = Release|ARM64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release|ARM64.Build.0 = Release|ARM64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release|x64.ActiveCfg = Release|x64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release|x64.Build.0 = Release|x64 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release|x86.ActiveCfg = Release|Win32 + {1218765A-B2F8-40FD-9BD6-7F5A769678CF}.Release|x86.Build.0 = Release|Win32 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug Static|ARM.ActiveCfg = Debug|ARM + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug Static|ARM.Build.0 = Debug|ARM + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug Static|ARM64.ActiveCfg = Debug|ARM64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug Static|ARM64.Build.0 = Debug|ARM64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug Static|x64.ActiveCfg = Debug|x64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug Static|x64.Build.0 = Debug|x64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug Static|x86.ActiveCfg = Debug|Win32 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug Static|x86.Build.0 = Debug|Win32 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug|ARM.ActiveCfg = Debug|ARM + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug|ARM.Build.0 = Debug|ARM + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug|ARM64.Build.0 = Debug|ARM64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug|x64.ActiveCfg = Debug|x64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug|x64.Build.0 = Debug|x64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug|x86.ActiveCfg = Debug|Win32 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Debug|x86.Build.0 = Debug|Win32 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release Static|ARM.ActiveCfg = Release|ARM + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release Static|ARM.Build.0 = Release|ARM + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release Static|ARM64.ActiveCfg = Release|ARM64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release Static|ARM64.Build.0 = Release|ARM64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release Static|x64.ActiveCfg = Release|x64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release Static|x64.Build.0 = Release|x64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release Static|x86.ActiveCfg = Release|Win32 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release Static|x86.Build.0 = Release|Win32 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release|ARM.ActiveCfg = Release|ARM + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release|ARM.Build.0 = Release|ARM + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release|ARM64.ActiveCfg = Release|ARM64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release|ARM64.Build.0 = Release|ARM64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release|x64.ActiveCfg = Release|x64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release|x64.Build.0 = Release|x64 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release|x86.ActiveCfg = Release|Win32 + {C303C939-130F-5791-D8EF-F0D58E61E824}.Release|x86.Build.0 = Release|Win32 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug Static|ARM.ActiveCfg = Debug|ARM + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug Static|ARM.Build.0 = Debug|ARM + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug Static|ARM64.ActiveCfg = Debug|ARM64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug Static|ARM64.Build.0 = Debug|ARM64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug Static|x64.ActiveCfg = Debug|x64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug Static|x64.Build.0 = Debug|x64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug Static|x86.ActiveCfg = Debug|Win32 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug Static|x86.Build.0 = Debug|Win32 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug|ARM.ActiveCfg = Debug|ARM + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug|ARM.Build.0 = Debug|ARM + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug|ARM64.Build.0 = Debug|ARM64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug|x64.ActiveCfg = Debug|x64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug|x64.Build.0 = Debug|x64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug|x86.ActiveCfg = Debug|Win32 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Debug|x86.Build.0 = Debug|Win32 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release Static|ARM.ActiveCfg = Release|ARM + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release Static|ARM.Build.0 = Release|ARM + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release Static|ARM64.ActiveCfg = Release|ARM64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release Static|ARM64.Build.0 = Release|ARM64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release Static|x64.ActiveCfg = Release|x64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release Static|x64.Build.0 = Release|x64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release Static|x86.ActiveCfg = Release|Win32 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release Static|x86.Build.0 = Release|Win32 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release|ARM.ActiveCfg = Release|ARM + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release|ARM.Build.0 = Release|ARM + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release|ARM64.ActiveCfg = Release|ARM64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release|ARM64.Build.0 = Release|ARM64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release|x64.ActiveCfg = Release|x64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release|x64.Build.0 = Release|x64 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release|x86.ActiveCfg = Release|Win32 + {3913A43D-0A65-45D6-A7A5-4D2E4E85CB8B}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7FF2A8C9-D7B2-4732-ABC3-545A4C4DB4BD} + EndGlobalSection +EndGlobal From ed821bfe2cb7c19c49cf095440bc670a58fd786f Mon Sep 17 00:00:00 2001 From: Administrator Date: Sun, 18 Feb 2024 21:15:16 +0800 Subject: [PATCH 2/2] Fix error on wim files larger than 2GiB --- include/wimlib/file_io.h | 10 +++++----- include/wimlib/integrity.h | 4 ++-- include/wimlib/wim.h | 2 +- include/wimlib/win32.h | 6 +++--- programs/imagex.c | 8 ++++---- src/file_io.c | 8 ++++---- src/header.c | 2 +- src/integrity.c | 10 +++++----- src/mount_image.c | 14 +++++++------- src/win32_replacements.c | 8 ++++---- src/write.c | 10 +++++----- 11 files changed, 41 insertions(+), 41 deletions(-) diff --git a/include/wimlib/file_io.h b/include/wimlib/file_io.h index 8dbdb120..4a89ffd8 100644 --- a/include/wimlib/file_io.h +++ b/include/wimlib/file_io.h @@ -11,27 +11,27 @@ struct filedes { int fd; unsigned int is_pipe : 1; - off_t offset; + uint64_t offset; }; int full_read(struct filedes *fd, void *buf, size_t n); int -full_pread(struct filedes *fd, void *buf, size_t nbyte, off_t offset); +full_pread(struct filedes *fd, void *buf, size_t nbyte, uint64_t offset); int full_write(struct filedes *fd, const void *buf, size_t n); int -full_pwrite(struct filedes *fd, const void *buf, size_t count, off_t offset); +full_pwrite(struct filedes *fd, const void *buf, size_t count, uint64_t offset); #ifndef _WIN32 # define O_BINARY 0 #endif -off_t -filedes_seek(struct filedes *fd, off_t offset); +uint64_t +filedes_seek(struct filedes *fd, uint64_t offset); bool filedes_is_seekable(struct filedes *fd); diff --git a/include/wimlib/integrity.h b/include/wimlib/integrity.h index 755cddda..5940979a 100644 --- a/include/wimlib/integrity.h +++ b/include/wimlib/integrity.h @@ -19,8 +19,8 @@ read_integrity_table(WIMStruct *wim, u64 num_checked_bytes, int write_integrity_table(WIMStruct *wim, - off_t new_blob_table_end, - off_t old_blob_table_end, + uint64_t new_blob_table_end, + uint64_t old_blob_table_end, struct integrity_table *old_table); int diff --git a/include/wimlib/wim.h b/include/wimlib/wim.h index 666f4b02..b20cd8d9 100644 --- a/include/wimlib/wim.h +++ b/include/wimlib/wim.h @@ -199,7 +199,7 @@ read_wim_header(WIMStruct *wim, struct wim_header *hdr); int write_wim_header(const struct wim_header *hdr, struct filedes *out_fd, - off_t offset); + uint64_t offset); int write_wim_header_flags(u32 hdr_flags, struct filedes *out_fd); diff --git a/include/wimlib/win32.h b/include/wimlib/win32.h index f100034d..463f0ea6 100644 --- a/include/wimlib/win32.h +++ b/include/wimlib/win32.h @@ -47,7 +47,7 @@ int win32_rename_replacement(const tchar *oldpath, const tchar *newpath); int -win32_truncate_replacement(const tchar *path, off_t size); +win32_truncate_replacement(const tchar *path, uint64_t size); int win32_strerror_r_replacement(int errnum, tchar *buf, size_t buflen); @@ -62,10 +62,10 @@ ssize_t win32_write(int fd, const void *buf, size_t count); ssize_t -win32_pread(int fd, void *buf, size_t count, off_t offset); +win32_pread(int fd, void *buf, size_t count, uint64_t offset); ssize_t -win32_pwrite(int fd, const void *buf, size_t count, off_t offset); +win32_pwrite(int fd, const void *buf, size_t count, uint64_t offset); #endif /* _WIN32 */ diff --git a/programs/imagex.c b/programs/imagex.c index 395c2fbc..66f910db 100644 --- a/programs/imagex.c +++ b/programs/imagex.c @@ -833,14 +833,14 @@ do_metadata_not_found_warning(const tchar *wimfile, /* Returns the size of a file given its name, or -1 if the file does not exist * or its size cannot be determined. */ -static off_t +static uint64_t file_get_size(const tchar *filename) { struct _stat st; if (tstat(filename, &st) == 0) return st.st_size; else - return (off_t)-1; + return (uint64_t)-1; } enum { @@ -3788,8 +3788,8 @@ imagex_optimize(int argc, tchar **argv, int cmd) WIMStruct *wim; struct wimlib_wim_info info; const tchar *wimfile; - off_t old_size; - off_t new_size; + uint64_t old_size; + uint64_t new_size; unsigned num_threads = 0; for_opt(c, optimize_options) { diff --git a/src/file_io.c b/src/file_io.c index 5b573eea..ea593037 100644 --- a/src/file_io.c +++ b/src/file_io.c @@ -73,7 +73,7 @@ full_read(struct filedes *fd, void *buf, size_t count) } static int -pipe_read(struct filedes *fd, void *buf, size_t count, off_t offset) +pipe_read(struct filedes *fd, void *buf, size_t count, uint64_t offset) { int ret; @@ -115,7 +115,7 @@ pipe_read(struct filedes *fd, void *buf, size_t count, off_t offset) * WIMLIB_ERR_RESOURCE_ORDER (errno set to ESPIPE) */ int -full_pread(struct filedes *fd, void *buf, size_t count, off_t offset) +full_pread(struct filedes *fd, void *buf, size_t count, uint64_t offset) { if (fd->is_pipe) goto is_pipe; @@ -180,7 +180,7 @@ full_write(struct filedes *fd, const void *buf, size_t count) * WIMLIB_ERR_WRITE (errno set) */ int -full_pwrite(struct filedes *fd, const void *buf, size_t count, off_t offset) +full_pwrite(struct filedes *fd, const void *buf, size_t count, uint64_t offset) { while (count) { ssize_t ret = pwrite(fd->fd, buf, count, offset); @@ -196,7 +196,7 @@ full_pwrite(struct filedes *fd, const void *buf, size_t count, off_t offset) return 0; } -off_t filedes_seek(struct filedes *fd, off_t offset) +uint64_t filedes_seek(struct filedes *fd, uint64_t offset) { if (fd->is_pipe) { errno = ESPIPE; diff --git a/src/header.c b/src/header.c index 0bbe253a..f637d24a 100644 --- a/src/header.c +++ b/src/header.c @@ -178,7 +178,7 @@ read_wim_header(WIMStruct *wim, struct wim_header *hdr) * header. */ int write_wim_header(const struct wim_header *hdr, struct filedes *out_fd, - off_t offset) + uint64_t offset) { #ifdef _MSC_VER #pragma pack(push, 8) diff --git a/src/integrity.c b/src/integrity.c index 2a63582d..6bb607f4 100644 --- a/src/integrity.c +++ b/src/integrity.c @@ -62,7 +62,7 @@ struct integrity_table { #endif static int calculate_chunk_sha1(struct filedes *in_fd, size_t this_chunk_size, - off_t offset, u8 sha1_md[]) + uint64_t offset, u8 sha1_md[]) { u8 buf[BUFFER_SIZE]; struct sha1_ctx ctx; @@ -178,9 +178,9 @@ read_integrity_table(WIMStruct *wim, u64 num_checked_bytes, */ static int calculate_integrity_table(struct filedes *in_fd, - off_t new_check_end, + uint64_t new_check_end, const struct integrity_table *old_table, - off_t old_check_end, + uint64_t old_check_end, struct integrity_table **integrity_table_ret, wimlib_progress_func_t progfunc, void *progctx) @@ -301,8 +301,8 @@ calculate_integrity_table(struct filedes *in_fd, */ int write_integrity_table(WIMStruct *wim, - off_t new_blob_table_end, - off_t old_blob_table_end, + uint64_t new_blob_table_end, + uint64_t old_blob_table_end, struct integrity_table *old_table) { struct integrity_table *new_table; diff --git a/src/mount_image.c b/src/mount_image.c index 4702d60d..7b3ddbd0 100644 --- a/src/mount_image.c +++ b/src/mount_image.c @@ -726,13 +726,13 @@ create_staging_file(const struct wimfs_context *ctx, char **name_ret) static int extract_blob_to_staging_dir(struct wim_inode *inode, struct wim_inode_stream *strm, - off_t size, const struct wimfs_context *ctx) + uint64_t size, const struct wimfs_context *ctx) { struct blob_descriptor *old_blob; struct blob_descriptor *new_blob; char *staging_file_name; int staging_fd; - off_t extract_size; + uint64_t extract_size; int result; int ret; @@ -1729,7 +1729,7 @@ wimfs_opendir(const char *path, struct fuse_file_info *fi) static int wimfs_read(const char *path, char *buf, size_t size, - off_t offset, struct fuse_file_info *fi) + uint64_t offset, struct fuse_file_info *fi) { struct wimfs_fd *fd = WIMFS_FD(fi); const struct blob_descriptor *blob; @@ -1773,7 +1773,7 @@ wimfs_read(const char *path, char *buf, size_t size, static int wimfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, - off_t offset, struct fuse_file_info *fi, + uint64_t offset, struct fuse_file_info *fi, enum fuse_readdir_flags flags) { struct wimfs_fd *fd = WIMFS_FD(fi); @@ -2004,7 +2004,7 @@ wimfs_symlink(const char *to, const char *from) } static int -do_truncate(int staging_fd, off_t size, +do_truncate(int staging_fd, uint64_t size, struct wim_inode *inode, struct blob_descriptor *blob) { if (ftruncate(staging_fd, size)) @@ -2015,7 +2015,7 @@ do_truncate(int staging_fd, off_t size, } static int -wimfs_truncate(const char *path, off_t size, struct fuse_file_info *fi) +wimfs_truncate(const char *path, uint64_t size, struct fuse_file_info *fi) { const struct wimfs_context *ctx = wimfs_get_context(); struct wim_dentry *dentry; @@ -2114,7 +2114,7 @@ wimfs_utimens(const char *path, const struct timespec tv[2], static int wimfs_write(const char *path, const char *buf, size_t size, - off_t offset, struct fuse_file_info *fi) + uint64_t offset, struct fuse_file_info *fi) { struct wimfs_fd *fd = WIMFS_FD(fi); ssize_t ret; diff --git a/src/win32_replacements.c b/src/win32_replacements.c index 4d019679..24cdd89d 100644 --- a/src/win32_replacements.c +++ b/src/win32_replacements.c @@ -471,7 +471,7 @@ win32_rename_replacement(const wchar_t *srcpath, const wchar_t *dstpath) #define MAX_IO_AMOUNT 1048576 static int -do_pread_or_pwrite(int fd, void *buf, size_t count, off_t offset, +do_pread_or_pwrite(int fd, void *buf, size_t count, uint64_t offset, bool is_pwrite) { HANDLE h; @@ -513,7 +513,7 @@ do_pread_or_pwrite(int fd, void *buf, size_t count, off_t offset, if (!bret) { err = GetLastError(); win32_error(err, L"Failed to %s %zu bytes at offset %"PRIu64, - (is_pwrite ? "write" : "read"), count, offset); + (is_pwrite ? L"write" : L"read"), count, offset); goto error; } @@ -539,7 +539,7 @@ do_pread_or_pwrite(int fd, void *buf, size_t count, off_t offset, * offset, so it is not safe to use with readers/writers on the same file * descriptor. */ ssize_t -win32_pread(int fd, void *buf, size_t count, off_t offset) +win32_pread(int fd, void *buf, size_t count, uint64_t offset) { return do_pread_or_pwrite(fd, buf, count, offset, false); } @@ -548,7 +548,7 @@ win32_pread(int fd, void *buf, size_t count, off_t offset) * offset, so it is not safe to use with readers/writers on the same file * descriptor. */ ssize_t -win32_pwrite(int fd, const void *buf, size_t count, off_t offset) +win32_pwrite(int fd, const void *buf, size_t count, uint64_t offset) { return do_pread_or_pwrite(fd, (void*)buf, count, offset, true); } diff --git a/src/write.c b/src/write.c index 2249ed50..29450df8 100644 --- a/src/write.c +++ b/src/write.c @@ -2331,9 +2331,9 @@ finish_write(WIMStruct *wim, int image, int write_flags, struct list_head *blob_table_list) { int write_resource_flags; - off_t old_blob_table_end = 0; + uint64_t old_blob_table_end = 0; struct integrity_table *old_integrity_table = NULL; - off_t new_blob_table_end; + uint64_t new_blob_table_end; u64 xml_totalbytes; int ret; @@ -2932,7 +2932,7 @@ static int check_resource_offset(struct blob_descriptor *blob, void *_wim) { const WIMStruct *wim = _wim; - off_t end_offset = *(const off_t*)wim->private; + uint64_t end_offset = *(const uint64_t*)wim->private; if (blob->blob_location == BLOB_IN_WIM && blob->rdesc->wim == wim && @@ -2945,7 +2945,7 @@ check_resource_offset(struct blob_descriptor *blob, void *_wim) * integrity table if present)--- otherwise we can't safely append to the WIM * file and we return WIMLIB_ERR_RESOURCE_ORDER. */ static int -check_resource_offsets(WIMStruct *wim, off_t end_offset) +check_resource_offsets(WIMStruct *wim, uint64_t end_offset) { int ret; unsigned i; @@ -3050,7 +3050,7 @@ static int overwrite_wim_inplace(WIMStruct *wim, int write_flags, unsigned num_threads) { int ret; - off_t old_wim_end; + uint64_t old_wim_end; struct list_head blob_list; struct list_head blob_table_list; struct filter_context filter_ctx;