Add Archive timestamp decoding
[installshield_z.git] / installshield_z.h
1 /*
2   InstallShield Z file format
3   Copyright 2015 <hacker@iam.tj>
4   Licenced on the terms of then GNU General Public Licence version 3
5
6   Data structures used in InstallShield .Z archive files
7  */
8
9 #include <sys/types.h>
10 #include <inttypes.h>
11 #include <stdbool.h>
12
13 const unsigned int file_magic = 0x8C655D12;
14 const ssize_t Z_FILE_HEADER_BYTES = 0x100;
15
16 /* __prefixed field purpose is not confirmed */
17 struct __attribute__((packed)) archive_header {
18         uint32_t                magic;                                          // 0x00
19         uint16_t                __version;                                      // 0x04
20         uint16_t                __flags;                                        // 0x06
21         uint32_t                __unknown08;                            // 0x08
22         uint16_t                files_entries;                          // 0x0C
23         uint16_t                datestamp;                                      // 0x0E
24         uint16_t                timestamp;                                      // 0x10
25         uint32_t                file_bytes;                                     // 0x12
26         uint32_t                payload_bytes;                          // 0x16
27         uint8_t                 __known1A;                                      // 0x1A
28         uint16_t                __unknown1B;                            // 0x1B
29         uint32_t                __unknown1D;                            // 0x1D
30         uint32_t                __unknown21;                            // 0x21
31         uint32_t                __unknown25;                            // 0x25
32         uint32_t                directories_offset;                     // 0x29
33         uint32_t                directories_bytes;                      // 0x2D
34         uint16_t                directories_entries;            // 0x31
35         uint32_t                files_offset;                           // 0x33
36         uint32_t                files_bytes;                            // 0x37
37         unsigned char   unknown3B[0x100 - 0x3B];        // 0x3B to 0xFF
38 };
39
40 struct __attribute__((packed)) dirent_prefix {
41         uint16_t                        __flags;                        // 0x00
42         uint16_t                        entry_bytes;            // 0x02
43         uint16_t                        name_bytes;                     // 0x04
44         char                            name[];                         // 0x06
45 };
46
47 struct __attribute__((packed)) dirent_suffix {
48         unsigned char           __eos;                                  // end of string NUL
49         uint32_t                        __unknown00;                    // 0x01 after end of directory_entry_prefix
50 };
51
52 struct __attribute__((packed)) fileent_prefix {
53         uint8_t                         __unknown00;
54         uint16_t                        dir_index;
55         uint32_t                        file_bytes;
56         uint32_t                        payload_bytes;
57         uint32_t                        payload_offset;
58         uint16_t                        datestamp;
59         uint16_t                        timestamp;
60         uint32_t                        __unknown13;
61         uint16_t                        entry_bytes;
62         uint32_t                        __unknown01;
63         uint8_t                         name_bytes;
64         char                            name[];
65 };
66
67 struct __attribute__((packed)) fileent_suffix {
68         uint32_t                        __unkown00;
69         uint32_t                        __unkown04;
70         uint32_t                        __unkown08;
71 };
72
73 struct dirent {
74         struct dirent_prefix *entry;
75         bool                            created;
76 };
77
78 struct ll_fileents {
79         struct fileent_prefix *entry;
80         struct ll_fileents *next;
81 };