0718f376ce51175d44dc7683b43599676dd88bd8
[reactos.git] / rostests / apitests / apphelp / apphelp.c
1 /*
2 * Copyright 2012 Detlef Riekenberg
3 * Copyright 2013 Mislav Blažević
4 * Copyright 2016 Mark Jansen
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21
22 #include <ntstatus.h>
23 #define WIN32_NO_STATUS
24 #include <windows.h>
25 #include <shlwapi.h>
26 #include <winnt.h>
27 #ifdef __REACTOS__
28 #include <ntndk.h>
29 #else
30 #include <winternl.h>
31 #endif
32
33 #include <winerror.h>
34 #include <stdio.h>
35 #include <initguid.h>
36
37 #include "wine/test.h"
38
39 /* data.c */
40 void test_create_exe_imp(const char* name, int skip_rsrc_exports);
41 void test_create_file_imp(const char* name, const char* contents, size_t len);
42 void test_create_ne_imp(const char* name, int skip_names);
43
44 #define test_create_exe (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_create_exe_imp
45 #define test_create_file (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_create_file_imp
46 #define test_create_ne (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_create_ne_imp
47
48
49 static DWORD g_Version;
50
51 #define VERSION_ANY 0
52 #define VERSION_WINXP 0x0501
53 #define VERSION_2003 0x0502
54 #define VERSION_VISTA 0x0600
55 #define VERSION_WIN7 0x0601
56 #define VERSION_WIN8 0x0602
57 #define VERSION_WIN10 0x1000
58
59
60 typedef WORD TAG;
61 typedef DWORD TAGID;
62 typedef DWORD TAGREF;
63 typedef UINT64 QWORD;
64
65 #define TAG_TYPE_MASK 0xF000
66
67 #define TAG_TYPE_NULL 0x1000
68 #define TAG_TYPE_BYTE 0x2000
69 #define TAG_TYPE_WORD 0x3000
70 #define TAG_TYPE_DWORD 0x4000
71 #define TAG_TYPE_QWORD 0x5000
72 #define TAG_TYPE_STRINGREF 0x6000
73 #define TAG_TYPE_LIST 0x7000
74 #define TAG_TYPE_STRING 0x8000
75 #define TAG_TYPE_BINARY 0x9000
76 #define TAG_NULL 0x0
77 #define TAG_SIZE (0x1 | TAG_TYPE_DWORD)
78 #define TAG_CHECKSUM (0x3 | TAG_TYPE_DWORD)
79 #define TAG_MODULE_TYPE (0x6 | TAG_TYPE_DWORD)
80 #define TAG_VERDATEHI (0x7 | TAG_TYPE_DWORD)
81 #define TAG_VERDATELO (0x8 | TAG_TYPE_DWORD)
82 #define TAG_VERFILEOS (0x9 | TAG_TYPE_DWORD)
83 #define TAG_VERFILETYPE (0xA | TAG_TYPE_DWORD)
84 #define TAG_PE_CHECKSUM (0xB | TAG_TYPE_DWORD)
85 #define TAG_VER_LANGUAGE (0x12 | TAG_TYPE_DWORD)
86 #define TAG_LINKER_VERSION (0x1C | TAG_TYPE_DWORD)
87 #define TAG_LINK_DATE (0x1D | TAG_TYPE_DWORD)
88 #define TAG_UPTO_LINK_DATE (0x1E | TAG_TYPE_DWORD)
89 #define TAG_EXE_WRAPPER (0x31 | TAG_TYPE_DWORD)
90 #define TAG_BIN_FILE_VERSION (0x2 | TAG_TYPE_QWORD)
91 #define TAG_BIN_PRODUCT_VERSION (0x3 | TAG_TYPE_QWORD)
92 #define TAG_UPTO_BIN_PRODUCT_VERSION (0x6 | TAG_TYPE_QWORD)
93 #define TAG_UPTO_BIN_FILE_VERSION (0xD | TAG_TYPE_QWORD)
94 #define TAG_NAME (0x1 | TAG_TYPE_STRINGREF)
95 #define TAG_COMPANY_NAME (0x9 | TAG_TYPE_STRINGREF)
96 #define TAG_PRODUCT_NAME (0x10 | TAG_TYPE_STRINGREF)
97 #define TAG_PRODUCT_VERSION (0x11 | TAG_TYPE_STRINGREF)
98 #define TAG_FILE_DESCRIPTION (0x12 | TAG_TYPE_STRINGREF)
99 #define TAG_FILE_VERSION (0x13 | TAG_TYPE_STRINGREF)
100 #define TAG_ORIGINAL_FILENAME (0x14 | TAG_TYPE_STRINGREF)
101 #define TAG_INTERNAL_NAME (0x15 | TAG_TYPE_STRINGREF)
102 #define TAG_LEGAL_COPYRIGHT (0x16 | TAG_TYPE_STRINGREF)
103 #define TAG_16BIT_DESCRIPTION (0x17 | TAG_TYPE_STRINGREF)
104 #define TAG_16BIT_MODULE_NAME (0x20 | TAG_TYPE_STRINGREF)
105 #define TAG_EXPORT_NAME (0x24 | TAG_TYPE_STRINGREF)
106
107
108 #define ATTRIBUTE_AVAILABLE 0x1
109 #define ATTRIBUTE_FAILED 0x2
110
111 typedef struct tagATTRINFO {
112 TAG type;
113 DWORD flags; /* ATTRIBUTE_AVAILABLE, ATTRIBUTE_FAILED */
114 union {
115 QWORD qwattr;
116 DWORD dwattr;
117 WCHAR *lpattr;
118 };
119 } ATTRINFO, *PATTRINFO;
120
121 static HMODULE hdll;
122 static LPCWSTR (WINAPI *pSdbTagToString)(TAG);
123 static BOOL (WINAPI *pSdbGUIDToString)(CONST GUID *, PCWSTR, SIZE_T);
124 static BOOL (WINAPI *pSdbIsNullGUID)(CONST GUID *);
125 static BOOL (WINAPI *pSdbGetStandardDatabaseGUID)(DWORD, GUID*);
126 static BOOL (WINAPI *pSdbGetFileAttributes)(LPCWSTR, PATTRINFO *, LPDWORD);
127 static BOOL (WINAPI *pSdbFreeFileAttributes)(PATTRINFO);
128
129 /* 'Known' database guids */
130 DEFINE_GUID(GUID_DATABASE_MSI,0xd8ff6d16,0x6a3a,0x468a,0x8b,0x44,0x01,0x71,0x4d,0xdc,0x49,0xea);
131 DEFINE_GUID(GUID_DATABASE_SHIM,0x11111111,0x1111,0x1111,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11);
132 DEFINE_GUID(GUID_DATABASE_DRIVERS,0xf9ab2228,0x3312,0x4a73,0xb6,0xf9,0x93,0x6d,0x70,0xe1,0x12,0xef);
133 DEFINE_GUID(GUID_DATABASE_TEST,0x6E989AB7,0x864D,0x4575,0x87,0x34,0x90,0x36,0x4A,0xC6,0x4F,0xBD);
134
135 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
136 DEFINE_GUID(test_UserAssist, 0xdd313e04, 0xfeff, 0x11d1, 0x8e, 0xcd, 0x00, 0x00, 0xf8, 0x7a, 0x47, 0x0c);
137
138 static void test_SdbTagToString(void)
139 {
140 static const TAG invalid_values[] = {
141 1, TAG_TYPE_WORD, TAG_TYPE_MASK,
142 TAG_TYPE_DWORD | 0xFF,
143 TAG_TYPE_DWORD | (0x800 + 0xEE),
144 0x900, 0xFFFF, 0xDEAD, 0xBEEF
145 };
146 static const WCHAR invalid[] = {'I','n','v','a','l','i','d','T','a','g',0};
147 LPCWSTR ret;
148 WORD i;
149
150 for (i = 0; i < 9; ++i)
151 {
152 ret = pSdbTagToString(invalid_values[i]);
153 ok(lstrcmpW(ret, invalid) == 0, "unexpected string %s, should be %s\n",
154 wine_dbgstr_w(ret), wine_dbgstr_w(invalid));
155 }
156 }
157
158 static int strcmp_wa(LPCWSTR strw, const char *stra)
159 {
160 CHAR buf[512];
161 WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), 0, 0);
162 return lstrcmpA(buf, stra);
163 }
164
165 void test_tag(TAG base, const char* names[], size_t upperlimit, int line)
166 {
167 TAG n;
168 for (n = 0; names[n]; ++n)
169 {
170 LPCWSTR tagstr = pSdbTagToString(base | n);
171 ok_(__FILE__, line + 2)(!strcmp_wa(tagstr, names[n]), "Got %s instead of '%s' for %x\n", wine_dbgstr_w(tagstr), names[n], base | n);
172 }
173 for (; n < upperlimit; ++n)
174 {
175 LPCWSTR tagstr = pSdbTagToString(base | n);
176 ok_(__FILE__, line + 2)(!strcmp_wa(tagstr, "InvalidTag"), "Got %s instead of 'InvalidTag' for %x\n", wine_dbgstr_w(tagstr), base | n);
177 }
178 }
179
180 static struct
181 {
182 TAG base;
183 DWORD upper_limit;
184 DWORD line;
185 DWORD min_ver;
186 DWORD max_ver;
187 const char* tags[7*8];
188 } data[] = {
189 {
190 TAG_TYPE_NULL, 0x1000, __LINE__, VERSION_ANY, VERSION_2003,
191 {
192 "InvalidTag", "INCLUDE", "GENERAL", "MATCH_LOGIC_NOT", "APPLY_ALL_SHIMS", "USE_SERVICE_PACK_FILES", NULL
193 }
194 },
195 {
196 TAG_TYPE_NULL, 0x1000, __LINE__, VERSION_VISTA, VERSION_VISTA,
197 {
198 "InvalidTag", "INCLUDE", "GENERAL", "MATCH_LOGIC_NOT", "APPLY_ALL_SHIMS", "USE_SERVICE_PACK_FILES", "MITIGATION_OS", "BLOCK_UPGRADE",
199 "INCLUDEEXCLUDEDLL", NULL
200 }
201 },
202 {
203 TAG_TYPE_NULL, 0x1000, __LINE__, VERSION_WIN7, VERSION_ANY,
204 {
205 "InvalidTag", "INCLUDE", "GENERAL", "MATCH_LOGIC_NOT", "APPLY_ALL_SHIMS", "USE_SERVICE_PACK_FILES", "MITIGATION_OS", "BLOCK_UPGRADE",
206 "INCLUDEEXCLUDEDLL", "RAC_EVENT_OFF", "TELEMETRY_OFF", "SHIM_ENGINE_OFF", "LAYER_PROPAGATION_OFF", "REINSTALL_UPGRADE", NULL
207 }
208 },
209
210 {
211 TAG_TYPE_BYTE, 0x1000, __LINE__, VERSION_ANY, VERSION_ANY,
212 {
213 "InvalidTag", NULL
214 }
215 },
216
217 {
218 TAG_TYPE_WORD, 0x800, __LINE__, VERSION_ANY, VERSION_WIN7,
219 {
220 "InvalidTag", "MATCH_MODE", NULL
221 }
222 },
223 {
224 TAG_TYPE_WORD, 0x800, __LINE__, VERSION_WIN8, VERSION_ANY,
225 {
226 "InvalidTag", "MATCH_MODE", "QUIRK_COMPONENT_CODE_ID", "QUIRK_CODE_ID", NULL
227 }
228 },
229 {
230 TAG_TYPE_WORD | 0x800, 0x800, __LINE__, VERSION_ANY, VERSION_ANY,
231 {
232 "InvalidTag", "TAG", "INDEX_TAG", "INDEX_KEY", NULL
233 }
234 },
235
236 {
237 TAG_TYPE_DWORD, 0x800, __LINE__, VERSION_ANY, VERSION_WINXP,
238 {
239 "InvalidTag", "SIZE", "OFFSET", "CHECKSUM", "SHIM_TAGID", "PATCH_TAGID", "MODULE_TYPE", "VERFILEDATEHI",
240 "VERFILEDATELO", "VERFILEOS", "VERFILETYPE", "PE_CHECKSUM", "PREVOSMAJORVERSION", "PREVOSMINORVERSION", "PREVOSPLATFORMID", "PREVOSBUILDNO",
241 "PROBLEM_SEVERITY", "APPHELP_LANGID", "VER_LANGUAGE", "InvalidTag", "ENGINE", "HTMLHELPID", "INDEXFLAGS", "FLAGS",
242 "VALUETYPE", "DATA_DWORD", "LAYER_TAGID", "MSI_TRANSFORM_TAGID", "LINKER_VERSION", "LINK_DATE", "UPTO_LINK_DATE", "OS_SERVICE_PACK",
243 "FLAG_TAGID", "RUNTIME_PLATFORM", "OS_SKU", NULL
244 }
245 },
246 {
247 TAG_TYPE_DWORD, 0x800, __LINE__, VERSION_2003, VERSION_2003,
248 {
249 "InvalidTag", "SIZE", "OFFSET", "CHECKSUM", "SHIM_TAGID", "PATCH_TAGID", "MODULE_TYPE", "VERFILEDATEHI",
250 "VERFILEDATELO", "VERFILEOS", "VERFILETYPE", "PE_CHECKSUM", "PREVOSMAJORVERSION", "PREVOSMINORVERSION", "PREVOSPLATFORMID", "PREVOSBUILDNO",
251 "PROBLEM_SEVERITY", "APPHELP_LANGID", "VER_LANGUAGE", "InvalidTag", "ENGINE", "HTMLHELPID", "INDEXFLAGS", "FLAGS",
252 "VALUETYPE", "DATA_DWORD", "LAYER_TAGID", "MSI_TRANSFORM_TAGID", "LINKER_VERSION", "LINK_DATE", "UPTO_LINK_DATE", "OS_SERVICE_PACK",
253 "FLAG_TAGID", "RUNTIME_PLATFORM", "OS_SKU", "OS_PLATFORM", NULL
254 }
255 },
256 {
257 TAG_TYPE_DWORD, 0x800, __LINE__, VERSION_VISTA, VERSION_VISTA,
258 {
259 "InvalidTag", "SIZE", "OFFSET", "CHECKSUM", "SHIM_TAGID", "PATCH_TAGID", "MODULE_TYPE", "VERDATEHI",
260 "VERDATELO", "VERFILEOS", "VERFILETYPE", "PE_CHECKSUM", "PREVOSMAJORVER", "PREVOSMINORVER", "PREVOSPLATFORMID", "PREVOSBUILDNO",
261 "PROBLEMSEVERITY", "LANGID", "VER_LANGUAGE", "InvalidTag", "ENGINE", "HTMLHELPID", "INDEX_FLAGS", "FLAGS",
262 "DATA_VALUETYPE", "DATA_DWORD", "LAYER_TAGID", "MSI_TRANSFORM_TAGID", "LINKER_VERSION", "LINK_DATE", "UPTO_LINK_DATE", "OS_SERVICE_PACK",
263 "FLAG_TAGID", "RUNTIME_PLATFORM", "OS_SKU", "OS_PLATFORM", "APP_NAME_RC_ID", "VENDOR_NAME_RC_ID", "SUMMARY_MSG_RC_ID", "VISTA_SKU",
264 NULL
265 }
266 },
267 {
268 TAG_TYPE_DWORD, 0x800, __LINE__, VERSION_WIN7, VERSION_ANY,
269 {
270 "InvalidTag", "SIZE", "OFFSET", "CHECKSUM", "SHIM_TAGID", "PATCH_TAGID", "MODULE_TYPE", "VERDATEHI",
271 "VERDATELO", "VERFILEOS", "VERFILETYPE", "PE_CHECKSUM", "PREVOSMAJORVER", "PREVOSMINORVER", "PREVOSPLATFORMID", "PREVOSBUILDNO",
272 "PROBLEMSEVERITY", "LANGID", "VER_LANGUAGE", "InvalidTag", "ENGINE", "HTMLHELPID", "INDEX_FLAGS", "FLAGS",
273 "DATA_VALUETYPE", "DATA_DWORD", "LAYER_TAGID", "MSI_TRANSFORM_TAGID", "LINKER_VERSION", "LINK_DATE", "UPTO_LINK_DATE", "OS_SERVICE_PACK",
274 "FLAG_TAGID", "RUNTIME_PLATFORM", "OS_SKU", "OS_PLATFORM", "APP_NAME_RC_ID", "VENDOR_NAME_RC_ID", "SUMMARY_MSG_RC_ID", "VISTA_SKU",
275 "DESCRIPTION_RC_ID", "PARAMETER1_RC_ID", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag",
276 "CONTEXT_TAGID", "EXE_WRAPPER", "URL_ID", NULL
277 }
278 },
279 {
280 TAG_TYPE_DWORD | 0x800, 0x800, __LINE__, VERSION_ANY, VERSION_ANY,
281 {
282 "InvalidTag", "TAGID", NULL
283 }
284 },
285
286 {
287 TAG_TYPE_QWORD, 0x1000, __LINE__, VERSION_ANY, VERSION_WINXP,
288 {
289 "InvalidTag", "TIME", "BIN_FILE_VERSION", "BIN_PRODUCT_VERSION", "MODTIME", "FLAG_MASK_KERNEL", "UPTO_BIN_PRODUCT_VERSION", "DATA_QWORD",
290 "FLAG_MASK_USER", "FLAGS_NTVDM1", "FLAGS_NTVDM2", "FLAGS_NTVDM3", "FLAG_MASK_SHELL", "UPTO_BIN_FILE_VERSION", NULL
291 }
292 },
293 {
294 TAG_TYPE_QWORD, 0x1000, __LINE__, VERSION_2003, VERSION_2003,
295 {
296 "InvalidTag", "TIME", "BIN_FILE_VERSION", "BIN_PRODUCT_VERSION", "MODTIME", "FLAG_MASK_KERNEL", "UPTO_BIN_PRODUCT_VERSION", "DATA_QWORD",
297 "FLAG_MASK_USER", "FLAGS_NTVDM1", "FLAGS_NTVDM2", "FLAGS_NTVDM3", "FLAG_MASK_SHELL", "UPTO_BIN_FILE_VERSION", "FLAG_MASK_FUSION", "FLAGS_PROCESSPARAM",
298 NULL
299 }
300 },
301 {
302 TAG_TYPE_QWORD, 0x1000, __LINE__, VERSION_VISTA, VERSION_ANY,
303 {
304 "InvalidTag", "TIME", "BIN_FILE_VERSION", "BIN_PRODUCT_VERSION", "MODTIME", "FLAG_MASK_KERNEL", "UPTO_BIN_PRODUCT_VERSION", "DATA_QWORD",
305 "FLAG_MASK_USER", "FLAGS_NTVDM1", "FLAGS_NTVDM2", "FLAGS_NTVDM3", "FLAG_MASK_SHELL", "UPTO_BIN_FILE_VERSION", "FLAG_MASK_FUSION", "FLAG_PROCESSPARAM",
306 "FLAG_LUA", "FLAG_INSTALL", NULL
307 }
308 },
309
310 {
311 TAG_TYPE_STRINGREF, 0x1000, __LINE__, VERSION_ANY, VERSION_2003,
312 {
313 "InvalidTag", "NAME", "DESCRIPTION", "MODULE", "API", "VENDOR", "APP_NAME", "InvalidTag",
314 "COMMAND_LINE", "COMPANY_NAME", "DLLFILE", "WILDCARD_NAME", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag",
315 "PRODUCT_NAME", "PRODUCT_VERSION", "FILE_DESCRIPTION", "FILE_VERSION", "ORIGINAL_FILENAME", "INTERNAL_NAME", "LEGAL_COPYRIGHT", "S16BIT_DESCRIPTION",
316 "PROBLEM_DETAILS", "LINK_URL", "LINK_TEXT", "APPHELP_TITLE", "APPHELP_CONTACT", "SXS_MANIFEST", "DATA_STRING", "MSI_TRANSFORM_FILE",
317 "S16BIT_MODULE_NAME", "LAYER_DISPLAYNAME", "COMPILER_VERSION", "ACTION_TYPE", NULL
318 }
319 },
320 {
321 TAG_TYPE_STRINGREF, 0x1000, __LINE__, VERSION_VISTA, VERSION_VISTA,
322 {
323 "InvalidTag", "NAME", "DESCRIPTION", "MODULE", "API", "VENDOR", "APP_NAME", "InvalidTag",
324 "COMMAND_LINE", "COMPANY_NAME", "DLLFILE", "WILDCARD_NAME", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag",
325 "PRODUCT_NAME", "PRODUCT_VERSION", "FILE_DESCRIPTION", "FILE_VERSION", "ORIGINAL_FILENAME", "INTERNAL_NAME", "LEGAL_COPYRIGHT", "16BIT_DESCRIPTION",
326 "APPHELP_DETAILS", "LINK_URL", "LINK_TEXT", "APPHELP_TITLE", "APPHELP_CONTACT", "SXS_MANIFEST", "DATA_STRING", "MSI_TRANSFORM_FILE",
327 "16BIT_MODULE_NAME", "LAYER_DISPLAYNAME", "COMPILER_VERSION", "ACTION_TYPE", "EXPORT_NAME", NULL
328 }
329 },
330 {
331 TAG_TYPE_STRINGREF, 0x1000, __LINE__, VERSION_WIN7, VERSION_ANY,
332 {
333 "InvalidTag", "NAME", "DESCRIPTION", "MODULE", "API", "VENDOR", "APP_NAME", "InvalidTag",
334 "COMMAND_LINE", "COMPANY_NAME", "DLLFILE", "WILDCARD_NAME", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag",
335 "PRODUCT_NAME", "PRODUCT_VERSION", "FILE_DESCRIPTION", "FILE_VERSION", "ORIGINAL_FILENAME", "INTERNAL_NAME", "LEGAL_COPYRIGHT", "16BIT_DESCRIPTION",
336 "APPHELP_DETAILS", "LINK_URL", "LINK_TEXT", "APPHELP_TITLE", "APPHELP_CONTACT", "SXS_MANIFEST", "DATA_STRING", "MSI_TRANSFORM_FILE",
337 "16BIT_MODULE_NAME", "LAYER_DISPLAYNAME", "COMPILER_VERSION", "ACTION_TYPE", "EXPORT_NAME", "URL", NULL
338 }
339 },
340
341 {
342 TAG_TYPE_LIST, 0x800, __LINE__, VERSION_ANY, VERSION_2003,
343 {
344 "InvalidTag", "DATABASE", "LIBRARY", "INEXCLUDE", "SHIM", "PATCH", "APP", "EXE",
345 "MATCHING_FILE", "SHIM_REF", "PATCH_REF", "LAYER", "FILE", "APPHELP", "LINK", "DATA",
346 "MSI TRANSFORM", "MSI TRANSFORM REF", "MSI PACKAGE", "FLAG", "MSI CUSTOM ACTION", "FLAG_REF", "ACTION", NULL
347 }
348 },
349 {
350 TAG_TYPE_LIST, 0x800, __LINE__, VERSION_VISTA, VERSION_VISTA,
351 {
352 "InvalidTag", "DATABASE", "LIBRARY", "INEXCLUDE", "SHIM", "PATCH", "APP", "EXE",
353 "MATCHING_FILE", "SHIM_REF", "PATCH_REF", "LAYER", "FILE", "APPHELP", "LINK", "DATA",
354 "MSI_TRANSFORM", "MSI_TRANSFORM_REF", "MSI_PACKAGE", "FLAG", "MSI_CUSTOM_ACTION", "FLAG_REF", "ACTION", "LOOKUP",
355 NULL
356 }
357 },
358 {
359 TAG_TYPE_LIST, 0x800, __LINE__, VERSION_WIN7, VERSION_ANY,
360 {
361 "InvalidTag", "DATABASE", "LIBRARY", "INEXCLUDE", "SHIM", "PATCH", "APP", "EXE",
362 "MATCHING_FILE", "SHIM_REF", "PATCH_REF", "LAYER", "FILE", "APPHELP", "LINK", "DATA",
363 "MSI_TRANSFORM", "MSI_TRANSFORM_REF", "MSI_PACKAGE", "FLAG", "MSI_CUSTOM_ACTION", "FLAG_REF", "ACTION", "LOOKUP",
364 "CONTEXT", "CONTEXT_REF", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag",
365 "SPC", NULL
366 }
367 },
368 {
369 TAG_TYPE_LIST | 0x800, 0x800, __LINE__, VERSION_ANY, VERSION_ANY,
370 {
371 "InvalidTag", "STRINGTABLE", "INDEXES", "INDEX", NULL
372 }
373 },
374
375 {
376 TAG_TYPE_STRING, 0x800, __LINE__, VERSION_ANY, VERSION_ANY,
377 {
378 "InvalidTag", NULL
379 }
380 },
381 {
382 TAG_TYPE_STRING | 0x800, 0x800, __LINE__, VERSION_ANY, VERSION_2003,
383 {
384 "InvalidTag", "STRTAB_ITEM", NULL
385 }
386 },
387 {
388 TAG_TYPE_STRING | 0x800, 0x800, __LINE__, VERSION_VISTA, VERSION_ANY,
389 {
390 "InvalidTag", "STRINGTABLE_ITEM", NULL
391 }
392 },
393
394
395 {
396 TAG_TYPE_BINARY, 0x800, __LINE__, VERSION_ANY, VERSION_2003,
397 {
398 "InvalidTag", "InvalidTag", "PATCH_BITS", "FILE_BITS", "EXE_ID(GUID)", "DATA_BITS", "MSI_PACKAGE_ID(GUID)", "DATABASE_ID(GUID)",
399 NULL
400 }
401 },
402 {
403 TAG_TYPE_BINARY, 0x800, __LINE__, VERSION_VISTA, VERSION_VISTA,
404 {
405 "InvalidTag", "InvalidTag", "PATCH_BITS", "FILE_BITS", "EXE_ID", "DATA_BITS", "MSI_PACKAGE_ID", "DATABASE_ID",
406 NULL
407 }
408 },
409 {
410 TAG_TYPE_BINARY, 0x800, __LINE__, VERSION_WIN7, VERSION_ANY,
411 {
412 "InvalidTag", "InvalidTag", "PATCH_BITS", "FILE_BITS", "EXE_ID", "DATA_BITS", "MSI_PACKAGE_ID", "DATABASE_ID",
413 "CONTEXT_PLATFORM_ID", "CONTEXT_BRANCH_ID", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag", "InvalidTag",
414 "FIX_ID", "APP_ID", NULL
415 }
416 },
417 {
418 TAG_TYPE_BINARY | 0x800, 0x800, __LINE__, VERSION_ANY, VERSION_ANY,
419 {
420 "InvalidTag", "INDEX_BITS", NULL
421 }
422 },
423
424 { 0, 0, 0, 0, 0, { NULL } }
425 };
426
427
428 static void test_SdbTagToStringAllTags(void)
429 {
430 int n;
431 for (n = 0; data[n].base; ++n)
432 {
433 if ((data[n].min_ver == VERSION_ANY || g_Version >= data[n].min_ver) &&
434 (data[n].max_ver == VERSION_ANY || g_Version <= data[n].max_ver))
435 {
436 test_tag(data[n].base, data[n].tags, data[n].upper_limit, data[n].line);
437 }
438 }
439 }
440
441 static void test_GuidFunctions(void)
442 {
443 GUID guid;
444 ok(pSdbIsNullGUID(&GUID_NULL), "expected GUID_NULL to be recognized as NULL GUID\n");
445 ok(pSdbIsNullGUID(NULL), "expected NULL to be recognized as NULL GUID\n");
446 ok(pSdbIsNullGUID(&test_UserAssist) == 0, "expected a set GUID not to be recognized as NULL GUID\n");
447
448 memset(&guid, 0, sizeof(guid));
449 ok(pSdbGetStandardDatabaseGUID(0, &guid) == 0,"Expected SdbGetStandardDatabaseGUID to fail\n");
450 ok(IsEqualGUID(&GUID_NULL, &guid), "Expected guid not to be changed\n");
451
452 ok(pSdbGetStandardDatabaseGUID(0x80020000, NULL),"Expected SdbGetStandardDatabaseGUID to succeed\n");
453
454 memset(&guid, 0, sizeof(guid));
455 ok(pSdbGetStandardDatabaseGUID(0x80020000, &guid),"Expected SdbGetStandardDatabaseGUID to succeed\n");
456 ok(IsEqualGUID(&GUID_DATABASE_MSI, &guid), "Expected guid to equal GUID_DATABASE_MSI, was: %s\n", wine_dbgstr_guid(&guid));
457
458 memset(&guid, 0, sizeof(guid));
459 ok(pSdbGetStandardDatabaseGUID(0x80030000, &guid),"Expected SdbGetStandardDatabaseGUID to succeed\n");
460 ok(IsEqualGUID(&GUID_DATABASE_SHIM, &guid), "Expected guid to equal GUID_DATABASE_SHIM, was: %s\n", wine_dbgstr_guid(&guid));
461
462 memset(&guid, 0, sizeof(guid));
463 ok(pSdbGetStandardDatabaseGUID(0x80040000, &guid),"Expected SdbGetStandardDatabaseGUID to succeed\n");
464 ok(IsEqualGUID(&GUID_DATABASE_DRIVERS, &guid), "Expected guid to equal GUID_DATABASE_DRIVERS, was: %s\n", wine_dbgstr_guid(&guid));
465 }
466
467 static void expect_tag_skip_imp(PATTRINFO pattr, DWORD num)
468 {
469 PATTRINFO p = &pattr[num];
470 winetest_ok(p->type == TAG_NULL, "expected entry #%d to be TAG_NULL, was %x\n", num, p->type);
471 winetest_ok(p->flags == ATTRIBUTE_FAILED, "expected entry #%d to be failed, was %d\n", num, p->flags);
472 winetest_ok(p->qwattr == 0, "expected entry #%d to be 0, was 0x%I64x\n", num, p->qwattr);
473 }
474 static void expect_tag_empty_imp(PATTRINFO pattr, DWORD num)
475 {
476 PATTRINFO p = &pattr[num];
477 winetest_ok(p->type == TAG_NULL, "expected entry #%d to be TAG_NULL, was %x\n", num, p->type);
478 winetest_ok(p->flags == 0, "expected entry #%d to be 0, was %d\n", num, p->flags);
479 winetest_ok(p->qwattr == 0, "expected entry #%d to be 0, was 0x%I64x\n", num, p->qwattr);
480 }
481
482 static void expect_tag_dword_imp(PATTRINFO pattr, DWORD num, TAG tag, DWORD value)
483 {
484 PATTRINFO p = &pattr[num];
485 winetest_ok(p->type == tag, "expected entry #%d to be %x, was %x\n", num, tag, p->type);
486 winetest_ok(p->flags == ATTRIBUTE_AVAILABLE, "expected entry #%d to be available, was %d\n", num, p->flags);
487 winetest_ok(p->dwattr == value, "expected entry #%d to be 0x%x, was 0x%x\n", num, value, p->dwattr);
488 }
489
490 static void expect_tag_qword_imp(PATTRINFO pattr, DWORD num, TAG tag, QWORD value)
491 {
492 PATTRINFO p = &pattr[num];
493 winetest_ok(p->type == tag, "expected entry #%d to be %x, was %x\n", num, tag, p->type);
494 winetest_ok(p->flags == ATTRIBUTE_AVAILABLE, "expected entry #%d to be available, was %d\n", num, p->flags);
495 winetest_ok(p->qwattr == value, "expected entry #%d to be 0x%I64x, was 0x%I64x\n", num, value, p->qwattr);
496 }
497
498 static void expect_tag_str_imp(PATTRINFO pattr, DWORD num, TAG tag, const WCHAR* value)
499 {
500 PATTRINFO p = &pattr[num];
501 winetest_ok(p->type == tag, "expected entry #%d to be %x, was %x\n", num, tag, p->type);
502 winetest_ok(p->flags == ATTRIBUTE_AVAILABLE, "expected entry #%d to be available, was %d\n", num, p->flags);
503 winetest_ok(p->lpattr && wcscmp(p->lpattr, value) == 0, "expected entry #%d to be %s, was %s\n", num, wine_dbgstr_w(value), wine_dbgstr_w(p->lpattr));
504 }
505
506 #define expect_tag_skip (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_tag_skip_imp
507 #define expect_tag_empty (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_tag_empty_imp
508 #define expect_tag_dword (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_tag_dword_imp
509 #define expect_tag_qword (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_tag_qword_imp
510 #define expect_tag_str (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_tag_str_imp
511 #define expect_tag_skip_range(ptr, from, to) \
512 do { \
513 int n = (from), n_end = (to); \
514 winetest_set_location(__FILE__, __LINE__); \
515 for ( ; n < n_end; ++n) \
516 expect_tag_skip_imp((ptr), n); \
517 } while (0)
518 #define test_crc (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_crc_imp
519 #define test_crc2 (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : test_crc2_imp
520
521 void test_onefile(WCHAR* filename)
522 {
523 PATTRINFO pattrinfo;
524 DWORD num;
525
526 if (!pSdbFreeFileAttributes)
527 {
528 hdll = LoadLibraryA("apphelp.dll");
529 pSdbTagToString = (void *)GetProcAddress(hdll, "SdbTagToString");
530 pSdbGetFileAttributes = (void *)GetProcAddress(hdll, "SdbGetFileAttributes");
531 pSdbFreeFileAttributes = (void *)GetProcAddress(hdll, "SdbFreeFileAttributes");
532 }
533
534 if (pSdbGetFileAttributes(filename, &pattrinfo, &num))
535 {
536 if (pattrinfo[16].flags == ATTRIBUTE_AVAILABLE)
537 {
538 if (pattrinfo[16].type != TAG_MODULE_TYPE)//SdbpSetAttrFail(&attr_info[16]); /* TAG_MODULE_TYPE (1: WIN16?) (3: WIN32?) (WIN64?), Win32VersionValue? */)
539 printf("FAIL TAG_MODULE_TYPE (%S)\n", filename);
540 if (pattrinfo[16].dwattr != 3 && pattrinfo[16].dwattr != 2)
541 printf("TAG_MODULE_TYPE(%S): %d\n", filename, pattrinfo[16].dwattr); // C:\Program Files (x86)\Windows Kits\8.1\Lib\win7\stub512.com
542 if (pattrinfo[16].dwattr == 2)
543 {
544 printf("TAG_MODULE_TYPE(%S): %d, %d\n", filename, pattrinfo[16].dwattr, pattrinfo[0].dwattr);
545 }
546 }
547
548 if (pattrinfo[27].flags == ATTRIBUTE_AVAILABLE)
549 {
550 if (pattrinfo[27].type != TAG_EXE_WRAPPER)
551 printf("FAIL TAG_EXE_WRAPPER (%S)\n", filename);
552 if (pattrinfo[27].dwattr != 0)
553 printf("TAG_EXE_WRAPPER(%S): %d\n", filename, pattrinfo[27].dwattr);
554 }
555
556 pSdbFreeFileAttributes(pattrinfo);
557 }
558 }
559
560 static void test_crc_imp(size_t len, DWORD expected)
561 {
562 static const WCHAR path[] = {'t','e','s','t','x','x','.','e','x','e',0};
563 static char crc_test[] = {4, 4, 4, 4, 1, 1, 1, 1, 4, 4, 4, 4, 2, 2, 2, 2};
564
565 PATTRINFO pattrinfo = (PATTRINFO)0xdead;
566 DWORD num = 333;
567 BOOL ret;
568
569 test_create_file_imp("testxx.exe", crc_test, len);
570 ret = pSdbGetFileAttributes(path, &pattrinfo, &num);
571 winetest_ok(ret != FALSE, "expected SdbGetFileAttributes to succeed.\n");
572 winetest_ok(pattrinfo != (PATTRINFO)0xdead, "expected a valid pointer.\n");
573 winetest_ok(num == 28, "expected 28 items, got %d.\n", num);
574
575 if (num == 28 && ret)
576 {
577 expect_tag_dword_imp(pattrinfo, 1, TAG_CHECKSUM, expected);
578 }
579 if (ret)
580 pSdbFreeFileAttributes(pattrinfo);
581 }
582
583 static void test_crc2_imp(size_t len, int fill, DWORD expected)
584 {
585 static const WCHAR path[] = {'t','e','s','t','x','x','.','e','x','e',0};
586
587 PATTRINFO pattrinfo = (PATTRINFO)0xdead;
588 DWORD num = 333;
589 BOOL ret;
590 size_t n;
591 char* crc_test = malloc(len);
592 for (n = 0; n < len; ++n)
593 crc_test[n] = (char)(fill ? fill : n);
594
595 test_create_file_imp("testxx.exe", crc_test, len);
596 free(crc_test);
597 ret = pSdbGetFileAttributes(path, &pattrinfo, &num);
598 winetest_ok(ret != FALSE, "expected SdbGetFileAttributes to succeed.\n");
599 winetest_ok(pattrinfo != (PATTRINFO)0xdead, "expected a valid pointer.\n");
600 winetest_ok(num == 28, "expected 28 items, got %d.\n", num);
601
602 if (num == 28 && ret)
603 {
604 expect_tag_dword_imp(pattrinfo, 0, TAG_SIZE, len);
605 expect_tag_dword_imp(pattrinfo, 1, TAG_CHECKSUM, expected);
606 }
607 if (ret)
608 pSdbFreeFileAttributes(pattrinfo);
609 }
610
611
612
613 static void test_ApplicationAttributes(void)
614 {
615 static const WCHAR path[] = {'t','e','s','t','x','x','.','e','x','e',0};
616 static const WCHAR PRODUCT_VERSION[] = {'1','.','0','.','0','.','1',0};
617 static const WCHAR FILE_DESCRIPTION[] = {'F','i','l','e','D','e','s','c','r','i','p','t','i','o','n',0};
618 static const WCHAR COMPANY_NAME[] = {'C','o','m','p','a','n','y','N','a','m','e',0};
619 static const WCHAR PRODUCT_NAME[] = {'P','r','o','d','u','c','t','N','a','m','e',0};
620 static const WCHAR FILE_VERSION[] = {'1','.','0','.','0','.','0',0};
621 static const WCHAR ORIGINAL_FILENAME[] = {'O','r','i','g','i','n','a','l','F','i','l','e','n','a','m','e',0};
622 static const WCHAR INTERNAL_NAME[] = {'I','n','t','e','r','n','a','l','N','a','m','e',0};
623 static const WCHAR LEGAL_COPYRIGHT[] = {'L','e','g','a','l','C','o','p','y','r','i','g','h','t',0};
624 static const WCHAR EXPORT_NAME[] = {'T','e','S','t','2','.','e','x','e',0};
625 static const WCHAR OS2_DESCRIPTION[] = {'M','O','D',' ','D','E','S','C','R','I','P','T','I','O','N',' ','H','E','R','E',0};
626 static const WCHAR OS2_EXPORT_NAME[] = {'T','E','S','T','M','O','D','.','h','X','x',0};
627 static const WCHAR OS2_DESCRIPTION_broken[] = {'Z',0};
628 static const WCHAR OS2_EXPORT_NAME_broken[] = {'E',0};
629
630 PATTRINFO pattrinfo = (PATTRINFO)0xdead;
631 DWORD num = 333;
632 BOOL ret;
633
634 /* ensure the file is not there. */
635 DeleteFileA("testxx.exe");
636 ret = pSdbGetFileAttributes(path, &pattrinfo, &num);
637 ok(ret == FALSE, "expected SdbGetFileAttributes to fail.\n");
638 ok(pattrinfo == (PATTRINFO)0xdead, "expected the pointer not to change.\n");
639 ok(num == 333, "expected the number of items not to change.\n");
640 if (ret)
641 pSdbFreeFileAttributes(pattrinfo);
642
643 /* Test a file with as much features as possible */
644 test_create_exe("testxx.exe", 0);
645
646 ret = pSdbGetFileAttributes(path, &pattrinfo, &num);
647 ok(ret != FALSE, "expected SdbGetFileAttributes to succeed.\n");
648 ok(pattrinfo != (PATTRINFO)0xdead, "expected a valid pointer.\n");
649 ok(num == 28, "expected 28 items, got %d.\n", num);
650
651 if (num == 28 && ret)
652 {
653 expect_tag_dword(pattrinfo, 0, TAG_SIZE, 0x800);
654 expect_tag_dword(pattrinfo, 1, TAG_CHECKSUM, 0x178bd629);
655 expect_tag_qword(pattrinfo, 2, TAG_BIN_FILE_VERSION, 0x1000000000000ull);
656 expect_tag_qword(pattrinfo, 3, TAG_BIN_PRODUCT_VERSION, 0x1000000000001ull);
657 expect_tag_str(pattrinfo, 4, TAG_PRODUCT_VERSION, PRODUCT_VERSION);
658 expect_tag_str(pattrinfo, 5, TAG_FILE_DESCRIPTION, FILE_DESCRIPTION);
659 expect_tag_str(pattrinfo, 6, TAG_COMPANY_NAME, COMPANY_NAME);
660 expect_tag_str(pattrinfo, 7, TAG_PRODUCT_NAME, PRODUCT_NAME);
661 expect_tag_str(pattrinfo, 8, TAG_FILE_VERSION, FILE_VERSION);
662 expect_tag_str(pattrinfo, 9, TAG_ORIGINAL_FILENAME, ORIGINAL_FILENAME);
663 expect_tag_str(pattrinfo, 10, TAG_INTERNAL_NAME, INTERNAL_NAME);
664 expect_tag_str(pattrinfo, 11, TAG_LEGAL_COPYRIGHT, LEGAL_COPYRIGHT);
665 expect_tag_dword(pattrinfo, 12, TAG_VERDATEHI, 0x1d1a019);
666 expect_tag_dword(pattrinfo, 13, TAG_VERDATELO, 0xac754c50);
667 expect_tag_dword(pattrinfo, 14, TAG_VERFILEOS, VOS__WINDOWS32);
668 expect_tag_dword(pattrinfo, 15, TAG_VERFILETYPE, VFT_APP);
669 expect_tag_dword(pattrinfo, 16, TAG_MODULE_TYPE, 0x3); /* Win32 */
670 expect_tag_dword(pattrinfo, 17, TAG_PE_CHECKSUM, 0xBAAD);
671 expect_tag_dword(pattrinfo, 18, TAG_LINKER_VERSION, 0x40002);
672 expect_tag_skip(pattrinfo, 19); /* TAG_16BIT_DESCRIPTION */
673 expect_tag_skip(pattrinfo, 20); /* TAG_16BIT_MODULE_NAME */
674 expect_tag_qword(pattrinfo, 21, TAG_UPTO_BIN_FILE_VERSION, 0x1000000000000ull);
675 expect_tag_qword(pattrinfo, 22, TAG_UPTO_BIN_PRODUCT_VERSION, 0x1000000000001ull);
676 expect_tag_dword(pattrinfo, 23, TAG_LINK_DATE, 0x12345);
677 expect_tag_dword(pattrinfo, 24, TAG_UPTO_LINK_DATE, 0x12345);
678 expect_tag_str(pattrinfo, 25, TAG_EXPORT_NAME, EXPORT_NAME);
679 expect_tag_dword(pattrinfo, 26, TAG_VER_LANGUAGE, 0xffff);
680 expect_tag_dword(pattrinfo, 27, TAG_EXE_WRAPPER, 0x0);
681 }
682 if (ret)
683 pSdbFreeFileAttributes(pattrinfo);
684
685
686 /* Disable resource and exports */
687 test_create_exe("testxx.exe", 1);
688
689 ret = pSdbGetFileAttributes(path, &pattrinfo, &num);
690 ok(ret != FALSE, "expected SdbGetFileAttributes to succeed.\n");
691 ok(pattrinfo != (PATTRINFO)0xdead, "expected a valid pointer.\n");
692 ok(num == 28, "expected 28 items, got %d.\n", num);
693
694 if (num == 28 && ret)
695 {
696 expect_tag_dword(pattrinfo, 0, TAG_SIZE, 0x800);
697 expect_tag_dword(pattrinfo, 1, TAG_CHECKSUM, 0xea7caffd);
698 expect_tag_skip_range(pattrinfo, 2, 16);
699 expect_tag_dword(pattrinfo, 16, TAG_MODULE_TYPE, 0x3); /* Win32 */
700 expect_tag_dword(pattrinfo, 17, TAG_PE_CHECKSUM, 0xBAAD);
701 expect_tag_dword(pattrinfo, 18, TAG_LINKER_VERSION, 0x40002);
702 expect_tag_skip_range(pattrinfo, 19, 23);
703 expect_tag_dword(pattrinfo, 23, TAG_LINK_DATE, 0x12345);
704 expect_tag_dword(pattrinfo, 24, TAG_UPTO_LINK_DATE, 0x12345);
705 expect_tag_skip(pattrinfo, 25); /* TAG_EXPORT_NAME */
706 expect_tag_empty(pattrinfo, 26); /* TAG_VER_LANGUAGE */
707 expect_tag_dword(pattrinfo, 27, TAG_EXE_WRAPPER, 0x0);
708 }
709 if (ret)
710 pSdbFreeFileAttributes(pattrinfo);
711
712 /* A file with just 'MZ' */
713 test_create_file("testxx.exe", "MZ", 2);
714
715 ret = pSdbGetFileAttributes(path, &pattrinfo, &num);
716 ok(ret != FALSE, "expected SdbGetFileAttributes to succeed.\n");
717 ok(pattrinfo != (PATTRINFO)0xdead, "expected a valid pointer.\n");
718 ok(num == 28, "expected 28 items, got %d.\n", num);
719
720 if (num == 28 && ret)
721 {
722 expect_tag_dword(pattrinfo, 0, TAG_SIZE, 0x2);
723 expect_tag_dword(pattrinfo, 1, TAG_CHECKSUM, 0);
724 expect_tag_skip_range(pattrinfo, 2, 16);
725 expect_tag_dword(pattrinfo, 16, TAG_MODULE_TYPE, 0x1);
726 expect_tag_skip_range(pattrinfo, 17, 26);
727 expect_tag_empty(pattrinfo, 26); /* TAG_VER_LANGUAGE */
728 expect_tag_skip(pattrinfo, 27); /* TAG_EXE_WRAPPER */
729 }
730 if (ret)
731 pSdbFreeFileAttributes(pattrinfo);
732
733 /* Empty file */
734 test_create_file("testxx.exe", NULL, 0);
735
736 ret = pSdbGetFileAttributes(path, &pattrinfo, &num);
737 ok(ret != FALSE, "expected SdbGetFileAttributes to succeed.\n");
738 ok(pattrinfo != (PATTRINFO)0xdead, "expected a valid pointer.\n");
739 ok(num == 28, "expected 28 items, got %d.\n", num);
740
741 if (num == 28 && ret)
742 {
743 expect_tag_dword(pattrinfo, 0, TAG_SIZE, 0);
744 expect_tag_skip_range(pattrinfo, 1, 26);
745 expect_tag_empty(pattrinfo, 26); /* TAG_VER_LANGUAGE */
746 expect_tag_skip(pattrinfo, 27); /* TAG_EXE_WRAPPER */
747 }
748 if (ret)
749 pSdbFreeFileAttributes(pattrinfo);
750
751 /* minimal NE executable */
752 test_create_ne("testxx.exe", 0);
753
754 ret = pSdbGetFileAttributes(path, &pattrinfo, &num);
755 ok(ret != FALSE, "expected SdbGetFileAttributes to succeed.\n");
756 ok(pattrinfo != (PATTRINFO)0xdead, "expected a valid pointer.\n");
757 ok(num == 28, "expected 28 items, got %d.\n", num);
758
759 if (num == 28 && ret)
760 {
761 expect_tag_dword(pattrinfo, 0, TAG_SIZE, 0xa8);
762 expect_tag_dword(pattrinfo, 1, TAG_CHECKSUM, 0xf2abe4e9);
763 expect_tag_skip_range(pattrinfo, 2, 16);
764 expect_tag_dword(pattrinfo, 16, TAG_MODULE_TYPE, 0x2);
765 expect_tag_skip(pattrinfo, 17); /* TAG_PE_CHECKSUM */
766 expect_tag_skip(pattrinfo, 18); /* TAG_LINKER_VERSION */
767 expect_tag_str(pattrinfo, 19, TAG_16BIT_DESCRIPTION, OS2_DESCRIPTION);
768 expect_tag_str(pattrinfo, 20, TAG_16BIT_MODULE_NAME, OS2_EXPORT_NAME);
769 expect_tag_skip_range(pattrinfo, 21, 26);
770 expect_tag_empty(pattrinfo, 26); /* TAG_VER_LANGUAGE */
771 expect_tag_skip(pattrinfo, 27); /* TAG_EXE_WRAPPER */
772 }
773 if (ret)
774 pSdbFreeFileAttributes(pattrinfo);
775
776 /* NE executable with description / module name pointers zero, to show they are always used */
777 test_create_ne("testxx.exe", 1);
778
779 ret = pSdbGetFileAttributes(path, &pattrinfo, &num);
780 ok(ret != FALSE, "expected SdbGetFileAttributes to succeed.\n");
781 ok(pattrinfo != (PATTRINFO)0xdead, "expected a valid pointer.\n");
782 ok(num == 28, "expected 28 items, got %d.\n", num);
783
784 if (num == 28 && ret)
785 {
786 expect_tag_dword(pattrinfo, 0, TAG_SIZE, 0xa8);
787 expect_tag_dword(pattrinfo, 1, TAG_CHECKSUM, 0xddcbe4c9);
788 expect_tag_skip_range(pattrinfo, 2, 16);
789 expect_tag_dword(pattrinfo, 16, TAG_MODULE_TYPE, 0x2);
790 expect_tag_skip(pattrinfo, 17); /* TAG_PE_CHECKSUM */
791 expect_tag_skip(pattrinfo, 18); /* TAG_LINKER_VERSION */
792 expect_tag_str(pattrinfo, 19, TAG_16BIT_DESCRIPTION, OS2_DESCRIPTION_broken); /* the 'Z' from 'MZ' */
793 expect_tag_str(pattrinfo, 20, TAG_16BIT_MODULE_NAME, OS2_EXPORT_NAME_broken); /* the 'E' from 'NE' */
794 expect_tag_skip_range(pattrinfo, 21, 26);
795 expect_tag_empty(pattrinfo, 26); /* TAG_VER_LANGUAGE */
796 expect_tag_skip(pattrinfo, 27); /* TAG_EXE_WRAPPER */
797 }
798 if (ret)
799 pSdbFreeFileAttributes(pattrinfo);
800
801 test_crc(1, 0);
802 test_crc(2, 0);
803 test_crc(3, 0);
804 test_crc(4, 0x2020202);
805 test_crc(5, 0x2020202);
806 test_crc(6, 0x2020202);
807 test_crc(7, 0x2020202);
808 test_crc(8, 0x81818181);
809 test_crc(9, 0x81818181);
810 test_crc(10, 0x81818181);
811 test_crc(11, 0x81818181);
812 test_crc(12, 0xc2c2c2c2);
813 test_crc(16, 0x62626262);
814
815 /* This seems to be the cutoff point */
816 test_crc2(0xffc, 4, 0xfbfbfcfc);
817 test_crc2(0xffc, 8, 0x7070717);
818 test_crc2(0xffc, 0xcc, 0xc8eba002);
819 test_crc2(0xffc, 0, 0x4622028d);
820
821 test_crc2(0x1000, 4, 0x80);
822 test_crc2(0x1000, 8, 0x8787878f);
823 test_crc2(0x1000, 0xcc, 0x4adc3667);
824 test_crc2(0x1000, 0, 0xa3108044);
825
826 /* Here is another cutoff point */
827 test_crc2(0x11fc, 4, 0x80);
828 test_crc2(0x11fc, 8, 0x8787878f);
829 test_crc2(0x11fc, 0xcc, 0x4adc3667);
830 test_crc2(0x11fc, 0, 0xf03e0800);
831
832 test_crc2(0x1200, 4, 0x80);
833 test_crc2(0x1200, 8, 0x8787878f);
834 test_crc2(0x1200, 0xcc, 0x4adc3667);
835 test_crc2(0x1200, 0, 0xa3108044);
836
837 /* After that, it stays the same for all sizes */
838 test_crc2(0xf000, 4, 0x80);
839 test_crc2(0xf000, 8, 0x8787878f);
840 test_crc2(0xf000, 0xcc, 0x4adc3667);
841 test_crc2(0xf000, 0, 0xa3108044);
842
843
844 DeleteFileA("testxx.exe");
845 }
846
847 START_TEST(apphelp)
848 {
849 RTL_OSVERSIONINFOEXW rtlinfo;
850 rtlinfo.dwOSVersionInfoSize = sizeof(rtlinfo);
851 #ifdef __REACTOS__
852 RtlGetVersion((PRTL_OSVERSIONINFOW)&rtlinfo);
853 #else
854 RtlGetVersion(&rtlinfo);
855 #endif
856 g_Version = (rtlinfo.dwMajorVersion << 8) | rtlinfo.dwMinorVersion;
857 trace("Detected version: 0x%x\n", g_Version);
858 //SetEnvironmentVariable("SHIM_DEBUG_LEVEL", "4");
859 //SetEnvironmentVariable("DEBUGCHANNEL", "+apphelp");
860 hdll = LoadLibraryA("apphelp.dll");
861 pSdbTagToString = (void *) GetProcAddress(hdll, "SdbTagToString");
862 pSdbGUIDToString = (void *) GetProcAddress(hdll, "SdbGUIDToString");
863 pSdbIsNullGUID = (void *) GetProcAddress(hdll, "SdbIsNullGUID");
864 pSdbGetStandardDatabaseGUID = (void *) GetProcAddress(hdll, "SdbGetStandardDatabaseGUID");
865 pSdbGetFileAttributes = (void *) GetProcAddress(hdll, "SdbGetFileAttributes");
866 pSdbFreeFileAttributes = (void *) GetProcAddress(hdll, "SdbFreeFileAttributes");
867
868 test_GuidFunctions();
869 test_ApplicationAttributes();
870 test_SdbTagToString();
871 #ifdef __REACTOS__
872 if (g_Version < VERSION_WIN7)
873 {
874 g_Version = VERSION_WIN7;
875 trace("Using version 0x%x for SdbTagToString tests\n", g_Version);
876 }
877 #endif
878 test_SdbTagToStringAllTags();
879 }