ReactOS  0.4.14-dev-599-g2d4d3f5
chm.h
Go to the documentation of this file.
1 /*
2 
3  Copyright (C) 2010 Alex Andreotti <alex.andreotti@gmail.com>
4 
5  This file is part of chmc.
6 
7  chmc is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  chmc is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with chmc. If not, see <http://www.gnu.org/licenses/>.
19 
20  NOTE this file is mainly based on chm_lib.c from chmLib by Jed Wing
21  http://www.jedrea.com/chmlib/
22 
23 */
24 #ifndef CHMC_CHM_H
25 #define CHMC_CHM_H
26 
27 /*
28  * architecture specific defines
29  *
30  * Note: as soon as C99 is more widespread, the below defines should
31  * probably just use the C99 sized-int types.
32  *
33  * The following settings will probably work for many platforms. The sizes
34  * don't have to be exactly correct, but the types must accommodate at least as
35  * many bits as they specify.
36  */
37 
38 /* i386, 32-bit/64-bit, Windows */
39 #ifdef _MSC_VER
40 typedef unsigned char UChar;
41 typedef __int16 Int16;
42 typedef unsigned __int16 UInt16;
43 typedef __int32 Int32;
44 typedef unsigned __int32 UInt32;
45 typedef __int64 Int64;
46 typedef unsigned __int64 UInt64;
47 
48 /* I386, 32-bit, non-Windows */
49 /* Sparc */
50 /* MIPS */
51 /* PPC */
52 #elif __i386__ || __sun || __sgi || __ppc__
53 typedef unsigned char UChar;
54 typedef short Int16;
55 typedef unsigned short UInt16;
56 typedef long Int32;
57 typedef unsigned long UInt32;
58 typedef long long Int64;
59 typedef unsigned long long UInt64;
60 
61 /* x86-64 */
62 /* Note that these may be appropriate for other 64-bit machines. */
63 #elif __x86_64__ || __ia64__
64 typedef unsigned char UChar;
65 typedef short Int16;
66 typedef unsigned short UInt16;
67 typedef int Int32;
68 typedef unsigned int UInt32;
69 typedef long Int64;
70 typedef unsigned long UInt64;
71 
72 #else
73 
74 /* yielding an error is preferable to yielding incorrect behavior */
75 #error "Please define the sized types for your platform"
76 #endif
77 
78 /* GCC */
79 #ifdef __GNUC__
80 #define memcmp __builtin_memcmp
81 #define memset __builtin_memset
82 #define memcpy __builtin_memcpy
83 #define strlen __builtin_strlen
84 #endif
85 
86 #define _CHMC_ITSF_V3_LEN (0x60)
88  char signature[4]; /* 0 (ITSF) */
89  Int32 version; /* 4 */
90  Int32 header_len; /* 8 */
93  UInt32 lang_id; /* 14 */
94  UChar dir_uuid[16]; /* 18 */
95  UChar stream_uuid[16]; /* 28 */
96  UInt64 sect0_offset; /* 38 */
97  UInt64 sect0_len; /* 40 */
98  UInt64 dir_offset; /* 48 */
99  UInt64 dir_len; /* 50 */
100  UInt64 data_offset; /* 58 (Not present before V3) */
101 }; /* __attribute__ ((aligned (1))); */
102 
103 #define _CHMC_SECT0_LEN (0x18)
104 struct chmcSect0 {
107  UInt64 file_len; /* 8 */
108  Int32 unknown_0010; /* 10 */
109  Int32 unknown_0014; /* 14 */
110 };
111 
112 #define CHM_IDX_INTVL 2
113 
114 /* structure of ITSP headers */
115 #define _CHMC_ITSP_V1_LEN (0x54)
117  char signature[4]; /* 0 (ITSP) */
118  Int32 version; /* 4 */
119  Int32 header_len; /* 8 */
121  UInt32 block_len; /* 10 */
123  Int32 index_depth; /* 18 */
124  Int32 index_root; /* 1c */
125  Int32 index_head; /* 20 */
126  Int32 index_last; /* 24 */
127  Int32 unknown_0028; /* 28 */
128  UInt32 num_blocks; /* 2c */
129  UInt32 lang_id; /* 30 */
130  UChar system_uuid[16]; /* 34 */
131  UInt32 header_len2; /* 44 */
132  UChar unknown_0048[12]; /* 48 */
133 }; /* __attribute__ ((aligned (1))); */
134 
135 /* structure of PMGL headers */
136 #define _CHMC_PMGL_LEN (0x14)
138 {
139  char signature[4]; /* 0 (PMGL) */
142  Int32 block_prev; /* c */
143  Int32 block_next; /* 10 */
144 }; /* __attribute__ ((aligned (1))); */
145 
146 #define _CHMC_PMGI_LEN (0x08)
148  char signature[4]; /* 0 (PMGI) */
150 }; /* __attribute__ ((aligned (1))); */
151 
152 /* structure of LZXC reset table */
153 #define _CHMC_LZXC_RESETTABLE_V1_LEN (0x28)
162 }; /* __attribute__ ((aligned (1))); */
163 
164 /* structure of LZXC control data block */
165 #define _CHMC_LZXC_MIN_LEN (0x18)
166 #define _CHMC_LZXC_V2_LEN (0x1c)
168  UInt32 size; /* 0 */
169  char signature[4]; /* 4 (LZXC) */
170  UInt32 version; /* 8 */
172  UInt32 windowSize; /* 10 */
174  UInt32 unknown_18; /* 18 */
175 };
176 
177 #endif /* CHMC_CHM_H */
Int32 unknown_0004
Definition: chm.h:106
UInt32 unknown_18
Definition: chm.h:174
UInt64 uncompressed_len
Definition: chm.h:159
Int32 header_len
Definition: chm.h:90
UInt32 lang_id
Definition: chm.h:93
DWORD UInt32
Definition: chm_lib.c:104
Int32 index_last
Definition: chm.h:126
ULONGLONG UInt64
Definition: chm_lib.c:106
UInt32 size
Definition: chm.h:168
UInt64 compressed_len
Definition: chm.h:160
BYTE UChar
Definition: chm_lib.c:100
UInt32 windowsPerReset
Definition: chm.h:173
UInt64 block_len
Definition: chm.h:161
USHORT UInt16
Definition: chm_lib.c:102
Int32 unknown_0014
Definition: chm.h:109
UInt32 free_space
Definition: chm.h:149
UInt32 unknown_0008
Definition: chm.h:141
UInt32 block_count
Definition: chm.h:156
Int32 unknown_000c
Definition: chm.h:91
Int32 block_prev
Definition: chm.h:142
UInt32 entry_size
Definition: chm.h:157
UInt32 lang_id
Definition: chm.h:129
Int32 unknown_000c
Definition: chm.h:120
char signature[4]
Definition: chm.h:117
Int32 unknown_0028
Definition: chm.h:127
char signature[4]
Definition: chm.h:88
UInt64 sect0_offset
Definition: chm.h:96
UInt32 free_space
Definition: chm.h:140
UInt32 version
Definition: chm.h:155
Int32 version
Definition: chm.h:118
UInt32 last_modified
Definition: chm.h:92
UInt32 version
Definition: chm.h:170
UChar stream_uuid[16]
Definition: chm.h:95
Int32 unknown_0010
Definition: chm.h:108
Definition: chm.h:104
UInt32 block_len
Definition: chm.h:121
Int32 header_len
Definition: chm.h:119
UInt64 dir_len
Definition: chm.h:99
char signature[4]
Definition: chm.h:169
UChar system_uuid[16]
Definition: chm.h:130
Int32 unknown_0000
Definition: chm.h:105
UInt64 sect0_len
Definition: chm.h:97
Int32 index_head
Definition: chm.h:125
LONGLONG Int64
Definition: chm_lib.c:105
UInt32 header_len2
Definition: chm.h:131
Int32 block_next
Definition: chm.h:143
#define __int32
Definition: basetyps.h:19
Int32 index_root
Definition: chm.h:124
SHORT Int16
Definition: chm_lib.c:101
Int32 blockidx_intvl
Definition: chm.h:122
UInt64 data_offset
Definition: chm.h:100
UInt64 file_len
Definition: chm.h:107
UChar dir_uuid[16]
Definition: chm.h:94
LONG Int32
Definition: chm_lib.c:103
UInt32 windowSize
Definition: chm.h:172
Int32 version
Definition: chm.h:89
UInt32 resetInterval
Definition: chm.h:171
Int32 index_depth
Definition: chm.h:123
char signature[4]
Definition: chm.h:148
UInt64 dir_offset
Definition: chm.h:98
UInt32 num_blocks
Definition: chm.h:128
UChar unknown_0048[12]
Definition: chm.h:132
char signature[4]
Definition: chm.h:139
UInt32 table_offset
Definition: chm.h:158
#define __int64
Definition: basetyps.h:16
#define __int16
Definition: basetyps.h:22