+/* WIM alternate data stream entry (on-disk format) */
+struct wim_ads_entry_on_disk {
+ /* Length of the entry, in bytes. This apparently includes all
+ * fixed-length fields, plus the stream name and null terminator if
+ * present, and the padding up to an 8 byte boundary. wimlib is a
+ * little less strict when reading the entries, and only requires that
+ * the number of bytes from this field is at least as large as the size
+ * of the fixed length fields and stream name without null terminator.
+ * */
+ le64 length;
+
+ le64 reserved;
+
+ /* SHA1 message digest of the uncompressed stream; or, alternatively,
+ * can be all zeroes if the stream has zero length. */
+ u8 hash[SHA1_HASH_SIZE];
+
+ /* Length of the stream name, in bytes. 0 if the stream is unnamed. */
+ le16 stream_name_nbytes;
+
+ /* Stream name in UTF-16LE. It is @stream_name_nbytes bytes long,
+ * excluding the the null terminator. There is a null terminator
+ * character if @stream_name_nbytes != 0; i.e., if this stream is named.
+ * */
+ utf16lechar stream_name[];
+} _packed_attribute;
+
+#define WIM_ADS_ENTRY_DISK_SIZE 38
+
+/* On-disk format of a WIM dentry (directory entry), located in the metadata
+ * resource for a WIM image. */
+struct wim_dentry_on_disk {
+
+ /* Length of this directory entry in bytes, not including any alternate
+ * data stream entries. Should be a multiple of 8 so that the following
+ * dentry or alternate data stream entry is aligned on an 8-byte
+ * boundary. (If not, wimlib will round it up.)
+ *
+ * It is also possible for this field to be 0. This situation, which is
+ * undocumented, indicates the end of a list of sibling nodes in a
+ * directory. It also means the real length is 8, because the dentry
+ * included only the length field, but that takes up 8 bytes. */
+ le64 length;
+
+ /* Attributes of the file or directory. This is a bitwise OR of the
+ * FILE_ATTRIBUTE_* constants and should correspond to the value
+ * retrieved by GetFileAttributes() on Windows. */
+ le32 attributes;
+
+ /* A value that specifies the security descriptor for this file or
+ * directory. If -1, the file or directory has no security descriptor.
+ * Otherwise, it is a 0-based index into the WIM image's table of
+ * security descriptors (see: `struct wim_security_data') */
+ sle32 security_id;
+
+ /* Offset from the start of the uncompressed metadata resource of this
+ * directory's child directory entries, or 0 if this directory entry
+ * does not correspond to a directory or otherwise does not have any
+ * children. */
+ le64 subdir_offset;
+
+ /* Reserved fields */
+ le64 unused_1;
+ le64 unused_2;
+
+ /* The following three time fields should correspond to those gotten by
+ * calling GetFileTime() on Windows. */
+
+ /* Creation time, in 100-nanosecond intervals since January 1, 1601. */
+ le64 creation_time;
+
+ /* Last access time, in 100-nanosecond intervals since January 1, 1601. */
+ le64 last_access_time;
+
+ /* Last write time, in 100-nanosecond intervals since January 1, 1601. */
+ le64 last_write_time;
+
+ /* Vaguely, the SHA-1 message digest ("hash") of the file's contents.
+ * More specifically, this is for the "unnamed data stream" rather than
+ * any "alternate data streams". This hash value is used to look up the
+ * corresponding entry in the WIM's stream lookup table to actually find
+ * the file contents within the WIM.
+ *
+ * If the file has no unnamed data stream (e.g. is a directory), then
+ * this field will be all zeroes. If the unnamed data stream is empty
+ * (i.e. an "empty file"), then this field is also expected to be all
+ * zeroes. (It will be if wimlib created the WIM image, at least;
+ * otherwise it can't be ruled out that the SHA-1 message digest of 0
+ * bytes of data is given explicitly.)
+ *
+ * If the file has reparse data, then this field will instead specify
+ * the SHA-1 message digest of the reparse data. If it is somehow
+ * possible for a file to have both an unnamed data stream and reparse
+ * data, then this is not handled by wimlib.
+ *
+ * As a further special case, if this field is all zeroes but there is
+ * an alternate data stream entry with no name and a nonzero SHA-1
+ * message digest field, then that hash must be used instead of this
+ * one. (wimlib does not use this quirk on WIM images it creates.)
+ */
+ u8 unnamed_stream_hash[SHA1_HASH_SIZE];