1c2c66affSColin Finck /*
2c2c66affSColin Finck  * PROJECT:     apphelp_apitest
3c2c66affSColin Finck  * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4c2c66affSColin Finck  * PURPOSE:     Common data / functions for apphelp_apitest
58bbbab53SMark Jansen  * COPYRIGHT:   Copyright 2015-2018 Mark Jansen (mark.jansen@reactos.org)
6c2c66affSColin Finck  */
7c2c66affSColin Finck 
8c2c66affSColin Finck #include <exdisp.h>
9c2c66affSColin Finck #include <winbase.h>
10c2c66affSColin Finck #include "wine/test.h"
11c2c66affSColin Finck 
12c2c66affSColin Finck 
13c2c66affSColin Finck static IMAGE_DOS_HEADER dos_header =
14c2c66affSColin Finck {
15c2c66affSColin Finck     IMAGE_DOS_SIGNATURE, /* e_magic */
16c2c66affSColin Finck     144, /* e_cblp */
17c2c66affSColin Finck     3, /* e_cp */
18c2c66affSColin Finck     0, /* e_crlc */
19c2c66affSColin Finck     4, /* e_cparhdr */
20c2c66affSColin Finck     0, /* e_minalloc */
21c2c66affSColin Finck     65535, /* e_maxalloc */
22c2c66affSColin Finck     0, /* e_ss */
23c2c66affSColin Finck     184, /* e_sp */
24c2c66affSColin Finck     0, /* e_csum */
25c2c66affSColin Finck     0, /* e_ip */
26c2c66affSColin Finck     0, /* e_cs */
27c2c66affSColin Finck     64, /* e_lfarlc */
28c2c66affSColin Finck     0, /* e_ovno */
29c2c66affSColin Finck     { 0 }, /* e_res[4] */
30c2c66affSColin Finck     0, /* e_oemid */
31c2c66affSColin Finck     0, /* e_oeminfo */
32c2c66affSColin Finck     { 0 }, /* e_res2[10] */
33c2c66affSColin Finck     0x80 /* e_lfanew */
34c2c66affSColin Finck };
35c2c66affSColin Finck 
36c2c66affSColin Finck static IMAGE_NT_HEADERS32 nt_header =
37c2c66affSColin Finck {
38c2c66affSColin Finck     IMAGE_NT_SIGNATURE, /* Signature */
39c2c66affSColin Finck     {
40c2c66affSColin Finck         IMAGE_FILE_MACHINE_I386, /* Machine */
41c2c66affSColin Finck         2, /* NumberOfSections */
42c2c66affSColin Finck         0x12345, /* TimeDateStamp */
43c2c66affSColin Finck         0, /* PointerToSymbolTable */
44c2c66affSColin Finck         0, /* NumberOfSymbols */
45c2c66affSColin Finck         sizeof(IMAGE_OPTIONAL_HEADER), /* SizeOfOptionalHeader */
46c2c66affSColin Finck         IMAGE_FILE_RELOCS_STRIPPED | IMAGE_FILE_EXECUTABLE_IMAGE | IMAGE_FILE_LINE_NUMS_STRIPPED | IMAGE_FILE_32BIT_MACHINE /* Characteristics */
47c2c66affSColin Finck     },
48c2c66affSColin Finck     {
49c2c66affSColin Finck         IMAGE_NT_OPTIONAL_HDR_MAGIC, /* Magic */
50c2c66affSColin Finck         6, /* MajorLinkerVersion */
51c2c66affSColin Finck         3, /* MinorLinkerVersion */
52c2c66affSColin Finck         0, /* SizeOfCode */
53c2c66affSColin Finck         0, /* SizeOfInitializedData */
54c2c66affSColin Finck         0, /* SizeOfUninitializedData */
55c2c66affSColin Finck         0x1000, /* AddressOfEntryPoint */
56c2c66affSColin Finck         0x1000, /* BaseOfCode */
57c2c66affSColin Finck         0, /* BaseOfData */
58c2c66affSColin Finck         0x400000, /* ImageBase */
59c2c66affSColin Finck         0x1000, /* SectionAlignment */
60c2c66affSColin Finck         0x200, /* FileAlignment */
61c2c66affSColin Finck         4, /* MajorOperatingSystemVersion */
62c2c66affSColin Finck         1, /* MinorOperatingSystemVersion */
63c2c66affSColin Finck         4, /* MajorImageVersion */
64c2c66affSColin Finck         2, /* MinorImageVersion */
65c2c66affSColin Finck         4, /* MajorSubsystemVersion */
66c2c66affSColin Finck         3, /* MinorSubsystemVersion */
67c2c66affSColin Finck         0, /* Win32VersionValue */
68c2c66affSColin Finck         0x3000, /* SizeOfImage */
69c2c66affSColin Finck         0x200, /* SizeOfHeaders */
70c2c66affSColin Finck         0xBAAD, /* CheckSum: This checksum is not the correct checksum, intentionally! */
71c2c66affSColin Finck         IMAGE_SUBSYSTEM_WINDOWS_CUI, /* Subsystem */
72c2c66affSColin Finck         0, /* DllCharacteristics */
73c2c66affSColin Finck         0x100000, /* SizeOfStackReserve */
74c2c66affSColin Finck         0x1000, /* SizeOfStackCommit */
75c2c66affSColin Finck         0x100000, /* SizeOfHeapReserve */
76c2c66affSColin Finck         0x1000, /* SizeOfHeapCommit */
77c2c66affSColin Finck         0, /* LoaderFlags */
78c2c66affSColin Finck         0x10, /* NumberOfRvaAndSizes */
79c2c66affSColin Finck         {
80c2c66affSColin Finck             /* IMAGE_DIRECTORY_ENTRY_EXPORT */
81c2c66affSColin Finck             {
82c2c66affSColin Finck                 0x2370, /* VirtualAddress */
83c2c66affSColin Finck                 76, /* Size */
84c2c66affSColin Finck             },
85c2c66affSColin Finck             { 0 },
86c2c66affSColin Finck             /* IMAGE_DIRECTORY_ENTRY_RESOURCE */
87c2c66affSColin Finck             {
88c2c66affSColin Finck                 0x2000, /* VirtualAddress */
89c2c66affSColin Finck                 868, /* Size */
90c2c66affSColin Finck             },
91c2c66affSColin Finck         } /* DataDirectory[IMAGE_NUMBEROF_DIRECTORY_ENTRIES] */
92c2c66affSColin Finck     }
93c2c66affSColin Finck };
94c2c66affSColin Finck 
95c2c66affSColin Finck static IMAGE_SECTION_HEADER section_headers[] =
96c2c66affSColin Finck {
97c2c66affSColin Finck     {
98c2c66affSColin Finck         { '.','t','e','x','t',0 }, /* Name */
99c2c66affSColin Finck         { 24 }, /* VirtualSize */
100c2c66affSColin Finck         0x1000, /* VirtualAddress */
101c2c66affSColin Finck         0x200, /* SizeOfRawData */
102c2c66affSColin Finck         0x200, /* PointerToRawData */
103c2c66affSColin Finck         0, /* PointerToRelocations */
104c2c66affSColin Finck         0, /* PointerToLinenumbers */
105c2c66affSColin Finck         0, /* NumberOfRelocations */
106c2c66affSColin Finck         0, /* NumberOfLinenumbers */
107c2c66affSColin Finck         IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ /* Characteristics */
108c2c66affSColin Finck     },
109c2c66affSColin Finck     {
110c2c66affSColin Finck         { '.','r','s','r','c',0 }, /* Name */
111c2c66affSColin Finck         { 880 }, /* VirtualSize */
112c2c66affSColin Finck         0x2000, /* VirtualAddress */
113c2c66affSColin Finck         0x400, /* SizeOfRawData */
114c2c66affSColin Finck         0x400, /* PointerToRawData */
115c2c66affSColin Finck         0, /* PointerToRelocations */
116c2c66affSColin Finck         0, /* PointerToLinenumbers */
117c2c66affSColin Finck         0, /* NumberOfRelocations */
118c2c66affSColin Finck         0, /* NumberOfLinenumbers */
119c2c66affSColin Finck         IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ /* Characteristics */
120c2c66affSColin Finck     }
121c2c66affSColin Finck };
122c2c66affSColin Finck 
123c2c66affSColin Finck static const unsigned char text_section[] =
124c2c66affSColin Finck {
125c2c66affSColin Finck     0x33, 0xc0,     /* xor eax, eax */
126c2c66affSColin Finck     0xc3            /* ret */
127c2c66affSColin Finck };
128c2c66affSColin Finck 
129c2c66affSColin Finck 
130c2c66affSColin Finck /* taken from fusionpriv.h */
131c2c66affSColin Finck typedef struct
132c2c66affSColin Finck {
133c2c66affSColin Finck     WORD wLength;
134c2c66affSColin Finck     WORD wValueLength;
135c2c66affSColin Finck     WORD wType;
136c2c66affSColin Finck     WCHAR szKey[17];
137c2c66affSColin Finck     VS_FIXEDFILEINFO Value;
138c2c66affSColin Finck } VS_VERSIONINFO;
139c2c66affSColin Finck 
140c2c66affSColin Finck typedef struct
141c2c66affSColin Finck {
142c2c66affSColin Finck     WORD wLength;
143c2c66affSColin Finck     WORD wValueLength;
144c2c66affSColin Finck     WORD wType;
145c2c66affSColin Finck     WCHAR szKey[15];
146c2c66affSColin Finck } STRINGFILEINFO;
147c2c66affSColin Finck 
148c2c66affSColin Finck typedef struct
149c2c66affSColin Finck {
150c2c66affSColin Finck     WORD wLength;
151c2c66affSColin Finck     WORD wValueLength;
152c2c66affSColin Finck     WORD wType;
153c2c66affSColin Finck     WCHAR szKey[9];
154c2c66affSColin Finck } STRINGTABLE;
155c2c66affSColin Finck 
156c2c66affSColin Finck typedef struct
157c2c66affSColin Finck {
158c2c66affSColin Finck     WORD wLength;
159c2c66affSColin Finck     WORD wValueLength;
160c2c66affSColin Finck     WORD wType;
161c2c66affSColin Finck } STRINGHDR;
162c2c66affSColin Finck 
163c2c66affSColin Finck typedef struct
164c2c66affSColin Finck {
165c2c66affSColin Finck     WORD wLength;
166c2c66affSColin Finck     WORD wValueLength;
167c2c66affSColin Finck     WORD wType;
168c2c66affSColin Finck     WCHAR szKey[13];
169c2c66affSColin Finck } VARFILEINFO;
170c2c66affSColin Finck 
171c2c66affSColin Finck typedef struct
172c2c66affSColin Finck {
173c2c66affSColin Finck     WORD wLength;
174c2c66affSColin Finck     WORD wValueLength;
175c2c66affSColin Finck     WORD wType;
176c2c66affSColin Finck     WCHAR szKey[13];
177c2c66affSColin Finck     DWORD Value;
178c2c66affSColin Finck } VAR;
179c2c66affSColin Finck 
180c2c66affSColin Finck typedef struct rsrc_section_t
181c2c66affSColin Finck {
182c2c66affSColin Finck     IMAGE_RESOURCE_DIRECTORY header;
183c2c66affSColin Finck     IMAGE_RESOURCE_DIRECTORY_ENTRY file_info_id;
184c2c66affSColin Finck     IMAGE_RESOURCE_DIRECTORY file_info_header;
185c2c66affSColin Finck     IMAGE_RESOURCE_DIRECTORY_ENTRY version_info_id;
186c2c66affSColin Finck     IMAGE_RESOURCE_DIRECTORY version_info_header;
187c2c66affSColin Finck     IMAGE_RESOURCE_DIRECTORY_ENTRY version_lang_id;
188c2c66affSColin Finck     IMAGE_RESOURCE_DATA_ENTRY version_data_entry;
189c2c66affSColin Finck 
190c2c66affSColin Finck     VS_VERSIONINFO version_info;
191c2c66affSColin Finck     STRINGFILEINFO string_file_info;
192c2c66affSColin Finck     STRINGTABLE string_table;
193c2c66affSColin Finck 
194c2c66affSColin Finck     STRINGHDR FileVersion_hdr;
195c2c66affSColin Finck     WCHAR FileVersion_key[13];
196c2c66affSColin Finck     WCHAR FileVersion_val[8];
197c2c66affSColin Finck 
198c2c66affSColin Finck     STRINGHDR ProductVersion_hdr;
199c2c66affSColin Finck     WCHAR ProductVersion_key[15];
200c2c66affSColin Finck     WCHAR ProductVersion_val[8];
201c2c66affSColin Finck 
202c2c66affSColin Finck     STRINGHDR CompanyName_hdr;
203c2c66affSColin Finck     WCHAR CompanyName_key[13];
204c2c66affSColin Finck     WCHAR CompanyName_val[12];
205c2c66affSColin Finck 
206c2c66affSColin Finck     STRINGHDR FileDescription_hdr;
207c2c66affSColin Finck     WCHAR FileDescription_key[17];
208c2c66affSColin Finck     WCHAR FileDescription_val[16];
209c2c66affSColin Finck 
210c2c66affSColin Finck     STRINGHDR InternalName_hdr;
211c2c66affSColin Finck     WCHAR InternalName_key[13];
212c2c66affSColin Finck     WCHAR InternalName_val[14];
213c2c66affSColin Finck 
214c2c66affSColin Finck     STRINGHDR LegalCopyright_hdr;
215c2c66affSColin Finck     WCHAR LegalCopyright_key[15];
216c2c66affSColin Finck     WCHAR LegalCopyright_val[16];
217c2c66affSColin Finck 
218c2c66affSColin Finck     STRINGHDR LegalTrademarks_hdr;
219c2c66affSColin Finck     WCHAR LegalTrademarks_key[17];
220c2c66affSColin Finck     WCHAR LegalTrademarks_val[16];
221c2c66affSColin Finck 
222c2c66affSColin Finck     STRINGHDR OriginalFilename_hdr;
223c2c66affSColin Finck     WCHAR OriginalFilename_key[17];
224c2c66affSColin Finck     WCHAR OriginalFilename_val[18];
225c2c66affSColin Finck 
226c2c66affSColin Finck     STRINGHDR Productname_hdr;
227c2c66affSColin Finck     WCHAR Productname_key[13];
228c2c66affSColin Finck     WCHAR Productname_val[12];
229c2c66affSColin Finck 
230c2c66affSColin Finck     VARFILEINFO file_info;
231c2c66affSColin Finck     VAR translation;
232c2c66affSColin Finck } rsrc_section_t;
233c2c66affSColin Finck 
2348bbbab53SMark Jansen #define    RT_VERSION_DW       16
235c2c66affSColin Finck static const rsrc_section_t rsrc_section =
236c2c66affSColin Finck {
237c2c66affSColin Finck     /* header */
238c2c66affSColin Finck     {
239c2c66affSColin Finck         0, /* Characteristics */
240c2c66affSColin Finck         0x55FE8E21, /* TimeDateStamp, 20/09/2015 10:44:49 */
241c2c66affSColin Finck         0, /* MajorVersion */
242c2c66affSColin Finck         0, /* MinorVersion */
243c2c66affSColin Finck         0, /* NumberOfNamedEntries */
244c2c66affSColin Finck         1, /* NumberOfIdEntries */
245c2c66affSColin Finck     },
246c2c66affSColin Finck     /* file_info_id */
247c2c66affSColin Finck     {
248c2c66affSColin Finck         {{
2498bbbab53SMark Jansen                 RT_VERSION_DW, /* NameOffset:31 */
250c2c66affSColin Finck             0 /* NameIsString:1 */
251c2c66affSColin Finck         }},
252c2c66affSColin Finck         {
253c2c66affSColin Finck             0x80000018 /* OffsetToData */
254c2c66affSColin Finck         }
255c2c66affSColin Finck     },
256c2c66affSColin Finck     /* file_info_header */
257c2c66affSColin Finck     {
258c2c66affSColin Finck         0, /* Characteristics */
259c2c66affSColin Finck         0x55FE8E21, /* TimeDateStamp, 20/09/2015 10:44:49 */
260c2c66affSColin Finck         0, /* MajorVersion */
261c2c66affSColin Finck         0, /* MinorVersion */
262c2c66affSColin Finck         0, /* NumberOfNamedEntries */
263c2c66affSColin Finck         1, /* NumberOfIdEntries */
264c2c66affSColin Finck     },
265c2c66affSColin Finck     /* version_info_id */
266c2c66affSColin Finck     {
267c2c66affSColin Finck         {{
268c2c66affSColin Finck             VS_VERSION_INFO, /* NameOffset:31 */
269c2c66affSColin Finck             0 /* NameIsString:1 */
270c2c66affSColin Finck         }},
271c2c66affSColin Finck         {
272c2c66affSColin Finck             0x80000030 /* OffsetToData */
273c2c66affSColin Finck         },
274c2c66affSColin Finck     },
275c2c66affSColin Finck     /* version_info_header */
276c2c66affSColin Finck     {
277c2c66affSColin Finck         0, /* Characteristics */
278c2c66affSColin Finck         0x55FE8E21, /* TimeDateStamp, 20/09/2015 10:44:49 */
279c2c66affSColin Finck         0, /* MajorVersion */
280c2c66affSColin Finck         0, /* MinorVersion */
281c2c66affSColin Finck         0, /* NumberOfNamedEntries */
282c2c66affSColin Finck         1, /* NumberOfIdEntries */
283c2c66affSColin Finck     },
284c2c66affSColin Finck     /* version_lang_id */
285c2c66affSColin Finck     {
286c2c66affSColin Finck         {{
287c2c66affSColin Finck             1033, /* NameOffset:31 */
288c2c66affSColin Finck             0 /* NameIsString:1 */
289c2c66affSColin Finck         }},
290c2c66affSColin Finck         {
291c2c66affSColin Finck             0x48 /* OffsetToDirectory */
292c2c66affSColin Finck         }
293c2c66affSColin Finck     },
294c2c66affSColin Finck     /* version_data_entry */
295c2c66affSColin Finck     {
296c2c66affSColin Finck         0x2058, /* OffsetToData */
297c2c66affSColin Finck         0x30C, /* Size */
298c2c66affSColin Finck         0, /* CodePage */
299c2c66affSColin Finck         0, /* Reserved */
300c2c66affSColin Finck     },
301c2c66affSColin Finck 
302c2c66affSColin Finck     /* version_info */
303c2c66affSColin Finck     {
304c2c66affSColin Finck     0x30C, /* wLength */
305c2c66affSColin Finck     0x34, /* wValueLength */
306c2c66affSColin Finck     0, /* wType: Binary */
307c2c66affSColin Finck     { 'V','S','_','V','E','R','S','I','O','N','_','I','N','F','O','\0','\0' }, /* szKey[17] */
308c2c66affSColin Finck         /* Value */
309c2c66affSColin Finck         {
310c2c66affSColin Finck             0xFEEF04BD, /* dwSignature */
311c2c66affSColin Finck             0x10000, /* dwStrucVersion */
312c2c66affSColin Finck             0x10000, /* dwFileVersionMS */
313c2c66affSColin Finck             0, /* dwFileVersionLS */
314c2c66affSColin Finck             0x10000, /* dwProductVersionMS */
315c2c66affSColin Finck             1, /* dwProductVersionLS */
316c2c66affSColin Finck             0, /* dwFileFlagsMask */
317c2c66affSColin Finck             0, /* dwFileFlags */
318c2c66affSColin Finck             VOS__WINDOWS32, /* dwFileOS */
319c2c66affSColin Finck             VFT_APP, /* dwFileType */
320c2c66affSColin Finck             0, /* dwFileSubtype */
321c2c66affSColin Finck             0x01d1a019, /* dwFileDateMS */
322c2c66affSColin Finck             0xac754c50 /* dwFileDateLS */
323c2c66affSColin Finck         },
324c2c66affSColin Finck     },
325c2c66affSColin Finck 
326c2c66affSColin Finck     /* string_file_info */
327c2c66affSColin Finck     {
328c2c66affSColin Finck         0x26C, /* wLength */
329c2c66affSColin Finck         0, /* wValueLength */
330c2c66affSColin Finck         1, /* wType: Text */
331c2c66affSColin Finck         { 'S','t','r','i','n','g','F','i','l','e','I','n','f','o','\0' } /* szKey[15] */
332c2c66affSColin Finck     },
333c2c66affSColin Finck     /* string_table */
334c2c66affSColin Finck     {
335c2c66affSColin Finck         0x248, /* wLength */
336c2c66affSColin Finck         0, /* wValueLength */
337c2c66affSColin Finck         1, /* wType: Text */
338c2c66affSColin Finck         { 'F','F','F','F','0','0','0','0','\0' } /* szKey[9] */
339c2c66affSColin Finck     },
340c2c66affSColin Finck 
341c2c66affSColin Finck     /* FileVersion */
342c2c66affSColin Finck     {
343c2c66affSColin Finck         48, /* wLength */
344c2c66affSColin Finck         8, /* wValueLength */
345c2c66affSColin Finck         1, /* wType: Text */
346c2c66affSColin Finck     },
347c2c66affSColin Finck     { 'F','i','l','e','V','e','r','s','i','o','n','\0' },
348c2c66affSColin Finck     { '1','.','0','.','0','.','0','\0' },
349c2c66affSColin Finck 
350c2c66affSColin Finck     /* ProductVersion */
351c2c66affSColin Finck     {
352c2c66affSColin Finck         52, /* wLength */
353c2c66affSColin Finck         8, /* wValueLength */
354c2c66affSColin Finck         1, /* wType: Text */
355c2c66affSColin Finck     },
356c2c66affSColin Finck     { 'P','r','o','d','u','c','t','V','e','r','s','i','o','n','\0' },
357c2c66affSColin Finck     { '1','.','0','.','0','.','1','\0' },
358c2c66affSColin Finck 
359c2c66affSColin Finck     /* CompanyName */
360c2c66affSColin Finck     {
361c2c66affSColin Finck         56, /* wLength */
362c2c66affSColin Finck         12, /* wValueLength */
363c2c66affSColin Finck         1, /* wType: Text */
364c2c66affSColin Finck     },
365c2c66affSColin Finck     { 'C','o','m','p','a','n','y','N','a','m','e','\0' },
366c2c66affSColin Finck     { 'C','o','m','p','a','n','y','N','a','m','e','\0' },
367c2c66affSColin Finck 
368c2c66affSColin Finck     /* FileDescription */
369c2c66affSColin Finck     {
370c2c66affSColin Finck         72, /* wLength */
371c2c66affSColin Finck         16, /* wValueLength */
372c2c66affSColin Finck         1, /* wType: Text */
373c2c66affSColin Finck     },
374c2c66affSColin Finck     { 'F','i','l','e','D','e','s','c','r','i','p','t','i','o','n','\0' },
375c2c66affSColin Finck     { 'F','i','l','e','D','e','s','c','r','i','p','t','i','o','n','\0' },
376c2c66affSColin Finck 
377c2c66affSColin Finck     /* InternalName */
378c2c66affSColin Finck     {
379c2c66affSColin Finck         58, /* wLength */
380c2c66affSColin Finck         13, /* wValueLength */
381c2c66affSColin Finck         1, /* wType: Text */
382c2c66affSColin Finck     },
383c2c66affSColin Finck     { 'I','n','t','e','r','n','a','l','N','a','m','e','\0' },
384c2c66affSColin Finck     { 'I','n','t','e','r','n','a','l','N','a','m','e','\0' },
385c2c66affSColin Finck 
386c2c66affSColin Finck     /* LegalCopyright */
387c2c66affSColin Finck     {
388c2c66affSColin Finck         66, /* wLength */
389c2c66affSColin Finck         15, /* wValueLength */
390c2c66affSColin Finck         1, /* wType: Text */
391c2c66affSColin Finck     },
392c2c66affSColin Finck     { 'L','e','g','a','l','C','o','p','y','r','i','g','h','t','\0' },
393c2c66affSColin Finck     { 'L','e','g','a','l','C','o','p','y','r','i','g','h','t','\0' },
394c2c66affSColin Finck 
395c2c66affSColin Finck     /* LegalTrademarks */
396c2c66affSColin Finck     {
397c2c66affSColin Finck         72, /* wLength */
398c2c66affSColin Finck         16, /* wValueLength */
399c2c66affSColin Finck         1, /* wType: Text */
400c2c66affSColin Finck     },
401c2c66affSColin Finck     { 'L','e','g','a','l','T','r','a','d','e','m','a','r','k','s','\0' },
402c2c66affSColin Finck     { 'L','e','g','a','l','T','r','a','d','e','m','a','r','k','s','\0' },
403c2c66affSColin Finck 
404c2c66affSColin Finck     /* OriginalFilename */
405c2c66affSColin Finck     {
406c2c66affSColin Finck         74, /* wLength */
407c2c66affSColin Finck         17, /* wValueLength */
408c2c66affSColin Finck         1, /* wType: Text */
409c2c66affSColin Finck     },
410c2c66affSColin Finck     { 'O','r','i','g','i','n','a','l','F','i','l','e','n','a','m','e','\0' },
411c2c66affSColin Finck     { 'O','r','i','g','i','n','a','l','F','i','l','e','n','a','m','e','\0' },
412c2c66affSColin Finck 
413c2c66affSColin Finck     /* ProductName */
414c2c66affSColin Finck     {
415c2c66affSColin Finck         56, /* wLength */
416c2c66affSColin Finck         12, /* wValueLength */
417c2c66affSColin Finck         1, /* wType: Text */
418c2c66affSColin Finck     },
419c2c66affSColin Finck     { 'P','r','o','d','u','c','t','N','a','m','e','\0' },
420c2c66affSColin Finck     { 'P','r','o','d','u','c','t','N','a','m','e','\0' },
421c2c66affSColin Finck 
422c2c66affSColin Finck 
423c2c66affSColin Finck     /* file_info */
424c2c66affSColin Finck     {
425c2c66affSColin Finck         0x44, /* wLength */
426c2c66affSColin Finck         0, /* wValueLength */
427c2c66affSColin Finck         1, /* wType: Text */
428c2c66affSColin Finck         { 'V','a','r','F','i','l','e','I','n','f','o','\0' } /* szKey[13] */
429c2c66affSColin Finck     },
430c2c66affSColin Finck 
431c2c66affSColin Finck     /* translation */
432c2c66affSColin Finck     {
433c2c66affSColin Finck         0x24, /* wLength */
434c2c66affSColin Finck         4, /* wValueLength */
435c2c66affSColin Finck         0, /* wType: Binary */
436c2c66affSColin Finck         { 'T','r','a','n','s','l','a','t','i','o','n','\0' }, /* szKey[13] */
437c2c66affSColin Finck         0xffff /* Value */
438c2c66affSColin Finck     }
439c2c66affSColin Finck };
440c2c66affSColin Finck 
441c2c66affSColin Finck typedef struct export_section_t
442c2c66affSColin Finck {
443c2c66affSColin Finck     IMAGE_EXPORT_DIRECTORY desc;
444c2c66affSColin Finck     char binary_name[10];
445c2c66affSColin Finck } export_section_t;
446c2c66affSColin Finck 
447c2c66affSColin Finck /* This export section is not complete, but the Name RVA is only taken into account */
448c2c66affSColin Finck static export_section_t export_dir =
449c2c66affSColin Finck {
450c2c66affSColin Finck     {
451c2c66affSColin Finck         0, /* Characteristics */
452c2c66affSColin Finck         0, /* TimeDateStamp */
453c2c66affSColin Finck         0, /* MajorVersion */
454c2c66affSColin Finck         0, /* MinorVersion */
455c2c66affSColin Finck         0x2398, /* Name (RVA) */
456c2c66affSColin Finck         1, /* Base */
457c2c66affSColin Finck         0, /* NumberOfFunctions */
458c2c66affSColin Finck         0, /* NumberOfNames */
459c2c66affSColin Finck         0, /* AddressOfFunctions (RVA)  */
460c2c66affSColin Finck         0, /* AddressOfNames (RVA) */
461c2c66affSColin Finck         0, /* AddressOfNameOrdinals (RVA) */
462c2c66affSColin Finck     },
463c2c66affSColin Finck     { 'T','e','S','t','2','.','e','x','e',0 }, /* binary_name */
464c2c66affSColin Finck };
465c2c66affSColin Finck 
466c2c66affSColin Finck 
test_create_exe_imp(const WCHAR * name,int skip_rsrc_exports)467c2c66affSColin Finck void test_create_exe_imp(const WCHAR* name, int skip_rsrc_exports)
468c2c66affSColin Finck {
469c2c66affSColin Finck     HANDLE file;
470c2c66affSColin Finck     char *buf, *cur;
471c2c66affSColin Finck     DWORD size = 0x800;
472e7440effSSerge Gautherie 
473c2c66affSColin Finck     buf = malloc(size);
474e7440effSSerge Gautherie     winetest_ok(buf != NULL, "malloc failed\n");
475e7440effSSerge Gautherie     if (buf == NULL)
476e7440effSSerge Gautherie     {
477e7440effSSerge Gautherie         return;
478e7440effSSerge Gautherie     }
479c2c66affSColin Finck 
480c2c66affSColin Finck     file = CreateFileW(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
481c2c66affSColin Finck     winetest_ok(file != INVALID_HANDLE_VALUE, "can't create file\n");
482c2c66affSColin Finck     if (file == INVALID_HANDLE_VALUE)
483e7440effSSerge Gautherie     {
484e7440effSSerge Gautherie         free(buf);
485c2c66affSColin Finck         return;
486e7440effSSerge Gautherie     }
487c2c66affSColin Finck 
488c2c66affSColin Finck     memset(buf, 0, size);
489c2c66affSColin Finck     cur = memcpy(buf, &dos_header, sizeof(dos_header));
490c2c66affSColin Finck     cur += dos_header.e_lfanew;
491c2c66affSColin Finck 
492c2c66affSColin Finck     memcpy(cur, &nt_header, sizeof(nt_header));
493c2c66affSColin Finck     if (skip_rsrc_exports)
494c2c66affSColin Finck     {
495c2c66affSColin Finck         ((IMAGE_NT_HEADERS32*)cur)->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress = 0;
496c2c66affSColin Finck         ((IMAGE_NT_HEADERS32*)cur)->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_RESOURCE].VirtualAddress = 0;
497c2c66affSColin Finck     }
498c2c66affSColin Finck     cur += sizeof(nt_header);
499c2c66affSColin Finck     memcpy(cur, section_headers, sizeof(section_headers));
500c2c66affSColin Finck 
501c2c66affSColin Finck     /* write code section: */
502c2c66affSColin Finck     cur = buf + section_headers[0].PointerToRawData;
503c2c66affSColin Finck     memcpy(cur, text_section, sizeof(text_section));
504c2c66affSColin Finck 
505c2c66affSColin Finck     if (!skip_rsrc_exports)
506c2c66affSColin Finck     {
507c2c66affSColin Finck         /* write resource section: */
508c2c66affSColin Finck         cur = buf + section_headers[1].PointerToRawData;
509c2c66affSColin Finck         memcpy(cur, &rsrc_section, sizeof(rsrc_section));
510c2c66affSColin Finck 
511c2c66affSColin Finck         /* write minimal export directory: */
512c2c66affSColin Finck         cur += 0x370;
513c2c66affSColin Finck         memcpy(cur, &export_dir, sizeof(export_dir));
514c2c66affSColin Finck     }
515c2c66affSColin Finck 
516c2c66affSColin Finck     WriteFile(file, buf, size, &size, NULL);
517c2c66affSColin Finck     free(buf);
518c2c66affSColin Finck     CloseHandle(file);
519c2c66affSColin Finck }
520c2c66affSColin Finck 
521c2c66affSColin Finck 
522c2c66affSColin Finck /* Almost everything in this filetype is ignored, only e_lfanew, ne_restab and ne_nrestab are relevant */
test_create_ne_imp(const WCHAR * name,int skip_names)523c2c66affSColin Finck void test_create_ne_imp(const WCHAR* name, int skip_names)
524c2c66affSColin Finck {
525c2c66affSColin Finck     HANDLE file;
526c2c66affSColin Finck     DWORD size;
527c2c66affSColin Finck     IMAGE_DOS_HEADER MZ_hdr = { IMAGE_DOS_SIGNATURE, 0 };
528c2c66affSColin Finck     IMAGE_OS2_HEADER NE_hdr = { IMAGE_OS2_SIGNATURE, 0 };
529c2c66affSColin Finck     static const BYTE NE_names[] =
530c2c66affSColin Finck     {
531c2c66affSColin Finck         /* Show that the length is used, not the nullterm*/
532c2c66affSColin Finck         11,'T','E','S','T','M','O','D','.','h','X','x','x',0,0,0,
533c2c66affSColin Finck         20,'M','O','D',' ','D','E','S','C','R','I','P','T','I','O','N',' ','H','E','R','E',0,0,0
534c2c66affSColin Finck     };
535c2c66affSColin Finck 
536c2c66affSColin Finck     file = CreateFileW(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
537c2c66affSColin Finck     winetest_ok(file != INVALID_HANDLE_VALUE, "can't create file\n");
538c2c66affSColin Finck     if(file == INVALID_HANDLE_VALUE)
539c2c66affSColin Finck         return;
540c2c66affSColin Finck 
541c2c66affSColin Finck     MZ_hdr.e_lfanew = sizeof(MZ_hdr);
542c2c66affSColin Finck     if (!skip_names)
543c2c66affSColin Finck     {
544c2c66affSColin Finck         NE_hdr.ne_restab = sizeof(NE_hdr);  /* First entry (pascal string + ordinal) = module name */
545c2c66affSColin Finck         NE_hdr.ne_nrestab = sizeof(MZ_hdr) + sizeof(NE_hdr) + 16;  /* First entry (pascal string + ordinal) = module description */
546c2c66affSColin Finck     }
547c2c66affSColin Finck 
548c2c66affSColin Finck     WriteFile(file, &MZ_hdr, sizeof(MZ_hdr), &size, NULL);
549c2c66affSColin Finck     WriteFile(file, &NE_hdr, sizeof(NE_hdr), &size, NULL);
550c2c66affSColin Finck     WriteFile(file, NE_names, sizeof(NE_names), &size, NULL);
551c2c66affSColin Finck 
552c2c66affSColin Finck     CloseHandle(file);
553c2c66affSColin Finck }
554c2c66affSColin Finck 
test_create_file_imp(const WCHAR * name,const char * contents,size_t len)555c2c66affSColin Finck void test_create_file_imp(const WCHAR* name, const char* contents, size_t len)
556c2c66affSColin Finck {
557c2c66affSColin Finck     HANDLE file = CreateFileW(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
558c2c66affSColin Finck     winetest_ok(file != INVALID_HANDLE_VALUE, "can't create file\n");
559c2c66affSColin Finck     if (file != INVALID_HANDLE_VALUE)
560c2c66affSColin Finck     {
561c2c66affSColin Finck         if (contents && len)
562c2c66affSColin Finck         {
563c2c66affSColin Finck             DWORD size;
5648bbbab53SMark Jansen             WriteFile(file, contents, (DWORD)len, &size, NULL);
565c2c66affSColin Finck         }
566c2c66affSColin Finck         CloseHandle(file);
567c2c66affSColin Finck     }
568c2c66affSColin Finck }
569c2c66affSColin Finck 
570c2c66affSColin Finck static unsigned char win10Header[8] = {
571c2c66affSColin Finck     0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
572c2c66affSColin Finck };
573c2c66affSColin Finck static unsigned char rawData[2356] = {
574c2c66affSColin Finck     0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x73, 0x64, 0x62, 0x66,
575c2c66affSColin Finck     0x02, 0x78, 0x3E, 0x01, 0x00, 0x00, 0x03, 0x78, 0x44, 0x00, 0x00, 0x00,
576c2c66affSColin Finck     0x02, 0x38, 0x07, 0x70, 0x03, 0x38, 0x01, 0x60, 0x16, 0x40, 0x01, 0x00,
577c2c66affSColin Finck     0x00, 0x00, 0x01, 0x98, 0x30, 0x00, 0x00, 0x00, 0x4C, 0x4C, 0x41, 0x5F,
578c2c66affSColin Finck     0x54, 0x53, 0x45, 0x54, 0xC6, 0x01, 0x00, 0x00, 0x53, 0x49, 0x44, 0x5F,
579c2c66affSColin Finck     0x54, 0x53, 0x45, 0x54, 0x56, 0x02, 0x00, 0x00, 0x57, 0x45, 0x4E, 0x5F,
580c2c66affSColin Finck     0x54, 0x53, 0x45, 0x54, 0xEC, 0x02, 0x00, 0x00, 0x4B, 0x32, 0x57, 0x5F,
581c2c66affSColin Finck     0x54, 0x53, 0x45, 0x54, 0x7C, 0x03, 0x00, 0x00, 0x03, 0x78, 0x0E, 0x00,
582c2c66affSColin Finck     0x00, 0x00, 0x02, 0x38, 0x07, 0x70, 0x03, 0x38, 0x0B, 0x60, 0x01, 0x98,
583c2c66affSColin Finck     0x00, 0x00, 0x00, 0x00, 0x03, 0x78, 0x0E, 0x00, 0x00, 0x00, 0x02, 0x38,
584c2c66affSColin Finck     0x07, 0x70, 0x03, 0x38, 0x20, 0x60, 0x01, 0x98, 0x00, 0x00, 0x00, 0x00,
585c2c66affSColin Finck     0x03, 0x78, 0x0E, 0x00, 0x00, 0x00, 0x02, 0x38, 0x04, 0x70, 0x03, 0x38,
586c2c66affSColin Finck     0x01, 0x60, 0x01, 0x98, 0x00, 0x00, 0x00, 0x00, 0x03, 0x78, 0x26, 0x00,
587c2c66affSColin Finck     0x00, 0x00, 0x02, 0x38, 0x0D, 0x70, 0x03, 0x38, 0x15, 0x40, 0x01, 0x98,
588c2c66affSColin Finck     0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
589c2c66affSColin Finck     0x74, 0x04, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
590c2c66affSColin Finck     0x50, 0x04, 0x00, 0x00, 0x03, 0x78, 0x14, 0x00, 0x00, 0x00, 0x02, 0x38,
591c2c66affSColin Finck     0x10, 0x70, 0x03, 0x38, 0x01, 0x60, 0x16, 0x40, 0x01, 0x00, 0x00, 0x00,
592c2c66affSColin Finck     0x01, 0x98, 0x00, 0x00, 0x00, 0x00, 0x03, 0x78, 0x0E, 0x00, 0x00, 0x00,
593c2c66affSColin Finck     0x02, 0x38, 0x12, 0x70, 0x03, 0x38, 0x06, 0x90, 0x01, 0x98, 0x00, 0x00,
594c2c66affSColin Finck     0x00, 0x00, 0x03, 0x78, 0x14, 0x00, 0x00, 0x00, 0x02, 0x38, 0x12, 0x70,
595c2c66affSColin Finck     0x03, 0x38, 0x04, 0x90, 0x16, 0x40, 0x01, 0x00, 0x00, 0x00, 0x01, 0x98,
596c2c66affSColin Finck     0x00, 0x00, 0x00, 0x00, 0x03, 0x78, 0x3E, 0x00, 0x00, 0x00, 0x02, 0x38,
597c2c66affSColin Finck     0x07, 0x70, 0x03, 0x38, 0x04, 0x90, 0x01, 0x98, 0x30, 0x00, 0x00, 0x00,
598c2c66affSColin Finck     0xED, 0xB4, 0x89, 0x50, 0xB1, 0xA4, 0x82, 0xA7, 0xEC, 0x02, 0x00, 0x00,
599c2c66affSColin Finck     0x85, 0x2B, 0x88, 0x40, 0x97, 0x76, 0xA6, 0xC4, 0xC6, 0x01, 0x00, 0x00,
600c2c66affSColin Finck     0x77, 0x7A, 0xBF, 0x48, 0x78, 0xB1, 0x69, 0xD2, 0x56, 0x02, 0x00, 0x00,
601c2c66affSColin Finck     0xD0, 0x15, 0xE6, 0xCB, 0xE8, 0x90, 0x68, 0xFE, 0x7C, 0x03, 0x00, 0x00,
602c2c66affSColin Finck     0x01, 0x70, 0x42, 0x03, 0x00, 0x00, 0x01, 0x50, 0x3E, 0xD6, 0xC0, 0x02,
603c2c66affSColin Finck     0x1A, 0xB9, 0xD1, 0x01, 0x22, 0x60, 0x06, 0x00, 0x00, 0x00, 0x01, 0x60,
604c2c66affSColin Finck     0x1C, 0x00, 0x00, 0x00, 0x23, 0x40, 0x01, 0x00, 0x00, 0x00, 0x07, 0x90,
605c2c66affSColin Finck     0x10, 0x00, 0x00, 0x00, 0xB0, 0x0E, 0x9B, 0xE3, 0xDB, 0x55, 0x0B, 0x45,
606c2c66affSColin Finck     0x9B, 0xD4, 0xD2, 0x0C, 0x94, 0x84, 0x26, 0x0F, 0x02, 0x70, 0x00, 0x00,
607c2c66affSColin Finck     0x00, 0x00, 0x0B, 0x70, 0x32, 0x00, 0x00, 0x00, 0x01, 0x60, 0x3E, 0x00,
608c2c66affSColin Finck     0x00, 0x00, 0x09, 0x70, 0x26, 0x00, 0x00, 0x00, 0x01, 0x60, 0x5C, 0x00,
609c2c66affSColin Finck     0x00, 0x00, 0x08, 0x60, 0x82, 0x00, 0x00, 0x00, 0x03, 0x70, 0x06, 0x00,
610c2c66affSColin Finck     0x00, 0x00, 0x03, 0x60, 0xA0, 0x00, 0x00, 0x00, 0x03, 0x70, 0x08, 0x00,
611c2c66affSColin Finck     0x00, 0x00, 0x01, 0x10, 0x03, 0x60, 0xBE, 0x00, 0x00, 0x00, 0x07, 0x70,
612c2c66affSColin Finck     0x8A, 0x00, 0x00, 0x00, 0x01, 0x60, 0xDC, 0x00, 0x00, 0x00, 0x06, 0x60,
613c2c66affSColin Finck     0x00, 0x01, 0x00, 0x00, 0x05, 0x60, 0x2C, 0x01, 0x00, 0x00, 0x04, 0x90,
614c2c66affSColin Finck     0x10, 0x00, 0x00, 0x00, 0x3F, 0xC9, 0x50, 0x4E, 0x63, 0xB8, 0xFA, 0x4D,
615c2c66affSColin Finck     0xBA, 0xE2, 0xD8, 0x0E, 0xF4, 0xCE, 0x5C, 0x89, 0x0D, 0x70, 0x24, 0x00,
616c2c66affSColin Finck     0x00, 0x00, 0x17, 0x40, 0x01, 0x00, 0x00, 0x00, 0x10, 0x40, 0x01, 0x00,
617c2c66affSColin Finck     0x00, 0x00, 0x15, 0x40, 0x01, 0x00, 0x00, 0x00, 0x24, 0x40, 0x72, 0x00,
618c2c66affSColin Finck     0x6F, 0x00, 0x25, 0x40, 0x67, 0x00, 0x72, 0x00, 0x26, 0x40, 0x00, 0x00,
619c2c66affSColin Finck     0x00, 0x00, 0x08, 0x70, 0x32, 0x00, 0x00, 0x00, 0x01, 0x60, 0x5C, 0x01,
620c2c66affSColin Finck     0x00, 0x00, 0x09, 0x60, 0x66, 0x01, 0x00, 0x00, 0x10, 0x60, 0x84, 0x01,
621c2c66affSColin Finck     0x00, 0x00, 0x11, 0x60, 0xA2, 0x01, 0x00, 0x00, 0x13, 0x60, 0xB8, 0x01,
622c2c66affSColin Finck     0x00, 0x00, 0x06, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
623c2c66affSColin Finck     0x0D, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x07, 0x70,
624c2c66affSColin Finck     0x90, 0x00, 0x00, 0x00, 0x01, 0x60, 0xCE, 0x01, 0x00, 0x00, 0x06, 0x60,
625c2c66affSColin Finck     0xF8, 0x01, 0x00, 0x00, 0x05, 0x60, 0x2A, 0x02, 0x00, 0x00, 0x04, 0x90,
626c2c66affSColin Finck     0x10, 0x00, 0x00, 0x00, 0xE1, 0x20, 0x67, 0x15, 0x98, 0xEF, 0x04, 0x4D,
627c2c66affSColin Finck     0x96, 0x5A, 0xD8, 0x5D, 0xE0, 0x5E, 0x6D, 0x9F, 0x0D, 0x70, 0x24, 0x00,
628c2c66affSColin Finck     0x00, 0x00, 0x17, 0x40, 0x01, 0x00, 0x00, 0x00, 0x10, 0x40, 0x02, 0x00,
629c2c66affSColin Finck     0x00, 0x00, 0x15, 0x40, 0x02, 0x00, 0x00, 0x00, 0x24, 0x40, 0x20, 0x00,
630c2c66affSColin Finck     0x32, 0x00, 0x25, 0x40, 0x2E, 0x00, 0x38, 0x00, 0x26, 0x40, 0x00, 0x00,
631c2c66affSColin Finck     0x00, 0x00, 0x08, 0x70, 0x38, 0x00, 0x00, 0x00, 0x01, 0x60, 0x5C, 0x01,
632c2c66affSColin Finck     0x00, 0x00, 0x09, 0x60, 0x66, 0x01, 0x00, 0x00, 0x10, 0x60, 0x84, 0x01,
633c2c66affSColin Finck     0x00, 0x00, 0x11, 0x60, 0xA2, 0x01, 0x00, 0x00, 0x02, 0x50, 0x00, 0x00,
634c2c66affSColin Finck     0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x50, 0x01, 0x00, 0x00, 0x00,
635c2c66affSColin Finck     0x00, 0x00, 0x01, 0x00, 0x0B, 0x40, 0xAD, 0xBA, 0x00, 0x00, 0x13, 0x60,
636c2c66affSColin Finck     0xB8, 0x01, 0x00, 0x00, 0x07, 0x70, 0x8A, 0x00, 0x00, 0x00, 0x01, 0x60,
637c2c66affSColin Finck     0x60, 0x02, 0x00, 0x00, 0x06, 0x60, 0x80, 0x02, 0x00, 0x00, 0x05, 0x60,
638c2c66affSColin Finck     0x9E, 0x02, 0x00, 0x00, 0x04, 0x90, 0x10, 0x00, 0x00, 0x00, 0x69, 0xEF,
639c2c66affSColin Finck     0x70, 0xCE, 0x1D, 0xA2, 0x8B, 0x40, 0x84, 0x5B, 0xF9, 0x9E, 0xAC, 0x06,
640c2c66affSColin Finck     0x09, 0xE7, 0x08, 0x70, 0x32, 0x00, 0x00, 0x00, 0x01, 0x60, 0x5C, 0x01,
641c2c66affSColin Finck     0x00, 0x00, 0x09, 0x60, 0x66, 0x01, 0x00, 0x00, 0x10, 0x60, 0x84, 0x01,
642c2c66affSColin Finck     0x00, 0x00, 0x11, 0x60, 0xA2, 0x01, 0x00, 0x00, 0x02, 0x50, 0x00, 0x00,
643c2c66affSColin Finck     0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x50, 0x01, 0x00, 0x00, 0x00,
644c2c66affSColin Finck     0x00, 0x00, 0x01, 0x00, 0x13, 0x60, 0xB8, 0x01, 0x00, 0x00, 0x08, 0x70,
645c2c66affSColin Finck     0x12, 0x00, 0x00, 0x00, 0x01, 0x60, 0xC0, 0x02, 0x00, 0x00, 0x01, 0x40,
646c2c66affSColin Finck     0x04, 0x00, 0x00, 0x00, 0x03, 0x40, 0xB0, 0xB0, 0xB0, 0xB0, 0x0B, 0x70,
647c2c66affSColin Finck     0x0C, 0x00, 0x00, 0x00, 0x01, 0x60, 0x3E, 0x00, 0x00, 0x00, 0x1A, 0x40,
648c2c66affSColin Finck     0x8E, 0x01, 0x00, 0x00, 0x07, 0x70, 0xCE, 0x00, 0x00, 0x00, 0x01, 0x60,
649c2c66affSColin Finck     0xEC, 0x02, 0x00, 0x00, 0x06, 0x60, 0x0E, 0x03, 0x00, 0x00, 0x05, 0x60,
650c2c66affSColin Finck     0x26, 0x03, 0x00, 0x00, 0x04, 0x90, 0x10, 0x00, 0x00, 0x00, 0x44, 0xD1,
651c2c66affSColin Finck     0xEA, 0xB4, 0x40, 0xF6, 0x4B, 0x4E, 0x94, 0xC4, 0x0C, 0x7F, 0xA8, 0x66,
652c2c66affSColin Finck     0x23, 0xB0, 0x08, 0x70, 0x94, 0x00, 0x00, 0x00, 0x01, 0x60, 0x5C, 0x01,
653c2c66affSColin Finck     0x00, 0x00, 0x01, 0x40, 0x00, 0x08, 0x00, 0x00, 0x03, 0x40, 0x29, 0xD6,
654c2c66affSColin Finck     0x8B, 0x17, 0x09, 0x60, 0x66, 0x01, 0x00, 0x00, 0x10, 0x60, 0x84, 0x01,
655c2c66affSColin Finck     0x00, 0x00, 0x11, 0x60, 0xA2, 0x01, 0x00, 0x00, 0x12, 0x60, 0x42, 0x03,
656c2c66affSColin Finck     0x00, 0x00, 0x02, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
657c2c66affSColin Finck     0x03, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x40,
658c2c66affSColin Finck     0x03, 0x00, 0x00, 0x00, 0x09, 0x40, 0x04, 0x00, 0x00, 0x00, 0x0A, 0x40,
659c2c66affSColin Finck     0x01, 0x00, 0x00, 0x00, 0x0B, 0x40, 0xAD, 0xBA, 0x00, 0x00, 0x1C, 0x40,
660c2c66affSColin Finck     0x02, 0x00, 0x04, 0x00, 0x13, 0x60, 0xB8, 0x01, 0x00, 0x00, 0x14, 0x60,
661c2c66affSColin Finck     0x68, 0x03, 0x00, 0x00, 0x15, 0x60, 0x90, 0x03, 0x00, 0x00, 0x16, 0x60,
662c2c66affSColin Finck     0xB0, 0x03, 0x00, 0x00, 0x06, 0x50, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
663c2c66affSColin Finck     0x01, 0x00, 0x0D, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
664c2c66affSColin Finck     0x1D, 0x40, 0x45, 0x23, 0x01, 0x00, 0x1E, 0x40, 0x45, 0x23, 0x01, 0x00,
665c2c66affSColin Finck     0x0B, 0x70, 0x06, 0x00, 0x00, 0x00, 0x01, 0x60, 0xD4, 0x03, 0x00, 0x00,
666c2c66affSColin Finck     0x0D, 0x70, 0x1E, 0x00, 0x00, 0x00, 0x15, 0x40, 0x02, 0x00, 0x00, 0x00,
667c2c66affSColin Finck     0x0E, 0x70, 0x06, 0x00, 0x00, 0x00, 0x19, 0x60, 0xEC, 0x03, 0x00, 0x00,
668c2c66affSColin Finck     0x1B, 0x60, 0xF8, 0x01, 0x00, 0x00, 0x18, 0x60, 0x2A, 0x04, 0x00, 0x00,
669c2c66affSColin Finck     0x0D, 0x70, 0x1E, 0x00, 0x00, 0x00, 0x15, 0x40, 0x01, 0x00, 0x00, 0x00,
670c2c66affSColin Finck     0x0E, 0x70, 0x06, 0x00, 0x00, 0x00, 0x19, 0x60, 0x4A, 0x04, 0x00, 0x00,
671c2c66affSColin Finck     0x1B, 0x60, 0x00, 0x01, 0x00, 0x00, 0x18, 0x60, 0x82, 0x04, 0x00, 0x00,
672c2c66affSColin Finck     0x01, 0x78, 0x96, 0x04, 0x00, 0x00, 0x01, 0x88, 0x10, 0x00, 0x00, 0x00,
673c2c66affSColin Finck     0x32, 0x00, 0x2E, 0x00, 0x31, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x2E, 0x00,
674c2c66affSColin Finck     0x33, 0x00, 0x00, 0x00, 0x01, 0x88, 0x1C, 0x00, 0x00, 0x00, 0x61, 0x00,
675c2c66affSColin Finck     0x70, 0x00, 0x70, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00,
676c2c66affSColin Finck     0x5F, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x31, 0x00,
677c2c66affSColin Finck     0x00, 0x00, 0x01, 0x88, 0x18, 0x00, 0x00, 0x00, 0x54, 0x00, 0x65, 0x00,
678c2c66affSColin Finck     0x73, 0x00, 0x74, 0x00, 0x4E, 0x00, 0x65, 0x00, 0x77, 0x00, 0x4D, 0x00,
679c2c66affSColin Finck     0x6F, 0x00, 0x64, 0x00, 0x65, 0x00, 0x00, 0x00, 0x01, 0x88, 0x20, 0x00,
680c2c66affSColin Finck     0x00, 0x00, 0x56, 0x00, 0x69, 0x00, 0x72, 0x00, 0x74, 0x00, 0x75, 0x00,
681c2c66affSColin Finck     0x61, 0x00, 0x6C, 0x00, 0x52, 0x00, 0x65, 0x00, 0x67, 0x00, 0x69, 0x00,
682c2c66affSColin Finck     0x73, 0x00, 0x74, 0x00, 0x72, 0x00, 0x79, 0x00, 0x00, 0x00, 0x01, 0x88,
683c2c66affSColin Finck     0x18, 0x00, 0x00, 0x00, 0x54, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6D, 0x00,
684c2c66affSColin Finck     0x65, 0x00, 0x41, 0x00, 0x63, 0x00, 0x74, 0x00, 0x69, 0x00, 0x76, 0x00,
685c2c66affSColin Finck     0x65, 0x00, 0x00, 0x00, 0x01, 0x88, 0x18, 0x00, 0x00, 0x00, 0x65, 0x00,
686c2c66affSColin Finck     0x78, 0x00, 0x63, 0x00, 0x6C, 0x00, 0x75, 0x00, 0x64, 0x00, 0x65, 0x00,
687c2c66affSColin Finck     0x2E, 0x00, 0x64, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x01, 0x88,
688c2c66affSColin Finck     0x18, 0x00, 0x00, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x63, 0x00, 0x6C, 0x00,
689c2c66affSColin Finck     0x75, 0x00, 0x64, 0x00, 0x65, 0x00, 0x2E, 0x00, 0x64, 0x00, 0x6C, 0x00,
690c2c66affSColin Finck     0x6C, 0x00, 0x00, 0x00, 0x01, 0x88, 0x1E, 0x00, 0x00, 0x00, 0x74, 0x00,
691c2c66affSColin Finck     0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x5F, 0x00, 0x61, 0x00, 0x6C, 0x00,
692c2c66affSColin Finck     0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x78, 0x00,
693c2c66affSColin Finck     0x65, 0x00, 0x00, 0x00, 0x01, 0x88, 0x26, 0x00, 0x00, 0x00, 0x61, 0x00,
694c2c66affSColin Finck     0x70, 0x00, 0x70, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00,
695c2c66affSColin Finck     0x5F, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x5F, 0x00,
696c2c66affSColin Finck     0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x00, 0x00,
697c2c66affSColin Finck     0x01, 0x88, 0x2A, 0x00, 0x00, 0x00, 0x61, 0x00, 0x70, 0x00, 0x70, 0x00,
698c2c66affSColin Finck     0x68, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00, 0x5F, 0x00, 0x76, 0x00,
699c2c66affSColin Finck     0x65, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x5F, 0x00,
700c2c66affSColin Finck     0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x00, 0x00,
701c2c66affSColin Finck     0x01, 0x88, 0x04, 0x00, 0x00, 0x00, 0x2A, 0x00, 0x00, 0x00, 0x01, 0x88,
702c2c66affSColin Finck     0x18, 0x00, 0x00, 0x00, 0x43, 0x00, 0x6F, 0x00, 0x6D, 0x00, 0x70, 0x00,
703c2c66affSColin Finck     0x61, 0x00, 0x6E, 0x00, 0x79, 0x00, 0x4E, 0x00, 0x61, 0x00, 0x6D, 0x00,
704c2c66affSColin Finck     0x65, 0x00, 0x00, 0x00, 0x01, 0x88, 0x18, 0x00, 0x00, 0x00, 0x50, 0x00,
705c2c66affSColin Finck     0x72, 0x00, 0x6F, 0x00, 0x64, 0x00, 0x75, 0x00, 0x63, 0x00, 0x74, 0x00,
706c2c66affSColin Finck     0x4E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x01, 0x88,
707c2c66affSColin Finck     0x10, 0x00, 0x00, 0x00, 0x31, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x2E, 0x00,
708c2c66affSColin Finck     0x30, 0x00, 0x2E, 0x00, 0x31, 0x00, 0x00, 0x00, 0x01, 0x88, 0x10, 0x00,
709c2c66affSColin Finck     0x00, 0x00, 0x31, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x2E, 0x00, 0x30, 0x00,
710c2c66affSColin Finck     0x2E, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x88, 0x24, 0x00, 0x00, 0x00,
711c2c66affSColin Finck     0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x5F, 0x00, 0x64, 0x00,
712c2c66affSColin Finck     0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00,
713c2c66affSColin Finck     0x77, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x78, 0x00, 0x65, 0x00, 0x00, 0x00,
714c2c66affSColin Finck     0x01, 0x88, 0x2C, 0x00, 0x00, 0x00, 0x61, 0x00, 0x70, 0x00, 0x70, 0x00,
715c2c66affSColin Finck     0x68, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00, 0x5F, 0x00, 0x6E, 0x00,
716c2c66affSColin Finck     0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x5F, 0x00, 0x64, 0x00, 0x69, 0x00,
717c2c66affSColin Finck     0x73, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00,
718c2c66affSColin Finck     0x00, 0x00, 0x01, 0x88, 0x30, 0x00, 0x00, 0x00, 0x61, 0x00, 0x70, 0x00,
719c2c66affSColin Finck     0x70, 0x00, 0x68, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x70, 0x00, 0x5F, 0x00,
720c2c66affSColin Finck     0x76, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x64, 0x00, 0x6F, 0x00, 0x72, 0x00,
721c2c66affSColin Finck     0x5F, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00, 0x6C, 0x00,
722c2c66affSColin Finck     0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x00, 0x00, 0x01, 0x88, 0x1A, 0x00,
723c2c66affSColin Finck     0x00, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x5F, 0x00,
724c2c66affSColin Finck     0x6E, 0x00, 0x65, 0x00, 0x77, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x78, 0x00,
725c2c66affSColin Finck     0x65, 0x00, 0x00, 0x00, 0x01, 0x88, 0x18, 0x00, 0x00, 0x00, 0x66, 0x00,
726c2c66affSColin Finck     0x69, 0x00, 0x78, 0x00, 0x6E, 0x00, 0x65, 0x00, 0x77, 0x00, 0x5F, 0x00,
727c2c66affSColin Finck     0x6E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x01, 0x88,
728c2c66affSColin Finck     0x1C, 0x00, 0x00, 0x00, 0x66, 0x00, 0x69, 0x00, 0x78, 0x00, 0x6E, 0x00,
729c2c66affSColin Finck     0x65, 0x00, 0x77, 0x00, 0x5F, 0x00, 0x76, 0x00, 0x65, 0x00, 0x6E, 0x00,
730c2c66affSColin Finck     0x64, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x00, 0x00, 0x01, 0x88, 0x26, 0x00,
731c2c66affSColin Finck     0x00, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x5F, 0x00,
732c2c66affSColin Finck     0x63, 0x00, 0x68, 0x00, 0x65, 0x00, 0x63, 0x00, 0x6B, 0x00, 0x66, 0x00,
733c2c66affSColin Finck     0x69, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x2E, 0x00, 0x74, 0x00, 0x78, 0x00,
734c2c66affSColin Finck     0x74, 0x00, 0x00, 0x00, 0x01, 0x88, 0x1C, 0x00, 0x00, 0x00, 0x74, 0x00,
735c2c66affSColin Finck     0x65, 0x00, 0x73, 0x00, 0x74, 0x00, 0x5F, 0x00, 0x77, 0x00, 0x32, 0x00,
736c2c66affSColin Finck     0x6B, 0x00, 0x33, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x78, 0x00, 0x65, 0x00,
737c2c66affSColin Finck     0x00, 0x00, 0x01, 0x88, 0x12, 0x00, 0x00, 0x00, 0x66, 0x00, 0x69, 0x00,
738c2c66affSColin Finck     0x78, 0x00, 0x5F, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00,
739c2c66affSColin Finck     0x00, 0x00, 0x01, 0x88, 0x16, 0x00, 0x00, 0x00, 0x66, 0x00, 0x69, 0x00,
740c2c66affSColin Finck     0x78, 0x00, 0x5F, 0x00, 0x76, 0x00, 0x65, 0x00, 0x6E, 0x00, 0x64, 0x00,
741c2c66affSColin Finck     0x6F, 0x00, 0x72, 0x00, 0x00, 0x00, 0x01, 0x88, 0x20, 0x00, 0x00, 0x00,
742c2c66affSColin Finck     0x46, 0x00, 0x69, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x44, 0x00, 0x65, 0x00,
743c2c66affSColin Finck     0x73, 0x00, 0x63, 0x00, 0x72, 0x00, 0x69, 0x00, 0x70, 0x00, 0x74, 0x00,
744c2c66affSColin Finck     0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x00, 0x00, 0x01, 0x88, 0x22, 0x00,
745c2c66affSColin Finck     0x00, 0x00, 0x4F, 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, 0x69, 0x00,
746c2c66affSColin Finck     0x6E, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x46, 0x00, 0x69, 0x00, 0x6C, 0x00,
747c2c66affSColin Finck     0x65, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00,
748c2c66affSColin Finck     0x01, 0x88, 0x1A, 0x00, 0x00, 0x00, 0x49, 0x00, 0x6E, 0x00, 0x74, 0x00,
749c2c66affSColin Finck     0x65, 0x00, 0x72, 0x00, 0x6E, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x4E, 0x00,
750c2c66affSColin Finck     0x61, 0x00, 0x6D, 0x00, 0x65, 0x00, 0x00, 0x00, 0x01, 0x88, 0x1E, 0x00,
751c2c66affSColin Finck     0x00, 0x00, 0x4C, 0x00, 0x65, 0x00, 0x67, 0x00, 0x61, 0x00, 0x6C, 0x00,
752c2c66affSColin Finck     0x43, 0x00, 0x6F, 0x00, 0x70, 0x00, 0x79, 0x00, 0x72, 0x00, 0x69, 0x00,
753c2c66affSColin Finck     0x67, 0x00, 0x68, 0x00, 0x74, 0x00, 0x00, 0x00, 0x01, 0x88, 0x12, 0x00,
754c2c66affSColin Finck     0x00, 0x00, 0x57, 0x00, 0x69, 0x00, 0x6E, 0x00, 0x53, 0x00, 0x72, 0x00,
755c2c66affSColin Finck     0x76, 0x00, 0x30, 0x00, 0x33, 0x00, 0x00, 0x00, 0x01, 0x88, 0x38, 0x00,
756c2c66affSColin Finck     0x00, 0x00, 0x68, 0x00, 0x74, 0x00, 0x74, 0x00, 0x70, 0x00, 0x3A, 0x00,
757c2c66affSColin Finck     0x2F, 0x00, 0x2F, 0x00, 0x72, 0x00, 0x65, 0x00, 0x61, 0x00, 0x63, 0x00,
758c2c66affSColin Finck     0x74, 0x00, 0x6F, 0x00, 0x73, 0x00, 0x2E, 0x00, 0x6F, 0x00, 0x72, 0x00,
759c2c66affSColin Finck     0x67, 0x00, 0x2F, 0x00, 0x64, 0x00, 0x69, 0x00, 0x73, 0x00, 0x61, 0x00,
760c2c66affSColin Finck     0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x00, 0x00, 0x01, 0x88,
761c2c66affSColin Finck     0x1A, 0x00, 0x00, 0x00, 0x4E, 0x00, 0x6F, 0x00, 0x74, 0x00, 0x20, 0x00,
762c2c66affSColin Finck     0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x65, 0x00,
763c2c66affSColin Finck     0x64, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x88, 0x32, 0x00, 0x00, 0x00,
764c2c66affSColin Finck     0x68, 0x00, 0x74, 0x00, 0x74, 0x00, 0x70, 0x00, 0x3A, 0x00, 0x2F, 0x00,
765c2c66affSColin Finck     0x2F, 0x00, 0x72, 0x00, 0x65, 0x00, 0x61, 0x00, 0x63, 0x00, 0x74, 0x00,
766c2c66affSColin Finck     0x6F, 0x00, 0x73, 0x00, 0x2E, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x67, 0x00,
767c2c66affSColin Finck     0x2F, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00,
768c2c66affSColin Finck     0x00, 0x00, 0x01, 0x88, 0x14, 0x00, 0x00, 0x00, 0x41, 0x00, 0x6C, 0x00,
769c2c66affSColin Finck     0x6C, 0x00, 0x6F, 0x00, 0x77, 0x00, 0x20, 0x00, 0x69, 0x00, 0x74, 0x00,
770c2c66affSColin Finck     0x21, 0x00, 0x00, 0x00
771c2c66affSColin Finck };
772c2c66affSColin Finck 
test_get_db_size()773c2c66affSColin Finck DWORD test_get_db_size()
774c2c66affSColin Finck {
775c2c66affSColin Finck     return sizeof(rawData);
776c2c66affSColin Finck }
777c2c66affSColin Finck 
test_create_db_imp(const WCHAR * name,int win10)778c2c66affSColin Finck void test_create_db_imp(const WCHAR* name, int win10)
779c2c66affSColin Finck {
780c2c66affSColin Finck     HANDLE file = CreateFileW(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
781c2c66affSColin Finck     winetest_ok(file != INVALID_HANDLE_VALUE, "can't create file '%s'\n", wine_dbgstr_w(name));
782c2c66affSColin Finck     if (file != INVALID_HANDLE_VALUE)
783c2c66affSColin Finck     {
784c2c66affSColin Finck         DWORD size;
785c2c66affSColin Finck         WriteFile(file, rawData, sizeof(rawData), &size, NULL);
786c2c66affSColin Finck         if (win10)
787c2c66affSColin Finck         {
788c2c66affSColin Finck             SetFilePointer(file, 0, NULL, FILE_BEGIN);
789c2c66affSColin Finck             WriteFile(file, win10Header, sizeof(win10Header), &size, NULL);
790c2c66affSColin Finck         }
791c2c66affSColin Finck         CloseHandle(file);
792c2c66affSColin Finck     }
793c2c66affSColin Finck }
794c2c66affSColin Finck 
795*2a5fd78fSHermès Bélusca-Maïto DWORD g_WinVersion;
get_host_winver(void)796c2c66affSColin Finck DWORD get_host_winver(void)
797c2c66affSColin Finck {
798c2c66affSColin Finck     if (!g_WinVersion)
799c2c66affSColin Finck     {
800c2c66affSColin Finck         RTL_OSVERSIONINFOEXW rtlinfo = {0};
801c2c66affSColin Finck         void (__stdcall* pRtlGetVersion)(RTL_OSVERSIONINFOEXW*);
802c2c66affSColin Finck         pRtlGetVersion = (void (__stdcall*)(RTL_OSVERSIONINFOEXW*))GetProcAddress(GetModuleHandleA("ntdll"), "RtlGetVersion");
803c2c66affSColin Finck 
804c2c66affSColin Finck         rtlinfo.dwOSVersionInfoSize = sizeof(rtlinfo);
805c2c66affSColin Finck         pRtlGetVersion(&rtlinfo);
806c2c66affSColin Finck         g_WinVersion = (rtlinfo.dwMajorVersion << 8) | rtlinfo.dwMinorVersion;
807c2c66affSColin Finck     }
808c2c66affSColin Finck     return g_WinVersion;
809c2c66affSColin Finck }
810c2c66affSColin Finck 
get_module_version(HMODULE mod)811c2c66affSColin Finck DWORD get_module_version(HMODULE mod)
812c2c66affSColin Finck {
813c2c66affSColin Finck     DWORD dwVersion = 0;
814c2c66affSColin Finck     HRSRC hResInfo = FindResource(mod, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION);
815c2c66affSColin Finck     DWORD dwSize = SizeofResource(mod, hResInfo);
816c2c66affSColin Finck     if (hResInfo && dwSize)
817c2c66affSColin Finck     {
818c2c66affSColin Finck         VS_FIXEDFILEINFO *lpFfi;
819c2c66affSColin Finck         UINT uLen;
820c2c66affSColin Finck 
821c2c66affSColin Finck         HGLOBAL hResData = LoadResource(mod, hResInfo);
822c2c66affSColin Finck         LPVOID pRes = LockResource(hResData);
823c2c66affSColin Finck         HLOCAL pResCopy = LocalAlloc(LMEM_FIXED, dwSize);
824c2c66affSColin Finck 
825c2c66affSColin Finck         CopyMemory(pResCopy, pRes, dwSize);
826c2c66affSColin Finck         FreeResource(hResData);
827c2c66affSColin Finck 
828c2c66affSColin Finck         if (VerQueryValueW(pResCopy, L"\\", (LPVOID*)&lpFfi, &uLen))
829c2c66affSColin Finck         {
830c2c66affSColin Finck             dwVersion = (HIWORD(lpFfi->dwProductVersionMS) << 8) | LOWORD(lpFfi->dwProductVersionMS);
831c2c66affSColin Finck             if (!dwVersion)
832c2c66affSColin Finck                 dwVersion = (HIWORD(lpFfi->dwFileVersionMS) << 8) | LOWORD(lpFfi->dwFileVersionMS);
833c2c66affSColin Finck         }
834c2c66affSColin Finck 
835c2c66affSColin Finck         LocalFree(pResCopy);
836c2c66affSColin Finck     }
837c2c66affSColin Finck 
838c2c66affSColin Finck     return dwVersion;
839c2c66affSColin Finck }
840c2c66affSColin Finck 
silence_debug_output(void)841c2c66affSColin Finck void silence_debug_output(void)
842c2c66affSColin Finck {
843c2c66affSColin Finck     if (GetEnvironmentVariableA("SHIM_DEBUG_LEVEL", NULL, 0) == ERROR_ENVVAR_NOT_FOUND)
844c2c66affSColin Finck         SetEnvironmentVariableA("SHIM_DEBUG_LEVEL", "0");
845c2c66affSColin Finck     if (GetEnvironmentVariableA("SHIMENG_DEBUG_LEVEL", NULL, 0) == ERROR_ENVVAR_NOT_FOUND)
846c2c66affSColin Finck         SetEnvironmentVariableA("SHIMENG_DEBUG_LEVEL", "0");
847c2c66affSColin Finck }
848c2c66affSColin Finck 
849