ReactOS  0.4.15-dev-2504-g2b52f3b
env.c File Reference
#include <ntstatus.h>
#include <windows.h>
#include <shlwapi.h>
#include <winnt.h>
#include <userenv.h>
#include <winternl.h>
#include <winerror.h>
#include <stdio.h>
#include "wine/test.h"
#include <pseh/pseh2.h>
#include "apphelp_apitest.h"
Include dependency graph for env.c:

Go to the source code of this file.

Classes

struct  ShimData_Win2k3
 
struct  ShimData_Win7
 
struct  ShimData_Win10_v1
 
struct  ShimData_Win10_v2
 
struct  ShimData_QueryOffset
 
struct  test_RemoteShimInfo
 

Macros

#define WIN32_NO_STATUS
 
#define SHIMDATA_MAGIC   0xAC0DEDAB
 
#define MAX_LAYER_LENGTH   256
 
#define SDB_DATABASE_MAIN_SHIM   0x80030000
 
#define SDBGMEF_IGNORE_ENVIRONMENT   0x1
 
#define expect_layeronly   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_layeronly_imp
 
#define RESET_CHECKRUNAPP_VARS()
 
#define CHECK_BASICS()
 
#define CHECKREASON(value, w10dum)   (g_ModuleVersion < WINVER_WIN10 ? value : w10dum)
 

Typedefs

typedef voidHSDB
 
typedef voidPDB
 
typedef DWORD TAGREF
 
typedef WORD TAG
 
typedef struct ShimData_Win2k3 ShimData_Win2k3
 
typedef struct ShimData_Win7 ShimData_Win7
 
typedef struct ShimData_Win10_v1 ShimData_Win10_v1
 
typedef struct ShimData_Win10_v2 ShimData_Win10_v2
 
typedef struct ShimData_QueryOffset ShimData_QueryOffset
 
typedef struct test_RemoteShimInfo test_RemoteShimInfo
 

Functions

 BOOL (WINAPI *pSdbGetMatchingExe)(HSDB hsdb
 
 HSDB (WINAPI *pSdbInitDatabase)(DWORD dwFlags
 
 void (WINAPI *pSdbReleaseDatabase)(HSDB hsdb)
 
 TAG (WINAPI *pSdbGetTagFromTagID)(PDB pdb
 
 TAGREF (WINAPI *pSdbGetLayerTagRef)(HSDB hsdb
 
 DWORD (WINAPI *pSdbGetAppCompatDataSize)(PVOID pData)
 
 C_ASSERT (sizeof(ShimData_Win2k3)==392)
 
 C_ASSERT (sizeof(ShimData_Win7)==1500)
 
 C_ASSERT (sizeof(ShimData_Win10_v1)==4712)
 
 C_ASSERT (sizeof(ShimData_Win10_v2)==3976)
 
 C_ASSERT (offsetof(ShimData_Win10_v2, dwSize)==0)
 
 C_ASSERT (offsetof(ShimData_Win2k3, dwSize)==68)
 
 C_ASSERT (offsetof(ShimData_Win7, dwSize)==520)
 
 C_ASSERT (offsetof(ShimData_Win10_v1, dwSize)==520)
 
 C_ASSERT (offsetof(ShimData_Win10_v2, dwMagic)==4)
 
 C_ASSERT (offsetof(ShimData_Win2k3, dwMagic)==72)
 
 C_ASSERT (offsetof(ShimData_Win7, dwMagic)==524)
 
 C_ASSERT (offsetof(ShimData_Win10_v1, dwMagic)==524)
 
 C_ASSERT (offsetof(ShimData_QueryOffset, dwSize_10_v2)==0)
 
 C_ASSERT (offsetof(ShimData_QueryOffset, dwSize_2k3)==68)
 
 C_ASSERT (offsetof(ShimData_QueryOffset, dwSize_7_10)==520)
 
 C_ASSERT (offsetof(ShimData_QueryOffset, dwMagic_10_v2)==4)
 
 C_ASSERT (offsetof(ShimData_QueryOffset, dwMagic_2k3)==72)
 
 C_ASSERT (offsetof(ShimData_QueryOffset, dwMagic_7_10)==524)
 
static BOOL readproc (HANDLE proc, LPVOID address, PVOID target, DWORD size)
 
static BOOL get_shiminfo (HANDLE proc, test_RemoteShimInfo *info)
 
static HANDLE create_proc (BOOL suspended)
 
static void create_environ (const char *layers[], size_t num)
 
static void ValidateShim (TAGREF trLayer, const char *name)
 
static void Validate_ShimData_Win2k3 (PVOID data, size_t count, const char *layers[])
 
static void Validate_ShimData_Win7 (PVOID data, WCHAR szApphelp[256], size_t count, const char *layers[])
 
static void Validate_ShimData_Win10_v2 (PVOID data, WCHAR szApphelp[256], size_t count, const char *layers[])
 
static void Validate_ShimData_Win10 (PVOID data, WCHAR szApphelp[256], size_t count, const char *layers[])
 
static void Validate_EmptyShimData_Win10 (PVOID data)
 
static void Test_layers (WCHAR szApphelp[256])
 
static void Test_repeatlayer (WCHAR szApphelp[256])
 
TAGREF find_layer (const char *szLayerStart, const char *szLayerEnd)
 
static void expect_layeronly_imp (SDBQUERYRESULT_VISTA *result, const char *layers, DWORD flags)
 
static void Test_Shimdata (SDBQUERYRESULT_VISTA *result, const WCHAR *szLayer)
 
static void Test_GetMatchingExe (void)
 
HANDLE xOpenFile (WCHAR *ApplicationName)
 
static BOOL call_ApphelpCheckRunApp (HANDLE FileHandle, PWCHAR ApplicationName, PVOID Environment, USHORT ExeType, PULONG Reason, PVOID *SdbQueryAppCompatData, PULONG SdbQueryAppCompatDataSize, PVOID *SxsData, PULONG SxsDataSize, PULONG FusionFlags)
 
static void Test_ApphelpCheckRunApp (WCHAR szApphelp[256])
 
 START_TEST (env)
 

Variables

static HMODULE hdll
 
LPCWSTR szPath
 
LPCWSTR LPCWSTR szModuleName
 
LPCWSTR LPCWSTR LPCWSTR pszEnvironment
 
LPCWSTR LPCWSTR LPCWSTR DWORD dwFlags
 
LPCWSTR LPCWSTR LPCWSTR DWORD PSDBQUERYRESULT_VISTA pQueryResult
 
LPCWSTR pszDatabasePath
 
TAGREF trWhich
 
TAGREF PDBppdb
 
TAGREF PDB TAGIDptiWhich
 
TAGID tiWhich
 
LPCWSTR layerName
 
PVOID Unk1
 
PVOID PVOID Unk2
 
PVOID PVOID PWCHAR ApplicationName
 
PVOID PVOID PWCHAR PVOID Environment
 
PVOID PVOID PWCHAR PVOID USHORT ExeType
 
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
 
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOIDSdbQueryAppCompatData
 
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG SdbQueryAppCompatDataSize
 
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOIDSxsData
 
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG SxsDataSize
 
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG FusionFlags
 
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG PULONG64 SomeFlag1
 
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG PULONG64 PULONG SomeFlag2
 
PVOID PVOID PWCHAR PVOID PVOID Unk3
 
PSDBQUERYRESULT_VISTA PVOIDppData
 
PSDBQUERYRESULT_VISTA PVOID DWORDdwSize
 
LPCWSTR pszImageName
 
LPCWSTR PVOID pData
 
static HSDB g_LayerDB
 
static DWORD g_ShimDataSize
 
static DWORD g_ModuleVersion
 
static const SDBQUERYRESULT_VISTA empty_result = { { 0 } }
 
static const SDBQUERYRESULT_VISTA almost_empty = { { 0 }, { 0 }, { 0 }, 0, 0, 0, 0, { 0 }, SHIMREG_DISABLE_LAYER, 0 }
 

Macro Definition Documentation

◆ CHECK_BASICS

#define CHECK_BASICS ( )
Value:
do { \
ok_hex(ret, TRUE); \
ok(AppCompatData != NULL && AppCompatData != &Query, "Expected the pointer to be valid\n"); \
ok_hex(AppCompatDataSize, sizeof(SDBQUERYRESULT_VISTA)); \
ok(SxsData == NULL, "Expected the pointer to be NULL\n"); \
ok_hex(SxsDataSize, 0); \
ok_hex(FusionFlags, 0); \
} while (0)
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG FusionFlags
Definition: env.c:47
#define TRUE
Definition: types.h:120
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
Definition: query.c:292
int ret
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG SxsDataSize
Definition: env.c:47
#define NULL
Definition: types.h:112
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID * SxsData
Definition: env.c:47

Definition at line 851 of file env.c.

◆ CHECKREASON

#define CHECKREASON (   value,
  w10dum 
)    (g_ModuleVersion < WINVER_WIN10 ? value : w10dum)

Definition at line 862 of file env.c.

◆ expect_layeronly

#define expect_layeronly   (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : expect_layeronly_imp

Definition at line 728 of file env.c.

◆ MAX_LAYER_LENGTH

#define MAX_LAYER_LENGTH   256

Definition at line 69 of file env.c.

◆ RESET_CHECKRUNAPP_VARS

#define RESET_CHECKRUNAPP_VARS ( )
Value:
do { \
if (AppCompatData && AppCompatData != &Query) { RtlFreeHeap(RtlGetProcessHeap(), 0, AppCompatData); } \
SxsDataSize = FusionFlags = Reason = 0; \
SxsData = NULL; \
memset(&Query, 0, sizeof(Query)); \
AppCompatData = &Query; \
AppCompatDataSize = 123456; \
} while (0)
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG FusionFlags
Definition: env.c:47
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define IMAGE_FILE_MACHINE_I386
Definition: pedump.c:174
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
Definition: query.c:292
#define NULL
Definition: types.h:112
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:47

Definition at line 840 of file env.c.

◆ SDB_DATABASE_MAIN_SHIM

#define SDB_DATABASE_MAIN_SHIM   0x80030000

Definition at line 176 of file env.c.

◆ SDBGMEF_IGNORE_ENVIRONMENT

#define SDBGMEF_IGNORE_ENVIRONMENT   0x1

Definition at line 178 of file env.c.

◆ SHIMDATA_MAGIC

#define SHIMDATA_MAGIC   0xAC0DEDAB

Definition at line 68 of file env.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 9 of file env.c.

Typedef Documentation

◆ HSDB

typedef void* HSDB

Definition at line 28 of file env.c.

◆ PDB

typedef void* PDB

Definition at line 29 of file env.c.

◆ ShimData_QueryOffset

◆ ShimData_Win10_v1

◆ ShimData_Win10_v2

◆ ShimData_Win2k3

◆ ShimData_Win7

◆ TAG

typedef WORD TAG

Definition at line 31 of file env.c.

◆ TAGREF

typedef DWORD TAGREF

Definition at line 30 of file env.c.

◆ test_RemoteShimInfo

Function Documentation

◆ BOOL()

BOOL ( WINAPI pSdbGetMatchingExe)

◆ C_ASSERT() [1/18]

C_ASSERT ( sizeof(ShimData_Win2k3 = =392)

◆ C_ASSERT() [2/18]

C_ASSERT ( sizeof(ShimData_Win7 = =1500)

◆ C_ASSERT() [3/18]

C_ASSERT ( sizeof(ShimData_Win10_v1 = =4712)

◆ C_ASSERT() [4/18]

C_ASSERT ( sizeof(ShimData_Win10_v2 = =3976)

◆ C_ASSERT() [5/18]

C_ASSERT ( offsetof(ShimData_Win10_v2, dwSize = =0)

◆ C_ASSERT() [6/18]

C_ASSERT ( offsetof(ShimData_Win2k3, dwSize = =68)

◆ C_ASSERT() [7/18]

C_ASSERT ( offsetof(ShimData_Win7, dwSize = =520)

◆ C_ASSERT() [8/18]

C_ASSERT ( offsetof(ShimData_Win10_v1, dwSize = =520)

◆ C_ASSERT() [9/18]

C_ASSERT ( offsetof(ShimData_Win10_v2, dwMagic)  = =4)

◆ C_ASSERT() [10/18]

C_ASSERT ( offsetof(ShimData_Win2k3, dwMagic)  = =72)

◆ C_ASSERT() [11/18]

C_ASSERT ( offsetof(ShimData_Win7, dwMagic)  = =524)

◆ C_ASSERT() [12/18]

C_ASSERT ( offsetof(ShimData_Win10_v1, dwMagic)  = =524)

◆ C_ASSERT() [13/18]

C_ASSERT ( offsetof(ShimData_QueryOffset, dwSize_10_v2)  = =0)

◆ C_ASSERT() [14/18]

C_ASSERT ( offsetof(ShimData_QueryOffset, dwSize_2k3)  = =68)

◆ C_ASSERT() [15/18]

C_ASSERT ( offsetof(ShimData_QueryOffset, dwSize_7_10)  = =520)

◆ C_ASSERT() [16/18]

C_ASSERT ( offsetof(ShimData_QueryOffset, dwMagic_10_v2)  = =4)

◆ C_ASSERT() [17/18]

C_ASSERT ( offsetof(ShimData_QueryOffset, dwMagic_2k3)  = =72)

◆ C_ASSERT() [18/18]

C_ASSERT ( offsetof(ShimData_QueryOffset, dwMagic_7_10)  = =524)

◆ call_ApphelpCheckRunApp()

static BOOL call_ApphelpCheckRunApp ( HANDLE  FileHandle,
PWCHAR  ApplicationName,
PVOID  Environment,
USHORT  ExeType,
PULONG  Reason,
PVOID SdbQueryAppCompatData,
PULONG  SdbQueryAppCompatDataSize,
PVOID SxsData,
PULONG  SxsDataSize,
PULONG  FusionFlags 
)
static

Definition at line 865 of file env.c.

868 {
869  ULONG64 SomeFlag1 = 0;
870  ULONG SomeFlag2 = 0;
871 
872  if (pApphelpCheckRunAppEx_w7)
873  {
874  return pApphelpCheckRunAppEx_w7(FileHandle, NULL, NULL, ApplicationName, Environment, ExeType, Reason,
877  }
878 
879  if (pApphelpCheckRunAppEx_w10)
880  {
881  return pApphelpCheckRunAppEx_w10(FileHandle, NULL, NULL, ApplicationName, Environment, NULL, ExeType, Reason,
884  }
885 
886  return FALSE;
887 }
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG FusionFlags
Definition: env.c:47
HANDLE FileHandle
Definition: stats.c:38
#define FALSE
Definition: types.h:117
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG PULONG64 SomeFlag1
Definition: env.c:47
unsigned __int64 ULONG64
Definition: imports.h:198
PVOID PVOID PWCHAR ApplicationName
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT ExeType
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG SxsDataSize
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG PULONG64 PULONG SomeFlag2
Definition: env.c:47
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID * SxsData
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID * SdbQueryAppCompatData
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG SdbQueryAppCompatDataSize
Definition: env.c:47

Referenced by Test_ApphelpCheckRunApp().

◆ create_environ()

static void create_environ ( const char layers[],
size_t  num 
)
static

Definition at line 258 of file env.c.

259 {
260  char buf[256] = { 0 };
261  size_t n;
262  for (n = 0; n < num; ++n)
263  {
264  if (n)
265  strcat(buf, " ");
266  strcat(buf, layers[n]);
267  }
268  SetEnvironmentVariableA("__COMPAT_LAYER", buf);
269 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
Definition: environ.c:218
GLuint GLuint num
Definition: glext.h:9618

Referenced by Test_layers().

◆ create_proc()

static HANDLE create_proc ( BOOL  suspended)
static

Definition at line 240 of file env.c.

241 {
242  static char proc_name[MAX_PATH] = { 0 };
243  STARTUPINFOA si = {sizeof(si)};
245  BOOL res;
246  if (!proc_name[0])
247  {
248  GetModuleFileNameA(NULL, proc_name, MAX_PATH);
249  }
250 
251  res = CreateProcessA(NULL, proc_name, NULL, NULL, TRUE, suspended ? CREATE_SUSPENDED : 0, NULL, NULL, &si, &pi);
252  if (!res)
253  return NULL;
254  CloseHandle(pi.hThread);
255  return pi.hProcess;
256 }
#define CloseHandle
Definition: compat.h:598
#define TRUE
Definition: types.h:120
DWORD WINAPI GetModuleFileNameA(HINSTANCE hModule, LPSTR lpFilename, DWORD nSize)
Definition: loader.c:539
#define CREATE_SUSPENDED
Definition: winbase.h:178
unsigned int BOOL
Definition: ntddk_ex.h:94
static refpint_t pi[]
Definition: server.c:96
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:4743
#define MAX_PATH
Definition: compat.h:34
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613

Referenced by Test_layers(), and Test_repeatlayer().

◆ DWORD()

DWORD ( WINAPI pSdbGetAppCompatDataSize)

◆ expect_layeronly_imp()

static void expect_layeronly_imp ( SDBQUERYRESULT_VISTA result,
const char layers,
DWORD  flags 
)
static

Definition at line 570 of file env.c.

571 {
572  DWORD dwLayerCount = 0, n;
573  TAGREF atrLayers[SDB_MAX_LAYERS] = { 0 };
574 
575  const char* layer = layers, *nextlayer;
576  while (layer && *layer)
577  {
578  nextlayer = strchr(layer, ' ');
579  atrLayers[dwLayerCount++] = find_layer(layer, nextlayer ? nextlayer : (layer + strlen(layer)));
580  layer = nextlayer ? (nextlayer+1) : NULL;
581  }
582 
584  {
586  result = NULL;
587 
588  winetest_ok(!memcmp(&result2->atrExes, &empty_result.atrExes, sizeof(result2->atrExes)), "Expected atrExes to be empty\n");
589  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");
590  for (n = 0; n < dwLayerCount; ++n)
591  {
592  winetest_ok(result2->atrLayers[n] == atrLayers[n], "Expected atrLayers[%u] to be %x, was %x\n",
593  n, atrLayers[n], result2->atrLayers[n]);
594  }
595  winetest_ok(result2->dwLayerFlags == 0, "Expected dwLayerFlags to be 0, was %u\n", result2->dwLayerFlags);
596  winetest_ok(result2->trApphelp == 0, "Expected trApphelp to be 0, was %u\n", result2->trApphelp);
597  winetest_ok(result2->dwExeCount == 0, "Expected dwExeCount to be 0, was %u\n", result2->dwExeCount);
598  winetest_ok(result2->dwLayerCount == dwLayerCount, "Expected dwLayerCount to be %u, was %u\n", dwLayerCount, result2->dwLayerCount);
599  winetest_ok(!memcmp(&result2->guidID, &empty_result.guidID, sizeof(result2->guidID)), "Expected guidID to be empty\n");
600  winetest_ok(result2->dwFlags == flags, "Expected dwFlags to be 0x%x, was 0x%x\n", flags, result2->dwFlags);
601  winetest_ok(result2->dwCustomSDBMap == 1, "Expected dwCustomSDBMap to be 1, was %u\n", result2->dwCustomSDBMap);
602  winetest_ok(!memcmp(&result2->rgGuidDB[1], &empty_result.rgGuidDB[1], sizeof(result2->rgGuidDB) - sizeof(result2->rgGuidDB[0])), "Expected rgGuidDB[+1] to be empty\n");
603  }
604  else
605  {
606  winetest_ok(!memcmp(&result->atrExes, &empty_result.atrExes, sizeof(empty_result.atrExes)), "Expected atrExes to be empty\n");
607  winetest_ok(!memcmp(&result->adwExeFlags, &empty_result.adwExeFlags, sizeof(empty_result.adwExeFlags)), "Expected adwExeFlags to be empty\n");
608  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");
609  for (n = 0; n < dwLayerCount; ++n)
610  {
611  winetest_ok(result->atrLayers[n] == atrLayers[n], "Expected atrLayers[%u] to be %x, was %x\n",
612  n, atrLayers[n], result->atrLayers[n]);
613  }
614  winetest_ok(result->dwLayerFlags == 0, "Expected dwLayerFlags to be 0, was %u\n", result->dwLayerFlags);
615  winetest_ok(result->trApphelp == 0, "Expected trApphelp to be 0, was %u\n", result->trApphelp);
616  winetest_ok(result->dwExeCount == 0, "Expected dwExeCount to be 0, was %u\n", result->dwExeCount);
617  winetest_ok(result->dwLayerCount == dwLayerCount, "Expected dwLayerCount to be %u, was %u\n", dwLayerCount, result->dwLayerCount);
618  winetest_ok(!memcmp(&result->guidID, &empty_result.guidID, sizeof(empty_result.guidID)), "Expected guidID to be empty\n");
619  winetest_ok(result->dwFlags == flags, "Expected dwFlags to be 0x%x, was 0x%x\n", flags, result->dwFlags);
620  winetest_ok(result->dwCustomSDBMap == 1, "Expected dwCustomSDBMap to be 1, was %u\n", result->dwCustomSDBMap);
621  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");
622  }
623 }
DWORD TAGREF
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLuint64EXT * result
Definition: glext.h:11304
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLdouble n
Definition: glext.h:7729
static DWORD g_ModuleVersion
Definition: env.c:63
TAGREF atrExes[SDB_MAX_EXES_VISTA]
DWORD dwLayerCount
Definition: db.cpp:869
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
static const SDBQUERYRESULT_VISTA empty_result
Definition: env.c:64
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
GUID rgGuidDB[SDB_MAX_SDBS]
TAGREF atrLayers[SDB_MAX_LAYERS]
TAGREF atrLayers[SDB_MAX_LAYERS]
#define WINVER_VISTA
#define NULL
Definition: types.h:112
char * strchr(const char *String, int ch)
Definition: utclib.c:501
GUID rgGuidDB[SDB_MAX_SDBS]
DWORD adwExeFlags[SDB_MAX_EXES_VISTA]
#define SDB_MAX_LAYERS
Definition: apphelp.h:44
TAGREF atrExes[SDB_MAX_EXES_2k3]
TAGREF find_layer(const char *szLayerStart, const char *szLayerEnd)
Definition: env.c:555

◆ find_layer()

TAGREF find_layer ( const char szLayerStart,
const char szLayerEnd 
)

Definition at line 555 of file env.c.

556 {
557  char layer[100] = { 0 };
558  WCHAR layerW[100] = { 0 };
559  strncpy(layer, szLayerStart, szLayerEnd - szLayerStart);
560 
561  if (!g_LayerDB)
562  {
563  g_LayerDB = pSdbInitDatabase(SDB_DATABASE_MAIN_SHIM, 0);
564  }
565 
566  mbstowcs(layerW, layer, strlen(layer));
567  return pSdbGetLayerTagRef(g_LayerDB, layerW);
568 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
size_t __cdecl mbstowcs(_Out_writes_opt_z_(_MaxCount) wchar_t *_Dest, _In_z_ const char *_Source, _In_ size_t _MaxCount)
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define SDB_DATABASE_MAIN_SHIM
Definition: env.c:176
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
__wchar_t WCHAR
Definition: xmlstorage.h:180
static HSDB g_LayerDB
Definition: env.c:61

Referenced by expect_layeronly_imp().

◆ get_shiminfo()

static BOOL get_shiminfo ( HANDLE  proc,
test_RemoteShimInfo info 
)
static

Definition at line 203 of file env.c.

204 {
206  ULONG sizeOut = 0;
208  ok(NT_SUCCESS(status), "Expected NtQI to succeed, but failed with: %x\n", status);
209  memset(info, 0, sizeof(*info));
210  if (NT_SUCCESS(status))
211  {
212  PEB peb = { 0 };
213  if (readproc(proc, pbi.PebBaseAddress, &peb, sizeof(peb)))
214  {
215  MEMORY_BASIC_INFORMATION mbi = { 0 };
216  SIZE_T dwRead;
217 
218  info->AppCompatFlags = peb.AppCompatFlags;
219  info->AppCompatFlagsUser = peb.AppCompatFlagsUser;
220  info->AppCompatInfo = peb.AppCompatInfo;
221  if (peb.pShimData == NULL)
222  return TRUE;
223 
224  dwRead = VirtualQueryEx(proc, (LPCVOID)peb.pShimData, &mbi, sizeof(mbi));
225  ok(dwRead == sizeof(mbi), "Expected VQE to return %u, got %lu\n", sizeof(mbi), dwRead);
226  if (dwRead == sizeof(mbi) || peb.pShimData == NULL)
227  {
228  info->ShimDataSize = mbi.RegionSize;
229  info->pShimData = malloc(mbi.RegionSize);
230  if (readproc(proc, peb.pShimData, info->pShimData, mbi.RegionSize))
231  return TRUE;
232  free(info->pShimData);
233  info->pShimData = NULL;
234  }
235  }
236  }
237  return FALSE;
238 }
#define TRUE
Definition: types.h:120
ULARGE_INTEGER AppCompatFlagsUser
Definition: winternl.h:350
#define free
Definition: debug_ros.c:5
LONG NTSTATUS
Definition: precomp.h:26
static HANDLE proc()
Definition: pdb.c:32
#define FALSE
Definition: types.h:117
static BOOL readproc(HANDLE proc, LPVOID address, PVOID target, DWORD size)
Definition: env.c:191
_Inout_ PERBANDINFO * pbi
Definition: winddi.h:3917
SIZE_T NTAPI VirtualQueryEx(IN HANDLE hProcess, IN LPCVOID lpAddress, OUT PMEMORY_BASIC_INFORMATION lpBuffer, IN SIZE_T dwLength)
Definition: virtmem.c:236
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PVOID AppCompatInfo
Definition: winternl.h:352
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
ULARGE_INTEGER AppCompatFlags
Definition: winternl.h:349
CONST void * LPCVOID
Definition: windef.h:191
unsigned int ULONG
Definition: retypes.h:1
#define malloc
Definition: debug_ros.c:4
#define memset(x, y, z)
Definition: compat.h:39
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
Definition: ps.c:97

Referenced by Test_layers(), and Test_repeatlayer().

◆ HSDB()

HSDB ( WINAPI pSdbInitDatabase)

◆ readproc()

static BOOL readproc ( HANDLE  proc,
LPVOID  address,
PVOID  target,
DWORD  size 
)
static

Definition at line 191 of file env.c.

192 {
193  SIZE_T dwRead;
194  if (ReadProcessMemory(proc, address, target, size, &dwRead))
195  {
196  ok(dwRead == size, "Expected to read %u bytes, got %lu\n", size, dwRead);
197  return dwRead == size;
198  }
199  ok(0, "RPM failed with %u\n", GetLastError());
200  return FALSE;
201 }
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define ReadProcessMemory(a, b, c, d, e)
Definition: compat.h:617
static HANDLE proc()
Definition: pdb.c:32
#define FALSE
Definition: types.h:117
GLsizeiptr size
Definition: glext.h:5919
GLuint address
Definition: glext.h:9393
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define ok(value,...)
Definition: atltest.h:57
GLenum target
Definition: glext.h:7315

Referenced by get_shiminfo(), and TIFFClientOpen().

◆ START_TEST()

START_TEST ( env  )

Definition at line 1245 of file env.c.

1246 {
1247  WCHAR szApphelp[MAX_PATH];
1248  ShimData_QueryOffset QueryOffset;
1249  DWORD ShimDataType;
1250  NTSTATUS ExceptionStatus = STATUS_SUCCESS;
1251 
1252  //SetEnvironmentVariable("SHIM_DEBUG_LEVEL", "127");
1253  //SetEnvironmentVariable("SHIMENG_DEBUG_LEVEL", "127");
1254 
1256 
1257  hdll = LoadLibraryA("apphelp.dll");
1258 
1259 
1260 
1263  trace("Detected host: 0x%x, module: 0x%x\n", g_WinVersion, g_ModuleVersion);
1264 
1265  GetModuleFileNameW(hdll, szApphelp, _countof(szApphelp));
1266 
1267 
1268  pSdbGetMatchingExe = (void*)GetProcAddress(hdll, "SdbGetMatchingExe");
1269  pSdbInitDatabase = (void*)GetProcAddress(hdll, "SdbInitDatabase");
1270  pSdbReleaseDatabase = (void*)GetProcAddress(hdll, "SdbReleaseDatabase");
1271  pSdbTagRefToTagID = (void*)GetProcAddress(hdll, "SdbTagRefToTagID");
1272  pSdbGetTagFromTagID = (void*)GetProcAddress(hdll, "SdbGetTagFromTagID");
1273  pSdbGetLayerTagRef = (void*)GetProcAddress(hdll, "SdbGetLayerTagRef");
1274 
1275  switch (g_ModuleVersion)
1276  {
1277  case WINVER_WIN7:
1278  pApphelpCheckRunAppEx_w7 = (void*)GetProcAddress(hdll, "ApphelpCheckRunAppEx");
1279  break;
1280  case WINVER_WIN10:
1281  pApphelpCheckRunAppEx_w10 = (void*)GetProcAddress(hdll, "ApphelpCheckRunAppEx");
1282  break;
1283  default:
1284  skip("Unknown apphelp.dll version %x, cannot determine which ApphelpCheckRunApp(Ex) function to use\n", g_ModuleVersion);
1285  break;
1286  }
1287 
1288  pSdbPackAppCompatData = (void*)GetProcAddress(hdll, "SdbPackAppCompatData");
1289  pSdbUnpackAppCompatData = (void*)GetProcAddress(hdll, "SdbUnpackAppCompatData");
1290  pSdbGetAppCompatDataSize = (void*)GetProcAddress(hdll, "SdbGetAppCompatDataSize");
1291 
1292 
1293  memset(&QueryOffset, 0, sizeof(QueryOffset));
1294  QueryOffset.dwMagic_2k3 = QueryOffset.dwMagic_7_10 = QueryOffset.dwMagic_10_v2 = SHIMDATA_MAGIC;
1295  QueryOffset.dwSize_2k3 = 1;
1296  QueryOffset.dwSize_7_10 = 2;
1297  QueryOffset.dwSize_10_v2 = 3;
1298 
1299  g_ShimDataSize = g_WinVersion < WINVER_WIN10 ? 4096 : 8192;
1300  _SEH2_TRY
1301  {
1302  ShimDataType = pSdbGetAppCompatDataSize(&QueryOffset);
1303  }
1305  {
1306  ExceptionStatus = _SEH2_GetExceptionCode();
1307  }
1308  _SEH2_END;
1309 
1310  ok(ExceptionStatus == STATUS_SUCCESS, "Exception 0x%08x, expected 0x%08x\n", ExceptionStatus, STATUS_SUCCESS);
1311  if (ExceptionStatus != STATUS_SUCCESS)
1312  {
1313  skip("SdbGetAppCompatDataSize not functional\n");
1314  return;
1315  }
1316 
1317  /* New version of Win10.. */
1318  if (g_WinVersion == WINVER_WIN10 && ShimDataType == 3)
1319  g_ShimDataSize = 4096;
1320 
1322  {
1323  Test_layers(szApphelp);
1324  Test_repeatlayer(szApphelp);
1325  }
1326  else
1327  {
1328  skip("Tests requiring process launch, reported OS version (0x%x) does not match apphelp version (0x%x)\n", g_WinVersion, g_ModuleVersion);
1329  }
1330 
1331  {
1333  }
1334 
1335  Test_ApphelpCheckRunApp(szApphelp);
1336  if (g_LayerDB)
1337  pSdbReleaseDatabase(g_LayerDB);
1338 }
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
static HMODULE hdll
Definition: env.c:35
static void Test_repeatlayer(WCHAR szApphelp[256])
Definition: env.c:511
static void Test_layers(WCHAR szApphelp[256])
Definition: env.c:442
LONG NTSTATUS
Definition: precomp.h:26
DWORD get_module_version(HMODULE mod)
Definition: data.c:811
static DWORD g_ModuleVersion
Definition: env.c:63
_SEH2_TRY
Definition: create.c:4226
DWORD dwMagic_7_10
Definition: env.c:147
DWORD get_host_winver(void)
Definition: data.c:796
DWORD dwMagic_2k3
Definition: env.c:142
#define WINVER_WIN10
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
DWORD dwMagic_10_v2
Definition: env.c:137
static DWORD g_WinVersion
#define trace
Definition: atltest.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static void Test_GetMatchingExe(void)
Definition: env.c:731
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD g_ShimDataSize
Definition: env.c:62
#define WINVER_WIN7
void silence_debug_output(void)
Definition: data.c:841
DWORD dwSize_7_10
Definition: env.c:146
#define SHIMDATA_MAGIC
Definition: env.c:68
static HSDB g_LayerDB
Definition: env.c:61
_SEH2_END
Definition: create.c:4400
#define ok(value,...)
Definition: atltest.h:57
static void Test_ApphelpCheckRunApp(WCHAR szApphelp[256])
Definition: env.c:893
DWORD dwSize_2k3
Definition: env.c:141
#define skip(...)
Definition: atltest.h:64
#define GetProcAddress(x, y)
Definition: compat.h:612
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:40
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define memset(x, y, z)
Definition: compat.h:39
DWORD dwSize_10_v2
Definition: env.c:136

◆ TAG()

TAG ( WINAPI pSdbGetTagFromTagID)

◆ TAGREF()

TAGREF ( WINAPI pSdbGetLayerTagRef)

◆ Test_ApphelpCheckRunApp()

static void Test_ApphelpCheckRunApp ( WCHAR  szApphelp[256])
static

Definition at line 893 of file env.c.

894 {
895  BOOL ret;
897  WCHAR ApplicationName[MAX_PATH], EmptyName[1] = { 0 };
898  DWORD expect_flags = (g_WinVersion < WINVER_WIN10) ? 1 : 0x21;
899 
900  USHORT ExeType;
901  PVOID AppCompatData = NULL, SxsData, DuplicatedEnv, Environment;
902  ULONG AppCompatDataSize, SxsDataSize, FusionFlags;
903  ULONG Reason;
905  int n;
906  /* this are the only interesting bits (with the exception of '1', which is there to invoke the 'default' case) */
907  const int kTestBits = 0x70503;
908 
909  if (!pApphelpCheckRunAppEx_w7 && !pApphelpCheckRunAppEx_w10)
910  {
911  skip("No usable ApphelpCheckRunAppEx\n");
912  return;
913  }
914 
916 
918  SetEnvironmentVariableA("__COMPAT_LAYER", NULL);
919  if (!CreateEnvironmentBlock(&DuplicatedEnv, NULL, TRUE))
920  DuplicatedEnv = NULL;
921  ok(DuplicatedEnv != NULL, "Invalid env (%u)\n", GetLastError());
922 
923  /* First with the environment without __COMPAT_LAYER */
925 
927  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
928 
929  CHECK_BASICS();
930  ok_hex(Reason, CHECKREASON(0x30000, 0));
931  ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
932 
933  /* We need this to be set for tests later on. */
934  SetEnvironmentVariableA("__COMPAT_LAYER", "256Color");
935 
937  {
938  /* Showing that when an environment is passed in, that is used instead of the current.
939  In Win10 this behavior is no longer observed */
940 
942 
944  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
945 
946  CHECK_BASICS();
947  ok_hex(Reason, CHECKREASON(0x30000, 0));
948  ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
949  }
950 
951  for (n = 0; n < 32; ++n)
952  {
953  ULONG ExpectedReason;
954  if (!(kTestBits & (1<<n)))
955  continue;
957  ExpectedReason = Reason = (1 << n);
959  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
960 
961  CHECK_BASICS();
962  if (ExpectedReason == 2)
963  ExpectedReason = 2;
964  else if (ExpectedReason == 0x100)
965  ExpectedReason = 0x30000;
966  else
967  ExpectedReason |= 0x30000;
968  ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
969  ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
970  }
971 
973  {
974  /* Now, using a NULL env, showing that the current environment is used.
975  W10 does no longer do this, so we skip this test here. */
976  Environment = NULL;
977 
979 
981  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
982 
983  CHECK_BASICS();
984  ok_hex(Reason, CHECKREASON(0x50000, 0));
985  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
986  expect_layeronly(AppCompatData, "256Color", expect_flags);
987 
988  for (n = 0; n < 32; ++n)
989  {
990  ULONG ExpectedReason;
992  if (!(kTestBits & (1<<n)))
993  continue;
994  ExpectedReason = Reason = (1 << n);
996  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
997 
998  CHECK_BASICS();
999  if (ExpectedReason == 2)
1000  ExpectedReason = 2;
1001  else if (ExpectedReason == 0x100)
1002  ExpectedReason = 0x50000;
1003  else if (ExpectedReason == 0x400)
1004  ExpectedReason = 0x30400;
1005  else
1006  ExpectedReason |= 0x50000;
1007  ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1008  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1009  {
1010  if (ExpectedReason != 0x30400)
1011  expect_layeronly(AppCompatData, "256Color", expect_flags);
1012  else
1013  ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1014  }
1015  }
1016  }
1017 
1018  /* Passing in an environment with __COMPAT_LAYER set */
1020 
1022 
1024  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1025 
1026  CHECK_BASICS();
1027  ok_hex(Reason, CHECKREASON(0x50000, 0));
1028  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1029  expect_layeronly(AppCompatData, "256Color", expect_flags);
1030 
1031  for (n = 0; n < 32; ++n)
1032  {
1033  ULONG ExpectedReason;
1034  if (!(kTestBits & (1<<n)))
1035  continue;
1037  ExpectedReason = Reason = (1 << n);
1039  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1040 
1041  CHECK_BASICS();
1042  if (ExpectedReason == 2)
1043  ExpectedReason = 2;
1044  else if (ExpectedReason == 0x100)
1045  ExpectedReason = 0x50000;
1046  else if (ExpectedReason == 0x400)
1047  ExpectedReason = 0x30400;
1048  else
1049  ExpectedReason |= 0x50000;
1050  ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1051  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1052  {
1053  if (ExpectedReason != 0x30400 || g_ModuleVersion >= WINVER_WIN10)
1054  expect_layeronly(AppCompatData, "256Color", expect_flags);
1055  else
1056  ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1057  }
1058  }
1059 
1060  /* NULL file handle still works */
1062 
1064  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1065 
1066  CHECK_BASICS();
1067  ok_hex(Reason, CHECKREASON(0x50000, 0));
1068  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1069  expect_layeronly(AppCompatData, "256Color", expect_flags);
1070 
1071  for (n = 0; n < 32; ++n)
1072  {
1073  ULONG ExpectedReason;
1075  if (!(kTestBits & (1<<n)))
1076  continue;
1077  ExpectedReason = Reason = (1 << n);
1079  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1080 
1081  CHECK_BASICS();
1082  if (ExpectedReason == 2)
1083  ExpectedReason = 2;
1084  else if (ExpectedReason == 0x100)
1085  ExpectedReason = 0x50000;
1086  else if (ExpectedReason == 0x400)
1087  ExpectedReason = 0x30400;
1088  else
1089  ExpectedReason |= 0x50000;
1090  ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1091  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1092  {
1093  /* W10 does not use the flags anymore? */
1094  if (ExpectedReason != 0x30400 || g_ModuleVersion >= WINVER_WIN10)
1095  expect_layeronly(AppCompatData, "256Color", expect_flags);
1096  else
1097  ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1098  }
1099  }
1100 
1101 
1102  /* INVALID_HANDLE_VALUE file handle results in failure (according to flags!), but still results in AppCompatData */
1104 
1106  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1107 
1108  CHECK_BASICS();
1109  ok_hex(Reason, 0);
1110  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1111  expect_layeronly(AppCompatData, "256Color", expect_flags);
1112 
1113  for (n = 0; n < 32; ++n)
1114  {
1115  ULONG ExpectedReason;
1116  if (!(kTestBits & (1<<n)))
1117  continue;
1119  ExpectedReason = Reason = (1 << n);
1121  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1122 
1123  CHECK_BASICS();
1124  if (ExpectedReason == 0x100)
1125  ExpectedReason = 0;
1126  ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1127  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1128  {
1129  if (ExpectedReason != 0x400 && g_ModuleVersion < WINVER_WIN7)
1130  expect_layeronly(AppCompatData, "256Color", expect_flags);
1131  else
1132  ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1133  }
1134  }
1135 
1136  /* NULL filename crashes, showing this in the log before going down:
1137 [Err ][SdbpGetLongFileName ] Failed to get NT path name for ""
1138 [Err ][SdbpCreateSearchDBContext] Unable to parse executable path for "".
1139 [Err ][SdbGetMatchingExe ] Failed to create search DB context.
1140 */
1142 
1144  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1145 
1146  CHECK_BASICS();
1147  ok_hex(Reason, CHECKREASON(0x30000, 0));
1148  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1149  ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1150 
1151  /* 0 ExeType = don't care? */
1153  ExeType = 0;
1154 
1156  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1157 
1158  CHECK_BASICS();
1159  ok_hex(Reason, CHECKREASON(0x50000, 0));
1160  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1161  expect_layeronly(AppCompatData, "256Color", expect_flags);
1162 
1163  for (n = 0; n < 32; ++n)
1164  {
1165  ULONG ExpectedReason;
1166  if (!(kTestBits & (1<<n)))
1167  continue;
1169  ExeType = 0;
1170  ExpectedReason = Reason = (1 << n);
1172  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1173 
1174  CHECK_BASICS();
1175  if (ExpectedReason == 2)
1176  ExpectedReason = 2;
1177  else if (ExpectedReason == 0x100)
1178  ExpectedReason = 0x50000;
1179  else if (ExpectedReason == 0x400)
1180  ExpectedReason = 0x30400;
1181  else
1182  ExpectedReason |= 0x50000;
1183  ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1184  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1185  {
1186  if (ExpectedReason != 0x30400 || g_ModuleVersion >= WINVER_WIN10)
1187  expect_layeronly(AppCompatData, "256Color", expect_flags);
1188  else
1189  ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1190  }
1191  }
1192 
1193 
1196 
1198  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1199 
1200  CHECK_BASICS();
1201  ok_hex(Reason, CHECKREASON(0x50000, 0));
1202  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1203  expect_layeronly(AppCompatData, "256Color", expect_flags);
1204 
1205  for (n = 0; n < 32; ++n)
1206  {
1207  ULONG ExpectedReason;
1208  if (!(kTestBits & (1<<n)))
1209  continue;
1212  ExpectedReason = Reason = (1 << n);
1214  &AppCompatData, &AppCompatDataSize, &SxsData, &SxsDataSize, &FusionFlags);
1215 
1216  CHECK_BASICS();
1217  if (ExpectedReason == 2)
1218  ExpectedReason = 2;
1219  else if (ExpectedReason == 0x100)
1220  ExpectedReason = 0x50000;
1221  else if (ExpectedReason == 0x400)
1222  ExpectedReason = 0x30400;
1223  else
1224  ExpectedReason |= 0x50000;
1225  ok_hex(Reason, CHECKREASON(ExpectedReason, (1 << n)));
1226  if (AppCompatData && AppCompatDataSize == sizeof(SDBQUERYRESULT_VISTA))
1227  {
1228  if (ExpectedReason != 0x30400 || g_ModuleVersion >= WINVER_WIN10)
1229  expect_layeronly(AppCompatData, "256Color", expect_flags);
1230  else
1231  ok(!memcmp(AppCompatData, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
1232  }
1233  }
1234 
1235 
1236  if (AppCompatData && AppCompatData != &Query)
1237  RtlFreeHeap(RtlGetProcessHeap(), 0, AppCompatData);
1238 
1240  DestroyEnvironmentBlock(DuplicatedEnv);
1242 }
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:865
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
PVOID PVOID PWCHAR PVOID Environment
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG PULONG FusionFlags
Definition: env.c:47
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
GLdouble n
Definition: glext.h:7729
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define expect_layeronly
Definition: env.c:728
static DWORD g_ModuleVersion
Definition: env.c:63
BOOL WINAPI CreateEnvironmentBlock(OUT LPVOID *lpEnvironment, IN HANDLE hToken, IN BOOL bInherit)
Definition: environment.c:505
#define ok_hex(expression, result)
Definition: atltest.h:94
HANDLE FileHandle
Definition: stats.c:38
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINVER_WIN10
static DWORD g_WinVersion
BOOL WINAPI FreeEnvironmentStringsW(IN LPWSTR EnvironmentStrings)
Definition: environ.c:389
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
Definition: environ.c:218
#define MAX_PATH
Definition: compat.h:34
static const SDBQUERYRESULT_VISTA empty_result
Definition: env.c:64
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Query(LPCTSTR *ServiceArgs, DWORD ArgCount, BOOL bExtended)
Definition: query.c:292
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3398
int ret
#define WINVER_WIN7
BOOL WINAPI DestroyEnvironmentBlock(IN LPVOID lpEnvironment)
Definition: environment.c:727
PVOID PVOID PWCHAR ApplicationName
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT ExeType
Definition: env.c:47
unsigned short USHORT
Definition: pedump.c:61
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID PULONG SxsDataSize
Definition: env.c:47
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
LPWSTR WINAPI GetEnvironmentStringsW(VOID)
Definition: environ.c:344
#define skip(...)
Definition: atltest.h:64
unsigned int ULONG
Definition: retypes.h:1
PVOID PVOID PWCHAR PVOID USHORT PULONG PVOID PULONG PVOID * SxsData
Definition: env.c:47
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:47
HANDLE xOpenFile(WCHAR *ApplicationName)
Definition: env.c:804
#define CHECKREASON(value, w10dum)
Definition: env.c:862
#define IMAGE_FILE_MACHINE_POWERPCFP
Definition: ntimage.h:28
#define RESET_CHECKRUNAPP_VARS()
Definition: env.c:840
#define CHECK_BASICS()
Definition: env.c:851

Referenced by START_TEST().

◆ Test_GetMatchingExe()

static void Test_GetMatchingExe ( void  )
static

Definition at line 731 of file env.c.

732 {
733  BOOL ret;
734  SDBQUERYRESULT_VISTA result = { { 0 } };
735  WCHAR self[MAX_PATH];
736  DWORD flags = (g_WinVersion < WINVER_VISTA) ? 0 : ((g_WinVersion < WINVER_WIN10) ? 1 : 0x21);
737 
739  SetEnvironmentVariableA("__COMPAT_LAYER", NULL);
740 
741  /* szPath cannot be NULL! */
742  ret = pSdbGetMatchingExe(NULL, L"", NULL, NULL, 0, &result);
743  ok(ret == FALSE, "Expected ret to be FALSE\n");
744  ok(!memcmp(&result, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
745 
747 
748  ret = pSdbGetMatchingExe(NULL, self, NULL, NULL, 0, &result);
749  ok(ret == FALSE, "Expected ret to be FALSE\n");
750  ok(!memcmp(&result, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
751 
753  SetEnvironmentVariableA("__COMPAT_LAYER", "Some_invalid_layer_name");
754 
755  ret = pSdbGetMatchingExe(NULL, self, NULL, NULL, 0, &result);
756  ok(ret == FALSE, "Expected ret to be FALSE\n");
758  ok(!memcmp(&result, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
759  else
760  ok(!memcmp(&result, &almost_empty, sizeof(almost_empty)), "Expected result to be almost empty\n");
761 
763  SetEnvironmentVariableA("__COMPAT_LAYER", "256Color");
764 
765  ret = pSdbGetMatchingExe(NULL, self, NULL, NULL, 0, &result);
766  ok(ret == TRUE, "Expected ret to be TRUE\n");
767  expect_layeronly(&result, "256Color", flags);
768 
769  Test_Shimdata(&result, L"256Color");
770 
772  SetEnvironmentVariableA("__COMPAT_LAYER", "640X480");
773 
774  ret = pSdbGetMatchingExe(NULL, self, NULL, NULL, 0, &result);
775  ok(ret == TRUE, "Expected ret to be TRUE\n");
776  expect_layeronly(&result, "640X480", flags);
777 
778  Test_Shimdata(&result, L"640X480");
779 
780  /* HIGHDPIAWARE does not exist in 2k3 */
782  {
784  SetEnvironmentVariableA("__COMPAT_LAYER", "HIGHDPIAWARE");
785 
786  ret = pSdbGetMatchingExe(NULL, self, NULL, NULL, 0, &result);
787  ok(ret == TRUE, "Expected ret to be TRUE\n");
788  expect_layeronly(&result, "HIGHDPIAWARE", flags);
789 
790  Test_Shimdata(&result, L"HIGHDPIAWARE");
791 
793  SetEnvironmentVariableA("__COMPAT_LAYER", "256Color HIGHDPIAWARE 640X480");
794 
795  ret = pSdbGetMatchingExe(NULL, self, NULL, NULL, 0, &result);
796  ok(ret == TRUE, "Expected ret to be TRUE\n");
797  expect_layeronly(&result, "256Color HIGHDPIAWARE 640X480", flags);
798 
799  Test_Shimdata(&result, L"256Color HIGHDPIAWARE 640X480");
800  }
801 }
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLuint64EXT * result
Definition: glext.h:11304
#define TRUE
Definition: types.h:120
static void Test_Shimdata(SDBQUERYRESULT_VISTA *result, const WCHAR *szLayer)
Definition: env.c:625
#define expect_layeronly
Definition: env.c:728
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINVER_WIN10
static DWORD g_WinVersion
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
Definition: environ.c:218
#define MAX_PATH
Definition: compat.h:34
static const SDBQUERYRESULT_VISTA empty_result
Definition: env.c:64
unsigned long DWORD
Definition: ntddk_ex.h:95
static const SDBQUERYRESULT_VISTA almost_empty
Definition: env.c:65
GLbitfield flags
Definition: glext.h:7161
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define WINVER_VISTA
#define WINVER_2003
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ Test_layers()

static void Test_layers ( WCHAR  szApphelp[256])
static

Definition at line 442 of file env.c.

443 {
444  static const char* layers[] = {
445  "256Color", "NT4SP5", "DisableNXHideUI", "DisableNXShowUI",
446  "WIN2000SP3", "640X480", /*"DISABLEDWM",*/ "HIGHDPIAWARE",
447  /*"RUNASADMIN",*/ "DISABLETHEMES" /*, "Layer_Win95VersionLie"*/ };
448 
449  size_t n;
450  HANDLE proc;
452  BOOL res;
453 
454  for (n = 0; n <= (sizeof(layers) / sizeof(layers[0])); ++n)
455  {
456  create_environ(layers, n);
457 
458  proc = create_proc(TRUE);
459  res = get_shiminfo(proc, &info);
461  CloseHandle(proc);
462 
463  if (!res)
464  {
465  ok(0, "Unable to get process info (%u)!\n", n);
466  continue;
467  }
468 
469  if (n == 0)
470  {
471  ok(info.AppCompatFlags.QuadPart == 0, "Expected AppCompatFlags to be 0, was: %s\n", wine_dbgstr_longlong(info.AppCompatFlags.QuadPart));
472  ok(info.AppCompatFlagsUser.QuadPart == 0, "Expected AppCompatFlagsUser to be 0, was: %s\n", wine_dbgstr_longlong(info.AppCompatFlagsUser.QuadPart));
473  ok(info.AppCompatInfo == NULL, "Expected AppCompatInfo to be NULL, was: %p\n", info.AppCompatInfo);
475  {
476  ok(info.pShimData == NULL, "Expected pShimData to be NULL, was: %p\n", info.pShimData);
477  }
478  else
479  {
481  }
482  }
483  else
484  {
485  ok(info.AppCompatFlags.QuadPart == 0, "Expected AppCompatFlags to be 0, was: %s\n", wine_dbgstr_longlong(info.AppCompatFlags.QuadPart));
486  ok(info.AppCompatFlagsUser.QuadPart == 0, "Expected AppCompatFlagsUser to be 0, was: %s\n", wine_dbgstr_longlong(info.AppCompatFlagsUser.QuadPart));
487  ok(info.AppCompatInfo == NULL, "Expected AppCompatInfo to be NULL, was: %p\n", info.AppCompatInfo);
488  ok(info.pShimData != NULL, "Expected pShimData to be valid, was NULL\n");
489  ok(info.ShimDataSize == g_ShimDataSize, "Expected ShimDataSize to be %u, was: %u\n", g_ShimDataSize, info.ShimDataSize);
490  if (info.pShimData)
491  {
493  Validate_ShimData_Win2k3(info.pShimData, n, layers);
494  else if (g_WinVersion < WINVER_WIN10)
495  Validate_ShimData_Win7(info.pShimData, szApphelp, n, layers);
496  else
497  Validate_ShimData_Win10(info.pShimData, szApphelp, n, layers);
498  }
499  }
500  free(info.pShimData);
501  }
502 }
#define CloseHandle
Definition: compat.h:598
#define TRUE
Definition: types.h:120
static void Validate_EmptyShimData_Win10(PVOID data)
Definition: env.c:413
#define free
Definition: debug_ros.c:5
GLdouble n
Definition: glext.h:7729
static HANDLE create_proc(BOOL suspended)
Definition: env.c:240
static HANDLE proc()
Definition: pdb.c:32
static void create_environ(const char *layers[], size_t num)
Definition: env.c:258
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINVER_WIN10
static BOOL get_shiminfo(HANDLE proc, test_RemoteShimInfo *info)
Definition: env.c:203
static DWORD g_WinVersion
struct _test_info info[]
Definition: SetCursorPos.c:19
static DWORD g_ShimDataSize
Definition: env.c:62
#define WINVER_VISTA
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
static void Validate_ShimData_Win2k3(PVOID data, size_t count, const char *layers[])
Definition: env.c:300
static void Validate_ShimData_Win7(PVOID data, WCHAR szApphelp[256], size_t count, const char *layers[])
Definition: env.c:311
static void Validate_ShimData_Win10(PVOID data, WCHAR szApphelp[256], size_t count, const char *layers[])
Definition: env.c:377

Referenced by START_TEST().

◆ Test_repeatlayer()

static void Test_repeatlayer ( WCHAR  szApphelp[256])
static

Definition at line 511 of file env.c.

512 {
513  static const char* layers[] = {
514  "256Color", "256Color", "256Color", "256Color",
515  "256Color", "256Color", "256Color", "256Color" };
516 
517  HANDLE proc;
519  BOOL res;
520 
521  SetEnvironmentVariableA("__COMPAT_LAYER", "256Color 256Color 256Color 256Color 256Color 256Color 256Color 256Color");
522 
523 
524  proc = create_proc(TRUE);
525  res = get_shiminfo(proc, &info);
527  CloseHandle(proc);
528 
529  if (res)
530  {
531  ok(info.AppCompatFlags.QuadPart == 0, "Expected AppCompatFlags to be 0, was: %s\n", wine_dbgstr_longlong(info.AppCompatFlags.QuadPart));
532  ok(info.AppCompatFlagsUser.QuadPart == 0, "Expected AppCompatFlagsUser to be 0, was: %s\n", wine_dbgstr_longlong(info.AppCompatFlagsUser.QuadPart));
533  ok(info.AppCompatInfo == 0, "Expected AppCompatInfo to be 0, was: %p\n", info.AppCompatInfo);
534  ok(info.pShimData != NULL, "Expected pShimData to be valid, was NULL\n");
535  ok(info.ShimDataSize == g_ShimDataSize, "Expected ShimDataSize to be %u, was: %u\n", g_ShimDataSize, info.ShimDataSize);
536  if (info.pShimData)
537  {
538  /* Win10 only 'loads' one layer */
540  Validate_ShimData_Win2k3(info.pShimData, SDB_MAX_LAYERS, layers);
541  else if (g_WinVersion < WINVER_WIN10)
542  Validate_ShimData_Win7(info.pShimData, szApphelp, SDB_MAX_LAYERS, layers);
543  else
544  Validate_ShimData_Win10(info.pShimData, szApphelp, 1, layers);
545  }
546  }
547  else
548  {
549  ok(0, "Unable to get process info!\n");
550  }
551 
552 }
#define CloseHandle
Definition: compat.h:598
#define TRUE
Definition: types.h:120
static HANDLE create_proc(BOOL suspended)
Definition: env.c:240
static HANDLE proc()
Definition: pdb.c:32
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINVER_WIN10
static BOOL get_shiminfo(HANDLE proc, test_RemoteShimInfo *info)
Definition: env.c:203
static DWORD g_WinVersion
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableA(IN LPCSTR lpName, IN LPCSTR lpValue)
Definition: environ.c:218
struct _test_info info[]
Definition: SetCursorPos.c:19
static DWORD g_ShimDataSize
Definition: env.c:62
#define WINVER_VISTA
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
static void Validate_ShimData_Win2k3(PVOID data, size_t count, const char *layers[])
Definition: env.c:300
static void Validate_ShimData_Win7(PVOID data, WCHAR szApphelp[256], size_t count, const char *layers[])
Definition: env.c:311
#define SDB_MAX_LAYERS
Definition: apphelp.h:44
static void Validate_ShimData_Win10(PVOID data, WCHAR szApphelp[256], size_t count, const char *layers[])
Definition: env.c:377

Referenced by START_TEST().

◆ Test_Shimdata()

static void Test_Shimdata ( SDBQUERYRESULT_VISTA result,
const WCHAR szLayer 
)
static

Definition at line 625 of file env.c.

626 {
627  BOOL ret;
628  PVOID pData;
629  DWORD dwSize;
630 
631  pData = NULL;
632  dwSize = 0;
633  ret = pSdbPackAppCompatData(g_LayerDB, result, &pData, &dwSize);
634  ok(ret == TRUE, "Expected ret to be TRUE\n");
635 
636  if (pData)
637  {
638  ShimData_Win2k3* pWin2k3;
639  ShimData_Win7* pWin7;
640  ShimData_Win10_v1* pWin10;
641  ShimData_Win10_v2* pWin10_v2;
642  SDBQUERYRESULT_VISTA result2 = { { 0 } };
643 
644  DWORD res = pSdbGetAppCompatDataSize(pData);
645  ok_int(dwSize, res);
646  switch(dwSize)
647  {
648  case sizeof(ShimData_Win2k3):
649  pWin2k3 = (ShimData_Win2k3*)pData;
650  ok_hex(pWin2k3->dwMagic, SHIMDATA_MAGIC);
651  ok_int(pWin2k3->dwSize, dwSize);
652  ok(pWin2k3->dwCustomSDBMap == 1, "Expected pWin2k3->dwCustomSDBMap to equal 1, was %u for %s\n", pWin2k3->dwCustomSDBMap, wine_dbgstr_w(szLayer));
653  //ok(!memcmp(&pWin2k3->Query, result, sizeof(SDBQUERYRESULT_2k3)), "Expected pWin2k3->Query to equal result\n");
654  //ok_wstr(pWin7->szLayer, szLayer);
655  break;
656  case sizeof(ShimData_Win7):
657  pWin7 = (ShimData_Win7*)pData;
658  ok_hex(pWin7->dwMagic, SHIMDATA_MAGIC);
659  ok_int(pWin7->dwSize, dwSize);
660  ok(!memcmp(&pWin7->Query, result, sizeof(*result)), "Expected pWin7->Query to equal result\n");
661  ok_wstr(pWin7->szLayer, szLayer);
662  break;
663  case sizeof(ShimData_Win10_v1):
664  pWin10 = (ShimData_Win10_v1*)pData;
665  ok_hex(pWin10->dwMagic, SHIMDATA_MAGIC);
666  ok_int(pWin10->dwSize, dwSize);
667  ok(!memcmp(&pWin10->Query, result, sizeof(*result)), "Expected pWin10->Query to equal result\n");
668  ok_wstr(pWin10->szLayerEnv, szLayer);
669  ok_wstr(pWin10->szLayer, L"");
670  break;
671  case sizeof(ShimData_Win10_v2):
672  pWin10_v2 = (ShimData_Win10_v2*)pData;
673  ok_hex(pWin10_v2->dwMagic, SHIMDATA_MAGIC);
674  ok_int(pWin10_v2->dwSize, dwSize);
675  ok(!memcmp(&pWin10_v2->Query, result, sizeof(*result)), "Expected pWin10->Query to equal result\n");
676  ok_wstr(pWin10_v2->szLayerEnv, szLayer);
677  ok_wstr(pWin10_v2->szLayer, L"");
678  break;
679  default:
680  skip("Unknown size %d\n", dwSize);
681  break;
682  }
683 
684  ret = pSdbUnpackAppCompatData(g_LayerDB, NULL, pData, &result2);
685  ok(ret == TRUE, "Expected ret to be TRUE\n");
686  /* TODO: For some reason 2k3 does not seem to output the database GUIDs,
687  investigate when we have support for multible db's! */
688  if (dwSize == sizeof(ShimData_Win2k3))
689  {
692  const GUID rgGuidDB0 = {0x11111111, 0x1111, 0x1111, {0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11}};
693 
694  // Check expected data.
695  ok(input->dwLayerCount == 1,
696  "Expected input->dwLayerCount to be 1, was %u for %s\n",
697  input->dwLayerCount, wine_dbgstr_w(szLayer));
698  ok(input->dwCustomSDBMap == 1,
699  "Expected input->dwCustomSDBMap to be 1, was %u for %s\n",
700  input->dwCustomSDBMap, wine_dbgstr_w(szLayer));
701  ok(IsEqualGUID(&input->rgGuidDB[0], &rgGuidDB0),
702  "Expected input->rgGuidDB[0] to be %s, was %s for %s\n",
703  wine_dbgstr_guid(&rgGuidDB0), wine_dbgstr_guid(&input->rgGuidDB[0]), wine_dbgstr_w(szLayer));
704 
705  // Check missing data.
706  ok(output->dwLayerCount == 0,
707  "Expected output->dwLayerCount to be 0, was %u for %s\n",
708  output->dwLayerCount, wine_dbgstr_w(szLayer));
709  ok(output->dwCustomSDBMap == 0,
710  "Expected output->dwCustomSDBMap to be 0, was %u for %s\n",
711  output->dwCustomSDBMap, wine_dbgstr_w(szLayer));
712  ok(IsEqualGUID(&output->rgGuidDB[0], &empty_result.rgGuidDB[0]),
713  "Expected output->rgGuidDB[0] to be empty, was %s for %s\n",
714  wine_dbgstr_guid(&output->rgGuidDB[0]), wine_dbgstr_w(szLayer));
715 
716  // Fake it for now, so the memcmp works.
717  output->dwLayerCount = input->dwLayerCount;
718  output->dwCustomSDBMap = input->dwCustomSDBMap;
719  output->rgGuidDB[0] = input->rgGuidDB[0];
720  }
721  ok(!memcmp(&result2, result, sizeof(*result)), "Expected result2 to equal result for %s\n", wine_dbgstr_w(szLayer));
722 
724  }
725 }
WCHAR szLayer[MAX_LAYER_LENGTH]
Definition: env.c:105
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
DWORD dwMagic
Definition: env.c:92
WCHAR szLayerEnv[MAX_LAYER_LENGTH]
Definition: env.c:111
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLuint64EXT * result
Definition: glext.h:11304
#define TRUE
Definition: types.h:120
struct ShimData_Win7 ShimData_Win7
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
const char * wine_dbgstr_guid(const GUID *guid)
DWORD dwMagic
Definition: env.c:119
DWORD dwMagic
Definition: env.c:76
#define ok_hex(expression, result)
Definition: atltest.h:94
DWORD dwMagic
Definition: env.c:102
WCHAR szLayer[MAX_LAYER_LENGTH]
Definition: env.c:94
DWORD dwCustomSDBMap
Definition: env.c:82
DWORD dwSize
Definition: env.c:91
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD dwSize
Definition: env.c:75
SDBQUERYRESULT_VISTA Query
Definition: env.c:104
#define ok_int(expression, result)
Definition: atltest.h:134
SDBQUERYRESULT_VISTA Query
Definition: env.c:122
struct ShimData_Win2k3 ShimData_Win2k3
#define GetProcessHeap()
Definition: compat.h:595
struct ShimData_Win10_v1 ShimData_Win10_v1
static const SDBQUERYRESULT_VISTA empty_result
Definition: env.c:64
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define ok_wstr(x, y)
Definition: atltest.h:130
WCHAR szLayerEnv[MAX_LAYER_LENGTH]
Definition: env.c:129
#define SHIMDATA_MAGIC
Definition: env.c:68
WCHAR szLayer[MAX_LAYER_LENGTH]
Definition: env.c:123
static HSDB g_LayerDB
Definition: env.c:61
GUID rgGuidDB[SDB_MAX_SDBS]
GLenum GLenum GLenum input
Definition: glext.h:9031
DWORD dwSize
Definition: env.c:118
DWORD dwSize
Definition: env.c:101
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define skip(...)
Definition: atltest.h:64
GLuint res
Definition: glext.h:9613
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
SDBQUERYRESULT_VISTA Query
Definition: env.c:93
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
LPCWSTR PVOID pData
Definition: env.c:57
struct ShimData_Win10_v2 ShimData_Win10_v2

Referenced by Test_GetMatchingExe().

◆ Validate_EmptyShimData_Win10()

static void Validate_EmptyShimData_Win10 ( PVOID  data)
static

Definition at line 413 of file env.c.

414 {
416  ok(pShimData != NULL, "Expected pShimData\n");
417  if (!pShimData)
418  return;
419 
420  if (pShimData->dwMagic != SHIMDATA_MAGIC)
421  {
422  ShimData_Win10_v2* pShimData2 = (ShimData_Win10_v2*)data;
423  if (pShimData2->dwMagic != SHIMDATA_MAGIC)
424  {
425  skip("Unknown shimdata (win10)\n");
426  return;
427  }
428 
429  ok(!lstrcmpiW(pShimData2->szLayer, L""), "Expected pShimData->szLayer to be '', was %s\n", wine_dbgstr_w(pShimData2->szLayer));
430  ok(pShimData2->dwSize == sizeof(ShimData_Win10_v2), "Expected pShimData->dwSize to be %u, was %u\n", sizeof(ShimData_Win10_v2), pShimData2->dwSize);
431  ok(!memcmp(&pShimData2->Query, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
432  }
433  else
434  {
435  ok(!lstrcmpiW(pShimData->szModule, L""), "Expected pShimData->Module to be '', was %s\n", wine_dbgstr_w(pShimData->szModule));
436  ok(!lstrcmpiW(pShimData->szLayer, L""), "Expected pShimData->szLayer to be '', was %s\n", wine_dbgstr_w(pShimData->szLayer));
437  ok(pShimData->dwSize == sizeof(ShimData_Win10_v1), "Expected pShimData->dwSize to be %u, was %u\n", sizeof(ShimData_Win10_v1), pShimData->dwSize);
438  ok(!memcmp(&pShimData->Query, &empty_result, sizeof(empty_result)), "Expected result to be empty\n");
439  }
440 }
WCHAR szLayer[MAX_LAYER_LENGTH]
Definition: env.c:105
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
DWORD dwMagic
Definition: env.c:119
DWORD dwMagic
Definition: env.c:102
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
SDBQUERYRESULT_VISTA Query
Definition: env.c:104
SDBQUERYRESULT_VISTA Query
Definition: env.c:122
static const SDBQUERYRESULT_VISTA empty_result
Definition: env.c:64
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static const WCHAR L[]
Definition: oid.c:1250
#define SHIMDATA_MAGIC
Definition: env.c:68
WCHAR szLayer[MAX_LAYER_LENGTH]
Definition: env.c:123
DWORD dwSize
Definition: env.c:118
DWORD dwSize
Definition: env.c:101
WCHAR szModule[260]
Definition: env.c:100
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64

Referenced by Test_layers().

◆ Validate_ShimData_Win10()

static void Validate_ShimData_Win10 ( PVOID  data,
WCHAR  szApphelp[256],
size_t  count,
const char layers[] 
)
static

Definition at line 377 of file env.c.

378 {
379  size_t n;
381 
382  if (pShimData->dwMagic != SHIMDATA_MAGIC)
383  {
384  Validate_ShimData_Win10_v2(data, szApphelp, count, layers);
385  return;
386  }
387 
388 
389  ok(!lstrcmpiW(pShimData->szModule, szApphelp), "Expected pShimData->Module to be %s, was %s\n",
390  wine_dbgstr_w(szApphelp), wine_dbgstr_w(pShimData->szModule));
391  ok(pShimData->dwSize == sizeof(ShimData_Win10_v1), "Expected pShimData->dwSize to be %u, was %u\n",
392  sizeof(ShimData_Win10_v1), pShimData->dwSize);
393  if (pShimData->Query.dwLayerCount != min(count, SDB_MAX_LAYERS))
394  {
395  char buf[250] = {0};
396  GetEnvironmentVariableA("__COMPAT_LAYER", buf, _countof(buf));
397  trace("At test: %s\n", buf);
398  }
399  ok(pShimData->Query.dwLayerCount == min(count, SDB_MAX_LAYERS),
400  "Expected LayerCount to be %u, was %u\n", min(count, SDB_MAX_LAYERS), pShimData->Query.dwLayerCount);
401  for (n = 0; n < SDB_MAX_LAYERS; ++n)
402  {
403  if (n < count)
404  {
405  ok(pShimData->Query.atrLayers[n] != 0, "Expected to find a valid layer in index %u / %u\n", n, count);
406  ValidateShim(pShimData->Query.atrLayers[n], layers[n]);
407  }
408  else
409  ok(pShimData->Query.atrLayers[n] == 0, "Expected to find an empty layer in index %u / %u\n", n, count);
410  }
411 }
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
DWORD dwMagic
Definition: env.c:102
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
SDBQUERYRESULT_VISTA Query
Definition: env.c:104
#define trace
Definition: atltest.h:70
#define GetEnvironmentVariableA(x, y, z)
Definition: compat.h:613
#define _countof(array)
Definition: sndvol32.h:68
static void Validate_ShimData_Win10_v2(PVOID data, WCHAR szApphelp[256], size_t count, const char *layers[])
Definition: env.c:343
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static void ValidateShim(TAGREF trLayer, const char *name)
Definition: env.c:271
#define SHIMDATA_MAGIC
Definition: env.c:68
TAGREF atrLayers[SDB_MAX_LAYERS]
DWORD dwSize
Definition: env.c:101
WCHAR szModule[260]
Definition: env.c:100
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
#define SDB_MAX_LAYERS
Definition: apphelp.h:44

Referenced by Test_layers(), and Test_repeatlayer().

◆ Validate_ShimData_Win10_v2()

static void Validate_ShimData_Win10_v2 ( PVOID  data,
WCHAR  szApphelp[256],
size_t  count,
const char layers[] 
)
static

Definition at line 343 of file env.c.

344 {
345  size_t n;
347 
348  if (pShimData->dwMagic != SHIMDATA_MAGIC)
349  {
350  skip("Yet another unknown shimdata variant...\n");
351  return;
352  }
353 
354  ok(pShimData->dwSize == sizeof(ShimData_Win10_v2), "Expected pShimData->dwSize to be %u, was %u\n",
355  sizeof(ShimData_Win10_v2), pShimData->dwSize);
356  if (pShimData->Query.dwLayerCount != min(count, SDB_MAX_LAYERS))
357  {
358  char buf[250] = {0};
359  GetEnvironmentVariableA("__COMPAT_LAYER", buf, _countof(buf));
360  trace("At test: %s\n", buf);
361  }
362  ok(pShimData->Query.dwLayerCount == min(count, SDB_MAX_LAYERS),
363  "Expected LayerCount to be %u, was %u\n", min(count, SDB_MAX_LAYERS), pShimData->Query.dwLayerCount);
364  for (n = 0; n < SDB_MAX_LAYERS; ++n)
365  {
366  if (n < count)
367  {
368  ok(pShimData->Query.atrLayers[n] != 0, "Expected to find a valid layer in index %u / %u\n", n, count);
369  ValidateShim(pShimData->Query.atrLayers[n], layers[n]);
370  }
371  else
372  ok(pShimData->Query.atrLayers[n] == 0, "Expected to find an empty layer in index %u / %u\n", n, count);
373  }
374 
375 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
DWORD dwMagic
Definition: env.c:119
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
SDBQUERYRESULT_VISTA Query
Definition: env.c:122
#define trace
Definition: atltest.h:70
#define GetEnvironmentVariableA(x, y, z)
Definition: compat.h:613
#define _countof(array)
Definition: sndvol32.h:68
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static void ValidateShim(TAGREF trLayer, const char *name)
Definition: env.c:271
#define SHIMDATA_MAGIC
Definition: env.c:68
TAGREF atrLayers[SDB_MAX_LAYERS]
DWORD dwSize
Definition: env.c:118
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
#define skip(...)
Definition: atltest.h:64
#define SDB_MAX_LAYERS
Definition: apphelp.h:44

Referenced by Validate_ShimData_Win10().

◆ Validate_ShimData_Win2k3()

static void Validate_ShimData_Win2k3 ( PVOID  data,
size_t  count,
const char layers[] 
)
static

Definition at line 300 of file env.c.

301 {
302  //size_t n;
303  ShimData_Win2k3* pShimData = (ShimData_Win2k3*)data;
304 
305  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));
306  ok(pShimData->dwMagic == SHIMDATA_MAGIC, "Expected pShimData->dwMagic to be 0x%x, was 0x%x\n", SHIMDATA_MAGIC, pShimData->dwMagic);
307  ok(pShimData->dwSize == sizeof(ShimData_Win2k3), "Expected pShimData->dwSize to be %u, was %u\n", sizeof(ShimData_Win2k3), pShimData->dwSize);
308  ok(pShimData->dwCustomSDBMap == 1, "Expected pShimData->dwCustomSDBMap to be 1, was %u\n", pShimData->dwCustomSDBMap);
309 }
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
DWORD dwMagic
Definition: env.c:76
DWORD dwCustomSDBMap
Definition: env.c:82
DWORD dwSize
Definition: env.c:75
WCHAR szModule[34]
Definition: env.c:74
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static const WCHAR L[]
Definition: oid.c:1250
#define SHIMDATA_MAGIC
Definition: env.c:68
#define ok(value,...)
Definition: atltest.h:57

Referenced by Test_layers(), and Test_repeatlayer().

◆ Validate_ShimData_Win7()

static void Validate_ShimData_Win7 ( PVOID  data,
WCHAR  szApphelp[256],
size_t  count,
const char layers[] 
)
static

Definition at line 311 of file env.c.

312 {
313  size_t n;
314  ShimData_Win7* pShimData = (ShimData_Win7*)data;
315 
316  ok(!lstrcmpW(pShimData->szModule, szApphelp), "Expected pShimData->Module to be %s, was %s\n",
317  wine_dbgstr_w(szApphelp), wine_dbgstr_w(pShimData->szModule));
318  ok(pShimData->dwMagic == SHIMDATA_MAGIC, "Expected pShimData->dwMagic to be 0x%x, was 0x%x\n",
319  SHIMDATA_MAGIC, pShimData->dwMagic);
320  ok(pShimData->dwSize == sizeof(ShimData_Win7), "Expected pShimData->dwSize to be %u, was %u\n",
321  sizeof(ShimData_Win7), pShimData->dwSize);
322  if (pShimData->Query.dwLayerCount != min(count, SDB_MAX_LAYERS))
323  {
324  char buf[250] = {0};
325  GetEnvironmentVariableA("__COMPAT_LAYER", buf, _countof(buf));
326  trace("At test: %s\n", buf);
327  }
328  ok(pShimData->Query.dwLayerCount == min(count, SDB_MAX_LAYERS),
329  "Expected LayerCount to be %u, was %u\n", min(count, SDB_MAX_LAYERS), pShimData->Query.dwLayerCount);
330  for (n = 0; n < SDB_MAX_LAYERS; ++n)
331  {
332  if (n < count)
333  {
334  ok(pShimData->Query.atrLayers[n] != 0, "Expected to find a valid layer in index %u / %u\n", n, count);
335  ValidateShim(pShimData->Query.atrLayers[n], layers[n]);
336  }
337  else
338  ok(pShimData->Query.atrLayers[n] == 0, "Expected to find an empty layer in index %u / %u\n", n, count);
339  }
340  ok(pShimData->unknown == 0x14c, "Expected pShimData->unknown to be 0x14c, was 0x%x\n", pShimData->unknown);
341 }
DWORD unknown
Definition: env.c:95
WCHAR szModule[260]
Definition: env.c:90
DWORD dwMagic
Definition: env.c:92
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
DWORD dwSize
Definition: env.c:91
#define trace
Definition: atltest.h:70
#define GetEnvironmentVariableA(x, y, z)
Definition: compat.h:613
#define _countof(array)
Definition: sndvol32.h:68
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static void ValidateShim(TAGREF trLayer, const char *name)
Definition: env.c:271
#define SHIMDATA_MAGIC
Definition: env.c:68
TAGREF atrLayers[SDB_MAX_LAYERS]
#define ok(value,...)
Definition: atltest.h:57
#define min(a, b)
Definition: monoChain.cc:55
#define SDB_MAX_LAYERS
Definition: apphelp.h:44
SDBQUERYRESULT_VISTA Query
Definition: env.c:93

Referenced by Test_layers(), and Test_repeatlayer().

◆ ValidateShim()

static void ValidateShim ( TAGREF  trLayer,
const char name 
)
static

Definition at line 271 of file env.c.

272 {
273  HSDB hsdb = pSdbInitDatabase(SDB_DATABASE_MAIN_SHIM, NULL);
274  ok(hsdb != NULL, "Expected a valid handle\n");
275  if (hsdb)
276  {
277  PDB pdb = NULL;
278  TAGID tagid = 0xdeadbeef;
279  WCHAR nameW[256] = { 0 };
280  BOOL ret;
281 
283 
284  ret = pSdbTagRefToTagID(hsdb, trLayer, &pdb, &tagid);
285  ok(ret == TRUE, "Expected pSdbTagRefToTagID to succeed\n");
286  if (ret)
287  {
288  TAG tag;
289  ok(pdb != NULL, "Expected pdb to be a valid pointer\n");
290  ok(tagid != 0 && tagid != 0xdeadbeef, "Expected tagid to be a valid tag id, was: 0x%x\n", tagid);
291  tag = pSdbGetTagFromTagID(pdb, tagid);
292  ok(tag == 0x700b, "Expected tag to be 0x700b, was 0x%x\n", (DWORD)tag);
293  }
294 
295  pSdbReleaseDatabase(hsdb);
296  }
297 }
static PDB pdb
Definition: db.cpp:172
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
size_t __cdecl mbstowcs(_Out_writes_opt_z_(_MaxCount) wchar_t *_Dest, _In_z_ const char *_Source, _In_ size_t _MaxCount)
#define TRUE
Definition: types.h:120
#define SDB_DATABASE_MAIN_SHIM
Definition: env.c:176
Definition: ecma_167.h:138
Definition: apphelp.h:27
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR nameW[]
Definition: main.c:46
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
Definition: fs_rec.h:142
Definition: name.c:38
DWORD TAGID
char * tag
Definition: main.c:59

Referenced by Validate_ShimData_Win10(), Validate_ShimData_Win10_v2(), and Validate_ShimData_Win7().

◆ void()

void ( WINAPI pSdbReleaseDatabase)

◆ xOpenFile()

HANDLE xOpenFile ( WCHAR ApplicationName)

Definition at line 804 of file env.c.

805 {
811 
813  {
814  skip("Unable to translate %s to Nt path\n", wine_dbgstr_w(ApplicationName));
815  return NULL;
816  }
817 
818 
821  SYNCHRONIZE |
824  FILE_EXECUTE,
826  &IoStatusBlock,
830 
832 
833  if (!NT_SUCCESS(Status))
834  return NULL;
835 
836  return FileHandle;
837 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
char * wine_dbgstr_w(const wchar_t *wstr)
Definition: atltest.h:87
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_SHARE_READ
Definition: compat.h:136
HANDLE FileHandle
Definition: stats.c:38
#define FILE_READ_DATA
Definition: nt_native.h:628
Status
Definition: gdiplustypes.h:24
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:3951
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#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
#define FILE_NON_DIRECTORY_FILE
Definition: constants.h:492
#define SYNCHRONIZE
Definition: nt_native.h:61
struct _FileName FileName
Definition: fatprocs.h:893
PVOID PVOID PWCHAR ApplicationName
Definition: env.c:47
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define NULL
Definition: types.h:112
#define skip(...)
Definition: atltest.h:64
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
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)

Referenced by Test_ApphelpCheckRunApp().

Variable Documentation

◆ almost_empty

const SDBQUERYRESULT_VISTA almost_empty = { { 0 }, { 0 }, { 0 }, 0, 0, 0, 0, { 0 }, SHIMREG_DISABLE_LAYER, 0 }
static

Definition at line 65 of file env.c.

Referenced by Test_GetMatchingExe().

◆ ApplicationName

◆ dwFlags

Definition at line 37 of file env.c.

◆ dwSize

Definition at line 56 of file env.c.

Referenced by _ILGetFileSize(), _RpcCommitSpoolData(), _RpcEnumInterfaces(), _RpcGetSpoolFileInfo(), _Struct_size_bytes_(), _tWinMain(), action_RegDeleteTreeA(), ActiveIMMApp_GetImeMenuItemsA(), ActiveIMMApp_GetImeMenuItemsW(), AddFSClassKeysToArray(), CRegFolderEnum::AddItemsFromKey(), AddItemToTreeView(), AddNewTopicEx(), AddNotificationDll(), AddUserProfile(), AddUserProfiles(), ADVAPI_IsLocalComputer(), AlignedAlloc(), Alloc(), AllocateAndGetIfTableFromStack(), AllocateAndGetIpAddrTableFromStack(), AllocateAndGetIpForwardTableFromStack(), AllocateAndGetIpNetTableFromStack(), AllocateAndGetTcpExTable2FromStack(), AllocateAndGetTcpExTableFromStack(), AllocateAndGetTcpTableFromStack(), AllocateAndGetUdpExTable2FromStack(), AllocateAndGetUdpExTableFromStack(), AllocateAndGetUdpTableFromStack(), AnalyzeEncoding(), BindStatusCallback_OnDataAvailable(), bsc_OnDataAvailable(), BuildCodePageList(), BuildDesktopNameList(), BuildLeftPopupMenu(), BuildVolatileEnvironment(), BuildWindowStationNameList(), CNewMenu::CacheItems(), CallNotificationDll(), capGetDriverDescriptionW(), CRecycleBinEnum::CBEnumRecycleBin(), CBSearchRecycleBin(), CFSExtractIcon_CreateInstance(), CheckForGuestsAndAdmins(), CheckForLiveCD(), CInstalledApplicationInfo::CInstalledApplicationInfo(), ComDBClaimNextFreePort(), ComDBClaimPort(), ComDBGetCurrentPortUsage(), ComDBOpen(), ComDBReleasePort(), ComDBResizeDatabase(), Compress(), convert_hash_to_blob(), CRAM_GetInfo(), CreateFilterList(), CreateKeyboardLayoutList(), CreateMultiSzString(), CreateNotificationObject(), CreateServiceListEntry(), CreateTapePartition(), CSize::CSize(), d3d_execute_buffer_GetExecuteData(), d3d_execute_buffer_Lock(), d3d_material3_GetMaterial(), d3d_viewport_GetViewport(), d3d_viewport_GetViewport2(), DdeGetData(), DECLARE_INTERFACE_(), Decompress(), delete_registry_key(), devinst_RegDeleteTreeW(), DIALOG_Execute(), DIALOG_ProgramAttributes(), DIALOG_StatusBarUpdateCaretPos(), CNetConnection::Disconnect(), DisplayClassCoinstallers(), DisplayClassProperties(), DisplayCurrentPowerState(), DisplayDeviceCoinstallers(), DisplayDevicePropertyText(), DisplayDevNodeEnumerator(), DisplayMatchingDeviceId(), DisplayPowerCapabilities(), DisplayPowerStateMappings(), DoesUserHavePrivilege(), DoExport(), DoImport(), DoParseFile(), DownloadBSC_OnDataAvailable(), downloadcb_OnDataAvailable(), DP_CalcSessionDescSize(), DrawDibBegin(), DrawDibGetBuffer(), DriverEnumProc(), DumpSubstedDrives(), EditTypeDlg_ReadClass(), EditTypeDlg_WriteClass(), ElfReportEventA(), ElfReportEventW(), CInstalledApps::Enum(), EnumClientServiceProtocol(), EnumDeviceClasses(), EnumerateConnectedDrives(), CNetConnectionManager::EnumerateINetConnections(), EnumerateNetworkAdapter(), EnumHotpluggedDevices(), EnumPwrSchemes(), CShellCommandHelp::Execute(), ExpandEnvironmentStringsForUserA(), ExpandEnvironmentStringsForUserW(), fdi_notify_extract(), FFSQueryDirectory(), CFontInfo::File(), FileTypesDlg_AddExt(), FileTypesDlg_InsertToLV(), fill_keyboard_dideviceinstanceA(), fill_keyboard_dideviceinstanceW(), fill_mouse_dideviceinstanceA(), fill_mouse_dideviceinstanceW(), find_registry_key(), FindNetworkAdapter(), ForceFriendlyUI(), FormatEnumProc(), FormatTagEnumProc(), FreeUrlCacheSpaceA(), FTP_ReceiveFileList(), Generate(), get_dest_dir(), get_module_version(), GetActivePwrScheme(), CInstalledApplicationInfo::GetApplicationRegDword(), CInstalledApplicationInfo::GetApplicationRegString(), GetClipboardDataDimensions(), GetCLSIDForFileTypeFromExtension(), GetComputerNameA(), GetComputerNames(), GetCurrentDPI(), GetCurrentLoggedOnUserName(), GetDeviceLocationString(), GetDllList(), GetDriverDateString(), GetDriverProviderString(), GetDriverVersionString(), GetEventMessageFileDLL(), GetExplorerRegValueSet(), GetFilePatchSignatureByHandle(), GetFileTypeIconsByKey(), GetHotPlugFlags(), GetInfo(), GetInstalledVersion_WowUser(), GetIntervalSetting(), GetLastErrorText(), GetLayoutCount(), GetListViewEntries(), GetPerAdapterInfo(), GetPnpKey(), GetPortType(), GetProfile(), CNetConnection::GetProperties(), GetRegistrySettings(), GetRegValue(), GetResourceList(), GetSelectionText(), GetServerTime(), GetServiceDescription(), GetServiceInstanceList(), GetServiceInstanceListSize(), CSysTray::GetServicesEnabled(), GetSetupType(), GetShutdownReasonUI(), GetStyleValue(), GetSyncSetting(), GetUserWaitInterval(), GlobalSize(), Help_OnSize(), IBindStatusCallback_OnDataAvailable_Proxy(), IBindStatusCallback_OnDataAvailable_Stub(), ICCVID_GetInfo(), IDirectInputDevice2AImpl_GetObjectInfo(), IDirectInputDevice2WImpl_GetObjectInfo(), IMAGEHLP_SetSecurityDirOffset(), ImageView_LoadSettings(), ImmGetImeMenuItemsA(), ImmGetImeMenuItemsW(), INetCfgComponentControl_fnApplyRegistryChanges(), INetCfgLock_fnIsWriteLocked(), INF_GetDataField(), init_access_tests(), init_wksta_tests(), InitAudioDlg(), InitControl(), InitDialog(), InitFontSizeList(), Initialize(), InitializeDefaultUserLocale(), InitializePropertyDialog(), InitializeRecycleBinDlg(), InitiateSystemShutdownThread(), InitIconOverlays(), InitKeyboardLayouts(), CFileDefExt::InitOpensWithField(), InitOSVersion(), InitOurDirectory(), InitRadioButtons(), InitSettings(), InsertDeviceTreeItem(), InstallParallelPort(), InstallSerialPort(), Int_EnumDependentServicesW(), IntGdiAddFontMemResource(), IntGetShellStateSettings(), IntGetUnderlineState(), IntKeyboardGetIndicatorTrans(), IntSetShellStateSettings(), IntSetUnderlineState(), IsFriendlyUIActive(), COpenWithList::IsHidden(), IsLayoutExists(), IsNTAdmin(), IsShowHibernateButtonActive(), IsTextNonZeroASCII(), IsUserAdmin(), JoystickAGenericImpl_GetObjectInfo(), LANStatusUiDetailsDlg(), LayoutList_Create(), lineAccept(), lineAnswer(), lineDevSpecific(), lineDevSpecificFeature(), lineDrop(), lineGetAddressIDA(), lineSendUserUserInfo(), lineSetDevConfigA(), CSettings::Load(), COpenWithList::Load(), CNewMenu::LoadCachedItems(), LoadCurrentLocale(), LoadDNSSettings(), LoadFilterSettings(), COpenWithList::LoadFromProgIdKey(), LoadJobs(), LoadKeyboardLayoutW(), LoadLocalizedResourcesFromINI(), COpenWithList::LoadRecommendedFromHKCR(), LoadSettings(), LoadShutdownSelState(), LoadTcpFilterSettingsFromRegistry(), LoadUsernameHint(), LocaleList_Create(), LsapIsLocalComputer(), main(), MAIN_AutoStart(), MAIN_CreateMainWindow(), Main_DDrawSurface_GetSurfaceDesc(), MAIN_LoadSettings(), MAIN_SaveSettings(), MainWnd_OnOpenRegKey(), MapFile(), MouseOnDialogInit(), MPR_Alloc(), MPR_ReAlloc(), mru_RegDeleteTreeA(), MsiEnumRelatedProductsW(), MyMalloc(), MyRealloc(), myRegDeleteTreeA(), myRegDeleteTreeW(), NetIDPage_OnApply(), NetpGetComputerName(), NetrServerGetInfo(), NetWkstaUserGetInfo(), NLS_RegGetDword(), NtGdiExtCreateRegion(), NtUserBuildNameList(), OLECONVERT_GetOLE10ProgID(), OLECONVERT_LoadOLE10(), OLECONVERT_SaveOLE10(), OnTimer(), OpenAdapterHandle(), OpenKeyFromFileType(), package_RegDeleteTreeW(), PATH_ExtTextOut(), pCDevSettings_Initialize(), pCDevSettings_InitializeExtInterface(), PerfDataRefresh(), phoneDevSpecific(), phoneGetData(), phoneSetData(), phoneSetDisplay(), PlayEnhMetaFileRecord(), PlayLogonSoundThread(), PNP_GetClassName(), PNP_GetHwProfInfo(), PNP_HwProfFlags(), PNP_IsDockStationPresent(), pointer_default(), POWRPROF_GetMachinePowerPolicy(), POWRPROF_GetUserPowerPolicy(), PropertySheetDialog::PropertySheetDialog(), PROPSHEET_CollectSheetInfoA(), PROPSHEET_CollectSheetInfoW(), PropSheetPage::PropSheetPage(), ProxyBindStatusCallback_OnDataAvailable(), pSetupGetVersionInfoFromImage(), QueryDriverInfo(), QuerySubstedDrive(), rdssl_cert_to_rkey(), CFontCache::Read(), read_advanced_key(), ReadAttributes(), ReadBindingString(), ReadGlobalPwrPolicy(), ReadKeysSettings(), ReadPortSettings(), ReadProcessorPwrScheme(), ReadText(), ReAlloc(), RegDeleteTreeW(), ATL::CRegObject::RegDeleteTreeX(), RegQueryString(), RegReadStringA(), RegReadStringW(), CNetConnection::Rename(), REnumServiceGroupW(), REnumServicesStatusExW(), RetreiveFileSecurity(), RetrieveQuote(), run_apibuf_tests(), run_usergetinfo_tests(), run_wkstausergetinfo_tests(), RunSetupThreadProc(), SampIsSetupRunning(), SaveSettings(), ScmDeleteRegKey(), ScmDeleteTree(), ScmEnableBackupRestorePrivileges(), ScmGetControlSetValues(), ScmGetSetupInProgress(), ScmIsDeleteFlagSet(), ScmReadString(), SdbGetMatchingExe(), service_main(), SetAutoAdminLogon(), SetClipboardData(), SetCommConfig(), SetConsoleScreenBufferSize(), SetDefaultCommConfigA(), SetDefaultCommConfigW(), COpenWithList::SetDefaultHandler(), SetDefaultLanguage(), SetFailedInstall(), ATL::CRegKey::SetMultiStringValue(), ATL::CRegKey::SetQWORDValue(), SETUP_CallInstaller(), SetupDeviceInstance(), SETUPDI_CreateDrvKey(), SetupDiOpenDeviceInfoW(), SHAllocShared(), SHCoCreateInstance(), SHCopyKeyW(), SHDeleteKeyW(), SHELL32_GetFSItemAttributes(), ShellExecCmdLine(), SHEmptyRecycleBinW(), SHGetInverseCMAP(), ShimLib_ShimMalloc(), show_export_ui(), ShowAppList(), ShowEthernetStatistics(), ShowTcpTable(), ShowUdpTable(), SHRegGetIntW(), SHRegGetPathA(), SHRegGetPathW(), START_TEST(), StoreDriveSettings(), SysMouseAImpl_GetObjectInfo(), TakeOwnershipOfFile(), test_animation(), test_CallForAttributes(), Test_CommandLine(), test_CPoint(), test_EnumBuffer(), test_GetBuffer(), test_HeapCreate(), test_InternetCanonicalizeUrlA(), test_ip_pktinfo(), test_normal_imports(), test_pack_COMMCONFIG(), test_pack_JOYINFOEX(), test_pack_MCI_DGV_RESERVE_PARMSA(), test_pack_MCI_DGV_RESERVE_PARMSW(), test_pack_RGNDATAHEADER(), test_SessionDesc(), test_SHGetValue(), Test_Shimdata(), test_SHQueryValueEx(), test_url_canonicalize(), test_url_combine(), test_url_part(), test_UrlCanonicalizeA(), test_UrlCanonicalizeW(), test_UrlGetPart(), testGetIfTable(), testGetIpAddrTable(), testGetIpForwardTable(), testGetIpNetTable(), testGetTcpTable(), testGetUdpTable(), testImportPublicKey(), TOOLBAR_Restore(), translateinfstring_test(), TRASH_CanTrashFile(), UpdateNetbiosName(), UpdateTcpIpInformation(), UserpShowInformationBalloon(), variant_from_registry_value(), ViewDlg_Apply(), VirtualAlloc(), VirtualAllocEx(), VirtualFree(), VirtualFreeEx(), VirtualLock(), VirtualProtect(), VirtualProtectEx(), VirtualUnlock(), WaitForService(), WDML_DataHandle2Global(), WhichPlatform(), WlanAllocateMemory(), wmain(), and wWinMain().

◆ empty_result

◆ Environment

◆ ExeType

◆ FusionFlags

◆ g_LayerDB

HSDB g_LayerDB
static

Definition at line 61 of file env.c.

Referenced by find_layer(), START_TEST(), and Test_Shimdata().

◆ g_ModuleVersion

DWORD g_ModuleVersion
static

Definition at line 63 of file env.c.

Referenced by expect_layeronly_imp(), START_TEST(), and Test_ApphelpCheckRunApp().

◆ g_ShimDataSize

DWORD g_ShimDataSize
static

Definition at line 62 of file env.c.

Referenced by START_TEST(), Test_layers(), and Test_repeatlayer().

◆ hdll

HMODULE hdll
static

Definition at line 35 of file env.c.

Referenced by START_TEST().

◆ layerName

LPCWSTR layerName

Definition at line 42 of file env.c.

◆ pData

Definition at line 57 of file env.c.

Referenced by Test_Shimdata().

◆ ppData

◆ ppdb

TAGREF PDB* ppdb

Definition at line 40 of file env.c.

◆ pQueryResult

Definition at line 37 of file env.c.

Referenced by SdbPackAppCompatData(), and SdbUnpackAppCompatData().

◆ pszDatabasePath

LPCWSTR pszDatabasePath

Definition at line 38 of file env.c.

Referenced by SdbRegisterDatabase(), and SdbRegisterDatabaseEx().

◆ pszEnvironment

LPCWSTR LPCWSTR LPCWSTR pszEnvironment

Definition at line 37 of file env.c.

◆ pszImageName

LPCWSTR pszImageName

Definition at line 57 of file env.c.

Referenced by MapAndLoad().

◆ ptiWhich

TAGREF PDB TAGID* ptiWhich

Definition at line 40 of file env.c.

◆ Reason

◆ SdbQueryAppCompatData

PVOID PVOID PWCHAR PVOID PVOID USHORT PULONG PVOID * SdbQueryAppCompatData

◆ SdbQueryAppCompatDataSize

PVOID PVOID PWCHAR PVOID PVOID USHORT PULONG PVOID PULONG SdbQueryAppCompatDataSize

◆ SomeFlag1

◆ SomeFlag2

◆ SxsData

◆ SxsDataSize

◆ szModuleName

◆ szPath

LPCWSTR szPath

Definition at line 37 of file env.c.

Referenced by _ILCreateFromPathW(), _SHGetUserProfileDirectoryW(), _tWinMain(), CDirectoryList::AddPathsFromDirectory(), AdvInstallFileW(), AudioDlgProc(), AutoStartupApplications(), AVIFILE_BasenameW(), BrowseCallbackProc(), BrsFolder_OnCommand(), BuildVolatileEnvironment(), cmd_vol(), CmdInstallService(), ContentsMatch(), CControlPanelEnum::CreateCPanelEnumList(), CreateDirectoryPath(), CreateDirectoryWatcherFromRegEntry(), CreateInternetShortcut(), CreateShortcut(), CreateShortcuts(), DIALOG_FileOpen(), DIALOG_FileSaveAs(), CNetConnection::Disconnect(), DoAddFilesFromItem(), CZipCreator::DoAddItem(), DoDeleteSpecW(), DoEntry(), CCopyToMenu::DoGetFileTitle(), CMoveToMenu::DoGetFileTitle(), DoGetZipName(), DoInitPaths(), CCopyToMenu::DoRealCopy(), CMoveToMenu::DoRealMove(), DoSaveFileAs(), DoUpdateAutoCompleteWithCWD(), CSendToZip::Drop(), CFontExt::Drop(), EditTypeDlg_OnChangeIcon(), EnumThemes(), extract_msvc_dll(), FileCompareOneSideWild(), FileExtractDialogWndProc(), fill_file_description(), CSearchBar::GetAddressEditBoxPath(), CFSFolder::GetCustomViewInfo(), GetDesktopPath(), CShellLink::GetIconLocation(), GetIconOverlay(), GetInstalledVersion_WowUser(), GetLayoutName(), GetProgramsPath(), GRPFILE_WriteGroupFile(), HACKISH_PathResolve(), InitializeListView(), InitLogs(), CShellMenuCallback::InsertRecentItem(), IntLoadFontsInRegistry(), LayoutList_Create(), LoadSoundFiles(), LoadSystemIni(), LoadTypeLibEx(), SEALED_::LoadTypeLibrary(), MakeShellURLFromPathA(), MsiProvideComponentFromDescriptorA(), MsiProvideComponentFromDescriptorW(), OleMetafilePictFromIconAndLabel(), OnAddStartMenuItems(), OnAdvancedStartMenuItems(), OnClearRecentItems(), OnDropFiles(), CShellMenuCallback::OnExec(), CFileDefExt::OnFolderCustChangeIcon(), CFSFolder::ParseDisplayName(), PathCanonicalizeA(), PathCompactPathA(), PathCompactPathExA(), PathFileExistsDefExtA(), PathIsDirectoryEmptyA(), PathMakeSystemFolderA(), PathRelativePathToA(), PathSetDlgItemPathA(), POWRPROF_GetMachinePowerPolicy(), POWRPROF_GetUserPowerPolicy(), PrintDirectoryHeader(), PrintPrompt(), PrintSummary(), CDirectoryWatcher::ProcessNotification(), ProcessSetupInf(), ProcessUnattendSection(), PushDirectory(), ReadCommand(), ReadProcessorPwrScheme(), RecursiveFind(), RecursiveRemoveDir(), RegisterInShimCache(), RegisterTypeLibraries(), RunApphelpCacheControlTests(), search_res_tlb(), set_cookie(), CShellLink::SetPath(), CShellLink::SetTargetFromPIDLOrPath(), SHAddToRecentDocs(), SHCreateStreamOnFileA(), SHELL_FS_HideExtension(), SHELL_FS_ProcessDisplayFilename(), Shell_GetCachedImageIndex(), Shell_GetCachedImageIndexA(), Shell_GetCachedImageIndexAW(), Shell_GetCachedImageIndexW(), SHEmptyRecycleBinW(), SheShortenPathA(), SHExplorerParseCmdLine(), SHGetFolderLocation(), SHGetSpecialFolderPathA(), SHGetSpecialFolderPathW(), SHGetWebFolderFilePathA(), SHLWAPI_PathFindInOtherDirs(), ShowCreateShortcutWizard(), SHRegOpenUSKeyA(), START_TEST(), Stream_WriteLocationInfo(), test_ACListISF_CURRENTDIR(), test_iconlocation(), test_Installer(), test_WritePwrScheme(), urlcache_create_file_pathA(), UXTHEME_LoadImage(), UXTHEME_SelectImage(), WelcomeDlgProc(), WindowProc(), wmain(), and wrapSdbSetPermLayerKeys2().

◆ tiWhich

TAGID tiWhich

Definition at line 41 of file env.c.

◆ trWhich

TAGREF trWhich

Definition at line 40 of file env.c.

◆ Unk1

PVOID Unk1

Definition at line 47 of file env.c.

◆ Unk2

PVOID PVOID Unk2

Definition at line 47 of file env.c.

◆ Unk3

Definition at line 51 of file env.c.