ReactOS  0.4.14-dev-49-gfb4591c
db.cpp
Go to the documentation of this file.
1 /*
2  * PROJECT: apphelp_apitest
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Tests for shim-database api's
5  * COPYRIGHT: Copyright 2012 Detlef Riekenberg
6  * Copyright 2013 Mislav Blažević
7  * Copyright 2015-2019 Mark Jansen (mark.jansen@reactos.org)
8  */
9 
10 #include <ntstatus.h>
11 #define WIN32_NO_STATUS
12 #include <windows.h>
13 #include <shlwapi.h>
14 #include <winnt.h>
15 #ifdef __REACTOS__
16 #include <ntndk.h>
17 #else
18 #include <winternl.h>
19 #endif
20 
21 #include <winerror.h>
22 #include <stdio.h>
23 #include <initguid.h>
24 
25 #include "wine/test.h"
26 
27 #include "apphelp_apitest.h"
28 
29 
30 #define DOS_PATH 0
31 #define HID_DATABASE_FULLPATH 2
32 
33 #define SDB_DATABASE_MAIN_SHIM 0x80030000
34 
35 
36 #define TAGID_NULL 0x0
37 #define TAGID_ROOT 0x0
38 #define _TAGID_ROOT 12
39 
40 
41 #define TAG_TYPE_MASK 0xF000
42 
43 #define TAG_TYPE_NULL 0x1000
44 #define TAG_TYPE_BYTE 0x2000
45 #define TAG_TYPE_WORD 0x3000
46 #define TAG_TYPE_DWORD 0x4000
47 #define TAG_TYPE_QWORD 0x5000
48 #define TAG_TYPE_STRINGREF 0x6000
49 #define TAG_TYPE_LIST 0x7000
50 #define TAG_TYPE_STRING 0x8000
51 #define TAG_TYPE_BINARY 0x9000
52 #define TAG_NULL 0x0
53 
54 #define TAG_INCLUDE (0x1 | TAG_TYPE_NULL)
55 
56 #define TAG_MATCH_MODE (0x1 | TAG_TYPE_WORD)
57 
58 #define TAG_SIZE (0x1 | TAG_TYPE_DWORD)
59 #define TAG_CHECKSUM (0x3 | TAG_TYPE_DWORD)
60 #define TAG_MODULE_TYPE (0x6 | TAG_TYPE_DWORD)
61 #define TAG_VERFILEOS (0x9 | TAG_TYPE_DWORD)
62 #define TAG_VERFILETYPE (0xA | TAG_TYPE_DWORD)
63 #define TAG_PE_CHECKSUM (0xB | TAG_TYPE_DWORD)
64 #define TAG_PROBLEMSEVERITY (0x10 | TAG_TYPE_DWORD)
65 #define TAG_HTMLHELPID (0x15 | TAG_TYPE_DWORD)
66 #define TAG_FLAGS (0x17 | TAG_TYPE_DWORD)
67 #define TAG_LAYER_TAGID (0x1A | 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_APP_NAME_RC_ID (0x24 | TAG_TYPE_DWORD)
72 #define TAG_VENDOR_NAME_RC_ID (0x25 | TAG_TYPE_DWORD)
73 #define TAG_SUMMARY_MSG_RC_ID (0x26 | TAG_TYPE_DWORD)
74 #define TAG_OS_PLATFORM (0x23 | TAG_TYPE_DWORD)
75 
76 #define TAG_TIME (0x1 | TAG_TYPE_QWORD)
77 #define TAG_BIN_FILE_VERSION (0x2 | TAG_TYPE_QWORD)
78 #define TAG_BIN_PRODUCT_VERSION (0x3 | TAG_TYPE_QWORD)
79 #define TAG_UPTO_BIN_PRODUCT_VERSION (0x6 | TAG_TYPE_QWORD)
80 #define TAG_UPTO_BIN_FILE_VERSION (0xD | TAG_TYPE_QWORD)
81 #define TAG_FLAG_LUA (0x10 | TAG_TYPE_QWORD)
82 
83 #define TAG_DATABASE (0x1 | TAG_TYPE_LIST)
84 #define TAG_INEXCLUD (0x3 | TAG_TYPE_LIST)
85 #define TAG_EXE (0x7 | TAG_TYPE_LIST)
86 #define TAG_MATCHING_FILE (0x8 | TAG_TYPE_LIST)
87 #define TAG_SHIM_REF (0x9| TAG_TYPE_LIST)
88 #define TAG_LAYER (0xB | TAG_TYPE_LIST)
89 #define TAG_APPHELP (0xD | TAG_TYPE_LIST)
90 #define TAG_LINK (0xE | TAG_TYPE_LIST)
91 #define TAG_DATA (0xF | TAG_TYPE_LIST)
92 #define TAG_STRINGTABLE (0x801 | TAG_TYPE_LIST)
93 
94 #define TAG_STRINGTABLE_ITEM (0x801 | TAG_TYPE_STRING)
95 
96 #define TAG_NAME (0x1 | TAG_TYPE_STRINGREF)
97 #define TAG_MODULE (0x3 | TAG_TYPE_STRINGREF)
98 #define TAG_VENDOR (0x5 | TAG_TYPE_STRINGREF)
99 #define TAG_APP_NAME (0x6 | TAG_TYPE_STRINGREF)
100 #define TAG_COMMAND_LINE (0x8 | TAG_TYPE_STRINGREF)
101 #define TAG_COMPANY_NAME (0x9 | TAG_TYPE_STRINGREF)
102 #define TAG_WILDCARD_NAME (0xB | TAG_TYPE_STRINGREF)
103 #define TAG_PRODUCT_NAME (0x10 | TAG_TYPE_STRINGREF)
104 #define TAG_PRODUCT_VERSION (0x11 | TAG_TYPE_STRINGREF)
105 #define TAG_FILE_DESCRIPTION (0x12 | TAG_TYPE_STRINGREF)
106 #define TAG_FILE_VERSION (0x13 | TAG_TYPE_STRINGREF)
107 #define TAG_ORIGINAL_FILENAME (0x14 | TAG_TYPE_STRINGREF)
108 #define TAG_INTERNAL_NAME (0x15 | TAG_TYPE_STRINGREF)
109 #define TAG_LEGAL_COPYRIGHT (0x16 | TAG_TYPE_STRINGREF)
110 #define TAG_APPHELP_DETAILS (0x18 | TAG_TYPE_STRINGREF)
111 #define TAG_LINK_URL (0x19 | TAG_TYPE_STRINGREF)
112 #define TAG_APPHELP_TITLE (0x1B | TAG_TYPE_STRINGREF)
113 
114 #define TAG_COMPILER_VERSION (0x22 | TAG_TYPE_STRINGREF)
115 
116 #define TAG_GENERAL (0x2 | TAG_TYPE_NULL)
117 
118 #define TAG_EXE_ID (0x4 | TAG_TYPE_BINARY)
119 #define TAG_DATA_BITS (0x5 | TAG_TYPE_BINARY)
120 #define TAG_DATABASE_ID (0x7 | TAG_TYPE_BINARY)
121 
122 
123 typedef struct _DB_INFORMATION
124 {
126  DWORD dwMajor;
127  DWORD dwMinor;
129  GUID Id;
130  /* Win10+ has an extra field here */
132 
133 
134 static HMODULE hdll;
135 static LPCWSTR (WINAPI *pSdbTagToString)(TAG);
136 static PDB (WINAPI *pSdbOpenDatabase)(LPCWSTR, PATH_TYPE);
137 static PDB (WINAPI *pSdbCreateDatabase)(LPCWSTR, PATH_TYPE);
138 static BOOL (WINAPI *pSdbGetDatabaseVersion)(LPCWSTR, PDWORD, PDWORD);
139 static void (WINAPI *pSdbCloseDatabase)(PDB);
140 static void (WINAPI *pSdbCloseDatabaseWrite)(PDB);
141 static TAG (WINAPI *pSdbGetTagFromTagID)(PDB, TAGID);
142 static BOOL (WINAPI *pSdbWriteNULLTag)(PDB, TAG);
143 static BOOL (WINAPI *pSdbWriteWORDTag)(PDB, TAG, WORD);
144 static BOOL (WINAPI *pSdbWriteDWORDTag)(PDB, TAG, DWORD);
145 static BOOL (WINAPI *pSdbWriteQWORDTag)(PDB, TAG, QWORD);
146 static BOOL (WINAPI *pSdbWriteBinaryTagFromFile)(PDB, TAG, LPCWSTR);
147 static BOOL (WINAPI *pSdbWriteStringTag)(PDB, TAG, LPCWSTR);
148 static BOOL (WINAPI *pSdbWriteStringRefTag)(PDB, TAG, TAGID);
149 static TAGID (WINAPI *pSdbBeginWriteListTag)(PDB, TAG);
150 static BOOL (WINAPI *pSdbEndWriteListTag)(PDB, TAGID);
151 static TAGID (WINAPI *pSdbFindFirstTag)(PDB, TAGID, TAG);
152 static TAGID (WINAPI *pSdbFindNextTag)(PDB, TAGID, TAGID);
153 static TAGID (WINAPI *pSdbFindFirstNamedTag)(PDB pdb, TAGID root, TAGID find, TAGID nametag, LPCWSTR find_name);
154 static WORD (WINAPI *pSdbReadWORDTag)(PDB, TAGID, WORD);
155 static DWORD (WINAPI *pSdbReadDWORDTag)(PDB, TAGID, DWORD);
156 static QWORD (WINAPI *pSdbReadQWORDTag)(PDB, TAGID, QWORD);
157 static BOOL (WINAPI *pSdbReadBinaryTag)(PDB, TAGID, PBYTE, DWORD);
158 static BOOL (WINAPI *pSdbReadStringTag)(PDB, TAGID, LPWSTR, DWORD);
159 static DWORD (WINAPI *pSdbGetTagDataSize)(PDB, TAGID);
160 static PVOID (WINAPI *pSdbGetBinaryTagData)(PDB, TAGID);
161 static LPWSTR (WINAPI *pSdbGetStringTagPtr)(PDB, TAGID);
162 static TAGID (WINAPI *pSdbGetFirstChild)(PDB, TAGID);
163 static TAGID (WINAPI *pSdbGetNextChild)(PDB, TAGID, TAGID);
164 static BOOL (WINAPI *pSdbGetDatabaseID)(PDB, GUID*);
165 static BOOL (WINAPI *pSdbGUIDToString)(CONST GUID *, PCWSTR, SIZE_T);
166 static HSDB (WINAPI *pSdbInitDatabase)(DWORD, LPCWSTR);
167 static void (WINAPI *pSdbReleaseDatabase)(HSDB);
169 static BOOL (WINAPI *pSdbTagRefToTagID)(HSDB hSDB, TAGREF trWhich, PDB *ppdb, TAGID *ptiWhich);
170 static BOOL (WINAPI *pSdbTagIDToTagRef)(HSDB hSDB, PDB pdb, TAGID tiWhich, TAGREF *ptrWhich);
171 static TAGREF (WINAPI *pSdbGetLayerTagRef)(HSDB hsdb, LPCWSTR layerName);
172 static LONGLONG (WINAPI* pSdbMakeIndexKeyFromString)(LPCWSTR);
176 static BOOL (WINAPI* pSdbGetDatabaseInformation)(PDB pdb, PDB_INFORMATION information);
177 static VOID (WINAPI* pSdbFreeDatabaseInformation)(PDB_INFORMATION information);
178 
179 DEFINE_GUID(GUID_DATABASE_TEST, 0xe39b0eb0, 0x55db, 0x450b, 0x9b, 0xd4, 0xd2, 0x0c, 0x94, 0x84, 0x26, 0x0f);
180 DEFINE_GUID(GUID_MAIN_DATABASE, 0x11111111, 0x1111, 0x1111, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11);
181 
182 
184 {
185  DWORD dwWritten = 0;
186  WriteFile(file, buffer, size, &dwWritten, NULL);
187 }
188 
190 {
191  PDB_INFORMATION pInfo;
192  BOOL fResult;
193 
194  if (!pSdbGetDatabaseInformation || !pSdbFreeDatabaseInformation)
195  {
196  skip("GetDatabaseInformation or SdbFreeDatabaseInformation not found\n");
197  return;
198  }
199 
200  pInfo = (PDB_INFORMATION)malloc(sizeof(*pInfo) * 4);
201  memset(pInfo, 0xDE, sizeof(*pInfo) * 2);
202 
203  fResult = pSdbGetDatabaseInformation(pdb, pInfo);
204  ok(fResult, "SdbGetDatabaseInformation failed\n");
205  if (fResult)
206  {
207  ok_int(pInfo->dwSomething, 0);
208  ok(IsEqualGUID(GUID_NULL, pInfo->Id), "expected guid to be empty(%s)\n", wine_dbgstr_guid(&pInfo->Id));
209  ok(pInfo->Description == NULL, "Expected pInfo->Description to be NULL, was %s\n", wine_dbgstr_w(pInfo->Description));
210 
211  /* Struct is slightly bigger on some Win10, and the DB version nr is different on all */
212  if (g_WinVersion >= WINVER_WIN10)
213  {
214  ok(pInfo->dwMajor == 3, "Expected pInfo->dwMajor to be 3, was: %d\n", pInfo->dwMajor);
215  ok(pInfo->dwMinor == 0, "Expected pInfo->dwMinor to be 0, was: %d\n", pInfo->dwMinor);
216 
217  ok(pInfo[1].dwSomething == 0 || pInfo[1].dwSomething == 0xdededede, "Something amiss: 0x%x\n", pInfo[1].dwSomething);
218  ok(pInfo[1].dwMajor == 0xdededede, "Cookie2 corrupt: 0x%x\n", pInfo[1].dwMajor);
219  }
220  else
221  {
222  ok(pInfo->dwMajor == 2, "Expected pInfo->dwMajor to be 2, was: %d\n", pInfo->dwMajor);
224  ok(pInfo->dwMinor == 1, "Expected pInfo->dwMinor to be 1, was: %d\n", pInfo->dwMinor);
225  else
226  ok(pInfo->dwMinor == 190915, "Expected pInfo->dwMinor to be 190915, was: %d\n", pInfo->dwMinor);
227 
228  ok(pInfo[1].dwSomething == 0xdededede, "Cookie1 corrupt: 0x%x\n", pInfo[1].dwSomething);
229  ok(pInfo[1].dwMajor == 0xdededede, "Cookie2 corrupt: 0x%x\n", pInfo[1].dwMajor);
230  }
231 
232  }
233  free(pInfo);
234 }
235 
236 
237 static void test_Sdb(void)
238 {
239  static const WCHAR temp[] = L"temp";
240  static const WCHAR path1[] = L"temp.sdb";
241  static const WCHAR path2[] = L"temp2.bin";
242  static const WCHAR tag_size_string[] = L"SIZE";
243  static const WCHAR tag_flag_lua_string[] = L"FLAG_LUA";
244  static const WCHAR invalid_tag[] = L"InvalidTag";
245  static const TAG tags[5] = {
248  };
249  WCHAR buffer[6] = { 0 };
250  PDB pdb;
251  QWORD qword;
252  DWORD dword;
253  WORD word;
254  BOOL ret;
255  HANDLE file; /* temp file created for testing purpose */
256  TAG tag;
257  TAGID tagid, ptagid, stringref = 6;
258  LPCWSTR string;
259  PBYTE binary;
260 
261  pdb = pSdbCreateDatabase(path1, DOS_PATH);
262  ok(pdb != NULL, "failed to create database\n");
263  if (pdb != NULL)
264  {
265  ret = pSdbWriteDWORDTag(pdb, tags[0], 0xDEADBEEF);
266  ok(ret, "failed to write DWORD tag\n");
267  ret = pSdbWriteQWORDTag(pdb, tags[1], 0xDEADBEEFBABE);
268  ok(ret, "failed to write QWORD tag\n");
269  ret = pSdbWriteStringRefTag(pdb, tags[2], stringref);
270  ok(ret, "failed to write stringref tag\n");
271  tagid = pSdbBeginWriteListTag(pdb, tags[3]);
272  ok(tagid != TAGID_NULL, "unexpected NULL tagid\n");
273  ret = pSdbWriteStringTag(pdb, tags[4], temp);
274  ok(ret, "failed to write string tag\n");
275  ret = pSdbWriteNULLTag(pdb, TAG_GENERAL);
276  ok(ret, "failed to write NULL tag\n");
277  ret = pSdbWriteWORDTag(pdb, TAG_MATCH_MODE, 0xACE);
278  ok(ret, "failed to write WORD tag\n");
279  ret = pSdbEndWriteListTag(pdb, tagid);
280  ok(ret, "failed to update list size\n");
281  /* [Err ][SdbCloseDatabase ] Failed to close the file. */
282  pSdbCloseDatabaseWrite(pdb);
283  }
284 
285  /* [Err ][SdbGetDatabaseID ] Failed to get root tag */
286  pdb = pSdbOpenDatabase(path1, DOS_PATH);
287  ok(pdb != NULL, "unexpected NULL handle\n");
288 
289  if (pdb)
290  {
291  tagid = pSdbGetFirstChild(pdb, TAGID_ROOT);
292  ok(tagid == _TAGID_ROOT, "unexpected tagid %u, expected %u\n", tagid, _TAGID_ROOT);
293 
294  tag = pSdbGetTagFromTagID(pdb, tagid);
295  ok(tag == TAG_SIZE, "unexpected tag 0x%x, expected 0x%x\n", tag, TAG_SIZE);
296 
297  string = pSdbTagToString(tag);
298  ok(lstrcmpW(string, tag_size_string) == 0, "unexpected string %s, expected %s\n",
299  wine_dbgstr_w(string), wine_dbgstr_w(tag_size_string));
300 
301  dword = pSdbReadDWORDTag(pdb, tagid, 0);
302  ok(dword == 0xDEADBEEF, "unexpected value %u, expected 0xDEADBEEF\n", dword);
303 
304  tagid = pSdbGetNextChild(pdb, TAGID_ROOT, tagid);
305  ok(tagid == _TAGID_ROOT + sizeof(TAG) + sizeof(DWORD), "unexpected tagid %u, expected %u\n",
306  tagid, _TAGID_ROOT + sizeof(TAG) + sizeof(DWORD));
307 
308  tag = pSdbGetTagFromTagID(pdb, tagid);
309  ok(tag == TAG_FLAG_LUA, "unexpected tag 0x%x, expected 0x%x\n", tag, TAG_FLAG_LUA);
310 
311  string = pSdbTagToString(tag);
312  if (g_WinVersion >= WINVER_VISTA)
313  {
314  ok(lstrcmpW(string, tag_flag_lua_string) == 0, "unexpected string %s, expected %s\n",
315  wine_dbgstr_w(string), wine_dbgstr_w(tag_flag_lua_string));
316  }
317  else
318  {
319  ok(lstrcmpW(string, invalid_tag) == 0, "unexpected string %s, expected %s\n",
320  wine_dbgstr_w(string), wine_dbgstr_w(invalid_tag));
321  }
322 
323  qword = pSdbReadQWORDTag(pdb, tagid, 0);
324  ok(qword == 0xDEADBEEFBABE, "unexpected value 0x%I64x, expected 0xDEADBEEFBABE\n", qword);
325 
326  tagid = pSdbGetNextChild(pdb, TAGID_ROOT, tagid);
327  string = pSdbGetStringTagPtr(pdb, tagid);
328  ok(string && (lstrcmpW(string, temp) == 0), "unexpected string %s, expected %s\n",
329  wine_dbgstr_w(string), wine_dbgstr_w(temp));
330 
331  ptagid = pSdbGetNextChild(pdb, TAGID_ROOT, tagid);
332  tagid = pSdbGetFirstChild(pdb, ptagid);
333 
334  string = pSdbGetStringTagPtr(pdb, tagid);
335  ok(string && (lstrcmpW(string, temp) == 0), "unexpected string %s, expected %s\n",
336  wine_dbgstr_w(string), wine_dbgstr_w(temp));
337 
338  ok(pSdbReadStringTag(pdb, tagid, buffer, 6), "failed to write string to buffer\n");
339  /* [Err ][SdbpReadTagData ] Buffer too small. Avail: 6, Need: 10. */
340  ok(!pSdbReadStringTag(pdb, tagid, buffer, 3), "string was written to buffer, but failure was expected");
341  ok(pSdbGetTagDataSize(pdb, tagid) == 5 * sizeof(WCHAR), "string has unexpected size\n");
342 
343  tagid = pSdbGetNextChild(pdb, ptagid, tagid);
344  tag = pSdbGetTagFromTagID(pdb, tagid);
345  ok(tag == TAG_GENERAL, "unexpected tag 0x%x, expected 0x%x\n", tag, TAG_GENERAL);
346  ok(pSdbGetTagDataSize(pdb, tagid) == 0, "null tag with size > 0\n");
347 
348  tagid = pSdbGetNextChild(pdb, ptagid, tagid);
349  word = pSdbReadWORDTag(pdb, tagid, 0);
350  ok(word == 0xACE, "unexpected value 0x%x, expected 0x%x\n", word, 0xACE);
351 
353 
354  pSdbCloseDatabase(pdb);
355  }
357 
359  ok(file != INVALID_HANDLE_VALUE, "failed to open file\n");
360  Write(file, &qword, 8);
361  CloseHandle(file);
362 
363  pdb = pSdbCreateDatabase(path1, DOS_PATH);
364  ok(pdb != NULL, "unexpected NULL handle\n");
365 
366  if (pdb)
367  {
368  ret = pSdbWriteBinaryTagFromFile(pdb, TAG_DATA_BITS, path2);
369  ok(ret, "failed to write tag from binary file\n");
370  pSdbCloseDatabaseWrite(pdb); /* [Err ][SdbCloseDatabase ] Failed to close the file. */
372 
373  /* FIXME: doesnt work on win10?! */
374  pdb = pSdbOpenDatabase(path1, DOS_PATH);
376  {
377  /* ERROR,SdbOpenDatabaseEx,845,Failed to open SDB - File size too large or small. */
378  ok(pdb != NULL, "unexpected NULL handle\n");
379  }
380  if (pdb)
381  {
382  binary = (PBYTE)pSdbGetBinaryTagData(pdb, _TAGID_ROOT);
383  ok(memcmp(binary, &qword, 8) == 0, "binary data is corrupt\n");
384  ret = pSdbReadBinaryTag(pdb, _TAGID_ROOT, (PBYTE)buffer, 12);
385  ok(ret, "failed to read binary tag\n");
386  ok(memcmp(buffer, &qword, 8) == 0, "binary data is corrupt\n");
387  pSdbCloseDatabase(pdb);
388  }
389  }
391 }
392 
393 /*
394  - Show that a stringtable is automatically generated,
395  - Show that entries in the stringtable are re-used,
396  - validate multiple lists (for the length)
397  */
398 static void test_write_ex(void)
399 {
400  WCHAR path1[] = {'t','e','s','t','.','s','d','b',0};
401  WCHAR test1[] = {'T','E','S','T',0};
402  WCHAR test2[] = {'t','e','s','t',0};
403  PDB pdb;
404  TAGID tagdb, tagstr;
405  TAG tag;
406  DWORD size;
407  BOOL ret;
408  LPWSTR ptr;
409 
410  /* Write a small database */
411  pdb = pSdbCreateDatabase(path1, DOS_PATH);
412  ok(pdb != NULL, "Expected a valid database\n");
413  if (!pdb)
414  return;
415  tagdb = pSdbBeginWriteListTag(pdb, TAG_DATABASE);
416  ok(tagdb == 12, "Expected tag to be 12, was %u\n", tagdb);
417  ret = pSdbWriteStringTag(pdb, TAG_NAME, test1);
418  ret = pSdbWriteStringTag(pdb, TAG_NAME, test2);
419  ok(ret, "Expected SdbWriteStringTag to succeed\n");
420  ret = pSdbEndWriteListTag(pdb, tagdb);
421  ok(ret, "Expected SdbEndWriteListTag to succeed\n");
422 
423  tagdb = pSdbBeginWriteListTag(pdb, TAG_DATABASE);
424  ok(tagdb == 30, "Expected tag to be 24, was %u\n", tagdb);
425  ret = pSdbWriteStringTag(pdb, TAG_NAME, test1);
426  ret = pSdbWriteStringTag(pdb, TAG_NAME, test2);
427  ok(ret, "Expected SdbWriteStringTag to succeed\n");
428  ret = pSdbEndWriteListTag(pdb, tagdb);
429  ok(ret, "Expected SdbEndWriteListTag to succeed\n");
430 
431  pSdbCloseDatabaseWrite(pdb);
432 
433  /* Now validate it's contents */
434  pdb = pSdbOpenDatabase(path1, DOS_PATH);
435  ok(pdb != NULL, "Expected a valid database\n");
436  if (!pdb)
437  return;
438 
439  tagdb = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_DATABASE);
440  ok(tagdb == 12, "Expected tag to be 12, was %u\n", tagdb);
441  size = pSdbGetTagDataSize(pdb, tagdb);
442  ok(size == 12, "Expected size to be 12, was %u\n", size);
443 
444  tagstr = pSdbFindFirstTag(pdb, tagdb, TAG_NAME);
445  ok(tagstr == 18, "Expected string tag to be 18, was %u\n", tagstr);
446  tag = pSdbGetTagFromTagID(pdb, tagstr);
447  ok(tag == TAG_NAME, "Expected tag to be TAG_NAME, was 0x%x\n", (DWORD)tag);
448  size = pSdbGetTagDataSize(pdb, tagstr);
449  ok(size == 4, "Expected size to be 4, was 0x%x\n", size);
450 
451  tagstr = pSdbFindNextTag(pdb, tagdb, tagstr);
452  ok(tagstr == 24, "Expected string tag to be 24, was %u\n", tagstr);
453  tag = pSdbGetTagFromTagID(pdb, tagstr);
454  ok(tag == TAG_NAME, "Expected tag to be TAG_NAME, was 0x%x\n", (DWORD)tag);
455  size = pSdbGetTagDataSize(pdb, tagstr);
456  ok(size == 4, "Expected size to be 4, was 0x%x\n", size);
457 
458  tagdb = pSdbFindNextTag(pdb, TAGID_ROOT, tagdb);
459  ok(tagdb == 30, "Expected tag to be 30, was %u\n", tagdb);
460  size = pSdbGetTagDataSize(pdb, tagdb);
461  ok(size == 12, "Expected size to be 12, was %u\n", size);
462 
463  tagstr = pSdbFindFirstTag(pdb, tagdb, TAG_NAME);
464  ok(tagstr == 36, "Expected string tag to be 36, was %u\n", tagstr);
465  tag = pSdbGetTagFromTagID(pdb, tagstr);
466  ok(tag == TAG_NAME, "Expected tag to be TAG_NAME, was 0x%x\n", (DWORD)tag);
467  size = pSdbGetTagDataSize(pdb, tagstr);
468  ok(size == 4, "Expected size to be 4, was %u\n", size);
469 
470  tagstr = pSdbFindNextTag(pdb, tagdb, tagstr);
471  ok(tagstr == 42, "Expected string tag to be 42, was %u\n", tagstr);
472  tag = pSdbGetTagFromTagID(pdb, tagstr);
473  ok(tag == TAG_NAME, "Expected tag to be TAG_NAME, was 0x%x\n", (DWORD)tag);
474  size = pSdbGetTagDataSize(pdb, tagstr);
475  ok(size == 4, "Expected size to be 4, was 0x%x\n", size);
476 
477  tagdb = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_STRINGTABLE);
478  ok(tagdb == 48, "Expected tag to be 48, was %u\n", tagdb);
479  size = pSdbGetTagDataSize(pdb, tagdb);
480  ok(size == 32, "Expected size to be 32, was %u\n", size);
481 
482  tagstr = pSdbGetFirstChild(pdb, tagdb);
483  ok(tagstr == 54, "Expected string tag to be 54, was %u\n", tagstr);
484  tag = pSdbGetTagFromTagID(pdb, tagstr);
485  ok(tag == TAG_STRINGTABLE_ITEM, "Expected tag to be TAG_STRINGTABLE_ITEM, was 0x%x\n", (DWORD)tag);
486  size = pSdbGetTagDataSize(pdb, tagstr);
487  ok(size == 10, "Expected size to be 10, was %u\n", size);
488  ptr = pSdbGetStringTagPtr(pdb, tagstr);
489  ok(ptr != NULL, "Expected a valid pointer\n");
490  if (ptr)
491  ok(!wcscmp(ptr, test1), "Expected ptr to be %s, was %s\n", wine_dbgstr_w(test1), wine_dbgstr_w(ptr));
492 
493  tagstr = pSdbGetNextChild(pdb, tagdb, tagstr);
494  ok(tagstr == 70, "Expected string tag to be 70, was %u\n", tagstr);
495  tag = pSdbGetTagFromTagID(pdb, tagstr);
496  ok(tag == TAG_STRINGTABLE_ITEM, "Expected tag to be TAG_STRINGTABLE_ITEM, was 0x%x\n", (DWORD)tag);
497  size = pSdbGetTagDataSize(pdb, tagstr);
498  ok(size == 10, "Expected size to be 10, was %u\n", size);
499  ptr = pSdbGetStringTagPtr(pdb, tagstr);
500  ok(ptr != NULL, "Expected a valid pointer\n");
501  if (ptr)
502  ok(!wcscmp(ptr, test2), "Expected ptr to be %s, was %s\n", wine_dbgstr_w(test2), wine_dbgstr_w(ptr));
503 
504  pSdbCloseDatabase(pdb);
505 }
506 
507 
508 static void write_db_strings(const WCHAR* name, const WCHAR* data[], size_t count)
509 {
510  PDB pdb;
511  size_t n;
512  BOOL ret;
513 
514  pdb = pSdbCreateDatabase(name, DOS_PATH);
515  ok(pdb != NULL, "Failed to create db for case %u\n", count);
516  for (n = 0; n < count; ++n)
517  {
518  ret = pSdbWriteStringTag(pdb, TAG_NAME, data[n]);
519  ok(ret, "Failed to write string %u/%u\n", n, count);
520  }
521  pSdbCloseDatabaseWrite(pdb);
522 }
523 
524 static void test_stringtable()
525 {
526  static const WCHAR path1[] = {'t','e','s','t','.','s','d','b',0};
527  static const WCHAR test1[] = {'t','e','s','t','1',0};
528  static const WCHAR test2[] = {'T','e','s','t','1',0};
529  static const WCHAR test3[] = {'T','E','s','t','1',0};
530  static const WCHAR test4[] = {'T','E','S','T','1',0};
531  static const WCHAR test5[] = {'T','E','S','T','2',0};
532  static const WCHAR lipsum[] = {'L','o','r','e','m',' ','i','p','s','u','m',' ','d','o','l','o','r',' ','s','i','t',' ','a','m','e','t',',',' ','c','o','n','s','e','c','t','e','t','u','r',' ','a','d','i','p','i','s','c','i','n','g',' ','e','l','i','t','.',' ','N','u','l','l','a',' ','a','n','t','e',' ','r','i','s','u','s',',',' ','m','a','l','e','s','u','a','d','a',' ','s','e','d',' ','i','a','c','u','l','i','s',' ','l','u','c','t','u','s',',',' ','o','r','n','a','r','e',' ','p','u','l','v','i','n','a','r',' ','v','e','l','i','t','.',' ','L','o','r','e','m',' ','i','p','s','u','m',' ','d','o','l','o','r',' ','s','i','t',' ','a','m','e','t',',',' ','c','o','n','s','e','c','t','e','t','u','r',' ','a','d','i','p','i','s','c','i','n','g',' ','e','l','i','t','.',' ','I','n','t','e','g','e','r',' ','q','u','i','s',' ','f','e','l','i','s',' ','u','t',' ','l','e','o',' ','e','l','e','i','f','e','n','d',' ','u','l','t','r','i','c','e','s',' ','f','i','n','i','b','u','s',' ','e','u',' ','d','o','l','o','r','.',' ','I','n',' ','b','i','b','e','n','d','u','m',',',' ','e','r','o','s',' ','e','u',' ','f','a','u','c','i','b','u','s',' ','c','o','n','s','e','q','u','a','t',',',' ','n','i','s','i',' ','m','a','g','n','a',' ','v','e','n','e','n','a','t','i','s',' ','j','u','s','t','o',',',' ','a','t',' ','t','r','i','s','t','i','q','u','e',' ','m','e','t','u','s',' ','d','o','l','o','r',' ','u','t',' ','r','i','s','u','s','.',' ','N','u','n','c',' ','e','u',' ','o','d','i','o',' ','d','i','g','n','i','s','s','i','m',',',' ','o','r','n','a','r','e',' ','a','n','t','e',' ','g','r','a','v','i','d','a',',',' ','l','o','b','o','r','t','i','s',' ','e','r','o','s','.',' ','C','r','a','s',' ','s','e','m',' ','e','x',',',' ','c','o','n','s','e','c','t','e','t','u','r',' ','p','u','l','v','i','n','a','r',' ','t','i','n','c','i','d','u','n','t',' ','e','u',',',' ','c','o','n','g','u','e',' ','a',' ','e','r','o','s','.',' ','C','u','r','a','b','i','t','u','r',' ','e','r','o','s',' ','e','r','a','t',',',' ','p','e','l','l','e','n','t','e','s','q','u','e',' ','e','t',' ','n','i','b','h',' ','q','u','i','s',',',' ','i','n','t','e','r','d','u','m',' ','t','e','m','p','o','r',' ','o','d','i','o','.',' ','E','t','i','a','m',' ','s','a','p','i','e','n',' ','s','a','p','i','e','n',',',' ','a','l','i','q','u','a','m',' ','u','t',' ','a','l','i','q','u','a','m',' ','a','t',',',' ','s','a','g','i','t','t','i','s',' ','e','u',' ','m','a','g','n','a','.',' ','M','a','e','c','e','n','a','s',' ','m','a','g','n','a',' ','m','a','g','n','a',',',' ','s','u','s','c','i','p','i','t',' ','u','t',' ','l','o','r','e','m',' ','u','t',',',' ','v','a','r','i','u','s',' ','p','r','e','t','i','u','m',' ','f','e','l','i','s','.',' ','I','n','t','e','g','e','r',' ','t','i','n','c','i','d','u','n','t',',',' ','m','e','t','u','s',' ','v','e','l',' ','s','o','l','l','i','c','i','t','u','d','i','n',' ','f','i','n','i','b','u','s',',',' ','f','e','l','i','s',' ','e','r','a','t',' ','m','o','l','e','s','t','i','e',' ','u','r','n','a',',',' ','a',' ','c','o','n','d','i','m','e','n','t','u','m',' ','a','u','g','u','e',' ','a','r','c','u',' ','v','i','t','a','e',' ','r','i','s','u','s','.',' ','E','t','i','a','m',' ','i','d',' ','s','a','g','i','t','t','i','s',' ','q','u','a','m','.',' ','M','o','r','b','i',' ','a',' ','u','l','t','r','i','c','i','e','s',' ','n','u','n','c','.',' ','P','h','a','s','e','l','l','u','s',' ','e','r','o','s',' ','r','i','s','u','s',',',' ','c','u','r','s','u','s',' ','u','l','l','a','m','c','o','r','p','e','r',' ','m','a','s','s','a',' ','s','e','d',',',' ','d','i','g','n','i','s','s','i','m',' ','c','o','n','s','e','q','u','a','t',' ','l','i','g','u','l','a','.',' ','A','l','i','q','u','a','m',' ','t','u','r','p','i','s',' ','a','r','c','u',',',' ','a','c','c','u','m','s','a','n',' ','q','u','i','s',' ','s','a','p','i','e','n',' ','v','i','t','a','e',',',' ','l','a','c','i','n','i','a',' ','e','u','i','s','m','o','d',' ','n','i','s','l','.',' ','M','a','u','r','i','s',' ','i','d',' ','f','e','l','i','s',' ','s','e','m','.',0};
533  /* Last char changed from '.' to '!' */
534  static const WCHAR lipsum2[] = {'L','o','r','e','m',' ','i','p','s','u','m',' ','d','o','l','o','r',' ','s','i','t',' ','a','m','e','t',',',' ','c','o','n','s','e','c','t','e','t','u','r',' ','a','d','i','p','i','s','c','i','n','g',' ','e','l','i','t','.',' ','N','u','l','l','a',' ','a','n','t','e',' ','r','i','s','u','s',',',' ','m','a','l','e','s','u','a','d','a',' ','s','e','d',' ','i','a','c','u','l','i','s',' ','l','u','c','t','u','s',',',' ','o','r','n','a','r','e',' ','p','u','l','v','i','n','a','r',' ','v','e','l','i','t','.',' ','L','o','r','e','m',' ','i','p','s','u','m',' ','d','o','l','o','r',' ','s','i','t',' ','a','m','e','t',',',' ','c','o','n','s','e','c','t','e','t','u','r',' ','a','d','i','p','i','s','c','i','n','g',' ','e','l','i','t','.',' ','I','n','t','e','g','e','r',' ','q','u','i','s',' ','f','e','l','i','s',' ','u','t',' ','l','e','o',' ','e','l','e','i','f','e','n','d',' ','u','l','t','r','i','c','e','s',' ','f','i','n','i','b','u','s',' ','e','u',' ','d','o','l','o','r','.',' ','I','n',' ','b','i','b','e','n','d','u','m',',',' ','e','r','o','s',' ','e','u',' ','f','a','u','c','i','b','u','s',' ','c','o','n','s','e','q','u','a','t',',',' ','n','i','s','i',' ','m','a','g','n','a',' ','v','e','n','e','n','a','t','i','s',' ','j','u','s','t','o',',',' ','a','t',' ','t','r','i','s','t','i','q','u','e',' ','m','e','t','u','s',' ','d','o','l','o','r',' ','u','t',' ','r','i','s','u','s','.',' ','N','u','n','c',' ','e','u',' ','o','d','i','o',' ','d','i','g','n','i','s','s','i','m',',',' ','o','r','n','a','r','e',' ','a','n','t','e',' ','g','r','a','v','i','d','a',',',' ','l','o','b','o','r','t','i','s',' ','e','r','o','s','.',' ','C','r','a','s',' ','s','e','m',' ','e','x',',',' ','c','o','n','s','e','c','t','e','t','u','r',' ','p','u','l','v','i','n','a','r',' ','t','i','n','c','i','d','u','n','t',' ','e','u',',',' ','c','o','n','g','u','e',' ','a',' ','e','r','o','s','.',' ','C','u','r','a','b','i','t','u','r',' ','e','r','o','s',' ','e','r','a','t',',',' ','p','e','l','l','e','n','t','e','s','q','u','e',' ','e','t',' ','n','i','b','h',' ','q','u','i','s',',',' ','i','n','t','e','r','d','u','m',' ','t','e','m','p','o','r',' ','o','d','i','o','.',' ','E','t','i','a','m',' ','s','a','p','i','e','n',' ','s','a','p','i','e','n',',',' ','a','l','i','q','u','a','m',' ','u','t',' ','a','l','i','q','u','a','m',' ','a','t',',',' ','s','a','g','i','t','t','i','s',' ','e','u',' ','m','a','g','n','a','.',' ','M','a','e','c','e','n','a','s',' ','m','a','g','n','a',' ','m','a','g','n','a',',',' ','s','u','s','c','i','p','i','t',' ','u','t',' ','l','o','r','e','m',' ','u','t',',',' ','v','a','r','i','u','s',' ','p','r','e','t','i','u','m',' ','f','e','l','i','s','.',' ','I','n','t','e','g','e','r',' ','t','i','n','c','i','d','u','n','t',',',' ','m','e','t','u','s',' ','v','e','l',' ','s','o','l','l','i','c','i','t','u','d','i','n',' ','f','i','n','i','b','u','s',',',' ','f','e','l','i','s',' ','e','r','a','t',' ','m','o','l','e','s','t','i','e',' ','u','r','n','a',',',' ','a',' ','c','o','n','d','i','m','e','n','t','u','m',' ','a','u','g','u','e',' ','a','r','c','u',' ','v','i','t','a','e',' ','r','i','s','u','s','.',' ','E','t','i','a','m',' ','i','d',' ','s','a','g','i','t','t','i','s',' ','q','u','a','m','.',' ','M','o','r','b','i',' ','a',' ','u','l','t','r','i','c','i','e','s',' ','n','u','n','c','.',' ','P','h','a','s','e','l','l','u','s',' ','e','r','o','s',' ','r','i','s','u','s',',',' ','c','u','r','s','u','s',' ','u','l','l','a','m','c','o','r','p','e','r',' ','m','a','s','s','a',' ','s','e','d',',',' ','d','i','g','n','i','s','s','i','m',' ','c','o','n','s','e','q','u','a','t',' ','l','i','g','u','l','a','.',' ','A','l','i','q','u','a','m',' ','t','u','r','p','i','s',' ','a','r','c','u',',',' ','a','c','c','u','m','s','a','n',' ','q','u','i','s',' ','s','a','p','i','e','n',' ','v','i','t','a','e',',',' ','l','a','c','i','n','i','a',' ','e','u','i','s','m','o','d',' ','n','i','s','l','.',' ','M','a','u','r','i','s',' ','i','d',' ','f','e','l','i','s',' ','s','e','m','!',0};
535  static const WCHAR empty[] = {0};
536  static const WCHAR* all[] = { test1, test2, test3, test4, test5, lipsum, lipsum2, empty };
537  static const TAGID expected_str[] = { 0xc, 0x12, 0x18, 0x1e, 0x24, 0x2a, 0x30, 0x36 };
538  static const TAGID expected_tab[] = { 6, 0x18, 0x2a, 0x3c, 0x4e, 0x60, 0x846, 0x102c };
539  DWORD n, j;
540 
541  for (n = 0; n < (sizeof(all) / sizeof(all[0])); ++n)
542  {
543  PDB pdb;
544  TAGID tagstr, table, expected_table;
545 
546  write_db_strings(path1, all, n+1);
547 
548  pdb = pSdbOpenDatabase(path1, DOS_PATH);
549  ok(pdb != NULL, "Expected a valid database\n");
550  if (!pdb)
551  {
553  continue;
554  }
555  tagstr = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_NAME);
556  for (j = 0; j <= n; ++j)
557  {
558  ok(tagstr == expected_str[j], "Expected tagstr to be 0x%x, was 0x%x for %u/%u\n", expected_str[j], tagstr, j, n);
559  if (tagstr)
560  {
561  LPWSTR data;
562  DWORD size;
563  TAG tag = pSdbGetTagFromTagID(pdb, tagstr);
564  ok(tag == TAG_NAME, "Expected tag to be TAG_NAME, was 0x%x for %u/%u\n", tag, j, n);
565  size = pSdbGetTagDataSize(pdb, tagstr);
566  ok(size == 4, "Expected datasize to be 4, was %u for %u/%u\n", size, j, n);
567  data = pSdbGetStringTagPtr(pdb, tagstr);
568  ok(data && !wcsicmp(data, all[j]), "Expected data to be %s was %s for %u/%u\n", wine_dbgstr_w(all[j]), wine_dbgstr_w(data), j, n);
569  }
570  tagstr = pSdbFindNextTag(pdb, TAGID_ROOT, tagstr);
571  }
572  ok(tagstr == TAGID_NULL, "Expected to be at the end for %u\n", n);
573 
574 
575  table = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_STRINGTABLE);
576  expected_table = 0xc + (n+1)*6;
577  ok(table == expected_table, "Expected to find a stringtable at 0x%x instead of 0x%x for %u\n", expected_table, table, n);
578  if (table)
579  {
580  tagstr = pSdbFindFirstTag(pdb, table, TAG_STRINGTABLE_ITEM);
581  for (j = 0; j <= n; ++j)
582  {
583  ok(tagstr == (expected_tab[j] + expected_table), "Expected tagstr to be 0x%x, was 0x%x for %u/%u\n", (expected_tab[j] + expected_table), tagstr, j, n);
584  if (tagstr)
585  {
586  LPWSTR data;
587  DWORD size, expected_size;
588  TAG tag = pSdbGetTagFromTagID(pdb, tagstr);
589  ok(tag == TAG_STRINGTABLE_ITEM, "Expected tag to be TAG_NAME, was 0x%x for %u/%u\n", tag, j, n);
590  size = pSdbGetTagDataSize(pdb, tagstr);
591  expected_size = (lstrlenW(all[j])+1) * 2;
592  ok(size == expected_size, "Expected datasize to be %u, was %u for %u/%u\n", expected_size, size, j, n);
593  data = pSdbGetStringTagPtr(pdb, tagstr);
594  ok(data && !wcsicmp(data, all[j]), "Expected data to be %s was %s for %u/%u\n", wine_dbgstr_w(all[j]), wine_dbgstr_w(data), j, n);
595  }
596  tagstr = pSdbFindNextTag(pdb, TAGID_ROOT, tagstr);
597  }
598  ok(tagstr == TAGID_NULL, "Expected to be at the end for %u\n", n);
599  }
600 
601  pSdbCloseDatabase(pdb);
603  }
604 }
605 
607 {
608  TAGID attr = pSdbFindFirstTag(pdb, parent, find);
609  winetest_ok(attr != TAG_NULL, "Could not find: %x\n", find);
610  if (attr != TAG_NULL)
611  {
612  LPWSTR name = pSdbGetStringTagPtr(pdb, attr);
613  winetest_ok(name != NULL, "Could not convert attr to str.\n");
614  if (name)
615  {
616  winetest_ok(wcscmp(name, compare) == 0, "Expected tagid %x to be %s, was %s\n", attr, wine_dbgstr_w(compare), wine_dbgstr_w(name));
617  }
618  }
619 }
620 
622 {
623  TAGID attr = pSdbFindFirstTag(pdb, parent, find);
624  winetest_ok(attr != TAG_NULL, "Could not find: %x\n", find);
625  if (attr != TAG_NULL)
626  {
627  DWORD val = pSdbReadDWORDTag(pdb, attr, 0x1234567);
628  winetest_ok(val == compare, "Expected tagid %x to be 0x%x, was 0x%x\n", attr, compare, val);
629  }
630 }
631 
633 {
634  TAGID attr = pSdbFindFirstTag(pdb, parent, find);
635  winetest_ok(attr != TAG_NULL, "Could not find: %x\n", find);
636  if (attr != TAG_NULL)
637  {
638  QWORD val = pSdbReadQWORDTag(pdb, attr, 0x123456789abcdef);
639  winetest_ok(val == compare, "Expected tagid %x to be 0x%I64x, was 0x%I64x\n", attr, compare, val);
640  }
641 }
642 
644 {
645  TAGID attr = pSdbFindFirstTag(pdb, parent, find);
646  winetest_ok(attr != TAG_NULL, "Could not find: %x\n", find);
647  if (attr != TAG_NULL)
648  {
649  GUID guid = { 0 };
650  BOOL result = pSdbReadBinaryTag(pdb, attr, (PBYTE)&guid, sizeof(guid));
651  winetest_ok(result, "expected pSdbReadBinaryTag not to fail.\n");
652  winetest_ok(IsEqualGUID(guid, *compare), "expected guids to be equal(%s:%s)\n", wine_dbgstr_guid(&guid), wine_dbgstr_guid(compare));
653  }
654 }
655 
656 #define match_strw_attr (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_strw_attr_imp
657 #define match_dw_attr (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_dw_attr_imp
658 #define match_qw_attr (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_qw_attr_imp
659 #define match_guid_attr (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : match_guid_attr_imp
660 
661 
662 //The application name cannot contain any of the following characters:
663 // \ / < > : * ? | "
664 
666 {
667  TAGID iter = pSdbFindFirstTag(pdb, root, TAG_DATABASE_ID);
668  ok(iter != TAGID_NULL, "expected a result, got TAGID_NULL\n");
669  if (iter != TAGID_NULL)
670  {
671  GUID guid = { 0 }, guid2 = { 0 };
672  BOOL result = pSdbReadBinaryTag(pdb, iter, (PBYTE)&guid, sizeof(guid));
673  ok(result, "expected SdbReadBinaryTag not to fail.\n");
674  if (result)
675  {
676  WCHAR guid_wstr[50];
677  result = pSdbGUIDToString(&guid, guid_wstr, 50);
678  ok(result, "expected SdbGUIDToString not to fail.\n");
679  if (result)
680  {
681  char guid_str[50];
682  WideCharToMultiByte(CP_ACP, 0, guid_wstr, -1, guid_str, sizeof(guid_str), NULL, NULL);
683  ok_str(guid_str, "{e39b0eb0-55db-450b-9bd4-d20c9484260f}");
684  }
685  ok(pSdbGetDatabaseID(pdb, &guid2), "expected SdbGetDatabaseID not to fail.\n");
686  ok(IsEqualGUID(guid, guid2), "expected guids to be equal(%s:%s)\n", wine_dbgstr_guid(&guid), wine_dbgstr_guid(&guid2));
687  }
688  }
689  match_qw_attr(pdb, root, TAG_TIME, 0x1d1b91a02c0d63e);
691  match_strw_attr(pdb, root, TAG_NAME, L"apphelp_test1");
693 }
694 
696 {
697  TAGID shimref, inexclude, is_include;
698  ok(layer != TAGID_NULL, "Expected a valid layer, got NULL\n");
699  if (!layer)
700  return;
701 
702  match_strw_attr(pdb, layer, TAG_NAME, L"TestNewMode");
703  shimref = pSdbFindFirstTag(pdb, layer, TAG_SHIM_REF);
704  ok(shimref != TAGID_NULL, "Expected a valid shim ref, got NULL\n");
705  if (!shimref)
706  return;
707 
708  match_strw_attr(pdb, shimref, TAG_NAME, L"VirtualRegistry");
709  match_strw_attr(pdb, shimref, TAG_COMMAND_LINE, L"ThemeActive");
710  inexclude = pSdbFindFirstTag(pdb, shimref, TAG_INEXCLUD);
711  ok(inexclude != TAGID_NULL, "Expected a valid in/exclude ref, got NULL\n");
712  if (!inexclude)
713  return;
714 
715  is_include = pSdbFindFirstTag(pdb, inexclude, TAG_INCLUDE);
716  ok(is_include == TAGID_NULL, "Expected a NULL include ref, but got one anyway.\n");
717  match_strw_attr(pdb, inexclude, TAG_MODULE, L"exclude.dll");
718 
719  inexclude = pSdbFindNextTag(pdb, shimref, inexclude);
720  ok(inexclude != TAGID_NULL, "Expected a valid in/exclude ref, got NULL\n");
721  if (!inexclude)
722  return;
723 
724  is_include = pSdbFindFirstTag(pdb, inexclude, TAG_INCLUDE);
725  ok(is_include != TAGID_NULL, "Expected a valid include ref, got NULL\n");
726  match_strw_attr(pdb, inexclude, TAG_MODULE, L"include.dll");
727 }
728 
729 static void check_matching_file(PDB pdb, TAGID exe, TAGID matching_file, int num)
730 {
731  ok(matching_file != TAGID_NULL, "Expected to find atleast 1 matching file.\n");
732  if (matching_file == TAGID_NULL)
733  return;
734 
735  ok(num < 4, "Too many matches, expected only 4!\n");
736  if (num >= 4)
737  return;
738 
739 
740  match_strw_attr(pdb, matching_file, TAG_NAME, L"*");
741  match_strw_attr(pdb, matching_file, TAG_COMPANY_NAME, L"CompanyName");
742  match_strw_attr(pdb, matching_file, TAG_PRODUCT_NAME, L"ProductName");
743  match_strw_attr(pdb, matching_file, TAG_PRODUCT_VERSION, L"1.0.0.1");
744  match_strw_attr(pdb, matching_file, TAG_FILE_VERSION, L"1.0.0.0");
745 
746  if (num == 0 || num == 3)
747  {
748  match_qw_attr(pdb, matching_file, TAG_UPTO_BIN_PRODUCT_VERSION, 0x1000000000001);
749  match_qw_attr(pdb, matching_file, TAG_UPTO_BIN_FILE_VERSION, 0x1000000000000);
750  }
751  if (num == 1 || num == 3)
752  {
753  match_dw_attr(pdb, matching_file, TAG_PE_CHECKSUM, 0xbaad);
754  }
755  if (num != 0)
756  {
757  match_qw_attr(pdb, matching_file, TAG_BIN_PRODUCT_VERSION, 0x1000000000001);
758  match_qw_attr(pdb, matching_file, TAG_BIN_FILE_VERSION, 0x1000000000000);
759  }
760  if (num == 3)
761  {
762  match_dw_attr(pdb, matching_file, TAG_SIZE, 0x800);
763  match_dw_attr(pdb, matching_file, TAG_CHECKSUM, 0x178bd629);
764  match_strw_attr(pdb, matching_file, TAG_FILE_DESCRIPTION, L"FileDescription");
765  match_dw_attr(pdb, matching_file, TAG_MODULE_TYPE, 3);
766  match_dw_attr(pdb, matching_file, TAG_VERFILEOS, 4);
767  match_dw_attr(pdb, matching_file, TAG_VERFILETYPE, 1);
768  match_dw_attr(pdb, matching_file, TAG_LINKER_VERSION, 0x40002);
769  match_strw_attr(pdb, matching_file, TAG_ORIGINAL_FILENAME, L"OriginalFilename");
770  match_strw_attr(pdb, matching_file, TAG_INTERNAL_NAME, L"InternalName");
771  match_strw_attr(pdb, matching_file, TAG_LEGAL_COPYRIGHT, L"LegalCopyright");
772  match_dw_attr(pdb, matching_file, TAG_LINK_DATE, 0x12345);
773  match_dw_attr(pdb, matching_file, TAG_UPTO_LINK_DATE, 0x12345);
774  }
775  if (num > 3)
776  {
777  ok(0, "unknown case: %d\n", num);
778  }
779  matching_file = pSdbFindNextTag(pdb, exe, matching_file);
780  if (num == 2)
781  {
782  ok(matching_file != TAGID_NULL, "Did expect a secondary match on %d\n", num);
783  match_strw_attr(pdb, matching_file, TAG_NAME, L"test_checkfile.txt");
784  match_dw_attr(pdb, matching_file, TAG_SIZE, 0x4);
785  match_dw_attr(pdb, matching_file, TAG_CHECKSUM, 0xb0b0b0b0);
786  }
787  else
788  {
789  ok(matching_file == TAGID_NULL, "Did not expect a secondary match on %d\n", num);
790  }
791 }
792 
793 // "C:\WINDOWS\system32\pcaui.exe" /g {bf39e0e6-c61c-4a22-8802-3ea8ad00b655} /x {4e50c93f-b863-4dfa-bae2-d80ef4ce5c89} /a "apphelp_name_allow" /v "apphelp_vendor_allow" /s "Allow it!" /b 1 /f 0 /k 0 /e "C:\Users\Mark\AppData\Local\Temp\apphelp_test\test_allow.exe" /u "http://reactos.org/allow" /c
794 // "C:\WINDOWS\system32\pcaui.exe" /g {fa150915-1244-4169-a4ba-fc098c442840} /x {156720e1-ef98-4d04-965a-d85de05e6d9f} /a "apphelp_name_disallow" /v "apphelp_vendor_disallow" /s "Not allowed!" /b 2 /f 0 /k 0 /e "C:\Users\Mark\AppData\Local\Temp\apphelp_test\test_disallow.exe" /u "http://reactos.org/disallow" /c
795 
796 static void check_matching_apphelp(PDB pdb, TAGID apphelp, int num)
797 {
798  if (num == 0)
799  {
800 /*
801 [Window Title]
802 Program Compatibility Assistant
803 
804 [Main Instruction]
805 This program has known compatibility issues
806 
807 [Expanded Information]
808 Allow it!
809 
810 [^] Hide details [ ] Don't show this message again [Check for solutions online] [Run program] [Cancel]
811 */
812  match_dw_attr(pdb, apphelp, TAG_FLAGS, 1);
813  match_dw_attr(pdb, apphelp, TAG_PROBLEMSEVERITY, 1);
814  match_dw_attr(pdb, apphelp, TAG_HTMLHELPID, 1);
815  match_dw_attr(pdb, apphelp, TAG_APP_NAME_RC_ID, 0x6f0072);
816  match_dw_attr(pdb, apphelp, TAG_VENDOR_NAME_RC_ID, 0x720067);
818  }
819  else
820  {
821 /*
822 [Window Title]
823 Program Compatibility Assistant
824 
825 [Main Instruction]
826 This program is blocked due to compatibility issues
827 
828 [Expanded Information]
829 Not allowed!
830 
831 [^] Hide details [Check for solutions online] [Cancel]
832 */
833  match_dw_attr(pdb, apphelp, TAG_FLAGS, 1);
834  match_dw_attr(pdb, apphelp, TAG_PROBLEMSEVERITY, 2);
835  match_dw_attr(pdb, apphelp, TAG_HTMLHELPID, 2);
836  match_dw_attr(pdb, apphelp, TAG_APP_NAME_RC_ID, 0x320020);
837  match_dw_attr(pdb, apphelp, TAG_VENDOR_NAME_RC_ID, 0x38002e);
839  }
840  apphelp = pSdbFindNextTag(pdb, apphelp, apphelp);
841  ok(apphelp == TAGID_NULL, "Did not expect a secondary match on %d\n", num);
842 }
843 
845 {
846  if (num == 2)
847  {
849  match_strw_attr(pdb, layer, TAG_NAME, L"TestNewMode");
850  }
851  else
852  {
853  TAGID layer_tagid = pSdbFindFirstTag(pdb, layer, TAG_LAYER_TAGID);
854  ok(layer_tagid == TAGID_NULL, "expected not to find a layer tagid, got %x\n", layer_tagid);
855  match_strw_attr(pdb, layer, TAG_NAME, L"WinSrv03");
856  }
857 }
858 
859 static struct
860 {
861  const WCHAR* name;
862  const WCHAR* app_name;
863  const WCHAR* vendor;
871  const char* env_var;
872 } test_exedata[5] = {
873  {
874  L"test_allow.exe",
875  L"apphelp_name_allow",
876  L"apphelp_vendor_allow",
877  { 0x4e50c93f, 0xb863, 0x4dfa, { 0xba, 0xe2, 0xd8, 0x0e, 0xf4, 0xce, 0x5c, 0x89 } },
878  NULL,
879  0,
880  0x1c6,
881  0x1000,
882  0,
883  0x1c6,
884  NULL,
885  },
886  {
887  L"test_disallow.exe",
888  L"apphelp_name_disallow",
889  L"apphelp_vendor_disallow",
890  { 0x156720e1, 0xef98, 0x4d04, { 0x96, 0x5a, 0xd8, 0x5d, 0xe0, 0x5e, 0x6d, 0x9f } },
891  NULL,
892  0,
893  0x256,
894  0x3000,
895  0,
896  0x256,
897  NULL,
898  },
899  {
900  L"test_new.exe",
901  L"fixnew_name",
902  L"fixnew_vendor",
903  { 0xce70ef69, 0xa21d, 0x408b, { 0x84, 0x5b, 0xf9, 0x9e, 0xac, 0x06, 0x09, 0xe7 } },
904  L"test_checkfile.txt",
905  1,
906  0x2ec,
907  0,
908  0x18e,
909  0,
910  NULL,
911  },
912  {
913  L"test_w2k3.exe",
914  L"fix_name",
915  L"fix_vendor",
916  { 0xb4ead144, 0xf640, 0x4e4b, { 0x94, 0xc4, 0x0c, 0x7f, 0xa8, 0x66, 0x23, 0xb0 } },
917  NULL,
918  0,
919  0x37c,
920  0,
921  0,
922  0,
923  NULL,
924  },
925  {
926  L"test_unknown_file.exe",
927  L"apphelp_name_allow",
928  L"apphelp_vendor_allow",
929  { 0x00000000, 0x0000, 0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } },
930  NULL,
931  1,
932  0,
933  0,
934  0x18e,
935  0,
936  "TestNewMode",
937  },
938 };
939 
941 {
942  int num = 0;
943  TAGID exe = pSdbFindFirstTag(pdb, root, TAG_EXE);
944  TAGID altExe = pSdbFindFirstNamedTag(pdb, root, TAG_EXE, TAG_NAME, L"test_allow.exe");
945  ok_hex(altExe, (int)exe);
946  while (exe != TAGID_NULL)
947  {
948  TAGID apphelp, layer;
949  ok(num < 4, "Too many matches, expected only 4!\n");
950  if (num >= 4)
951  break;
956  check_matching_file(pdb, exe, pSdbFindFirstTag(pdb, exe, TAG_MATCHING_FILE), num);
957  apphelp = pSdbFindFirstTag(pdb, exe, TAG_APPHELP);
958  if (num == 0 || num == 1)
959  {
960  ok(apphelp != TAGID_NULL, "Expected to find a valid apphelp match on %d.\n", num);
961  if (apphelp)
962  check_matching_apphelp(pdb, apphelp, num);
963  }
964  else
965  {
966  ok(apphelp == TAGID_NULL, "Did not expect an apphelp match on %d\n", num);
967  }
968  layer = pSdbFindFirstTag(pdb, exe, TAG_LAYER);
969  if (num == 2 || num == 3)
970  {
971  ok(layer != TAGID_NULL, "Expected to find a valid layer match on %d.\n", num);
972  if (layer)
974  }
975  else
976  {
977  ok(layer == TAGID_NULL, "Did not expect a layer match on %d\n", num);
978  }
979  ++num;
980  exe = pSdbFindNextTag(pdb, root, exe);
981  }
982  ok(num == 4, "Expected to find 4 exe tags, found: %d\n", num);
983 }
984 
985 static struct
986 {
988  const WCHAR* link;
991 } test_layerdata[2] = {
992  {
993  2,
994  L"http://reactos.org/disallow",
995  L"apphelp_name_disallow",
996  L"Not allowed!",
997  },
998  {
999  1,
1000  L"http://reactos.org/allow",
1001  L"apphelp_name_allow",
1002  L"Allow it!",
1003  },
1004 };
1005 
1007 {
1008  int num = 0;
1009  TAGID apphelp = pSdbFindFirstTag(pdb, root, TAG_APPHELP);
1010  while (apphelp != TAGID_NULL)
1011  {
1012  TAGID link;
1013  ok(num < 2, "Too many matches, expected only 4!\n");
1014  if (num >= 2)
1015  break;
1017  link = pSdbFindFirstTag(pdb, apphelp, TAG_LINK);
1018  ok(link != TAGID_NULL, "expected to find a link tag\n");
1019  if (link != TAGID_NULL)
1020  {
1022  }
1025  apphelp = pSdbFindNextTag(pdb, root, apphelp);
1026  num++;
1027  }
1028  ok(num == 2, "Expected to find 2 layer tags, found: %d\n", num);
1029 }
1030 
1032 {
1033  PDB_INFORMATION pInfo;
1034  BOOL fResult;
1035 
1036  if (!pSdbGetDatabaseInformation || !pSdbFreeDatabaseInformation)
1037  {
1038  skip("GetDatabaseInformation or SdbFreeDatabaseInformation not found\n");
1039  return;
1040  }
1041 
1042  _SEH2_TRY
1043  {
1044  pSdbFreeDatabaseInformation(NULL);
1045  }
1047  {
1048  ok(0, "SdbFreeDatabaseInformation did not handle a NULL pointer very gracefully.\n");
1049  }
1050  _SEH2_END;
1051 
1052 
1053  pInfo = (PDB_INFORMATION)malloc(sizeof(*pInfo) * 4);
1054  memset(pInfo, 0xDE, sizeof(*pInfo) * 2);
1055 
1056  fResult = pSdbGetDatabaseInformation(pdb, pInfo);
1057  ok(fResult, "SdbGetDatabaseInformation failed\n");
1058  if (fResult)
1059  {
1060  ok_int(pInfo->dwSomething, 1);
1061  ok(IsEqualGUID(GUID_DATABASE_TEST, pInfo->Id), "expected guids to be equal(%s:%s)\n",
1062  wine_dbgstr_guid(&GUID_DATABASE_TEST), wine_dbgstr_guid(&pInfo->Id));
1063  ok(wcscmp(pInfo->Description, L"apphelp_test1") == 0,
1064  "Expected pInfo->Description to be 'apphelp_test1', was %s\n", wine_dbgstr_w(pInfo->Description));
1065 
1066  /* Struct is slightly bigger on some Win10, and the DB version nr is different on all */
1067  if (g_WinVersion >= WINVER_WIN10)
1068  {
1069  ok(pInfo->dwMajor == 3, "Expected pInfo->dwMajor to be 3, was: %d\n", pInfo->dwMajor);
1070  ok(pInfo->dwMinor == 0, "Expected pInfo->dwMinor to be 0, was: %d\n", pInfo->dwMinor);
1071 
1072  ok(pInfo[1].dwSomething == 4 || pInfo[1].dwSomething == 0xdededede, "Something amiss: 0x%x\n", pInfo[1].dwSomething);
1073  ok(pInfo[1].dwMajor == 0xdededede, "Cookie2 corrupt: 0x%x\n", pInfo[1].dwMajor);
1074  }
1075  else
1076  {
1077  ok(pInfo->dwMajor == 2, "Expected pInfo->dwMajor to be 2, was: %d\n", pInfo->dwMajor);
1078  ok(pInfo->dwMinor == 1, "Expected pInfo->dwMinor to be 1, was: %d\n", pInfo->dwMinor);
1079 
1080  ok(pInfo[1].dwSomething == 0xdededede, "Cookie1 corrupt: 0x%x\n", pInfo[1].dwSomething);
1081  ok(pInfo[1].dwMajor == 0xdededede, "Cookie2 corrupt: 0x%x\n", pInfo[1].dwMajor);
1082  }
1083 
1084  }
1085  free(pInfo);
1086 }
1087 
1089 {
1090  static const WCHAR path[] = {'t','e','s','t','_','d','b','.','s','d','b',0};
1091  TAGID root;
1092  PDB pdb;
1093  BOOL ret;
1094  DWORD ver_hi, ver_lo;
1095 
1096  test_create_db(L"test_db.sdb", g_WinVersion >= WINVER_WIN10);
1097 
1098  /* both ver_hi and ver_lo cannot be null, it'll crash. */
1099  ver_hi = ver_lo = 0x12345678;
1100  ret = pSdbGetDatabaseVersion(path, &ver_hi, &ver_lo);
1101  ok(ret, "Expected SdbGetDatabaseVersion to succeed\n");
1102  if (g_WinVersion >= WINVER_WIN10)
1103  {
1104  ok(ver_hi == 3, "Expected ver_hi to be 3, was: %d\n", ver_hi);
1105  ok(ver_lo == 0, "Expected ver_lo to be 0, was: %d\n", ver_lo);
1106  }
1107  else
1108  {
1109  ok(ver_hi == 2, "Expected ver_hi to be 2, was: %d\n", ver_hi);
1110  ok(ver_lo == 1, "Expected ver_lo to be 1, was: %d\n", ver_lo);
1111  }
1112 
1113  ver_hi = ver_lo = 0x12345678;
1114  ret = pSdbGetDatabaseVersion(NULL, &ver_hi, &ver_lo);
1115  if (g_WinVersion >= WINVER_WIN10)
1116  {
1117  ok(!ret, "Expected SdbGetDatabaseVersion to fail\n");
1118  ok(ver_hi == 0, "Expected ver_hi to be 0, was: 0x%x\n", ver_hi);
1119  ok(ver_lo == 0, "Expected ver_lo to be 0, was: 0x%x\n", ver_lo);
1120  }
1121  else
1122  {
1123  ok(ret, "Expected SdbGetDatabaseVersion to succeed\n");
1124  ok(ver_hi == 0x12345678, "Expected ver_hi to be 0x12345678, was: 0x%x\n", ver_hi);
1125  ok(ver_lo == 0x12345678, "Expected ver_lo to be 0x12345678, was: 0x%x\n", ver_lo);
1126  }
1127 
1128  ver_hi = ver_lo = 0x12345678;
1129  ret = pSdbGetDatabaseVersion(path + 1, &ver_hi, &ver_lo);
1130  if (g_WinVersion >= WINVER_WIN10)
1131  {
1132  ok(!ret, "Expected SdbGetDatabaseVersion to fail\n");
1133  ok(ver_hi == 0, "Expected ver_hi to be 0, was: 0x%x\n", ver_hi);
1134  ok(ver_lo == 0, "Expected ver_lo to be 0, was: 0x%x\n", ver_lo);
1135  }
1136  else
1137  {
1138  ok(ret, "Expected SdbGetDatabaseVersion to succeed\n");
1139  ok(ver_hi == 0x12345678, "Expected ver_hi to be 0x12345678, was: 0x%x\n", ver_hi);
1140  ok(ver_lo == 0x12345678, "Expected ver_lo to be 0x12345678, was: 0x%x\n", ver_lo);
1141  }
1142 
1143  pdb = pSdbOpenDatabase(path, DOS_PATH);
1144  ok(pdb != NULL, "unexpected NULL handle\n");
1145 
1146  root = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_DATABASE);
1147  ok(root != TAGID_NULL, "expected to find a root tag\n");
1148  if (root != TAGID_NULL)
1149  {
1150  TAGID tagLayer = pSdbFindFirstTag(pdb, root, TAG_LAYER);
1151  TAGID tagAlt = pSdbFindFirstNamedTag(pdb, root, TAG_LAYER, TAG_NAME, L"TestNewMode");
1152  TAGID tagAlt2 = pSdbFindFirstNamedTag(pdb, root, TAG_LAYER, TAG_NAME, L"TESTNEWMODE");
1153  TAGID tagAlt3 = pSdbFindFirstNamedTag(pdb, root, TAG_LAYER, TAG_NAME, L"testnewmode");
1154  ok_hex(tagLayer, (int)tagAlt);
1155  ok_hex(tagLayer, (int)tagAlt2);
1156  ok_hex(tagLayer, (int)tagAlt3);
1158  check_db_layer(pdb, tagLayer);
1161  }
1163 
1164  pSdbCloseDatabase(pdb);
1165  DeleteFileA("test_db.sdb");
1166 }
1167 
1168 static void test_is_testdb(PDB pdb)
1169 {
1170  if (pdb)
1171  {
1172  GUID guid;
1173  memset(&guid, 0, sizeof(guid));
1174  ok(pSdbGetDatabaseID(pdb, &guid), "expected SdbGetDatabaseID not to fail.\n");
1175  ok(IsEqualGUID(guid, GUID_DATABASE_TEST), "Expected SdbGetDatabaseID to return the test db GUID, was: %s\n", wine_dbgstr_guid(&guid));
1176  }
1177  else
1178  {
1179  skip("Not checking DB GUID, received a null pdb\n");
1180  }
1181 }
1182 
1184 {
1185  BOOL Result;
1187  PSID AdministratorsGroup;
1188 
1192  0, 0, 0, 0, 0, 0,
1193  &AdministratorsGroup);
1194  if (Result)
1195  {
1196  if (!CheckTokenMembership( NULL, AdministratorsGroup, &Result))
1197  Result = FALSE;
1198  FreeSid(AdministratorsGroup);
1199  }
1200 
1201  return Result;
1202 }
1203 
1204 
1205 template<typename SDBQUERYRESULT_T>
1206 static void check_adwExeFlags(DWORD adwExeFlags_0, SDBQUERYRESULT_T& query, const char* file, int line, size_t cur)
1207 {
1208  ok_(file, line)(query.adwExeFlags[0] == adwExeFlags_0, "Expected adwExeFlags[0] to be 0x%x, was: 0x%x for %d\n", adwExeFlags_0, query.adwExeFlags[0], cur);
1209  for (size_t n = 1; n < _countof(query.atrExes); ++n)
1210  ok_(file, line)(query.adwExeFlags[n] == 0, "Expected adwExeFlags[%d] to be 0, was: %x for %d\n", n, query.adwExeFlags[0], cur);
1211 }
1212 
1213 template<>
1214 void check_adwExeFlags(DWORD, SDBQUERYRESULT_2k3&, const char*, int, size_t)
1215 {
1216 }
1217 
1218 
1219 template<typename SDBQUERYRESULT_T>
1220 static void test_mode_generic(const WCHAR* workdir, HSDB hsdb, size_t cur)
1221 {
1222  WCHAR exename[MAX_PATH], testfile[MAX_PATH];
1223  BOOL ret;
1224  SDBQUERYRESULT_T query;
1225  PDB pdb;
1226  TAGID tagid;
1227  TAGREF trApphelp;
1228  DWORD expect_flags = 0, adwExeFlags_0, exe_count;
1229  UNICODE_STRING exenameNT;
1230 
1231  memset(&query, 0xab, sizeof(query));
1232 
1233  swprintf(exename, L"%s\\%s", workdir, test_exedata[cur].name);
1234  if (test_exedata[cur].extra_file)
1235  swprintf(testfile, L"%s\\%s", workdir, test_exedata[cur].extra_file);
1237 
1238  if (test_exedata[cur].extra_file)
1239  {
1240  /* First we try without the file at all. */
1241  DeleteFileW(testfile);
1242  ret = pSdbGetMatchingExe(hsdb, exename, NULL, NULL, 0, (SDBQUERYRESULT_VISTA*)&query);
1243  ok(ret == 0, "SdbGetMatchingExe should have failed for %d.\n", cur);
1244  /* Now re-try with the correct file */
1245  test_create_file(testfile, "aaaa", 4);
1246  }
1247 
1248 #if 0
1249  // Results seem to be cached based on filename, until we can invalidate this, do not test the same filename twice!
1251  // skip exports
1253  ret = pSdbGetMatchingExe(hsdb, exenameW, NULL, NULL, 0, &query);
1254  ok(ret == 0, "SdbGetMatchingExe should have failed for %d.\n", cur);
1255 
1258 #endif
1259 
1260  if (test_exedata[cur].env_var)
1261  {
1262  SetEnvironmentVariableA("__COMPAT_LAYER", test_exedata[cur].env_var);
1263  }
1264 
1265  ret = pSdbGetMatchingExe(hsdb, exename, NULL, NULL, 0, (SDBQUERYRESULT_VISTA*)&query);
1266  ok(ret, "SdbGetMatchingExe should not fail for %d.\n", cur);
1267 
1268  exe_count = (test_exedata[cur].env_var == NULL) ? 1 : 0;
1269 
1270  ok(query.dwExeCount == exe_count, "Expected dwExeCount to be %d, was %d for %d\n", exe_count, query.dwExeCount, cur);
1271  ok(query.dwLayerCount == test_exedata[cur].dwLayerCount, "Expected dwLayerCount to be %d, was %d for %d\n", test_exedata[cur].dwLayerCount, query.dwLayerCount, cur);
1272  ok(query.dwCustomSDBMap == 1, "Expected dwCustomSDBMap to be 1, was %d for %d\n", query.dwCustomSDBMap, cur);
1273  ok(query.dwLayerFlags == 0, "Expected dwLayerFlags to be 0, was 0x%x for %d\n", query.dwLayerFlags, cur);
1275  ok(query.trApphelp == trApphelp, "Expected trApphelp to be 0x%x, was 0x%x for %d\n", trApphelp, query.trApphelp, cur);
1276 
1277  if (g_WinVersion < WINVER_WIN7)
1278  expect_flags = 0;
1279  else if (g_WinVersion < WINVER_WIN8)
1280  expect_flags = 1;
1281  else if (g_WinVersion < WINVER_WIN10)
1282  expect_flags = 0x101;
1283  else
1284  {
1285  expect_flags = 0x121; /* for 2 and 3, this becomes 101 when not elevated. */
1286  if ((cur == 2 || cur == 3) && !IsUserAdmin())
1287  expect_flags &= ~0x20;
1288  }
1289 
1290  if (test_exedata[cur].env_var)
1291  expect_flags &= ~0x100;
1292 
1293  ok(query.dwFlags == expect_flags, "Expected dwFlags to be 0x%x, was 0x%x for %d\n", expect_flags, query.dwFlags, cur);
1294 
1295  ok(query.atrExes[0] == test_exedata[cur].atrExes_0, "Expected atrExes[0] to be 0x%x, was: 0x%x for %d\n", test_exedata[cur].atrExes_0, query.atrExes[0], cur);
1296  for (size_t n = 1; n < _countof(query.atrExes); ++n)
1297  ok(query.atrExes[n] == 0, "Expected atrExes[%d] to be 0, was: %x for %d\n", n, query.atrExes[n], cur);
1298 
1300  check_adwExeFlags(adwExeFlags_0, query, __FILE__, __LINE__, cur);
1301 
1302  ok(query.atrLayers[0] == test_exedata[cur].atrLayers_0, "Expected atrLayers[0] to be 0x%x, was: %x for %d\n", test_exedata[cur].atrLayers_0, query.atrLayers[0], cur);
1303  for (size_t n = 1; n < _countof(query.atrLayers); ++n)
1304  ok(query.atrLayers[n] == 0, "Expected atrLayers[%d] to be 0, was: %x for %d\n", n, query.atrLayers[0], cur);
1305 
1306  if (g_WinVersion >= WINVER_VISTA)
1307  ok(IsEqualGUID(query.rgGuidDB[0], GUID_DATABASE_TEST), "Expected rgGuidDB[0] to be the test db GUID, was: %s for %d\n", wine_dbgstr_guid(&query.rgGuidDB[0]), cur);
1308  else
1309  ok(IsEqualGUID(query.rgGuidDB[0], GUID_MAIN_DATABASE), "Expected rgGuidDB[0] to be the main db GUID, was: %s for %d\n", wine_dbgstr_guid(&query.rgGuidDB[0]), cur);
1310  for (size_t n = 1; n < _countof(query.rgGuidDB); ++n)
1311  ok(IsEqualGUID(query.rgGuidDB[n], GUID_NULL), "Expected rgGuidDB[%d] to be GUID_NULL, was: %s for %d\n", n, wine_dbgstr_guid(&query.rgGuidDB[n]), cur);
1312 
1313  if (query.atrExes[0])
1314  {
1315  pdb = (PDB)0x12345678;
1316  tagid = 0x76543210;
1317  ret = pSdbTagRefToTagID(hsdb, query.atrExes[0], &pdb, &tagid);
1318  ok(ret, "SdbTagRefToTagID failed for %d.\n", cur);
1319  ok(pdb != NULL && pdb != (PDB)0x12345678, "SdbTagRefToTagID failed to return a pdb for %d.\n", cur);
1320  ok(tagid != 0 && tagid != 0x76543210, "SdbTagRefToTagID failed to return a tagid for %d.\n", cur);
1321 
1322  if (pdb && pdb != (PDB)0x12345678)
1323  {
1324  TAGREF tr = 0x12345678;
1325  TAG tag = pSdbGetTagFromTagID(pdb, tagid);
1327  ok(tag == TAG_EXE, "Expected tag to be TAG_EXE, was 0x%x for %d.\n", tag, cur);
1328  match_strw_attr(pdb, tagid, TAG_NAME, test_exedata[cur].name);
1329 
1330  /* And back again */
1331  ret = pSdbTagIDToTagRef(hsdb, pdb, tagid, &tr);
1332  ok(ret, "SdbTagIDToTagRef failed for %d.\n", cur);
1333  ok(tr == query.atrExes[0], "Expected tr to be 0x%x, was 0x%x for %d.\n", query.atrExes[0], tr, cur);
1334  }
1335  else
1336  {
1337  skip("Skipping a bunch of tests because of an invalid pointer\n");
1338  }
1339  }
1340 
1341  if (test_exedata[cur].atrLayers_0)
1342  {
1343  pdb = (PDB)0x12345678;
1344  tagid = 0x76543210;
1345  ret = pSdbTagRefToTagID(hsdb, query.atrLayers[0], &pdb, &tagid);
1346  ok(ret, "SdbTagRefToTagID failed for %d.\n", cur);
1347  ok(pdb != NULL && pdb != (PDB)0x12345678, "SdbTagRefToTagID failed to return a pdb for %d.\n", cur);
1348  ok(tagid != 0 && tagid != 0x76543210, "SdbTagRefToTagID failed to return a tagid for %d.\n", cur);
1349 
1350  if (pdb && pdb != (PDB)0x12345678)
1351  {
1352  TAGREF tr = 0x12345678;
1353  TAG tag = pSdbGetTagFromTagID(pdb, tagid);
1355  ok(tag == TAG_LAYER, "Expected tag to be TAG_LAYER, was 0x%x for %d.\n", tag, cur);
1356  match_strw_attr(pdb, tagid, TAG_NAME, L"TestNewMode");
1357 
1358  /* And back again */
1359  ret = pSdbTagIDToTagRef(hsdb, pdb, tagid, &tr);
1360  ok(ret, "SdbTagIDToTagRef failed for %d.\n", cur);
1361  ok(tr == test_exedata[cur].atrLayers_0, "Expected tr to be 0x%x, was 0x%x for %d.\n", test_exedata[cur].atrLayers_0, tr, cur);
1362  }
1363  else
1364  {
1365  skip("Skipping a bunch of tests because of an invalid pointer\n");
1366  }
1367  }
1368 
1369  pdb = (PDB)0x12345678;
1370  tagid = 0x76543210;
1371  ret = pSdbTagRefToTagID(hsdb, 0, &pdb, &tagid);
1372  ok(pdb != NULL && pdb != (PDB)0x12345678, "Expected pdb to be set to a valid pdb, was: %p\n", pdb);
1373  ok(tagid == 0, "Expected tagid to be set to 0, was: 0x%x\n", tagid);
1374 
1375 
1376 
1377  if (RtlDosPathNameToNtPathName_U(exename, &exenameNT, NULL, NULL))
1378  {
1379  /*
1380  ERROR,AslPathGetLongFileNameLongpath,110,Long path conversion failed 123 [c0000001]
1381  ERROR,AslPathBuildSignatureLongpath,1086,AslPathGetLongFileNameLongpath failed for \??\C:\Users\MARK~1.DEV\AppData\Local\Temp\apphelp_test\test_allow.exe [c0000001]
1382  */
1383  ret = pSdbGetMatchingExe(hsdb, exenameNT.Buffer, NULL, NULL, 0, (SDBQUERYRESULT_VISTA*)&query);
1384  ok(!ret, "SdbGetMatchingExe should not succeed for %d.\n", cur);
1385 
1386  RtlFreeUnicodeString(&exenameNT);
1387  }
1388 
1389  if (test_exedata[cur].extra_file)
1390  DeleteFileW(testfile);
1392 
1393  if (test_exedata[cur].env_var)
1394  {
1395  SetEnvironmentVariableA("__COMPAT_LAYER", NULL);
1396  }
1397 }
1398 
1399 template<typename SDBQUERYRESULT_T>
1400 static void test_MatchApplications(void)
1401 {
1402  WCHAR workdir[MAX_PATH], dbpath[MAX_PATH];
1403  BOOL ret;
1404  HSDB hsdb;
1405 
1407  ok(ret, "GetTempPathW error: %d\n", GetLastError());
1408  wcscat(workdir, L"apphelp_test");
1409 
1411  ok(ret, "CreateDirectoryW error: %d\n", GetLastError());
1412 
1413  /* SdbInitDatabase needs an nt-path */
1414  swprintf(dbpath, L"\\??\\%s\\test.sdb", workdir);
1415 
1416  test_create_db(dbpath + 4, g_WinVersion >= WINVER_WIN10);
1417 
1418  hsdb = pSdbInitDatabase(HID_DATABASE_FULLPATH, dbpath);
1419 
1420  ok(hsdb != NULL, "Expected a valid database handle\n");
1421 
1422  if (!hsdb)
1423  {
1424  skip("SdbInitDatabase not implemented?\n");
1425  }
1426  else
1427  {
1428  /* now that our enviroment is setup, let's go ahead and run the actual tests.. */
1429  size_t n;
1430  for (n = 0; n < _countof(test_exedata); ++n)
1431  test_mode_generic<SDBQUERYRESULT_T>(workdir, hsdb, n);
1432  pSdbReleaseDatabase(hsdb);
1433  }
1434 
1435  DeleteFileW(dbpath + 4);
1436 
1438  ok(ret, "RemoveDirectoryW error: %d\n", GetLastError());
1439 }
1440 
1441 static BOOL write_raw_file(const WCHAR* FileName, const void* Data, DWORD Size)
1442 {
1443  BOOL Success;
1444  DWORD dwWritten;
1446 
1448  {
1449  skip("Failed to create temp file %ls, error %u\n", FileName, GetLastError());
1450  return FALSE;
1451  }
1452  Success = WriteFile(Handle, Data, Size, &dwWritten, NULL);
1453  ok(Success == TRUE, "WriteFile failed with %u\n", GetLastError());
1454  ok(dwWritten == Size, "WriteFile wrote %u bytes instead of %u\n", dwWritten, Size);
1456  return Success && (dwWritten == Size);
1457 }
1458 
1459 static bool extract_resource(const WCHAR* Filename, LPCWSTR ResourceName)
1460 {
1461  HMODULE hMod = GetModuleHandleW(NULL);
1462  HRSRC hRsrc = FindResourceW(hMod, ResourceName, MAKEINTRESOURCEW(RT_RCDATA));
1463  ok(!!hRsrc, "Unable to find %s\n", wine_dbgstr_w(ResourceName));
1464  if (!hRsrc)
1465  return false;
1466 
1467  HGLOBAL hGlobal = LoadResource(hMod, hRsrc);
1468  DWORD Size = SizeofResource(hMod, hRsrc);
1469  LPVOID pData = LockResource(hGlobal);
1470 
1471  ok(Size && !!pData, "Unable to load %s\n", wine_dbgstr_w(ResourceName));
1472  if (!Size || !pData)
1473  return false;
1474 
1475  BOOL Written = write_raw_file(Filename, pData, Size);
1477  return Written;
1478 }
1479 
1480 template<typename SDBQUERYRESULT_T>
1481 static void test_match_ex(const WCHAR* workdir, HSDB hsdb)
1482 {
1484  PWCHAR Vendor, AppName, TestName;
1485  SDBQUERYRESULT_T query;
1486  TAGID dbtag, exetag, tagid;
1487  BOOL ret, Succeed;
1488  PDB pdb;
1489 
1490  memset(&query, 0xab, sizeof(query));
1491 
1492  ret = pSdbTagRefToTagID(hsdb, 0, &pdb, &tagid);
1493  ok(pdb != NULL && pdb != (PDB)0x12345678, "Expected pdb to be set to a valid pdb, was: %p\n", pdb);
1494 
1495  dbtag = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_DATABASE);
1496  ok(dbtag != TAGID_NULL, "Expected to get a valid TAG_DATABASE\n");
1497 
1498  for (exetag = pSdbFindFirstTag(pdb, dbtag, TAG_EXE); exetag; exetag = pSdbFindNextTag(pdb, dbtag, exetag))
1499  {
1500  tagid = pSdbFindFirstTag(pdb, exetag, TAG_VENDOR);
1501  Vendor = pSdbGetStringTagPtr(pdb, tagid);
1502  if (!Vendor)
1503  continue;
1504  Succeed = !wcsicmp(Vendor, L"Succeed");
1505  if (!Succeed && wcsicmp(Vendor, L"Fail"))
1506  continue;
1507  tagid = pSdbFindFirstTag(pdb, exetag, TAG_APP_NAME);
1508  AppName = pSdbGetStringTagPtr(pdb, tagid);
1509  if (!AppName)
1510  continue;
1511 
1512  tagid = pSdbFindFirstTag(pdb, exetag, TAG_NAME);
1513  TestName = pSdbGetStringTagPtr(pdb, tagid);
1514  if (!TestName)
1515  continue;
1516 
1517  swprintf(exename, L"%s\\%s", workdir, AppName);
1519 
1520  ret = pSdbGetMatchingExe(hsdb, exename, NULL, NULL, 0, (SDBQUERYRESULT_VISTA*)&query);
1521  DWORD exe_count = Succeed ? 1 : 0;
1522 
1523  if (Succeed && !ret && g_WinVersion == _WIN32_WINNT_WS03)
1524  {
1525  skip("As long as we do not have indexes, we will hit a bug in W2k3\n");
1526 #if 0
1527 [Info][SdbGetIndex ] index 0x7007(0x600b) was not found in the index table
1528 [Info][SdbGetIndex ] index 0x7007(0x6001) was not found in the index table
1529 [Info][SdbpSearchDB ] Searching database with no index.
1530 [Err ][SdbpSearchDB ] No DATABASE tag found.
1531 #endif
1532  }
1533  else
1534  {
1535  if (Succeed)
1536  ok(ret, "SdbGetMatchingExe should not fail for %s.\n", wine_dbgstr_w(TestName));
1537  else
1538  ok(!ret, "SdbGetMatchingExe should not succeed for %s.\n", wine_dbgstr_w(TestName));
1539 
1540  ok(query.dwExeCount == exe_count, "Expected dwExeCount to be %d, was %d for %s\n", exe_count, query.dwExeCount, wine_dbgstr_w(TestName));
1541  }
1543  }
1544 }
1545 
1546 
1547 template<typename SDBQUERYRESULT_T>
1548 static void test_MatchApplicationsEx(void)
1549 {
1550  WCHAR workdir[MAX_PATH], dbpath[MAX_PATH];
1551  BOOL ret;
1552  HSDB hsdb;
1553 
1555  ok(ret, "GetTempPathW error: %d\n", GetLastError());
1556  lstrcatW(workdir, L"apphelp_test");
1557 
1559  ok(ret, "CreateDirectoryW error: %d\n", GetLastError());
1560 
1561  /* SdbInitDatabase needs an nt-path */
1562  swprintf(dbpath, L"\\??\\%s\\test.sdb", workdir);
1563 
1564  if (extract_resource(dbpath + 4, MAKEINTRESOURCEW(101)))
1565  {
1566  hsdb = pSdbInitDatabase(HID_DATABASE_FULLPATH, dbpath);
1567 
1568  ok(hsdb != NULL, "Expected a valid database handle\n");
1569 
1570  if (!hsdb)
1571  {
1572  skip("SdbInitDatabase not implemented?\n");
1573  }
1574  else
1575  {
1576  /* now that our enviroment is setup, let's go ahead and run the actual tests.. */
1577  test_match_ex<SDBQUERYRESULT_T>(workdir, hsdb);
1578  pSdbReleaseDatabase(hsdb);
1579  }
1580  }
1581  else
1582  {
1583  ok(0, "Unable to extract database\n");
1584  }
1585 
1586  DeleteFileW(dbpath + 4);
1587 
1589  ok(ret, "RemoveDirectoryW error: %d\n", GetLastError());
1590 }
1591 
1592 
1593 
1594 
1595 static void test_TagRef(void)
1596 {
1597  WCHAR tmpdir[MAX_PATH], dbpath[MAX_PATH];
1598  BOOL ret;
1599  HSDB hsdb;
1600  PDB pdb;
1601  TAGID db;
1602  DWORD size;
1603  TAGREF tr;
1604 
1606  ok(ret, "GetTempPathA error: %d\n", GetLastError());
1607 
1608  /* SdbInitDatabase needs an nt-path */
1609  swprintf(dbpath, L"\\??\\%stest.sdb", tmpdir);
1610 
1611  test_create_db(dbpath + 4, g_WinVersion >= WINVER_WIN10);
1612 
1613  hsdb = pSdbInitDatabase(HID_DATABASE_FULLPATH, dbpath);
1614 
1615  /* HSDB is the only arg that can't be null */
1616  ret = pSdbTagRefToTagID(hsdb, 0, NULL, NULL);
1617  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1618 
1619  size = test_get_db_size();
1620 
1621  pdb = (PDB)&db;
1622  db = 12345;
1623  ret = pSdbTagRefToTagID(hsdb, size - 1, &pdb, &db);
1624  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1625  ok(pdb != NULL, "Expected a result, got: %p\n", pdb);
1626  ok(db == (size - 1), "Expected %u, got: %u\n", size - 1, db);
1627 
1628  /* Convert it back. */
1629  tr = 0x12345678;
1630  ret = pSdbTagIDToTagRef(hsdb, pdb, db, &tr);
1631  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1632  ok(tr == (size - 1), "Expected %u, got: %u\n", size - 1, tr);
1633 
1634  pdb = (PDB)&db;
1635  db = 12345;
1636  ret = pSdbTagRefToTagID(hsdb, size, &pdb, &db);
1637  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1638  ok(pdb != NULL, "Expected a result, got: %p\n", pdb);
1639  ok(db == size, "Expected %u, got: %u\n", size, db);
1640 
1641  tr = 0x12345678;
1642  ret = pSdbTagIDToTagRef(hsdb, pdb, db, &tr);
1643  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1644  ok(tr == size, "Expected %u, got: %u\n", size, tr);
1645 
1646  pdb = (PDB)&db;
1647  db = 12345;
1648  ret = pSdbTagRefToTagID(hsdb, size + 1, &pdb, &db);
1649  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1650  ok(pdb != NULL, "Expected a result, got: %p\n", pdb);
1651  ok(db == (size + 1), "Expected %u, got: %u\n", size + 1, db);
1652 
1653  tr = 0x12345678;
1654  ret = pSdbTagIDToTagRef(hsdb, pdb, db, &tr);
1655  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1656  ok(tr == (size + 1), "Expected %u, got: %u\n", (size + 1), tr);
1657 
1658  pdb = (PDB)&db;
1659  db = 12345;
1660  ret = pSdbTagRefToTagID(hsdb, 0x0fffffff, &pdb, &db);
1661  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1662  ok(pdb != NULL, "Expected a result, got: %p\n", pdb);
1663  ok(db == 0x0fffffff, "Expected %u, got: %u\n", 0x0fffffff, db);
1664 
1665  tr = 0x12345678;
1666  ret = pSdbTagIDToTagRef(hsdb, pdb, db, &tr);
1667  ok(ret == TRUE, "Expected ret to be TRUE, was: %d\n", ret);
1668  ok(tr == 0x0fffffff, "Expected %u, got: %u\n", 0x0fffffff, tr);
1669 
1670  pdb = (PDB)&db;
1671  db = 12345;
1672  ret = pSdbTagRefToTagID(hsdb, 0x10000000, &pdb, &db);
1673  ok(ret == FALSE, "Expected ret to be FALSE, was: %d\n", ret);
1674  ok(pdb == NULL, "Expected no result, got: %p\n", pdb);
1675  ok(db == 0, "Expected no result, got: 0x%x\n", db);
1676 
1677  tr = 0x12345678;
1678  ret = pSdbTagIDToTagRef(hsdb, pdb, 0x10000000, &tr);
1679  ok(ret == FALSE, "Expected ret to be TRUE, was: %d\n", ret);
1680  ok(tr == 0, "Expected %u, got: %u\n", 0, tr);
1681 
1682  pdb = NULL;
1683  db = TAGID_NULL;
1684  ret = pSdbTagRefToTagID(hsdb, TAGID_ROOT, &pdb, NULL);
1685  ok(ret != FALSE, "Expected ret to be TRUE, was: %d\n", ret);
1686  ok(pdb != NULL, "Expected pdb to be valid\n");
1687 
1688  if (pdb == NULL)
1689  {
1690  skip("Cannot run tests without pdb\n");
1691  }
1692  else
1693  {
1694  db = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_DATABASE);
1695  if (db != TAGID_NULL)
1696  {
1697  TAGID child;
1698  child = pSdbGetFirstChild(pdb, db);
1699  while (child != TAGID_NULL)
1700  {
1701  PDB pdb_res;
1702  TAGID tagid_res;
1703  /* We are using a TAGID as a TAGREF here. */
1704  ret = pSdbTagRefToTagID(hsdb, child, &pdb_res, &tagid_res);
1705  ok(ret, "Expected SdbTagRefToTagID to succeed\n");
1706 
1707  /* For simple cases (primary DB) TAGREF == TAGID */
1708  tr = 0x12345678;
1709  ret = pSdbTagIDToTagRef(hsdb, pdb_res, tagid_res, &tr);
1710  ok(ret, "Expected SdbTagIDToTagRef to succeed\n");
1711  ok_hex(tr, (int)tagid_res);
1712 
1713  child = pSdbGetNextChild(pdb, db, child);
1714  }
1715  }
1716  else
1717  {
1718  skip("Cannot run tests without valid db tag\n");
1719  }
1720  }
1721 
1722  /* Get a tagref for our own layer */
1723  tr = pSdbGetLayerTagRef(hsdb, L"TestNewMode");
1724  ok_hex(tr, 0x18e);
1725 
1726  /* We cannot find a tagref from the main database. */
1727  tr = pSdbGetLayerTagRef(hsdb, L"256Color");
1728  ok_hex(tr, 0);
1729 
1730  pSdbReleaseDatabase(hsdb);
1731 
1732  DeleteFileW(dbpath + 4);
1733 }
1734 
1735 
1736 static void test_DataTags(HSDB hsdb)
1737 {
1738  PDB pdb = NULL;
1739  TAGID db = TAGID_NULL, layer, exe;
1740  TAGREF trData;
1741  BYTE Buffer[1024];
1742  DWORD dwBufferSize, dwDataType, dwRet;
1743  TAGID tiData;
1744 
1745  BOOL ret = pSdbTagRefToTagID(hsdb, TAGID_ROOT, &pdb, NULL);
1746 
1747  ok(ret != FALSE, "Expected ret to be TRUE, was: %d\n", ret);
1748  ok(pdb != NULL, "Expected pdb to be valid\n");
1749 
1750  if (pdb == NULL)
1751  {
1752  skip("Cannot run tests without pdb\n");
1753  return;
1754  }
1755 
1756  db = pSdbFindFirstTag(pdb, TAGID_ROOT, TAG_DATABASE);
1757  ok(db != NULL, "Expected db to be valid\n");
1758  if (db == TAGID_NULL)
1759  {
1760  skip("Cannot run tests without db\n");
1761  return;
1762  }
1763 
1764  layer = pSdbFindFirstNamedTag(pdb, db, TAG_LAYER, TAG_NAME, L"DATA_LAYER");
1765  ok(layer != NULL, "Expected layer to be valid\n");
1766  if (layer == TAGID_NULL)
1767  {
1768  skip("Cannot run tests without layer\n");
1769  return;
1770  }
1771 
1772  memset(Buffer, 0xaa, sizeof(Buffer));
1773  dwBufferSize = sizeof(Buffer);
1774  dwDataType = 0x12345;
1775  tiData = 0x111111;
1776  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA1", &dwDataType, Buffer, &dwBufferSize, &tiData);
1777  ok_hex(dwRet, ERROR_SUCCESS);
1778  ok_hex(dwDataType, REG_DWORD);
1779  ok_hex(dwBufferSize, sizeof(DWORD));
1780  ok_hex(*(DWORD*)Buffer, 3333);
1781  ok(tiData != NULL && tiData != 0x111111, "Expected tiData, got NULL\n");
1782  ok_hex(pSdbGetTagFromTagID(pdb, tiData), TAG_DATA);
1783 
1784  memset(Buffer, 0xaa, sizeof(Buffer));
1785  dwBufferSize = sizeof(Buffer);
1786  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA1", NULL, Buffer, &dwBufferSize, NULL);
1787  ok_hex(dwRet, ERROR_SUCCESS);
1788  ok_hex(dwBufferSize, sizeof(DWORD));
1789  ok_hex(*(DWORD*)Buffer, 3333);
1790 
1792  {
1793  memset(Buffer, 0xaa, sizeof(Buffer));
1794  dwBufferSize = sizeof(Buffer);
1795  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA1", NULL, Buffer, NULL, NULL);
1797  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1798  }
1799 
1800  memset(Buffer, 0xaa, sizeof(Buffer));
1801  dwBufferSize = 1;
1802  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA1", NULL, Buffer, &dwBufferSize, NULL);
1804  ok_hex(dwBufferSize, sizeof(DWORD));
1805  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1806 
1807  memset(Buffer, 0xaa, sizeof(Buffer));
1808  dwBufferSize = sizeof(Buffer);
1809  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA1", NULL, NULL, &dwBufferSize, NULL);
1811  ok_hex(dwBufferSize, sizeof(DWORD));
1812  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1813 
1814  memset(Buffer, 0xaa, sizeof(Buffer));
1815  dwBufferSize = sizeof(Buffer);
1816  dwRet = pSdbQueryDataExTagID(pdb, TAGID_NULL, L"TESTDATA1", NULL, Buffer, &dwBufferSize, NULL);
1817  ok_hex(dwRet, ERROR_NOT_FOUND);
1818  ok_hex(dwBufferSize, sizeof(Buffer));
1819  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1820 
1821  memset(Buffer, 0xaa, sizeof(Buffer));
1822  dwBufferSize = sizeof(Buffer);
1823  dwDataType = 0x12345;
1824  tiData = 0x111111;
1825  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA2", &dwDataType, Buffer, &dwBufferSize, &tiData);
1826  ok_hex(dwRet, ERROR_SUCCESS);
1827  ok_hex(dwDataType, REG_QWORD);
1828  ok_hex(dwBufferSize, sizeof(QWORD));
1829  ok(*(QWORD*)Buffer == 4294967295ull, "unexpected value 0x%I64x, expected 4294967295\n", *(QWORD*)Buffer);
1830  ok(tiData != NULL && tiData != 0x111111, "Expected tiData, got NULL\n");
1831  ok_hex(pSdbGetTagFromTagID(pdb, tiData), TAG_DATA);
1832 
1833  /* Not case sensitive */
1834  memset(Buffer, 0xaa, sizeof(Buffer));
1835  dwBufferSize = sizeof(Buffer);
1836  dwDataType = 0x12345;
1837  tiData = 0x111111;
1838  dwRet = pSdbQueryDataExTagID(pdb, layer, L"TESTDATA3", &dwDataType, Buffer, &dwBufferSize, &tiData);
1839  ok_hex(dwRet, ERROR_SUCCESS);
1840  ok_hex(dwDataType, REG_SZ);
1841  ok_hex(dwBufferSize, (int)((wcslen(L"Test string")+1) * sizeof(WCHAR)));
1842  Buffer[_countof(Buffer)-1] = L'\0';
1843  ok_wstr(((WCHAR*)Buffer), L"Test string");
1844  ok(tiData != NULL && tiData != 0x111111, "Expected tiData, got NULL\n");
1845  ok_hex(pSdbGetTagFromTagID(pdb, tiData), TAG_DATA);
1846 
1847  /* Show that SdbQueryDataEx behaves the same */
1848  memset(Buffer, 0xaa, sizeof(Buffer));
1849  dwBufferSize = sizeof(Buffer);
1850  dwDataType = 0x12345;
1851  trData = 0x111111;
1852  dwRet = pSdbQueryDataEx(hsdb, layer, L"TESTDATA1", &dwDataType, Buffer, &dwBufferSize, &trData);
1853  ok_hex(dwRet, ERROR_SUCCESS);
1854  ok_hex(dwDataType, REG_DWORD);
1855  ok_hex(dwBufferSize, sizeof(DWORD));
1856  ok_hex(*(DWORD*)Buffer, 3333);
1857  ok(trData != NULL && trData != 0x111111, "Expected trData, got NULL\n");
1858 
1859  /* And SdbQueryData as well */
1860  memset(Buffer, 0xaa, sizeof(Buffer));
1861  dwBufferSize = sizeof(Buffer);
1862  dwDataType = 0x12345;
1863  dwRet = pSdbQueryData(hsdb, layer, L"TESTDATA1", &dwDataType, Buffer, &dwBufferSize);
1864  ok_hex(dwRet, ERROR_SUCCESS);
1865  ok_hex(dwDataType, REG_DWORD);
1866  ok_hex(dwBufferSize, sizeof(DWORD));
1867  ok_hex(*(DWORD*)Buffer, 3333);
1868 
1869  exe = pSdbFindFirstNamedTag(pdb, db, TAG_EXE, TAG_NAME, L"test_match0.exe");
1870  ok(exe != NULL, "Expected exe to be valid\n");
1871  if (exe == TAGID_NULL)
1872  {
1873  skip("Cannot run tests without exe\n");
1874  return;
1875  }
1876 
1877  memset(Buffer, 0xaa, sizeof(Buffer));
1878  dwBufferSize = sizeof(Buffer);
1879  dwDataType = 0x12345;
1880  tiData = 0x111111;
1881  dwRet = pSdbQueryDataExTagID(pdb, exe, L"TESTDATA1", &dwDataType, Buffer, &dwBufferSize, &tiData);
1882  ok_hex(dwRet, ERROR_NOT_FOUND);
1883  ok_hex(dwDataType, 0x12345);
1884  ok_hex(dwBufferSize, sizeof(Buffer));
1885  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1886  ok(tiData == 0x111111, "Expected 0x111111, got 0x%x\n", tiData);
1887 
1888  /* Show that SdbQueryDataEx behaves the same */
1889  memset(Buffer, 0xaa, sizeof(Buffer));
1890  dwBufferSize = sizeof(Buffer);
1891  dwDataType = 0x12345;
1892  trData = 0x111111;
1893  dwRet = pSdbQueryDataEx(hsdb, exe, L"TESTDATA1", &dwDataType, Buffer, &dwBufferSize, &trData);
1894  ok_hex(dwRet, ERROR_NOT_FOUND);
1895  ok_hex(dwDataType, 0x12345);
1896  ok_hex(dwBufferSize, sizeof(Buffer));
1897  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1899  ok(trData == 0, "Expected 0, got 0x%x\n", trData);
1900  else
1901  ok(trData == 0x111111, "Expected 0x111111, got 0x%x\n", trData);
1902 
1903  /* And SdbQueryData as well */
1904  memset(Buffer, 0xaa, sizeof(Buffer));
1905  dwBufferSize = sizeof(Buffer);
1906  dwDataType = 0x12345;
1907  dwRet = pSdbQueryData(hsdb, exe, L"TESTDATA1", &dwDataType, Buffer, &dwBufferSize);
1908  ok_hex(dwRet, ERROR_NOT_FOUND);
1909  ok_hex(dwDataType, 0x12345);
1910  ok_hex(dwBufferSize, sizeof(Buffer));
1911  ok_hex(*(DWORD*)Buffer, (int)0xaaaaaaaa);
1912 }
1913 
1914 
1915 static void test_Data(void)
1916 {
1917  WCHAR workdir[MAX_PATH], dbpath[MAX_PATH];
1918  BOOL ret;
1919  HSDB hsdb;
1920 
1922  ok(ret, "GetTempPathW error: %d\n", GetLastError());
1923  lstrcatW(workdir, L"apphelp_test");
1924 
1926  ok(ret, "CreateDirectoryW error: %d\n", GetLastError());
1927 
1928  /* SdbInitDatabase needs an nt-path */
1929  swprintf(dbpath, L"\\??\\%s\\test.sdb", workdir);
1930 
1931  if (extract_resource(dbpath + 4, MAKEINTRESOURCEW(101)))
1932  {
1933  hsdb = pSdbInitDatabase(HID_DATABASE_FULLPATH, dbpath);
1934 
1935  ok(hsdb != NULL, "Expected a valid database handle\n");
1936 
1937  if (!hsdb)
1938  {
1939  skip("SdbInitDatabase not implemented?\n");
1940  }
1941  else
1942  {
1943  test_DataTags(hsdb);
1944  pSdbReleaseDatabase(hsdb);
1945  }
1946  }
1947  else
1948  {
1949  ok(0, "Unable to extract database\n");
1950  }
1951 
1952  DeleteFileW(dbpath + 4);
1953 
1955  ok(ret, "RemoveDirectoryW error: %d\n", GetLastError());
1956 }
1957 
1958 
1959 static void expect_indexA_imp(const char* text, LONGLONG expected)
1960 {
1961  static WCHAR wide_string[100] = { 0 };
1962  LONGLONG result;
1963  MultiByteToWideChar(CP_ACP, 0, text, -1, wide_string, 100);
1964 
1965  result = pSdbMakeIndexKeyFromString(wide_string);
1966  winetest_ok(result == expected, "Expected %s to result in %s, was: %s\n", text, wine_dbgstr_longlong(expected), wine_dbgstr_longlong(result));
1967 }
1968 
1969 #define expect_indexA (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_indexA_imp
1970 
1971 static void test_IndexKeyFromString(void)
1972 {
1973 #if 0
1974  static WCHAR tmp[] = { 0xabba, 0xbcde, 0x2020, 0x20, 0x4444, 0 };
1975  static WCHAR tmp2[] = { 0xabba, 0xbcde, 0x20, 0x4444, 0 };
1976  static WCHAR tmp3[] = { 0x20, 0xbcde, 0x4041, 0x4444, 0 };
1977  static WCHAR tmp4[] = { 0x20, 0xbcde, 0x4041, 0x4444, 0x4444, 0 };
1978  static WCHAR tmp5[] = { 0x2020, 0xbcde, 0x4041, 0x4444, 0x4444, 0 };
1979  static WCHAR tmp6 [] = { 0x20, 0xbcde, 0x4041, 0x4444, 0x4444, 0x4444, 0};
1980  static WCHAR tmp7 [] = { 0xbcde, 0x4041, 0x4444, 0x4444, 0x4444, 0x4444, 0x4444, 0x4444, 0x4444, 0};
1981  static WCHAR tmp8 [] = { 0xbc00, 0x4041, 0x4444, 0x4444, 0x4444, 0x4444, 0x4444, 0x4444, 0x4444, 0};
1982 #endif
1983 
1984 #if 0
1985  /* This crashes. */
1986  pSdbMakeIndexKeyFromString(NULL);
1987 #endif
1988 
1989  expect_indexA("", 0x0000000000000000);
1990  expect_indexA("a", 0x4100000000000000);
1991  expect_indexA("aa", 0x4141000000000000);
1992  expect_indexA("aaa", 0x4141410000000000);
1993  expect_indexA("aaaa", 0x4141414100000000);
1994  expect_indexA("aaaaa", 0x4141414141000000);
1995  expect_indexA("aaaaaa", 0x4141414141410000);
1996  expect_indexA("aaaaaaa", 0x4141414141414100);
1997  expect_indexA("aaaaaaaa", 0x4141414141414141);
1998  expect_indexA("aaa aaaaa", 0x4141412041414141);
1999  /* Does not change */
2000  expect_indexA("aaaaaaaaa", 0x4141414141414141);
2001  expect_indexA("aaaaaaaab", 0x4141414141414141);
2002  expect_indexA("aaaaaaaac", 0x4141414141414141);
2003  expect_indexA("aaaaaaaaF", 0x4141414141414141);
2004  /* Upcase */
2005  expect_indexA("AAAAAAAA", 0x4141414141414141);
2006  expect_indexA("ABABABAB", 0x4142414241424142);
2007  expect_indexA("ABABABABZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ", 0x4142414241424142);
2008 
2009 #if 0
2010  /* These fail, but is that because the codepoints are too weird, or because the func is not correct? */
2011  result = pSdbMakeIndexKeyFromString(tmp);
2012  ok(result == 0xbaabdebc20200000, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp),
2013  wine_dbgstr_longlong(0xbaabdebc20200000), wine_dbgstr_longlong(result));
2014 
2015  result = pSdbMakeIndexKeyFromString(tmp2);
2016  ok(result == 0xbaabdebc00000000, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp2),
2017  wine_dbgstr_longlong(0xbaabdebc00000000), wine_dbgstr_longlong(result));
2018 
2019  result = pSdbMakeIndexKeyFromString(tmp3);
2020  ok(result == 0x20debc4140000000, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp3),
2021  wine_dbgstr_longlong(0x20debc4140000000), wine_dbgstr_longlong(result));
2022 
2023  result = pSdbMakeIndexKeyFromString(tmp4);
2024  ok(result == 0x20debc4140000000, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp4),
2025  wine_dbgstr_longlong(0x20debc4140000000), wine_dbgstr_longlong(result));
2026 
2027  result = pSdbMakeIndexKeyFromString(tmp5);
2028  ok(result == 0x2020debc41400000, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp5),
2029  wine_dbgstr_longlong(0x2020debc41400000), wine_dbgstr_longlong(result));
2030 
2031  result = pSdbMakeIndexKeyFromString(tmp6);
2032  ok(result == 0x20debc4140444400, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp6),
2033  wine_dbgstr_longlong(0x20debc4140444400), wine_dbgstr_longlong(result));
2034 
2035  result = pSdbMakeIndexKeyFromString(tmp7);
2036  ok(result == 0xdebc414044444444, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp7),
2037  wine_dbgstr_longlong(0xdebc414044444444), wine_dbgstr_longlong(result));
2038 
2039  result = pSdbMakeIndexKeyFromString(tmp8);
2040  ok(result == 0xbc414044444444, "Expected %s to result in %s, was: %s\n", wine_dbgstr_w(tmp8),
2041  wine_dbgstr_longlong(0xbc414044444444), wine_dbgstr_longlong(result));
2042 #endif
2043 }
2044 
2046 {
2047  unsigned char buffer[SDBQUERYRESULT_EXPECTED_SIZE_VISTA * 2];
2048  WCHAR path[MAX_PATH];
2049  size_t n;
2050 
2051  memset(buffer, 0xab, sizeof(buffer));
2052 
2054  pSdbGetMatchingExe(NULL, path, NULL, NULL, 0, (SDBQUERYRESULT_VISTA*)buffer);
2055  if (buffer[0] == 0xab)
2056  {
2057  trace("SdbGetMatchingExe didnt do anything, cannot determine SDBQUERYRESULT size\n");
2058  return 0;
2059  }
2060 
2062  {
2063  return 1;
2064  }
2065 
2067  {
2068  return 2;
2069  }
2070 
2071  for (n = 0; n < _countof(buffer); ++n)
2072  {
2073  if (buffer[n] != 0xab)
2074  {
2075  trace("Unknown size: %i\n", n);
2076  break;
2077  }
2078  }
2079 
2080  return 0;
2081 }
2082 
2083 
2085 {
2086  //SetEnvironmentVariableA("SHIM_DEBUG_LEVEL", "4");
2087  //SetEnvironmentVariableA("SHIMENG_DEBUG_LEVEL", "4");
2088  //SetEnvironmentVariableA("DEBUGCHANNEL", "+apphelp");
2089 
2091  hdll = LoadLibraryA("apphelp.dll");
2092 
2093  /* We detect the apphelp version that is loaded, instead of the os we are running on.
2094  This allows for easier testing multiple versions of the dll */
2096  trace("Apphelp version: 0x%x\n", g_WinVersion);
2097 
2098  *(void**)&pSdbTagToString = (void *)GetProcAddress(hdll, "SdbTagToString");
2099  *(void**)&pSdbOpenDatabase = (void *)GetProcAddress(hdll, "SdbOpenDatabase");
2100  *(void**)&pSdbCreateDatabase = (void *)GetProcAddress(hdll, "SdbCreateDatabase");
2101  *(void**)&pSdbGetDatabaseVersion = (void *)GetProcAddress(hdll, "SdbGetDatabaseVersion");
2102  *(void**)&pSdbCloseDatabase = (void *)GetProcAddress(hdll, "SdbCloseDatabase");
2103  *(void**)&pSdbCloseDatabaseWrite = (void *)GetProcAddress(hdll, "SdbCloseDatabaseWrite");
2104  *(void**)&pSdbGetTagFromTagID = (void *)GetProcAddress(hdll, "SdbGetTagFromTagID");
2105  *(void**)&pSdbWriteNULLTag = (void *)GetProcAddress(hdll, "SdbWriteNULLTag");
2106  *(void**)&pSdbWriteWORDTag = (void *)GetProcAddress(hdll, "SdbWriteWORDTag");
2107  *(void**)&pSdbWriteDWORDTag = (void *)GetProcAddress(hdll, "SdbWriteDWORDTag");
2108  *(void**)&pSdbWriteQWORDTag = (void *)GetProcAddress(hdll, "SdbWriteQWORDTag");
2109  *(void**)&pSdbWriteBinaryTagFromFile = (void *)GetProcAddress(hdll, "SdbWriteBinaryTagFromFile");
2110  *(void**)&pSdbWriteStringTag = (void *)GetProcAddress(hdll, "SdbWriteStringTag");
2111  *(void**)&pSdbWriteStringRefTag = (void *)GetProcAddress(hdll, "SdbWriteStringRefTag");
2112  *(void**)&pSdbBeginWriteListTag = (void *)GetProcAddress(hdll, "SdbBeginWriteListTag");
2113  *(void**)&pSdbEndWriteListTag = (void *)GetProcAddress(hdll, "SdbEndWriteListTag");
2114  *(void**)&pSdbFindFirstTag = (void *)GetProcAddress(hdll, "SdbFindFirstTag");
2115  *(void**)&pSdbFindNextTag = (void *)GetProcAddress(hdll, "SdbFindNextTag");
2116  *(void**)&pSdbFindFirstNamedTag = (void *)GetProcAddress(hdll, "SdbFindFirstNamedTag");
2117  *(void**)&pSdbReadWORDTag = (void *)GetProcAddress(hdll, "SdbReadWORDTag");
2118  *(void**)&pSdbReadDWORDTag = (void *)GetProcAddress(hdll, "SdbReadDWORDTag");
2119  *(void**)&pSdbReadQWORDTag = (void *)GetProcAddress(hdll, "SdbReadQWORDTag");
2120  *(void**)&pSdbReadBinaryTag = (void *)GetProcAddress(hdll, "SdbReadBinaryTag");
2121  *(void**)&pSdbReadStringTag = (void *)GetProcAddress(hdll, "SdbReadStringTag");
2122  *(void**)&pSdbGetTagDataSize = (void *)GetProcAddress(hdll, "SdbGetTagDataSize");
2123  *(void**)&pSdbGetBinaryTagData = (void *)GetProcAddress(hdll, "SdbGetBinaryTagData");
2124  *(void**)&pSdbGetStringTagPtr = (void *)GetProcAddress(hdll, "SdbGetStringTagPtr");
2125  *(void**)&pSdbGetFirstChild = (void *)GetProcAddress(hdll, "SdbGetFirstChild");
2126  *(void**)&pSdbGetNextChild = (void *)GetProcAddress(hdll, "SdbGetNextChild");
2127  *(void**)&pSdbGetDatabaseID = (void *)GetProcAddress(hdll, "SdbGetDatabaseID");
2128  *(void**)&pSdbGUIDToString = (void *)GetProcAddress(hdll, "SdbGUIDToString");
2129  *(void**)&pSdbInitDatabase = (void *)GetProcAddress(hdll, "SdbInitDatabase");
2130  *(void**)&pSdbReleaseDatabase = (void *)GetProcAddress(hdll, "SdbReleaseDatabase");
2131  *(void**)&pSdbGetMatchingExe = (void *)GetProcAddress(hdll, "SdbGetMatchingExe");
2132  *(void**)&pSdbTagRefToTagID = (void *)GetProcAddress(hdll, "SdbTagRefToTagID");
2133  *(void**)&pSdbTagIDToTagRef = (void *)GetProcAddress(hdll, "SdbTagIDToTagRef");
2134  *(void**)&pSdbMakeIndexKeyFromString = (void *)GetProcAddress(hdll, "SdbMakeIndexKeyFromString");
2135  *(void**)&pSdbQueryData = (void *)GetProcAddress(hdll, "SdbQueryData");
2136  *(void**)&pSdbQueryDataEx = (void *)GetProcAddress(hdll, "SdbQueryDataEx");
2137  *(void**)&pSdbQueryDataExTagID = (void *)GetProcAddress(hdll, "SdbQueryDataExTagID");
2138  *(void**)&pSdbGetLayerTagRef = (void *)GetProcAddress(hdll, "SdbGetLayerTagRef");
2139  *(void**)&pSdbGetDatabaseInformation = (void *)GetProcAddress(hdll, "SdbGetDatabaseInformation");
2140  *(void**)&pSdbFreeDatabaseInformation = (void *)GetProcAddress(hdll, "SdbFreeDatabaseInformation");
2141 
2142  test_Sdb();
2143  test_write_ex();
2144  test_stringtable();
2146  switch (validate_SDBQUERYRESULT_size())
2147  {
2148  case 1:
2149  test_MatchApplications<SDBQUERYRESULT_2k3>();
2150  test_MatchApplicationsEx<SDBQUERYRESULT_2k3>();
2151  break;
2152  case 2:
2153  test_MatchApplications<SDBQUERYRESULT_VISTA>();
2154  test_MatchApplicationsEx<SDBQUERYRESULT_VISTA>();
2155  break;
2156  default:
2157  skip("Skipping tests with SDBQUERYRESULT due to a wrong size reported\n");
2158  break;
2159  }
2160  test_TagRef();
2161  test_Data();
2162  skip("test_SecondaryDB()\n");
2164 }
struct _DB_INFORMATION * PDB_INFORMATION
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
static void test_IndexKeyFromString(void)
Definition: db.cpp:1971
#define TAG_BIN_FILE_VERSION
Definition: db.cpp:77
#define TAG_INTERNAL_NAME
Definition: db.cpp:108
DWORD TAGREF
Definition: bug.cpp:7
static const WCHAR path2[]
Definition: path.c:29
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:609
static TAGREF PDB * ppdb
Definition: db.cpp:169
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
struct _DB_INFORMATION DB_INFORMATION
#define TAG_HTMLHELPID
Definition: db.cpp:65
#define TAG_OS_PLATFORM
Definition: db.cpp:74
#define TAG_UPTO_BIN_PRODUCT_VERSION
Definition: db.cpp:79
static LPCWSTR layerName
Definition: db.cpp:171
#define TRUE
Definition: types.h:120
const char * tags[7 *8]
Definition: apphelp.c:214
#define CloseHandle
Definition: compat.h:398
#define TAG_INCLUDE
Definition: db.cpp:54
static PDB pdb
Definition: db.cpp:170
#define TAG_PE_CHECKSUM
Definition: db.cpp:63
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TAG_LINK
Definition: db.cpp:90
#define TAG_MODULE_TYPE
Definition: db.cpp:60
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ok_str(x, y)
Definition: atltest.h:127
#define test_create_db
#define WideCharToMultiByte
Definition: compat.h:101
#define SDBQUERYRESULT_EXPECTED_SIZE_VISTA
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
#define TAG_CHECKSUM
Definition: db.cpp:59
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
static TAGID
Definition: db.cpp:141
static LPCWSTR LPCWSTR module_name
Definition: db.cpp:168
#define TAG_LAYER_TAGID
Definition: db.cpp:67
static void expect_indexA_imp(const char *text, LONGLONG expected)
Definition: db.cpp:1959
void test3(void)
Definition: hivetest.c:423
#define TAG_EXE_ID
Definition: db.cpp:118
#define expect_indexA
Definition: db.cpp:1969
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
static const WCHAR empty[]
Definition: main.c:49
static void check_matching_apphelp(PDB pdb, TAGID apphelp, int num)
Definition: db.cpp:796
const WCHAR * text
Definition: package.c:1827
#define CP_ACP
Definition: compat.h:99
#define _countof(array)
Definition: fontsub.cpp:30
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define TAG_DATABASE
Definition: db.cpp:83
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define TAG_GENERAL
Definition: db.cpp:116
#define TAG_PRODUCT_NAME
Definition: db.cpp:103
#define free
Definition: debug_ros.c:5
static bool extract_resource(const WCHAR *Filename, LPCWSTR ResourceName)
Definition: db.cpp:1459
const WCHAR * app_name
Definition: db.cpp:862
const WCHAR * apphelp_details
Definition: db.cpp:990
static void check_db_exes(PDB pdb, TAGID root)
Definition: db.cpp:940
static PDB TAGID tiWhich
Definition: db.cpp:170
static void check_db_properties(PDB pdb, TAGID root)
Definition: db.cpp:665
static TAGREF(WINAPI *pSdbGetLayerTagRef)(HSDB hsdb
GLdouble n
Definition: glext.h:7729
static CHAR AppName[MAX_PATH]
Definition: dem.c:252
const char * wine_dbgstr_guid(const GUID *guid)
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
LPCWSTR Description
Definition: apphelp.h:83
static LONGLONG(WINAPI *pSdbMakeIndexKeyFromString)(LPCWSTR)
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
Definition: ecma_167.h:138
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
#define TAG_COMMAND_LINE
Definition: db.cpp:100
GLuint buffer
Definition: glext.h:5915
DWORD get_module_version(HMODULE mod)
Definition: data.c:803
#define TAG_BIN_PRODUCT_VERSION
Definition: db.cpp:78
static PBYTE
Definition: db.cpp:157
DEFINE_GUID(GUID_DATABASE_TEST, 0xe39b0eb0, 0x55db, 0x450b, 0x9b, 0xd4, 0xd2, 0x0c, 0x94, 0x84, 0x26, 0x0f)
DWORD dwSomething
Definition: db.cpp:125
BOOL WINAPI CheckTokenMembership(IN HANDLE ExistingTokenHandle, IN PSID SidToCheck, OUT PBOOL IsMember)
Definition: token.c:21
static TAG
Definition: db.cpp:142
#define TAG_APP_NAME
Definition: db.cpp:99
static void match_strw_attr_imp(PDB pdb, TAGID parent, TAG find, const WCHAR *compare)
Definition: db.cpp:606
static void test_TagRef(void)
Definition: db.cpp:1595
uint16_t * PWCHAR
Definition: typedefs.h:54
DWORD dwMajor
Definition: apphelp.h:81
DWORD adwExeFlags_0
Definition: db.cpp:868
static struct @1548 test_exedata[5]
#define lstrlenW
Definition: compat.h:407
static void check_adwExeFlags(DWORD adwExeFlags_0, SDBQUERYRESULT_T &query, const char *file, int line, size_t cur)
Definition: db.cpp:1206
const char * env_var
Definition: db.cpp:871
static void check_matching_layer(PDB pdb, TAGID layer, int num)
Definition: db.cpp:844
#define ok_hex(expression, result)
Definition: atltest.h:94
static HWND child
Definition: cursoricon.c:298
#define TAG_MATCHING_FILE
Definition: db.cpp:86
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
#define TAG_UPTO_LINK_DATE
Definition: db.cpp:70
struct TraceInfo Info
#define HID_DATABASE_FULLPATH
Definition: db.cpp:31
IN PVCB IN PBCB OUT PDIRENT IN USHORT IN POEM_STRING Filename
Definition: fatprocs.h:925
#define TAG_VENDOR
Definition: db.cpp:98
#define match_qw_attr
Definition: db.cpp:658
#define TAG_LINK_URL
Definition: db.cpp:111
Definition: apphelp.h:27
_SEH2_TRY
Definition: create.c:4250
static void write_db_strings(const WCHAR *name, const WCHAR *data[], size_t count)
Definition: db.cpp:508
#define TAG_LINKER_VERSION
Definition: db.cpp:68
#define TAG_ORIGINAL_FILENAME
Definition: db.cpp:107
#define UnlockResource(h)
Definition: winbase.h:3189
static struct @1549 test_layerdata[2]
#define TAG_SIZE
Definition: db.cpp:58
#define TAG_EXE
Definition: db.cpp:85
const WCHAR * apphelp_title
Definition: db.cpp:989
static TAGID TAGID TAGID nametag
Definition: db.cpp:153
#define TAG_INEXCLUD
Definition: db.cpp:84
DWORD htmlhelpid
Definition: db.cpp:987
static GUID guid2
Definition: devinst.c:42
const GUID * guid
static BOOL IsUserAdmin()
Definition: db.cpp:1183
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
static TAGREF PDB TAGID * ptiWhich
Definition: db.cpp:169
#define TAG_MODULE
Definition: db.cpp:97
static void check_matching_file(PDB pdb, TAGID exe, TAGID matching_file, int num)
Definition: db.cpp:729
DWORD WINAPI GetTempPathW(IN DWORD count, OUT LPWSTR path)
Definition: path.c:2079
static PDB TAGID TAGREF * ptrWhich
Definition: db.cpp:170
#define TAG_STRINGTABLE
Definition: db.cpp:92
static TAGREF trWhich
Definition: db.cpp:169
unsigned int BOOL
Definition: ntddk_ex.h:94
PVOID WINAPI FreeSid(PSID pSid)
Definition: security.c:577
#define _TAGID_ROOT
Definition: db.cpp:38
#define WINVER_WIN10
#define GENERIC_WRITE
Definition: nt_native.h:90
static GUID *static PCWSTR
Definition: db.cpp:165
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static void test_is_testdb(PDB pdb)
Definition: db.cpp:1168
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
static PVOID ptr
Definition: dispmode.c:27
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
#define TAG_APPHELP_DETAILS
Definition: db.cpp:110
static void check_db_layer(PDB pdb, TAGID layer)
Definition: db.cpp:695
DWORD dwLayerCount
Definition: db.cpp:866
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
static WORD
Definition: db.cpp:143
static void Write(HANDLE file, LPCVOID buffer, DWORD size)
Definition: db.cpp:183
smooth NULL
Definition: ftsmooth.c:416
#define ok_int(expression, result)
Definition: atltest.h:134
static PATH_TYPE
Definition: db.cpp:136
#define TAG_FLAG_LUA
Definition: db.cpp:81
#define TAG_PROBLEMSEVERITY
Definition: db.cpp:64
static LPWSTR
Definition: db.cpp:158
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
static LPCWSTR LPCWSTR LPCWSTR DWORD flags
Definition: db.cpp:168
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
Definition: parser.c:48
Definition: bufpool.h:45
static BOOL(WINAPI *pSdbGetDatabaseVersion)(LPCWSTR
GLuint index
Definition: glext.h:6031
static void test_GetDatabaseInformationEmpty(PDB pdb)
Definition: db.cpp:189
static LPWSTR exenameW
Definition: FindFiles.c:27
BOOL WINAPI RemoveDirectoryW(IN LPCWSTR lpPathName)
Definition: dir.c:732
static TAGREF LPCWSTR LPDWORD LPVOID LPDWORD TAGREF * ptrData
Definition: db.cpp:174
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:526
const WCHAR * extra_file
Definition: db.cpp:865
#define TAG_LINK_DATE
Definition: db.cpp:69
static PDWORD
Definition: db.cpp:138
static DWORD g_WinVersion
GLuint GLfloat * val
Definition: glext.h:7180
static void test_MatchApplications(void)
Definition: db.cpp:1400
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static const WCHAR path1[]
Definition: path.c:28
#define match_strw_attr
Definition: db.cpp:656
START_TEST(db)
Definition: db.cpp:2084
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
int64_t LONGLONG
Definition: typedefs.h:66
_In_ HANDLE Handle
Definition: extypes.h:390
#define TAG_FILE_DESCRIPTION
Definition: db.cpp:105
static WCHAR no[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2340
GLsizeiptr size
Definition: glext.h:5919
static char tmpdir[MAX_PATH]
Definition: shlexec.c:59
static HSDB(WINAPI *pSdbInitDatabase)(DWORD
#define trace
Definition: atltest.h:70
#define SECURITY_BUILTIN_DOMAIN_RID
Definition: setypes.h:553
static TAGID TAGID TAGID LPCWSTR find_name
Definition: db.cpp:153
r parent
Definition: btrfs.c:2897
__wchar_t WCHAR
Definition: xmlstorage.h:180
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
Definition: environ.c:218
UINT64 QWORD
Definition: shimdbg.c:104
const WCHAR * vendor
Definition: db.cpp:863
static char workdir[MAX_PATH]
Definition: batch.c:26
static TAGREF LPCWSTR lpszDataName
Definition: db.cpp:173
TAGREF trApphelp
Definition: db.cpp:870
#define DOS_PATH
Definition: db.cpp:30
#define TAG_APP_NAME_RC_ID
Definition: db.cpp:71
#define TAG_DATA_BITS
Definition: db.cpp:119
#define MAX_PATH
Definition: compat.h:26
#define swprintf(buf, format,...)
Definition: sprintf.c:56
void test1(void)
Definition: hivetest.c:366
#define WINAPI
Definition: msvc.h:8
const char file[]
Definition: icontest.c:11
#define TAG_VERFILEOS
Definition: db.cpp:61
unsigned short WORD
Definition: ntddk_ex.h:93
static TAGREF LPCWSTR LPDWORD LPVOID LPDWORD lpcbBufferSize
Definition: db.cpp:173
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static void match_guid_attr_imp(PDB pdb, TAGID parent, TAG find, const GUID *compare)
Definition: db.cpp:643
Definition: cookie.c:170
#define OPEN_ALWAYS
Definition: disk.h:70
const GLuint GLenum const GLvoid * binary
Definition: glext.h:7538
#define TAG_VENDOR_NAME_RC_ID
Definition: db.cpp:72
#define SDBQUERYRESULT_EXPECTED_SIZE_2k3
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static void match_dw_attr_imp(PDB pdb, TAGID parent, TAG find, DWORD compare)
Definition: db.cpp:621
#define RT_RCDATA
Definition: pedump.c:372
#define TAG_DATA
Definition: db.cpp:91
static BOOL write_raw_file(const WCHAR *FileName, const void *Data, DWORD Size)
Definition: db.cpp:1441
static PVOID(WINAPI *pSdbGetBinaryTagData)(PDB
#define TAG_FLAGS
Definition: db.cpp:66
int ret
#define WINVER_WIN7
static void check_db_apphelp(PDB pdb, TAGID root)
Definition: db.cpp:1006
static void test_write_ex(void)
Definition: db.cpp:398
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
static const WCHAR L[]
Definition: oid.c:1250
void silence_debug_output(void)
Definition: data.c:833
#define TAG_SHIM_REF
Definition: db.cpp:87
#define test_create_exe
#define ok_wstr(x, y)
Definition: atltest.h:130
unsigned char BYTE
Definition: mem.h:68
#define GUID_NULL
Definition: ks.h:106
static LPCWSTR path
Definition: db.cpp:168
#define TAG_STRINGTABLE_ITEM
Definition: db.cpp:94
static void test_Sdb(void)
Definition: db.cpp:237
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
static void test_Data(void)
Definition: db.cpp:1915
#define WINVER_WIN8
static void test_DataTags(HSDB hsdb)
Definition: db.cpp:1736
#define wcsicmp
Definition: string.h:1152
#define TAG_SUMMARY_MSG_RC_ID
Definition: db.cpp:73
static int validate_SDBQUERYRESULT_size()
Definition: db.cpp:2045
static VOID(WINAPI *pSdbFreeDatabaseInformation)(PDB_INFORMATION information)
char string[160]
Definition: util.h:11
static void test_GetDatabaseInformation(PDB pdb)
Definition: db.cpp:1031
static TAGID tiExe
Definition: db.cpp:175
#define TAGID_NULL
Definition: db.cpp:36
#define TAG_COMPANY_NAME
Definition: db.cpp:101
#define TAG_APPHELP_TITLE
Definition: db.cpp:112
void test2(void)
Definition: regtest.c:173
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define CREATE_ALWAYS
Definition: disk.h:72
_SEH2_END
Definition: create.c:4424
#define WINVER_VISTA
GLuint in
Definition: glext.h:9616
static void test_match_ex(const WCHAR *workdir, HSDB hsdb)
Definition: db.cpp:1481
static TAGREF LPCWSTR LPDWORD lpdwDataType
Definition: db.cpp:173
TAGREF atrLayers_0
Definition: db.cpp:869
static calc_node_t temp
Definition: rpn_ieee.c:38
TAGREF atrExes_0
Definition: db.cpp:867
static GUID *static SIZE_T
Definition: db.cpp:165
static DWORD
Definition: db.cpp:144
DWORD dwMinor
Definition: apphelp.h:82
#define ok(value,...)
Definition: atltest.h:57
Definition: services.c:325
#define TAG_LAYER
Definition: db.cpp:88
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define TAG_NAME
Definition: db.cpp:96
#define test_create_file
#define TAG_TIME
Definition: db.cpp:76
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
#define TAGID_ROOT
Definition: db.cpp:37
#define ERROR_NOT_FOUND
Definition: winerror.h:690
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
Definition: fs_rec.h:142
#define TAG_UPTO_BIN_FILE_VERSION
Definition: db.cpp:80
#define TAG_APPHELP
Definition: db.cpp:89
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:168
const WCHAR * word
Definition: lex.c:78
#define MultiByteToWideChar
Definition: compat.h:100
#define TAG_COMPILER_VERSION
Definition: db.cpp:114
static void(WINAPI *pSdbCloseDatabase)(PDB)
#define CreateFileW
Definition: compat.h:400
#define skip(...)
Definition: atltest.h:64
static TAGID TAGID find
Definition: db.cpp:153
CONST void * LPCVOID
Definition: windef.h:191
#define TAG_VERFILETYPE
Definition: db.cpp:62
Definition: name.c:36
static PDB(WINAPI *pSdbOpenDatabase)(LPCWSTR
uint32_t * LPDWORD
Definition: typedefs.h:57
static PDB_INFORMATION information
Definition: db.cpp:176
#define REG_QWORD
Definition: sdbapi.c:597
static LPCWSTR LPCWSTR LPCWSTR DWORD PSDBQUERYRESULT_VISTA result
Definition: db.cpp:168
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:847
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
static TAGID LPCWSTR LPDWORD LPVOID LPDWORD TAGID * ptiData
Definition: db.cpp:175
#define TAG_DATABASE_ID
Definition: db.cpp:120
#define GetProcAddress(x, y)
Definition: compat.h:410
#define malloc
Definition: debug_ros.c:4
static void test_MatchApplicationsEx(void)
Definition: db.cpp:1548
#define TAG_NULL
Definition: db.cpp:52
static void test_mode_generic(const WCHAR *workdir, HSDB hsdb, size_t cur)
Definition: db.cpp:1220
#define match_guid_attr
Definition: db.cpp:659
const WCHAR * link
Definition: db.cpp:988
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
static HMODULE hdll
Definition: db.cpp:134
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
const WCHAR * name
Definition: db.cpp:861
static QWORD
Definition: db.cpp:145
DWORD TAGID
WCHAR * LPWSTR
Definition: xmlstorage.h:184
void test5(void)
Definition: hivetest.c:623
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define match_dw_attr
Definition: db.cpp:657
static char * exename
Definition: process.c:101
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
GLuint64EXT * result
Definition: glext.h:11304
#define memset(x, y, z)
Definition: compat.h:39
#define REG_DWORD
Definition: sdbapi.c:596
static void test_stringtable()
Definition: db.cpp:524
#define DOMAIN_ALIAS_RID_ADMINS
Definition: setypes.h:624
#define TAG_MATCH_MODE
Definition: db.cpp:56
static LPCWSTR
Definition: db.cpp:146
BYTE * PBYTE
Definition: pedump.c:66
GLenum query
Definition: glext.h:7781
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define CONST
Definition: pedump.c:81
#define TAG_PRODUCT_VERSION
Definition: db.cpp:104
#define TAG_LEGAL_COPYRIGHT
Definition: db.cpp:109
static TAGID root
Definition: db.cpp:153
DWORD test_get_db_size()
Definition: data.c:765
static void match_qw_attr_imp(PDB pdb, TAGID parent, TAG find, QWORD compare)
Definition: db.cpp:632
#define TAG_FILE_VERSION
Definition: db.cpp:106
static void test_CheckDatabaseManually(void)
Definition: db.cpp:1088
BOOL expected
Definition: store.c:2063
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
GUID exe_id
Definition: db.cpp:864
SID_IDENTIFIER_AUTHORITY NtAuthority
Definition: database.c:19
void test4(void)
Definition: hivetest.c:461
BOOL WINAPI AllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority, BYTE nSubAuthorityCount, DWORD nSubAuthority0, DWORD nSubAuthority1, DWORD nSubAuthority2, DWORD nSubAuthority3, DWORD nSubAuthority4, DWORD nSubAuthority5, DWORD nSubAuthority6, DWORD nSubAuthority7, PSID *pSid)
Definition: security.c:553
#define ok_(x1, x2)
Definition: atltest.h:61
Definition: fci.c:126
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22
char * tag
Definition: main.c:59