ReactOS 0.4.16-dev-1457-g02ea0aa
env.c
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 showing shim artifacts in the environment
5 * COPYRIGHT: Copyright 2016,2017 Mark Jansen (mark.jansen@reactos.org)
6 */
7
8#include <ntstatus.h>
9#define WIN32_NO_STATUS
10#include <windows.h>
11#include <shlwapi.h>
12#include <winnt.h>
13#include <userenv.h>
14#ifdef __REACTOS__
15#include <ntndk.h>
16#else
17#include <winternl.h>
18#endif
19#include <winerror.h>
20#include <stdio.h>
21
22#include "wine/test.h"
23
24#include <pseh/pseh2.h>
25
26#include "apphelp_apitest.h"
27
28typedef void* HSDB;
29typedef void* PDB;
30typedef DWORD TAGREF;
31typedef WORD TAG;
32
33
34
36
39void (WINAPI *pSdbReleaseDatabase)(HSDB hsdb);
40BOOL (WINAPI *pSdbTagRefToTagID)(HSDB hsdb, TAGREF trWhich, PDB* ppdb, TAGID* ptiWhich);
41TAG (WINAPI *pSdbGetTagFromTagID)(PDB pdb, TAGID tiWhich);
42TAGREF (WINAPI *pSdbGetLayerTagRef)(HSDB hsdb, LPCWSTR layerName);
43
44
45/* TODO: Investigate ApphelpCheckRunApp, for some reason there is not AppCompatData generated... */
46
50
54
55
58DWORD (WINAPI *pSdbGetAppCompatDataSize)(PVOID pData);
59
60
64static const SDBQUERYRESULT_VISTA empty_result = { { 0 } };
65static const SDBQUERYRESULT_VISTA almost_empty = { { 0 }, { 0 }, { 0 }, 0, 0, 0, 0, { 0 }, SHIMREG_DISABLE_LAYER, 0 };
66
67
68#define SHIMDATA_MAGIC 0xAC0DEDAB
69#define MAX_LAYER_LENGTH 256
70
71
72typedef struct ShimData_Win2k3
73{
77
85
86typedef struct ShimData_WinVista
87{
93
94typedef struct ShimData_Win7
95{
101 DWORD unknown; // 0x14c
103
104typedef struct ShimData_Win8
105{
112 char padding1[0x200];
113 char padding2[0x404];
119 char padding4[112];
121
122typedef struct ShimData_Win10_v1
123{
130 char padding1[0x200];
131 char padding2[0x404]; // Contains some data at the start
137 char padding4[120];
139
140typedef struct ShimData_Win10_v2
141{
148 char padding1[0x200];
149 char padding2[0x2ae + 0x54 + 0x2a + 0x16 + 0x16];
155 char padding4[76];
157
159{
162
163 char spacing1[60];
164
167
168 char spacing2[444];
169
173
174
175C_ASSERT(sizeof(ShimData_Win2k3) == 392);
177C_ASSERT(sizeof(ShimData_Win7) == 1500);
178C_ASSERT(sizeof(ShimData_Win8) == 4704);
181
186
191
195
199
200
201
202#define SDB_DATABASE_MAIN_SHIM 0x80030000
203
204#define SDBGMEF_IGNORE_ENVIRONMENT 0x1
205
206
208{
215
216
218{
219 SIZE_T dwRead;
220 if (ReadProcessMemory(proc, address, target, size, &dwRead))
221 {
222 ok(dwRead == size, "Expected to read %u bytes, got %lu\n", size, dwRead);
223 return dwRead == size;
224 }
225 ok(0, "RPM failed with %u\n", GetLastError());
226 return FALSE;
227}
228
230{
232 ULONG sizeOut = 0;
234 ok(NT_SUCCESS(status), "Expected NtQI to succeed, but failed with: %x\n", status);
235 memset(info, 0, sizeof(*info));
236 if (NT_SUCCESS(status))
237 {
238 PEB peb = { 0 };
239 if (readproc(proc, pbi.PebBaseAddress, &peb, sizeof(peb)))
240 {
241 MEMORY_BASIC_INFORMATION mbi = { 0 };
242 SIZE_T dwRead;
243
244 info->AppCompatFlags = peb.AppCompatFlags;
245 info->AppCompatFlagsUser = peb.AppCompatFlagsUser;
246 info->AppCompatInfo = peb.AppCompatInfo;
247 if (peb.pShimData == NULL)
248 return TRUE;
249
250 dwRead = VirtualQueryEx(proc, (LPCVOID)peb.pShimData, &mbi, sizeof(mbi));
251 ok(dwRead == sizeof(mbi), "Expected VQE to return %u, got %lu\n", sizeof(mbi), dwRead);
252 if (dwRead == sizeof(mbi) || peb.pShimData == NULL)
253 {
254 info->ShimDataSize = mbi.RegionSize;
255 info->pShimData = malloc(mbi.RegionSize);
256 if (readproc(proc, peb.pShimData, info->pShimData, mbi.RegionSize))
257 return TRUE;
258 free(info->pShimData);
259 info->pShimData = NULL;
260 }
261 }
262 }
263 return FALSE;
264}
265
266static HANDLE create_proc(BOOL suspended)
267{
268 static char proc_name[MAX_PATH] = { 0 };
269 STARTUPINFOA si = {sizeof(si)};
271 BOOL res;
272 if (!proc_name[0])
273 {
274 GetModuleFileNameA(NULL, proc_name, MAX_PATH);
275 }
276
277 res = CreateProcessA(NULL, proc_name, NULL, NULL, TRUE, suspended ? CREATE_SUSPENDED : 0, NULL, NULL, &si, &pi);
278 if (!res)
279 return NULL;
280 CloseHandle(pi.hThread);
281 return pi.hProcess;
282}
283
284static void create_environ(const char* layers[], size_t num)
285{
286 char buf[256] = { 0 };
287 size_t n;
288 for (n = 0; n < num; ++n)
289 {
290 if (n)
291 strcat(buf, " ");
292 strcat(buf, layers[n]);
293 }
294 SetEnvironmentVariableA("__COMPAT_LAYER", buf);
295}
296
297static void ValidateShim(TAGREF trLayer, const char* name)
298{
299 HSDB hsdb = pSdbInitDatabase(SDB_DATABASE_MAIN_SHIM, NULL);
300 ok(hsdb != NULL, "Expected a valid handle\n");
301 if (hsdb)
302 {
303 PDB pdb = NULL;
304 TAGID tagid = 0xdeadbeef;
305 WCHAR nameW[256] = { 0 };
306 BOOL ret;
307
309
310 ret = pSdbTagRefToTagID(hsdb, trLayer, &pdb, &tagid);
311 ok(ret == TRUE, "Expected pSdbTagRefToTagID to succeed\n");
312 if (ret)
313 {
314 TAG tag;
315 ok(pdb != NULL, "Expected pdb to be a valid pointer\n");
316 ok(tagid != 0 && tagid != 0xdeadbeef, "Expected tagid to be a valid tag id, was: 0x%x\n", tagid);
317 tag = pSdbGetTagFromTagID(pdb, tagid);
318 ok(tag == 0x700b, "Expected tag to be 0x700b, was 0x%x\n", (DWORD)tag);
319 }
320
321 pSdbReleaseDatabase(hsdb);
322 }
323}
324
325
326static void Validate_ShimData_Win2k3(PVOID data, size_t count, const char* layers[])
327{
328 //size_t n;
329 ShimData_Win2k3* pShimData = (ShimData_Win2k3*)data;
330
331 ok(!lstrcmpW(pShimData->szModule, L"ShimEng.dll"), "Expected pShimData->Module to be %s, was %s\n", wine_dbgstr_w(L"ShimEng.dll"), wine_dbgstr_w(pShimData->szModule));
332 ok(pShimData->dwMagic == SHIMDATA_MAGIC, "Expected pShimData->dwMagic to be 0x%x, was 0x%x\n", SHIMDATA_MAGIC, pShimData->dwMagic);
333 ok(pShimData->dwSize == sizeof(ShimData_Win2k3), "Expected pShimData->dwSize to be %u, was %u\n", sizeof(ShimData_Win2k3), pShimData->dwSize);
334 ok(pShimData->dwCustomSDBMap == 1, "Expected pShimData->dwCustomSDBMap to be 1, was %u\n", pShimData->dwCustomSDBMap);
335}
336
337static void Validate_ShimData_WinVista(PVOID data, size_t count, const char* layers[])
338{
339 size_t n;
341 WCHAR szShimEng[MAX_PATH];
342 HMODULE hShimEngDll = LoadLibraryA("ShimEng.dll");
343
344 GetModuleFileNameW(hShimEngDll, szShimEng, _countof(szShimEng));
345
346 ok(!lstrcmpW(pShimData->szModule, szShimEng), "Expected pShimData->Module to be %s, was %s\n",
347 wine_dbgstr_w(szShimEng), wine_dbgstr_w(pShimData->szModule));
348 ok(pShimData->dwMagic == SHIMDATA_MAGIC, "Expected pShimData->dwMagic to be 0x%x, was 0x%x\n",
349 SHIMDATA_MAGIC, pShimData->dwMagic);
350 ok(pShimData->dwSize == sizeof(ShimData_WinVista), "Expected pShimData->dwSize to be %u, was %u\n",
351 sizeof(ShimData_WinVista), pShimData->dwSize);
352 if (pShimData->Query.dwLayerCount != min(count, SDB_MAX_LAYERS))
353 {
354 char buf[250] = {0};
355 GetEnvironmentVariableA("__COMPAT_LAYER", buf, _countof(buf));
356 trace("At test: %s\n", buf);
357 }
359 "Expected LayerCount to be %u, was %u\n", min(count, SDB_MAX_LAYERS), pShimData->Query.dwLayerCount);
360 for (n = 0; n < SDB_MAX_LAYERS; ++n)
361 {
362 if (n < count)
363 {
364 ok(pShimData->Query.atrLayers[n] != 0, "Expected to find a valid layer in index %u / %u\n", n, count);
365 ValidateShim(pShimData->Query.atrLayers[n], layers[n]);
366 }
367 else
368 ok(pShimData->Query.atrLayers[n] == 0, "Expected to find an empty layer in index %u / %u\n", n, count);
369 }
370}
371
372static void Validate_ShimData_Win7(PVOID data, WCHAR szApphelp[256], size_t count, const char* layers[])
373{
374 size_t n;
375 ShimData_Win7* pShimData = (ShimData_Win7*)data;
376
377 ok(!lstrcmpW(pShimData->szModule, szApphelp), "Expected pShimData->Module to be %s, was %s\n",
378 wine_dbgstr_w(szApphelp), wine_dbgstr_w(pShimData->szModule));
379 ok(pShimData->dwMagic == SHIMDATA_MAGIC, "Expected pShimData->dwMagic to be 0x%x, was 0x%x\n",
380 SHIMDATA_MAGIC, pShimData->dwMagic);
381 ok(pShimData->dwSize == sizeof(ShimData_Win7), "Expected pShimData->dwSize to be %u, was %u\n",
382 sizeof(ShimData_Win7), pShimData->dwSize);
383 if (pShimData->Query.dwLayerCount != min(count, SDB_MAX_LAYERS))
384 {
385 char buf[250] = {0};
386 GetEnvironmentVariableA("__COMPAT_LAYER", buf, _countof(buf));
387 trace("At test: %s\n", buf);
388 }
390 "Expected LayerCount to be %u, was %u\n", min(count, SDB_MAX_LAYERS), pShimData->Query.dwLayerCount);
391 for (n = 0; n < SDB_MAX_LAYERS; ++n)
392 {
393 if (n < count)
394 {
395 ok(pShimData->Query.atrLayers[n] != 0, "Expected to find a valid layer in index %u / %u\n", n, count);
396 ValidateShim(pShimData->Query.atrLayers[n], layers[n]);
397 }
398 else
399 ok(pShimData->Query.atrLayers[n] == 0, "Expected to find an empty layer in index %u / %u\n", n, count);
400 }
401 ok(pShimData->unknown == 0x14c, "Expected pShimData->unknown to be 0x14c, was 0x%x\n", pShimData->unknown);
402}
403
404static void Validate_ShimData_Win8(PVOID data, WCHAR szApphelp[256], size_t count, const char* layers[])
405{
406 size_t n;
407 ShimData_Win8* pShimData = (ShimData_Win8*)data;
408
409 ok(!lstrcmpiW(pShimData->szModule, szApphelp), "Expected pShimData->Module to be %s, was %s\n",
410 wine_dbgstr_w(szApphelp), wine_dbgstr_w(pShimData->szModule));
411 ok(pShimData->dwSize == sizeof(ShimData_Win8), "Expected pShimData->dwSize to be %u, was %u\n",
412 sizeof(ShimData_Win8), pShimData->dwSize);
413 if (pShimData->Query.dwLayerCount != min(count, SDB_MAX_LAYERS))
414 {
415 char buf[250] = {0};
416 GetEnvironmentVariableA("__COMPAT_LAYER", buf, _countof(buf));
417 trace("At test: %s\n", buf);
418 }
420 "Expected LayerCount to be %u, was %u\n", min(count, SDB_MAX_LAYERS), pShimData->Query.dwLayerCount);
421 for (n = 0; n < SDB_MAX_LAYERS; ++n)
422 {
423 if (n < count)
424 {
425 ok(pShimData->Query.atrLayers[n] != 0, "Expected to find a valid layer in index %u / %u\n", n, count);
426 ValidateShim(pShimData->Query.atrLayers[n], layers[n]);
427 }
428 else
429 ok(pShimData->Query.atrLayers[n] == 0, "Expected to find an empty layer in index %u / %u\n", n, count);
430 }
431}
432
433static void Validate_ShimData_Win10_v2(PVOID data, WCHAR szApphelp[256], size_t count, const char* layers[])
434{
435 size_t n;
437
438 if (pShimData->dwMagic != SHIMDATA_MAGIC)
439 {
440 skip("Yet another unknown shimdata variant...\n");
441 return;
442 }
443
444 ok(pShimData->dwSize == sizeof(ShimData_Win10_v2), "Expected pShimData->dwSize to be %u, was %u\n",
445 sizeof(ShimData_Win10_v2), pShimData->dwSize);
446 if (pShimData->Query.dwLayerCount != min(count, SDB_MAX_LAYERS))
447 {
448 char buf[250] = {0};
449 GetEnvironmentVariableA("__COMPAT_LAYER", buf, _countof(buf));
450 trace("At test: %s\n", buf);
451 }
453 "Expected LayerCount to be %u, was %u\n", min(count, SDB_MAX_LAYERS), pShimData->Query.dwLayerCount);
454 for (n = 0; n < SDB_MAX_LAYERS; ++n)
455 {
456 if (n < count)
457 {
458 ok(pShimData->Query.atrLayers[n] != 0, "Expected to find a valid layer in index %u / %u\n", n, count);
459 ValidateShim(pShimData->Query.atrLayers[n], layers[n]);
460 }
461 else
462 ok(pShimData->Query.atrLayers[n] == 0, "Expected to find an empty layer in index %u / %u\n", n, count);
463 }
464
465}
466
467static void Validate_ShimData_Win10(PVOID data, WCHAR szApphelp[256], size_t count, const char* layers[])
468{
469 size_t n;
471
472 if (pShimData->dwMagic != SHIMDATA_MAGIC)
473 {
474 Validate_ShimData_Win10_v2(data, szApphelp, count, layers);
475 return;
476 }
477
478
479 ok(!lstrcmpiW(pShimData->szModule, szApphelp), "Expected pShimData->Module to be %s, was %s\n",
480 wine_dbgstr_w(szApphelp), wine_dbgstr_w(pShimData->szModule));
481 ok(pShimData->dwSize == sizeof(ShimData_Win10_v1), "Expected pShimData->dwSize to be %u, was %u\n",
482 sizeof(ShimData_Win10_v1), pShimData->dwSize);
483 if (pShimData->Query.dwLayerCount != min(count, SDB_MAX_LAYERS))
484 {
485 char buf[250] = {0};
486 GetEnvironmentVariableA("__COMPAT_LAYER", buf, _countof(buf));
487 trace("At test: %s\n", buf);
488 }
490 "Expected LayerCount to be %u, was %u\n", min(count, SDB_MAX_LAYERS), pShimData->Query.dwLayerCount);
491 for (n = 0; n < SDB_MAX_LAYERS; ++n)
492 {
493 if (n < count)
494 {
495 ok(pShimData->Query.atrLayers[n] != 0, "Expected to find a valid layer in index %u / %u\n", n, count);
496 ValidateShim(pShimData->Query.atrLayers[n], layers[n]);
497 }
498 else
499 ok(pShimData->Query.atrLayers[n] == 0, "Expected to find an empty layer in index %u / %u\n", n, count);
500 }
501}
502
504{
505 ShimData_Win8* pShimData = (ShimData_Win8*)data;
506 ok(pShimData != NULL, "Expected pShimData\n");
507 if (!pShimData)
508 return;
509
510 ok(!lstrcmpiW(pShimData->szModule, L""), "Expected pShimData->Module to be '', was %s\n", wine_dbgstr_w(pShimData->szModule));
511 ok(!lstrcmpiW(pShimData->szLayer, L""), "Expected pShimData->szLayer to be '', was %s\n", wine_dbgstr_w(pShimData->szLayer));
512 ok(pShimData->dwSize == sizeof(ShimData_Win8), "Expected pShimData->dwSize to be %u, was %u\n", sizeof(ShimData_Win8), pShimData->dwSize);
513 ok(!memcmp(&pShimData->Query, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
514}
515
517{
519 ok(pShimData != NULL, "Expected pShimData\n");
520 if (!pShimData)
521 return;
522
523 if (pShimData->dwMagic != SHIMDATA_MAGIC)
524 {
526 if (pShimData2->dwMagic != SHIMDATA_MAGIC)
527 {
528 skip("Unknown shimdata (win10)\n");
529 return;
530 }
531
532 ok(!lstrcmpiW(pShimData2->szLayer, L""), "Expected pShimData->szLayer to be '', was %s\n", wine_dbgstr_w(pShimData2->szLayer));
533 ok(pShimData2->dwSize == sizeof(ShimData_Win10_v2), "Expected pShimData->dwSize to be %u, was %u\n", sizeof(ShimData_Win10_v2), pShimData2->dwSize);
534 ok(!memcmp(&pShimData2->Query, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
535 }
536 else
537 {
538 ok(!lstrcmpiW(pShimData->szModule, L""), "Expected pShimData->Module to be '', was %s\n", wine_dbgstr_w(pShimData->szModule));
539 ok(!lstrcmpiW(pShimData->szLayer, L""), "Expected pShimData->szLayer to be '', was %s\n", wine_dbgstr_w(pShimData->szLayer));
540 ok(pShimData->dwSize == sizeof(ShimData_Win10_v1), "Expected pShimData->dwSize to be %u, was %u\n", sizeof(ShimData_Win10_v1), pShimData->dwSize);
541 ok(!memcmp(&pShimData->Query, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
542 }
543}
544
545static void Test_layers(WCHAR szApphelp[256])
546{
547 static const char* layers[] = {
548 "256Color", "NT4SP5", "DisableNXHideUI", "DisableNXShowUI",
549 "WIN2000SP3", "640X480", /*"DISABLEDWM",*/ "HIGHDPIAWARE",
550 /*"RUNASADMIN",*/ "DISABLETHEMES" /*, "Layer_Win95VersionLie"*/ };
551
552 size_t n;
553 HANDLE proc;
555 BOOL res;
556
557 for (n = 0; n <= (sizeof(layers) / sizeof(layers[0])); ++n)
558 {
559 create_environ(layers, n);
560
565
566 if (!res)
567 {
568 ok(0, "Unable to get process info (%u)!\n", n);
569 continue;
570 }
571
572 if (n == 0)
573 {
574 ok(info.AppCompatFlags.QuadPart == 0, "Expected AppCompatFlags to be 0, was: %s\n", wine_dbgstr_longlong(info.AppCompatFlags.QuadPart));
575 ok(info.AppCompatFlagsUser.QuadPart == 0, "Expected AppCompatFlagsUser to be 0, was: %s\n", wine_dbgstr_longlong(info.AppCompatFlagsUser.QuadPart));
576 ok(info.AppCompatInfo == NULL, "Expected AppCompatInfo to be NULL, was: %p\n", info.AppCompatInfo);
578 {
579 ok(info.pShimData == NULL, "Expected pShimData to be NULL, was: %p\n", info.pShimData);
580 }
581 else if (g_WinVersion < WINVER_WIN10)
582 {
584 }
585 else
586 {
588 }
589 }
590 else
591 {
592 ok(info.AppCompatFlags.QuadPart == 0, "Expected AppCompatFlags to be 0, was: %s\n", wine_dbgstr_longlong(info.AppCompatFlags.QuadPart));
593 ok(info.AppCompatFlagsUser.QuadPart == 0, "Expected AppCompatFlagsUser to be 0, was: %s\n", wine_dbgstr_longlong(info.AppCompatFlagsUser.QuadPart));
594 ok(info.AppCompatInfo == NULL, "Expected AppCompatInfo to be NULL, was: %p\n", info.AppCompatInfo);
595 ok(info.pShimData != NULL, "Expected pShimData to be valid, was NULL\n");
596 ok(info.ShimDataSize == g_ShimDataSize, "Expected ShimDataSize to be %u, was: %u\n", g_ShimDataSize, info.ShimDataSize);
597 if (info.pShimData)
598 {
600 Validate_ShimData_Win2k3(info.pShimData, n, layers);
601 else if (g_WinVersion == WINVER_VISTA)
602 Validate_ShimData_WinVista(info.pShimData, n, layers);
603 else if (g_WinVersion < WINVER_WIN8)
604 Validate_ShimData_Win7(info.pShimData, szApphelp, n, layers);
605 else if (g_WinVersion < WINVER_WIN10)
606 Validate_ShimData_Win8(info.pShimData, szApphelp, n, layers);
607 else
608 Validate_ShimData_Win10(info.pShimData, szApphelp, n, layers);
609 }
610 }
611 free(info.pShimData);
612 }
613}
614
615
616/*
617[Warn][SdbGetMatchingExe ] __COMPAT_LAYER name cannot exceed 256 characters.
618[Info][SdbpGetPermLayersInternal] Failed to read value info from Key "\Registry\Machine\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" Status 0xc0000034
619[Info][SdbpGetPermLayersInternal] Failed to read value info from Key "\REGISTRY\USER\S-1-5-21-4051718696-421402927-393408651-2638\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" Status 0xc0000034
620[Warn][SdbpEnumUserSdb ] Failed to open key "\Registry\Machine\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Custom\NotepadReplacer.exe" Status 0xc0000034
621*/
622static void Test_repeatlayer(WCHAR szApphelp[256])
623{
624 static const char* layers[] = {
625 "256Color", "256Color", "256Color", "256Color",
626 "256Color", "256Color", "256Color", "256Color" };
627
628 HANDLE proc;
630 BOOL res;
631
632 SetEnvironmentVariableA("__COMPAT_LAYER", "256Color 256Color 256Color 256Color 256Color 256Color 256Color 256Color");
633
634
639
640 if (res)
641 {
642 ok(info.AppCompatFlags.QuadPart == 0, "Expected AppCompatFlags to be 0, was: %s\n", wine_dbgstr_longlong(info.AppCompatFlags.QuadPart));
643 ok(info.AppCompatFlagsUser.QuadPart == 0, "Expected AppCompatFlagsUser to be 0, was: %s\n", wine_dbgstr_longlong(info.AppCompatFlagsUser.QuadPart));
644 ok(info.AppCompatInfo == 0, "Expected AppCompatInfo to be 0, was: %p\n", info.AppCompatInfo);
645 ok(info.pShimData != NULL, "Expected pShimData to be valid, was NULL\n");
646 ok(info.ShimDataSize == g_ShimDataSize, "Expected ShimDataSize to be %u, was: %u\n", g_ShimDataSize, info.ShimDataSize);
647 if (info.pShimData)
648 {
649 /* Win10 only 'loads' one layer */
651 Validate_ShimData_Win2k3(info.pShimData, SDB_MAX_LAYERS, layers);
652 else if (g_WinVersion == WINVER_VISTA)
654 else if (g_WinVersion < WINVER_WIN8)
655 Validate_ShimData_Win7(info.pShimData, szApphelp, SDB_MAX_LAYERS, layers);
656 else if (g_WinVersion < WINVER_WIN10)
657 Validate_ShimData_Win8(info.pShimData, szApphelp, SDB_MAX_LAYERS, layers);
658 else
659 Validate_ShimData_Win10(info.pShimData, szApphelp, 1, layers);
660 }
661 }
662 else
663 {
664 ok(0, "Unable to get process info!\n");
665 }
666
667}
668
669
670TAGREF find_layer(const char* szLayerStart, const char* szLayerEnd)
671{
672 char layer[100] = { 0 };
673 WCHAR layerW[100] = { 0 };
674 strncpy(layer, szLayerStart, szLayerEnd - szLayerStart);
675
676 if (!g_LayerDB)
677 {
678 g_LayerDB = pSdbInitDatabase(SDB_DATABASE_MAIN_SHIM, 0);
679 }
680
681 mbstowcs(layerW, layer, strlen(layer));
682 return pSdbGetLayerTagRef(g_LayerDB, layerW);
683}
684
686{
687 DWORD dwLayerCount = 0, n;
688 TAGREF atrLayers[SDB_MAX_LAYERS] = { 0 };
689
690 const char* layer = layers, *nextlayer;
691 while (layer && *layer)
692 {
693 nextlayer = strchr(layer, ' ');
694 atrLayers[dwLayerCount++] = find_layer(layer, nextlayer ? nextlayer : (layer + strlen(layer)));
695 layer = nextlayer ? (nextlayer+1) : NULL;
696 }
697
699 {
701 result = NULL;
702
703 winetest_ok(!memcmp(&result2->atrExes, &empty_result.atrExes, sizeof(result2->atrExes)), "Expected atrExes to be empty\n");
704 winetest_ok(!memcmp(&result2->atrLayers[dwLayerCount], &empty_result.atrLayers[dwLayerCount], sizeof(result2->atrLayers) - dwLayerCount * sizeof(result2->atrLayers[0])), "Expected atrLayers[+1] to be empty\n");
705 for (n = 0; n < dwLayerCount; ++n)
706 {
707 winetest_ok(result2->atrLayers[n] == atrLayers[n], "Expected atrLayers[%u] to be %x, was %x\n",
708 n, atrLayers[n], result2->atrLayers[n]);
709 }
710 winetest_ok(result2->dwLayerFlags == 0, "Expected dwLayerFlags to be 0, was %u\n", result2->dwLayerFlags);
711 winetest_ok(result2->trApphelp == 0, "Expected trApphelp to be 0, was %u\n", result2->trApphelp);
712 winetest_ok(result2->dwExeCount == 0, "Expected dwExeCount to be 0, was %u\n", result2->dwExeCount);
713 winetest_ok(result2->dwLayerCount == dwLayerCount, "Expected dwLayerCount to be %u, was %u\n", dwLayerCount, result2->dwLayerCount);
714 winetest_ok(!memcmp(&result2->guidID, &empty_result.guidID, sizeof(result2->guidID)), "Expected guidID to be empty\n");
715 winetest_ok(result2->dwFlags == flags, "Expected dwFlags to be 0x%x, was 0x%x\n", flags, result2->dwFlags);
716 winetest_ok(result2->dwCustomSDBMap == 1, "Expected dwCustomSDBMap to be 1, was %u\n", result2->dwCustomSDBMap);
717 winetest_ok(!memcmp(&result2->rgGuidDB[1], &empty_result.rgGuidDB[1], sizeof(result2->rgGuidDB) - sizeof(result2->rgGuidDB[0])), "Expected rgGuidDB[+1] to be empty\n");
718 }
719 else
720 {
721 winetest_ok(!memcmp(&result->atrExes, &empty_result.atrExes, sizeof(empty_result.atrExes)), "Expected atrExes to be empty\n");
722 winetest_ok(!memcmp(&result->adwExeFlags, &empty_result.adwExeFlags, sizeof(empty_result.adwExeFlags)), "Expected adwExeFlags to be empty\n");
723 winetest_ok(!memcmp(&result->atrLayers[dwLayerCount], &empty_result.atrLayers[dwLayerCount], sizeof(empty_result.atrLayers) - dwLayerCount * sizeof(empty_result.atrLayers[0])), "Expected atrLayers[+1] to be empty\n");
724 for (n = 0; n < dwLayerCount; ++n)
725 {
726 winetest_ok(result->atrLayers[n] == atrLayers[n], "Expected atrLayers[%u] to be %x, was %x\n",
727 n, atrLayers[n], result->atrLayers[n]);
728 }
729 winetest_ok(result->dwLayerFlags == 0, "Expected dwLayerFlags to be 0, was %u\n", result->dwLayerFlags);
730 winetest_ok(result->trApphelp == 0, "Expected trApphelp to be 0, was %u\n", result->trApphelp);
731 winetest_ok(result->dwExeCount == 0, "Expected dwExeCount to be 0, was %u\n", result->dwExeCount);
732 winetest_ok(result->dwLayerCount == dwLayerCount, "Expected dwLayerCount to be %u, was %u\n", dwLayerCount, result->dwLayerCount);
733 winetest_ok(!memcmp(&result->guidID, &empty_result.guidID, sizeof(empty_result.guidID)), "Expected guidID to be empty\n");
734 winetest_ok(result->dwFlags == flags, "Expected dwFlags to be 0x%x, was 0x%x\n", flags, result->dwFlags);
735 winetest_ok(result->dwCustomSDBMap == 1, "Expected dwCustomSDBMap to be 1, was %u\n", result->dwCustomSDBMap);
736 winetest_ok(!memcmp(&result->rgGuidDB[1], &empty_result.rgGuidDB[1], sizeof(empty_result.rgGuidDB) - sizeof(empty_result.rgGuidDB[0])), "Expected rgGuidDB[+1] to be empty\n");
737 }
738}
739
740static void Test_Shimdata(SDBQUERYRESULT_VISTA* result, const WCHAR* szLayer)
741{
742 BOOL ret;
743 PVOID pData;
745
746 pData = NULL;
747 dwSize = 0;
748 ret = pSdbPackAppCompatData(g_LayerDB, result, &pData, &dwSize);
749 ok(ret == TRUE, "Expected ret to be TRUE\n");
750
751 if (pData)
752 {
753 ShimData_Win2k3* pWin2k3;
754 ShimData_WinVista* pWinVista;
755 ShimData_Win7* pWin7;
756 ShimData_Win8* pWin8;
757 ShimData_Win10_v1* pWin10;
758 ShimData_Win10_v2* pWin10_v2;
759 SDBQUERYRESULT_VISTA result2 = { { 0 } };
760
761 DWORD res = pSdbGetAppCompatDataSize(pData);
762 ok_int(dwSize, res);
763 switch(dwSize)
764 {
765 case sizeof(ShimData_Win2k3):
766 pWin2k3 = (ShimData_Win2k3*)pData;
767 ok_hex(pWin2k3->dwMagic, SHIMDATA_MAGIC);
768 ok_int(pWin2k3->dwSize, dwSize);
769 ok(pWin2k3->dwCustomSDBMap == 1, "Expected pWin2k3->dwCustomSDBMap to equal 1, was %u for %s\n", pWin2k3->dwCustomSDBMap, wine_dbgstr_w(szLayer));
770 //ok(!memcmp(&pWin2k3->Query, result, sizeof(SDBQUERYRESULT_2k3)), "Expected pWin2k3->Query to equal result\n");
771 //ok_wstr(pWin7->szLayer, szLayer);
772 break;
773 case sizeof(ShimData_WinVista):
774 pWinVista = (ShimData_WinVista*)pData;
775 ok_hex(pWinVista->dwMagic, SHIMDATA_MAGIC);
776 ok_int(pWinVista->dwSize, dwSize);
777 ok(!memcmp(&pWinVista->Query, result, sizeof(*result)), "Expected pWinVista->Query to equal result\n");
778 break;
779 case sizeof(ShimData_Win7):
780 pWin7 = (ShimData_Win7*)pData;
782 ok_int(pWin7->dwSize, dwSize);
783 ok(!memcmp(&pWin7->Query, result, sizeof(*result)), "Expected pWin7->Query to equal result\n");
784 ok_wstr(pWin7->szLayer, szLayer);
785 break;
786 case sizeof(ShimData_Win8):
787 pWin8 = (ShimData_Win8*)pData;
789 ok_int(pWin8->dwSize, dwSize);
790 ok(!memcmp(&pWin8->Query, result, sizeof(*result)), "Expected pWin8->Query to equal result\n");
791 ok_wstr(pWin8->szLayerEnv, szLayer);
792 ok_wstr(pWin8->szLayer, L"");
793 break;
794 case sizeof(ShimData_Win10_v1):
795 pWin10 = (ShimData_Win10_v1*)pData;
796 ok_hex(pWin10->dwMagic, SHIMDATA_MAGIC);
797 ok_int(pWin10->dwSize, dwSize);
798 ok(!memcmp(&pWin10->Query, result, sizeof(*result)), "Expected pWin10->Query to equal result\n");
799 ok_wstr(pWin10->szLayerEnv, szLayer);
800 ok_wstr(pWin10->szLayer, L"");
801 break;
802 case sizeof(ShimData_Win10_v2):
803 pWin10_v2 = (ShimData_Win10_v2*)pData;
804 ok_hex(pWin10_v2->dwMagic, SHIMDATA_MAGIC);
805 ok_int(pWin10_v2->dwSize, dwSize);
806 ok(!memcmp(&pWin10_v2->Query, result, sizeof(*result)), "Expected pWin10->Query to equal result\n");
807 ok_wstr(pWin10_v2->szLayerEnv, szLayer);
808 ok_wstr(pWin10_v2->szLayer, L"");
809 break;
810 default:
811 skip("Unknown size %d\n", dwSize);
812 break;
813 }
814
815 ret = pSdbUnpackAppCompatData(g_LayerDB, NULL, pData, &result2);
816 ok(ret == TRUE, "Expected ret to be TRUE\n");
817 /* TODO: For some reason 2k3 does not seem to output the database GUIDs,
818 investigate when we have support for multible db's! */
819 if (dwSize == sizeof(ShimData_Win2k3))
820 {
822 SDBQUERYRESULT_2k3* output = (SDBQUERYRESULT_2k3*)&result2;
823 const GUID rgGuidDB0 = {0x11111111, 0x1111, 0x1111, {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11}};
824
825 // Check expected data.
826 ok(input->dwLayerCount == 1,
827 "Expected input->dwLayerCount to be 1, was %u for %s\n",
828 input->dwLayerCount, wine_dbgstr_w(szLayer));
829 ok(input->dwCustomSDBMap == 1,
830 "Expected input->dwCustomSDBMap to be 1, was %u for %s\n",
831 input->dwCustomSDBMap, wine_dbgstr_w(szLayer));
832 ok(IsEqualGUID(&input->rgGuidDB[0], &rgGuidDB0),
833 "Expected input->rgGuidDB[0] to be %s, was %s for %s\n",
834 wine_dbgstr_guid(&rgGuidDB0), wine_dbgstr_guid(&input->rgGuidDB[0]), wine_dbgstr_w(szLayer));
835
836 // Check missing data.
837 ok(output->dwLayerCount == 0,
838 "Expected output->dwLayerCount to be 0, was %u for %s\n",
839 output->dwLayerCount, wine_dbgstr_w(szLayer));
840 ok(output->dwCustomSDBMap == 0,
841 "Expected output->dwCustomSDBMap to be 0, was %u for %s\n",
842 output->dwCustomSDBMap, wine_dbgstr_w(szLayer));
843 ok(IsEqualGUID(&output->rgGuidDB[0], &empty_result.rgGuidDB[0]),
844 "Expected output->rgGuidDB[0] to be empty, was %s for %s\n",
845 wine_dbgstr_guid(&output->rgGuidDB[0]), wine_dbgstr_w(szLayer));
846
847 // Fake it for now, so the memcmp works.
848 output->dwLayerCount = input->dwLayerCount;
849 output->dwCustomSDBMap = input->dwCustomSDBMap;
850 output->rgGuidDB[0] = input->rgGuidDB[0];
851 }
852 ok(!memcmp(&result2, result, sizeof(*result)), "Expected result2 to equal result for %s\n", wine_dbgstr_w(szLayer));
853
855 }
856}
857
858
859#define expect_layeronly (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_layeronly_imp
860
861
862static void Test_GetMatchingExe(void)
863{
864 BOOL ret;
865 SDBQUERYRESULT_VISTA result = { { 0 } };
866 WCHAR self[MAX_PATH];
867 DWORD flags = (g_WinVersion <= WINVER_VISTA) ? 0 : ((g_WinVersion < WINVER_WIN10) ? 1 : 0x21);
868
870 SetEnvironmentVariableA("__COMPAT_LAYER", NULL);
871
872 /* szPath cannot be NULL! */
873 ret = pSdbGetMatchingExe(NULL, L"", NULL, NULL, 0, &result);
874 ok(ret == FALSE, "Expected ret to be FALSE\n");
875 ok(!memcmp(&result, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
876
878
879 ret = pSdbGetMatchingExe(NULL, self, NULL, NULL, 0, &result);
880 ok(ret == FALSE, "Expected ret to be FALSE\n");
881 ok(!memcmp(&result, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
882
884 SetEnvironmentVariableA("__COMPAT_LAYER", "Some_invalid_layer_name");
885
886 ret = pSdbGetMatchingExe(NULL, self, NULL, NULL, 0, &result);
887 ok(ret == FALSE, "Expected ret to be FALSE\n");
889 ok(!memcmp(&result, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
890 else
891 ok(!memcmp(&result, &almost_empty, sizeof(almost_empty)), "Expected result to be almost empty\n");
892
894 SetEnvironmentVariableA("__COMPAT_LAYER", "256Color");
895
896 ret = pSdbGetMatchingExe(NULL, self, NULL, NULL, 0, &result);
897 ok(ret == TRUE, "Expected ret to be TRUE\n");
898 expect_layeronly(&result, "256Color", flags);
899
900 Test_Shimdata(&result, L"256Color");
901
903 SetEnvironmentVariableA("__COMPAT_LAYER", "640X480");
904
905 ret = pSdbGetMatchingExe(NULL, self, NULL, NULL, 0, &result);
906 ok(ret == TRUE, "Expected ret to be TRUE\n");
907 expect_layeronly(&result, "640X480", flags);
908
909 Test_Shimdata(&result, L"640X480");
910
911 /* HIGHDPIAWARE does not exist in 2k3 */
913 {
915 SetEnvironmentVariableA("__COMPAT_LAYER", "HIGHDPIAWARE");
916
917 ret = pSdbGetMatchingExe(NULL, self, NULL, NULL, 0, &result);
918 ok(ret == TRUE, "Expected ret to be TRUE\n");
919 expect_layeronly(&result, "HIGHDPIAWARE", flags);
920
921 Test_Shimdata(&result, L"HIGHDPIAWARE");
922
924 SetEnvironmentVariableA("__COMPAT_LAYER", "256Color HIGHDPIAWARE 640X480");
925
926 ret = pSdbGetMatchingExe(NULL, self, NULL, NULL, 0, &result);
927 ok(ret == TRUE, "Expected ret to be TRUE\n");
928 expect_layeronly(&result, "256Color HIGHDPIAWARE 640X480", flags);
929
930 Test_Shimdata(&result, L"256Color HIGHDPIAWARE 640X480");
931 }
932}
933
934
936{
942
944 {
945 skip("Unable to translate %s to Nt path\n", wine_dbgstr_w(ApplicationName));
946 return NULL;
947 }
948
949
961
963
964 if (!NT_SUCCESS(Status))
965 return NULL;
966
967 return FileHandle;
968}
969
970
971#define RESET_CHECKRUNAPP_VARS()\
972 do { \
973 if (AppCompatData && AppCompatData != &Query) { RtlFreeHeap(RtlGetProcessHeap(), 0, AppCompatData); } \
974 ExeType = IMAGE_FILE_MACHINE_I386; \
975 SxsDataSize = FusionFlags = Reason = 0; \
976 SxsData = NULL; \
977 memset(&Query, 0, sizeof(Query)); \
978 AppCompatData = &Query; \
979 AppCompatDataSize = 123456; \
980 } while (0)
981
982#define CHECK_BASICS()\
983 do { \
984 ok_hex(ret, TRUE); \
985 ok(AppCompatData != NULL && AppCompatData != &Query, "Expected the pointer to be valid\n"); \
986 ok_hex(AppCompatDataSize, sizeof(SDBQUERYRESULT_VISTA)); \
987 ok(SxsData == NULL, "Expected the pointer to be NULL\n"); \
988 ok_hex(SxsDataSize, 0); \
989 ok_hex(FusionFlags, 0); \
990 } while (0)
991
992/* W10 does not seem to use the flags at all, so with this macro we can still test it below 10. */
993#define CHECKREASON(value, w10dum) (g_ModuleVersion < WINVER_WIN10 ? value : w10dum)
994
995
999{
1000 ULONG64 SomeFlag1 = 0;
1001 ULONG SomeFlag2 = 0;
1002
1003 if (pApphelpCheckRunAppEx_w7)
1004 {
1005 return pApphelpCheckRunAppEx_w7(FileHandle, NULL, NULL, ApplicationName, Environment, ExeType, Reason,
1008 }
1009
1010 if (pApphelpCheckRunAppEx_w10)
1011 {
1012 return pApphelpCheckRunAppEx_w10(FileHandle, NULL, NULL, ApplicationName, Environment, NULL, ExeType, Reason,
1015 }
1016
1017 return FALSE;
1018}
1019
1020
1021
1022
1023
1024static void Test_ApphelpCheckRunApp(WCHAR szApphelp[256])
1025{
1026 BOOL ret;
1028 WCHAR ApplicationName[MAX_PATH], EmptyName[1] = { 0 };
1029 DWORD expect_flags = (g_WinVersion < WINVER_WIN10) ? 1 : 0x21;
1030
1032 PVOID AppCompatData = NULL, SxsData, DuplicatedEnv, Environment;
1033 ULONG AppCompatDataSize, SxsDataSize, FusionFlags;
1034 ULONG Reason;
1036 int n;
1037 /* this are the only interesting bits (with the exception of '1', which is there to invoke the 'default' case) */
1038 const int kTestBits = 0x70503;
1039
1040 if (!pApphelpCheckRunAppEx_w7 && !pApphelpCheckRunAppEx_w10)
1041 {
1042 skip("No usable ApphelpCheckRunAppEx\n");
1043 return;
1044 }
1045
1047
1049 SetEnvironmentVariableA("__COMPAT_LAYER", NULL);
1050 if (!CreateEnvironmentBlock(&DuplicatedEnv, NULL, TRUE))
1051 DuplicatedEnv = NULL;
1052 ok(DuplicatedEnv != NULL, "Invalid env (%u)\n", GetLastError());
1053
1054 /* First with the environment without __COMPAT_LAYER */
1056
1058 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1059
1060 CHECK_BASICS();
1061 ok_hex(Reason, CHECKREASON(0x30000, 0));
1062 ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1063
1064 /* We need this to be set for tests later on. */
1065 SetEnvironmentVariableA("__COMPAT_LAYER", "256Color");
1066
1068 {
1069 /* Showing that when an environment is passed in, that is used instead of the current.
1070 In Win10 this behavior is no longer observed */
1071
1073
1075 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1076
1077 CHECK_BASICS();
1078 ok_hex(Reason, CHECKREASON(0x30000, 0));
1079 ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1080 }
1081
1082 for (n = 0; n < 32; ++n)
1083 {
1084 ULONG ExpectedReason;
1085 if (!(kTestBits & (1<<n)))
1086 continue;
1088 ExpectedReason = Reason = (1 << n);
1090 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1091
1092 CHECK_BASICS();
1093 if (ExpectedReason == 2)
1094 ExpectedReason = 2;
1095 else if (ExpectedReason == 0x100)
1096 ExpectedReason = 0x30000;
1097 else
1098 ExpectedReason |= 0x30000;
1099 ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1100 ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1101 }
1102
1104 {
1105 /* Now, using a NULL env, showing that the current environment is used.
1106 W10 does no longer do this, so we skip this test here. */
1107 Environment = NULL;
1108
1110
1112 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1113
1114 CHECK_BASICS();
1115 ok_hex(Reason, CHECKREASON(0x50000, 0));
1116 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1117 expect_layeronly(AppCompatData, "256Color", expect_flags);
1118
1119 for (n = 0; n < 32; ++n)
1120 {
1121 ULONG ExpectedReason;
1123 if (!(kTestBits & (1<<n)))
1124 continue;
1125 ExpectedReason = Reason = (1 << n);
1127 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1128
1129 CHECK_BASICS();
1130 if (ExpectedReason == 2)
1131 ExpectedReason = 2;
1132 else if (ExpectedReason == 0x100)
1133 ExpectedReason = 0x50000;
1134 else if (ExpectedReason == 0x400)
1135 ExpectedReason = 0x30400;
1136 else
1137 ExpectedReason |= 0x50000;
1138 ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1139 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1140 {
1141 if (ExpectedReason != 0x30400)
1142 expect_layeronly(AppCompatData, "256Color", expect_flags);
1143 else
1144 ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1145 }
1146 }
1147 }
1148
1149 /* Passing in an environment with __COMPAT_LAYER set */
1151
1153
1155 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1156
1157 CHECK_BASICS();
1158 ok_hex(Reason, CHECKREASON(0x50000, 0));
1159 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1160 expect_layeronly(AppCompatData, "256Color", expect_flags);
1161
1162 for (n = 0; n < 32; ++n)
1163 {
1164 ULONG ExpectedReason;
1165 if (!(kTestBits & (1<<n)))
1166 continue;
1168 ExpectedReason = Reason = (1 << n);
1170 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1171
1172 CHECK_BASICS();
1173 if (ExpectedReason == 2)
1174 ExpectedReason = 2;
1175 else if (ExpectedReason == 0x100)
1176 ExpectedReason = 0x50000;
1177 else if (ExpectedReason == 0x400)
1178 ExpectedReason = 0x30400;
1179 else
1180 ExpectedReason |= 0x50000;
1181 ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1182 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1183 {
1184 if (ExpectedReason != 0x30400 || g_ModuleVersion >= WINVER_WIN10)
1185 expect_layeronly(AppCompatData, "256Color", expect_flags);
1186 else
1187 ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1188 }
1189 }
1190
1191 /* NULL file handle still works */
1193
1195 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1196
1197 CHECK_BASICS();
1198 ok_hex(Reason, CHECKREASON(0x50000, 0));
1199 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1200 expect_layeronly(AppCompatData, "256Color", expect_flags);
1201
1202 for (n = 0; n < 32; ++n)
1203 {
1204 ULONG ExpectedReason;
1206 if (!(kTestBits & (1<<n)))
1207 continue;
1208 ExpectedReason = Reason = (1 << n);
1210 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1211
1212 CHECK_BASICS();
1213 if (ExpectedReason == 2)
1214 ExpectedReason = 2;
1215 else if (ExpectedReason == 0x100)
1216 ExpectedReason = 0x50000;
1217 else if (ExpectedReason == 0x400)
1218 ExpectedReason = 0x30400;
1219 else
1220 ExpectedReason |= 0x50000;
1221 ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1222 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1223 {
1224 /* W10 does not use the flags anymore? */
1225 if (ExpectedReason != 0x30400 || g_ModuleVersion >= WINVER_WIN10)
1226 expect_layeronly(AppCompatData, "256Color", expect_flags);
1227 else
1228 ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1229 }
1230 }
1231
1232
1233 /* INVALID_HANDLE_VALUE file handle results in failure (according to flags!), but still results in AppCompatData */
1235
1237 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1238
1239 CHECK_BASICS();
1240 ok_hex(Reason, 0);
1241 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1242 expect_layeronly(AppCompatData, "256Color", expect_flags);
1243
1244 for (n = 0; n < 32; ++n)
1245 {
1246 ULONG ExpectedReason;
1247 if (!(kTestBits & (1<<n)))
1248 continue;
1250 ExpectedReason = Reason = (1 << n);
1252 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1253
1254 CHECK_BASICS();
1255 if (ExpectedReason == 0x100)
1256 ExpectedReason = 0;
1257 ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1258 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1259 {
1260 if (ExpectedReason != 0x400 && g_ModuleVersion < WINVER_WIN7)
1261 expect_layeronly(AppCompatData, "256Color", expect_flags);
1262 else
1263 ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1264 }
1265 }
1266
1267 /* NULL filename crashes, showing this in the log before going down:
1268[Err ][SdbpGetLongFileName ] Failed to get NT path name for ""
1269[Err ][SdbpCreateSearchDBContext] Unable to parse executable path for "".
1270[Err ][SdbGetMatchingExe ] Failed to create search DB context.
1271*/
1273
1275 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1276
1277 CHECK_BASICS();
1278 ok_hex(Reason, CHECKREASON(0x30000, 0));
1279 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1280 ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1281
1282 /* 0 ExeType = don't care? */
1284 ExeType = 0;
1285
1287 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1288
1289 CHECK_BASICS();
1290 ok_hex(Reason, CHECKREASON(0x50000, 0));
1291 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1292 expect_layeronly(AppCompatData, "256Color", expect_flags);
1293
1294 for (n = 0; n < 32; ++n)
1295 {
1296 ULONG ExpectedReason;
1297 if (!(kTestBits & (1<<n)))
1298 continue;
1300 ExeType = 0;
1301 ExpectedReason = Reason = (1 << n);
1303 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1304
1305 CHECK_BASICS();
1306 if (ExpectedReason == 2)
1307 ExpectedReason = 2;
1308 else if (ExpectedReason == 0x100)
1309 ExpectedReason = 0x50000;
1310 else if (ExpectedReason == 0x400)
1311 ExpectedReason = 0x30400;
1312 else
1313 ExpectedReason |= 0x50000;
1314 ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1315 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1316 {
1317 if (ExpectedReason != 0x30400 || g_ModuleVersion >= WINVER_WIN10)
1318 expect_layeronly(AppCompatData, "256Color", expect_flags);
1319 else
1320 ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1321 }
1322 }
1323
1324
1327
1329 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1330
1331 CHECK_BASICS();
1332 ok_hex(Reason, CHECKREASON(0x50000, 0));
1333 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1334 expect_layeronly(AppCompatData, "256Color", expect_flags);
1335
1336 for (n = 0; n < 32; ++n)
1337 {
1338 ULONG ExpectedReason;
1339 if (!(kTestBits & (1<<n)))
1340 continue;
1343 ExpectedReason = Reason = (1 << n);
1345 &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1346
1347 CHECK_BASICS();
1348 if (ExpectedReason == 2)
1349 ExpectedReason = 2;
1350 else if (ExpectedReason == 0x100)
1351 ExpectedReason = 0x50000;
1352 else if (ExpectedReason == 0x400)
1353 ExpectedReason = 0x30400;
1354 else
1355 ExpectedReason |= 0x50000;
1356 ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1357 if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1358 {
1359 if (ExpectedReason != 0x30400 || g_ModuleVersion >= WINVER_WIN10)
1360 expect_layeronly(AppCompatData, "256Color", expect_flags);
1361 else
1362 ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1363 }
1364 }
1365
1366
1367 if (AppCompatData && AppCompatData != &Query)
1368 RtlFreeHeap(RtlGetProcessHeap(), 0, AppCompatData);
1369
1371 DestroyEnvironmentBlock(DuplicatedEnv);
1373}
1374
1375
1377{
1378 WCHAR szApphelp[MAX_PATH];
1379 ShimData_QueryOffset QueryOffset;
1380 DWORD ShimDataType;
1381 NTSTATUS ExceptionStatus = STATUS_SUCCESS;
1382
1383 //SetEnvironmentVariable("SHIM_DEBUG_LEVEL", "127");
1384 //SetEnvironmentVariable("SHIMENG_DEBUG_LEVEL", "127");
1385
1387
1388 hdll = LoadLibraryA("apphelp.dll");
1389
1390
1391
1394 trace("Detected host: 0x%x, module: 0x%x\n", g_WinVersion, g_ModuleVersion);
1395
1396 GetModuleFileNameW(hdll, szApphelp, _countof(szApphelp));
1397
1398
1399 pSdbGetMatchingExe = (void*)GetProcAddress(hdll, "SdbGetMatchingExe");
1400 pSdbInitDatabase = (void*)GetProcAddress(hdll, "SdbInitDatabase");
1401 pSdbReleaseDatabase = (void*)GetProcAddress(hdll, "SdbReleaseDatabase");
1402 pSdbTagRefToTagID = (void*)GetProcAddress(hdll, "SdbTagRefToTagID");
1403 pSdbGetTagFromTagID = (void*)GetProcAddress(hdll, "SdbGetTagFromTagID");
1404 pSdbGetLayerTagRef = (void*)GetProcAddress(hdll, "SdbGetLayerTagRef");
1405
1406 switch (g_ModuleVersion)
1407 {
1408 case WINVER_WIN7:
1409 pApphelpCheckRunAppEx_w7 = (void*)GetProcAddress(hdll, "ApphelpCheckRunAppEx");
1410 break;
1411 case WINVER_WIN8:
1412 case WINVER_WIN81:
1413 case WINVER_WIN10:
1414 pApphelpCheckRunAppEx_w10 = (void*)GetProcAddress(hdll, "ApphelpCheckRunAppEx");
1415 break;
1416 default:
1417 skip("Unknown apphelp.dll version %x, cannot determine which ApphelpCheckRunApp(Ex) function to use\n", g_ModuleVersion);
1418 break;
1419 }
1420
1421 pSdbPackAppCompatData = (void*)GetProcAddress(hdll, "SdbPackAppCompatData");
1422 pSdbUnpackAppCompatData = (void*)GetProcAddress(hdll, "SdbUnpackAppCompatData");
1423 pSdbGetAppCompatDataSize = (void*)GetProcAddress(hdll, "SdbGetAppCompatDataSize");
1424
1425
1426 memset(&QueryOffset, 0, sizeof(QueryOffset));
1427 QueryOffset.dwMagic_2k3 = QueryOffset.dwMagic_7_10 = QueryOffset.dwMagic_10_v2 = SHIMDATA_MAGIC;
1428 QueryOffset.dwSize_2k3 = 1;
1429 QueryOffset.dwSize_7_10 = 2;
1430 QueryOffset.dwSize_10_v2 = 3;
1431
1432 g_ShimDataSize = g_WinVersion < WINVER_WIN8 ? 4096 : 8192;
1433 _SEH2_TRY
1434 {
1435 ShimDataType = pSdbGetAppCompatDataSize(&QueryOffset);
1436 }
1438 {
1439 ExceptionStatus = _SEH2_GetExceptionCode();
1440 }
1441 _SEH2_END;
1442
1443 ok(ExceptionStatus == STATUS_SUCCESS, "Exception 0x%08x, expected 0x%08x\n", ExceptionStatus, STATUS_SUCCESS);
1444 if (ExceptionStatus != STATUS_SUCCESS)
1445 {
1446 skip("SdbGetAppCompatDataSize not functional\n");
1447 return;
1448 }
1449
1450#ifdef _M_IX86
1451 /* New version of Win10 */
1452 if (g_WinVersion == WINVER_WIN10 && ShimDataType == 3)
1453 g_ShimDataSize = 4096;
1454
1456 {
1457 Test_layers(szApphelp);
1458 Test_repeatlayer(szApphelp);
1459 }
1460 else
1461 {
1462 skip("Tests requiring process launch, reported OS version (0x%x) does not match apphelp version (0x%x)\n", g_WinVersion, g_ModuleVersion);
1463 }
1464
1465 {
1467 }
1468
1469 Test_ApphelpCheckRunApp(szApphelp);
1470#else
1471 skip("FIXME: apphelp:env tests invalid for non-x86 platforms.\n");
1472#endif
1473 if (g_LayerDB)
1474 pSdbReleaseDatabase(g_LayerDB);
1475}
1476
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define SDB_MAX_LAYERS
Definition: apphelp.h:47
#define SHIMREG_DISABLE_LAYER
Definition: apphelp.h:55
#define SDB_MAX_SDBS
Definition: apphelp.h:45
DWORD get_host_winver(void)
Definition: data.c:796
#define WINVER_WIN10
#define WINVER_2003
DWORD get_module_version(HMODULE mod)
Definition: data.c:811
#define SDB_MAX_EXES_2k3
void silence_debug_output(void)
Definition: data.c:841
DWORD TAGREF
DWORD TAGID
DWORD g_WinVersion
Definition: data.c:795
#define WINVER_WIN81
#define WINVER_WIN7
#define WINVER_WIN8
#define WINVER_VISTA
#define ok_hex(expression, result)
Definition: atltest.h:94
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define ok_wstr(x, y)
Definition: atltest.h:130
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
LONG NTSTATUS
Definition: precomp.h:26
static const WCHAR nameW[]
Definition: main.c:49
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
Definition: query.c:292
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
@ ProcessBasicInformation
Definition: cicbase.cpp:44
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
static PDB pdb
Definition: db.cpp:172
DWORD dwLayerCount
Definition: db.cpp:875
static LPCWSTR LPCWSTR LPCWSTR env
Definition: db.cpp:170
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define CloseHandle
Definition: compat.h:739
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:758
#define GetProcessHeap()
Definition: compat.h:736
#define GetProcAddress(x, y)
Definition: compat.h:753
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define MAX_PATH
Definition: compat.h:34
#define GetEnvironmentVariableA(x, y, z)
Definition: compat.h:754
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI FreeEnvironmentStringsW(IN LPWSTR EnvironmentStrings)
Definition: environ.c:389
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
Definition: environ.c:218
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4747
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4246
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4265
LPWSTR WINAPI DECLSPEC_HOTPATCH GetEnvironmentStringsW(void)
Definition: process.c:1538
BOOL WINAPI DestroyEnvironmentBlock(IN LPVOID lpEnvironment)
Definition: environment.c:725
BOOL WINAPI CreateEnvironmentBlock(OUT LPVOID *lpEnvironment, IN HANDLE hToken, IN BOOL bInherit)
Definition: environment.c:503
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
struct _FileName FileName
Definition: fatprocs.h:897
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
Status
Definition: gdiplustypes.h:25
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLdouble n
Definition: glext.h:7729
GLuint res
Definition: glext.h:9613
GLuint address
Definition: glext.h:9393
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
GLuint64EXT * result
Definition: glext.h:11304
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
GLuint GLuint num
Definition: glext.h:9618
GLenum GLenum GLenum input
Definition: glext.h:9031
GLenum target
Definition: glext.h:7315
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define C_ASSERT(e)
Definition: intsafe.h:73
#define wine_dbgstr_w
Definition: kernel32.h:34
unsigned __int64 * PULONG64
Definition: imports.h:198
unsigned __int64 ULONG64
Definition: imports.h:198
static DWORD g_ModuleVersion
Definition: env.c:63
static void Test_layers(WCHAR szApphelp[256])
Definition: env.c:545
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG PULONG64 PULONG SomeFlag2
Definition: env.c:49
#define SDB_DATABASE_MAIN_SHIM
Definition: env.c:202
HANDLE xOpenFile(WCHAR *ApplicationName)
Definition: env.c:935
#define SHIMDATA_MAGIC
Definition: env.c:68
#define CHECKREASON(value, w10dum)
Definition: env.c:993
static void Test_ApphelpCheckRunApp(WCHAR szApphelp[256])
Definition: env.c:1024
LPCWSTR LPCWSTR LPCWSTR DWORD PSDBQUERYRESULT_VISTA pQueryResult
Definition: env.c:37
static HMODULE hdll
Definition: env.c:35
PVOID PVOID PWCHAR PVOID USHORT ExeType
Definition: env.c:47
LPCWSTR pszImageName
Definition: env.c:57
static void Validate_ShimData_Win8(PVOID data, WCHAR szApphelp[256], size_t count, const char *layers[])
Definition: env.c:404
static BOOL get_shiminfo(HANDLE proc, test_RemoteShimInfo *info)
Definition: env.c:229
static void expect_layeronly_imp(SDBQUERYRESULT_VISTA *result, const char *layers, DWORD flags)
Definition: env.c:685
static void ValidateShim(TAGREF trLayer, const char *name)
Definition: env.c:297
static void Validate_ShimData_Win2k3(PVOID data, size_t count, const char *layers[])
Definition: env.c:326
static void Test_GetMatchingExe(void)
Definition: env.c:862
void * PDB
Definition: env.c:29
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:47
TAGREF PDB TAGID * ptiWhich
Definition: env.c:40
TAGREF PDB * ppdb
Definition: env.c:40
LPCWSTR layerName
Definition: env.c:42
PVOID PVOID Unk2
Definition: env.c:47
static BOOL call_ApphelpCheckRunApp(HANDLE FileHandle, PWCHAR ApplicationName, PVOID Environment, USHORT ExeType, PULONG Reason, PVOID *SdbQueryAppCompatData, PULONG SdbQueryAppCompatDataSize, PVOID *SxsData, PULONG SxsDataSize, PULONG FusionFlags)
Definition: env.c:996
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID * SdbQueryAppCompatData
Definition: env.c:48
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG SxsDataSize
Definition: env.c:48
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG PULONG64 SomeFlag1
Definition: env.c:49
PVOID Unk1
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID * SxsData
Definition: env.c:48
static void Validate_ShimData_Win10(PVOID data, WCHAR szApphelp[256], size_t count, const char *layers[])
Definition: env.c:467
#define CHECK_BASICS()
Definition: env.c:982
DWORD TAGREF
Definition: env.c:30
#define expect_layeronly
Definition: env.c:859
PSDBQUERYRESULT_VISTA PVOID * ppData
Definition: env.c:56
LPCWSTR szPath
Definition: env.c:37
LPCWSTR LPCWSTR szModuleName
Definition: env.c:37
static const SDBQUERYRESULT_VISTA empty_result
Definition: env.c:64
static void Test_Shimdata(SDBQUERYRESULT_VISTA *result, const WCHAR *szLayer)
Definition: env.c:740
static void Validate_EmptyShimData_Win8(PVOID data)
Definition: env.c:503
static void Validate_EmptyShimData_Win10(PVOID data)
Definition: env.c:516
static HANDLE create_proc(BOOL suspended)
Definition: env.c:266
static void Validate_ShimData_WinVista(PVOID data, size_t count, const char *layers[])
Definition: env.c:337
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG FusionFlags
Definition: env.c:49
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:47
static void create_environ(const char *layers[], size_t num)
Definition: env.c:284
static const SDBQUERYRESULT_VISTA almost_empty
Definition: env.c:65
PVOID PVOID PWCHAR PVOID PVOID Unk3
Definition: env.c:51
static void Validate_ShimData_Win10_v2(PVOID data, WCHAR szApphelp[256], size_t count, const char *layers[])
Definition: env.c:433
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG SdbQueryAppCompatDataSize
Definition: env.c:48
LPCWSTR PVOID pData
Definition: env.c:57
LPCWSTR LPCWSTR LPCWSTR pszEnvironment
Definition: env.c:37
WORD TAG
Definition: env.c:31
#define MAX_LAYER_LENGTH
Definition: env.c:69
LPCWSTR LPCWSTR LPCWSTR DWORD dwFlags
Definition: env.c:37
void * HSDB
Definition: env.c:28
static DWORD g_ShimDataSize
Definition: env.c:62
LPCWSTR pszDatabasePath
Definition: env.c:38
static HSDB g_LayerDB
Definition: env.c:61
TAGREF trWhich
Definition: env.c:40
static BOOL readproc(HANDLE proc, LPVOID address, PVOID target, DWORD size)
Definition: env.c:217
PVOID PVOID PWCHAR ApplicationName
Definition: env.c:47
static void Test_repeatlayer(WCHAR szApphelp[256])
Definition: env.c:622
static void Validate_ShimData_Win7(PVOID data, WCHAR szApphelp[256], size_t count, const char *layers[])
Definition: env.c:372
TAGID tiWhich
Definition: env.c:41
#define RESET_CHECKRUNAPP_VARS()
Definition: env.c:971
TAGREF find_layer(const char *szLayerStart, const char *szLayerEnd)
Definition: env.c:670
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static refpint_t pi[]
Definition: server.c:96
#define min(a, b)
Definition: monoChain.cc:55
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)
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3953
#define BOOL
Definition: nt_native.h:43
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_READ_DATA
Definition: nt_native.h:628
#define FILE_READ_ATTRIBUTES
Definition: nt_native.h:647
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define FILE_EXECUTE
Definition: nt_native.h:642
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define DWORD
Definition: nt_native.h:44
#define IMAGE_FILE_MACHINE_POWERPCFP
Definition: ntimage.h:28
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
static HANDLE proc()
Definition: pdb.c:34
unsigned short USHORT
Definition: pedump.c:61
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define offsetof(TYPE, MEMBER)
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
mbstowcs
Definition: stdlib.h:925
strncpy
Definition: string.h:335
strcat
Definition: string.h:92
#define memset(x, y, z)
Definition: compat.h:39
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _countof(array)
Definition: sndvol32.h:70
DWORD dwMagic_7_10
Definition: env.c:171
char spacing2[444]
Definition: env.c:168
char spacing1[60]
Definition: env.c:163
DWORD dwMagic_2k3
Definition: env.c:166
DWORD dwSize_2k3
Definition: env.c:165
DWORD dwSize_10_v2
Definition: env.c:160
DWORD dwMagic_10_v2
Definition: env.c:161
DWORD dwSize_7_10
Definition: env.c:170
DWORD unk3
Definition: env.c:133
DWORD dwSize
Definition: env.c:125
WCHAR unk4[MAX_LAYER_LENGTH]
Definition: env.c:136
WCHAR processname[MAX_PATH]
Definition: env.c:134
DWORD dwMagic
Definition: env.c:126
DWORD unk1
Definition: env.c:127
char padding4[120]
Definition: env.c:137
DWORD unk2
Definition: env.c:132
char padding1[0x200]
Definition: env.c:130
SDBQUERYRESULT_VISTA Query
Definition: env.c:128
WCHAR szLayer[MAX_LAYER_LENGTH]
Definition: env.c:129
char padding2[0x404]
Definition: env.c:131
WCHAR szLayerEnv[MAX_LAYER_LENGTH]
Definition: env.c:135
WCHAR szModule[260]
Definition: env.c:124
char padding2[0x2ae+0x54+0x2a+0x16+0x16]
Definition: env.c:149
SDBQUERYRESULT_VISTA Query
Definition: env.c:146
WCHAR unk5[MAX_LAYER_LENGTH]
Definition: env.c:154
WCHAR szLayerEnv[MAX_LAYER_LENGTH]
Definition: env.c:153
DWORD unk4
Definition: env.c:151
WCHAR processname[MAX_PATH-2]
Definition: env.c:152
WCHAR szLayer[MAX_LAYER_LENGTH]
Definition: env.c:147
DWORD unk3
Definition: env.c:150
char padding1[0x200]
Definition: env.c:148
DWORD dwSize
Definition: env.c:142
char padding4[76]
Definition: env.c:155
DWORD unk1
Definition: env.c:144
DWORD unk2
Definition: env.c:145
DWORD dwMagic
Definition: env.c:143
TAGREF atrLayers[SDB_MAX_LAYERS]
Definition: env.c:79
WCHAR szModule[34]
Definition: env.c:74
DWORD dwCustomSDBMap
Definition: env.c:82
TAGREF atrExes[SDB_MAX_EXES_2k3]
Definition: env.c:78
DWORD dwMagic
Definition: env.c:76
DWORD dwUnk0
Definition: env.c:80
DWORD dwUnk1
Definition: env.c:81
DWORD dwSize
Definition: env.c:75
GUID rgGuidDB[SDB_MAX_SDBS]
Definition: env.c:83
DWORD dwMagic
Definition: env.c:98
SDBQUERYRESULT_VISTA Query
Definition: env.c:99
DWORD dwSize
Definition: env.c:97
WCHAR szModule[260]
Definition: env.c:96
WCHAR szLayer[MAX_LAYER_LENGTH]
Definition: env.c:100
DWORD unknown
Definition: env.c:101
DWORD dwMagic
Definition: env.c:108
DWORD unk3
Definition: env.c:115
char padding4[112]
Definition: env.c:119
SDBQUERYRESULT_VISTA Query
Definition: env.c:110
WCHAR szLayerEnv[MAX_LAYER_LENGTH]
Definition: env.c:117
WCHAR szLayer[MAX_LAYER_LENGTH]
Definition: env.c:111
WCHAR unk4[MAX_LAYER_LENGTH]
Definition: env.c:118
WCHAR szModule[260]
Definition: env.c:106
char padding1[0x200]
Definition: env.c:112
WCHAR processname[MAX_PATH]
Definition: env.c:116
DWORD dwSize
Definition: env.c:107
char padding2[0x404]
Definition: env.c:113
DWORD unk2
Definition: env.c:114
DWORD unk1
Definition: env.c:109
DWORD dwMagic
Definition: env.c:90
SDBQUERYRESULT_VISTA Query
Definition: env.c:91
DWORD dwSize
Definition: env.c:89
WCHAR szModule[260]
Definition: env.c:88
ULARGE_INTEGER AppCompatFlagsUser
Definition: winternl.h:350
ULARGE_INTEGER AppCompatFlags
Definition: winternl.h:349
PVOID AppCompatInfo
Definition: winternl.h:352
Definition: apphelp.h:30
Definition: fs_rec.h:143
Definition: name.c:39
Definition: ps.c:97
GUID rgGuidDB[SDB_MAX_SDBS]
TAGREF atrLayers[SDB_MAX_LAYERS]
TAGREF atrExes[SDB_MAX_EXES_2k3]
TAGREF atrLayers[SDB_MAX_LAYERS]
TAGREF atrExes[SDB_MAX_EXES_VISTA]
DWORD adwExeFlags[SDB_MAX_EXES_VISTA]
GUID rgGuidDB[SDB_MAX_SDBS]
Definition: ecma_167.h:138
ULARGE_INTEGER AppCompatFlagsUser
Definition: env.c:210
ULARGE_INTEGER AppCompatFlags
Definition: env.c:209
PVOID pShimData
Definition: env.c:211
PVOID AppCompatInfo
Definition: env.c:213
DWORD ShimDataSize
Definition: env.c:212
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
uint32_t * PULONG
Definition: typedefs.h:59
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint16_t * PWCHAR
Definition: typedefs.h:56
uint32_t ULONG
Definition: typedefs.h:59
SIZE_T NTAPI VirtualQueryEx(IN HANDLE hProcess, IN LPCVOID lpAddress, OUT PMEMORY_BASIC_INFORMATION lpBuffer, IN SIZE_T dwLength)
Definition: virtmem.c:227
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CREATE_SUSPENDED
Definition: winbase.h:188
_Inout_ PERBANDINFO * pbi
Definition: winddi.h:3917
CONST void * LPCVOID
Definition: windef.h:191
#define WINAPI
Definition: msvc.h:6
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185