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