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