Add decompression support using the implode library
[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         uint32_t                __crc32;                                        // 0x0E
24         uint32_t                file_bytes;                                     // 0x12
25         uint32_t                payload_bytes;                          // 0x16
26         uint8_t                 __known1A;                                      // 0x1A
27         uint16_t                __unknown1B;                            // 0x1B
28         uint32_t                __unknown1D;                            // 0x1D
29         uint32_t                __unknown21;                            // 0x21
30         uint32_t                __unknown25;                            // 0x25
31         uint32_t                directories_offset;                     // 0x29
32         uint32_t                directories_bytes;                      // 0x2D
33         uint16_t                directories_entries;            // 0x31
34         uint32_t                files_offset;                           // 0x33
35         uint32_t                files_bytes;                            // 0x37
36         unsigned char   unknown3B[0x100 - 0x3B];        // 0x3B to 0xFF
37 };
38
39 struct __attribute__((packed)) dirent_prefix {
40         uint16_t                        __flags;                        // 0x00
41         uint16_t                        entry_bytes;            // 0x02
42         uint16_t                        name_bytes;                     // 0x04
43         char                            name[];                         // 0x06
44 };
45
46 struct __attribute__((packed)) dirent_suffix {
47         unsigned char           __eos;                                  // end of string NUL
48         uint32_t                        __unknown00;                    // 0x01 after end of directory_entry_prefix
49 };
50
51 struct __attribute__((packed)) fileent_prefix {
52         uint8_t                         __unknown00;
53         uint16_t                        dir_index;
54         uint32_t                        file_bytes;
55         uint32_t                        payload_bytes;
56         uint32_t                        payload_offset;
57         uint32_t                        __crc32;
58         uint32_t                        __unknown13;
59         uint16_t                        entry_bytes;
60         uint32_t                        __unknown01;
61         uint8_t                         name_bytes;
62         char                            name[];
63 };
64
65 struct __attribute__((packed)) fileent_suffix {
66         uint32_t                        __unkown00;
67         uint32_t                        __unkown04;
68         uint32_t                        __unkown08;
69 };
70
71 struct dirent {
72         struct dirent_prefix *entry;
73         bool                            created;
74 };
75
76 struct ll_fileents {
77         struct fileent_prefix *entry;
78         struct ll_fileents *next;
79 };