2016-12-03 21:24:47 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Mark Jansen
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ntstatus.h>
|
|
|
|
#define WIN32_NO_STATUS
|
|
|
|
#include <windows.h>
|
|
|
|
#ifdef __REACTOS__
|
|
|
|
#include <ntndk.h>
|
|
|
|
#else
|
|
|
|
#include <winternl.h>
|
|
|
|
#endif
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <strsafe.h>
|
|
|
|
#include "wine/test.h"
|
|
|
|
|
2016-12-14 19:19:57 +00:00
|
|
|
static DWORD g_Version;
|
2016-12-03 21:24:47 +00:00
|
|
|
#define WINVER_ANY 0
|
|
|
|
|
|
|
|
|
|
|
|
/* apphelp.dll */
|
|
|
|
static BOOL(WINAPI* pSdbGetAppPatchDir)(PVOID, LPWSTR, DWORD);
|
|
|
|
|
2016-12-14 19:19:57 +00:00
|
|
|
/* aclayers.dll / acgenral.dll */
|
2016-12-03 21:24:47 +00:00
|
|
|
static PVOID(WINAPI* pGetHookAPIs)(LPCSTR, LPCWSTR, PDWORD);
|
|
|
|
static BOOL(WINAPI* pNotifyShims)(DWORD fdwReason, PVOID ptr);
|
|
|
|
|
2016-12-14 19:19:57 +00:00
|
|
|
DWORD get_module_version(HMODULE mod)
|
|
|
|
{
|
|
|
|
DWORD dwVersion = 0;
|
|
|
|
HRSRC hResInfo = FindResource(mod, MAKEINTRESOURCE(VS_VERSION_INFO), RT_VERSION);
|
|
|
|
DWORD dwSize = SizeofResource(mod, hResInfo);
|
|
|
|
if (hResInfo && dwSize)
|
|
|
|
{
|
|
|
|
VS_FIXEDFILEINFO *lpFfi;
|
|
|
|
UINT uLen;
|
|
|
|
|
|
|
|
HGLOBAL hResData = LoadResource(mod, hResInfo);
|
|
|
|
LPVOID pRes = LockResource(hResData);
|
|
|
|
HLOCAL pResCopy = LocalAlloc(LMEM_FIXED, dwSize);
|
|
|
|
|
|
|
|
CopyMemory(pResCopy, pRes, dwSize);
|
|
|
|
FreeResource(hResData);
|
|
|
|
|
|
|
|
if (VerQueryValueW(pResCopy, L"\\", (LPVOID*)&lpFfi, &uLen))
|
|
|
|
{
|
|
|
|
dwVersion = (HIWORD(lpFfi->dwProductVersionMS) << 8) | LOWORD(lpFfi->dwProductVersionMS);
|
|
|
|
if (!dwVersion)
|
|
|
|
dwVersion = (HIWORD(lpFfi->dwFileVersionMS) << 8) | LOWORD(lpFfi->dwFileVersionMS);
|
|
|
|
}
|
2016-12-03 21:24:47 +00:00
|
|
|
|
2016-12-14 19:19:57 +00:00
|
|
|
LocalFree(pResCopy);
|
|
|
|
}
|
|
|
|
|
|
|
|
return dwVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LONG g_ChangeCount;
|
2016-12-03 21:24:47 +00:00
|
|
|
static DEVMODEA g_LastDevmode;
|
|
|
|
static DWORD g_LastFlags;
|
|
|
|
|
2016-12-04 15:33:28 +00:00
|
|
|
static LONG (WINAPI *pChangeDisplaySettingsA)(_In_opt_ PDEVMODEA lpDevMode, _In_ DWORD dwflags);
|
2016-12-03 21:24:47 +00:00
|
|
|
LONG WINAPI mChangeDisplaySettingsA(_In_opt_ PDEVMODEA lpDevMode, _In_ DWORD dwflags)
|
|
|
|
{
|
2016-12-14 19:19:57 +00:00
|
|
|
g_ChangeCount++;
|
2016-12-03 21:24:47 +00:00
|
|
|
g_LastDevmode = *lpDevMode;
|
|
|
|
g_LastFlags = dwflags;
|
|
|
|
|
|
|
|
return DISP_CHANGE_FAILED;
|
|
|
|
}
|
|
|
|
|
2016-12-14 19:19:57 +00:00
|
|
|
static LONG g_EnumCount;
|
|
|
|
static BOOL bFix = TRUE;
|
|
|
|
|
|
|
|
static BOOL (WINAPI *pEnumDisplaySettingsA)(_In_opt_ LPCSTR lpszDeviceName, _In_ DWORD iModeNum, _Inout_ PDEVMODEA lpDevMode);
|
|
|
|
BOOL WINAPI mEnumDisplaySettingsA(_In_opt_ LPCSTR lpszDeviceName, _In_ DWORD iModeNum, _Inout_ PDEVMODEA lpDevMode)
|
|
|
|
{
|
|
|
|
g_EnumCount++;
|
|
|
|
if (pEnumDisplaySettingsA(lpszDeviceName, iModeNum, lpDevMode))
|
|
|
|
{
|
|
|
|
if (bFix)
|
|
|
|
{
|
|
|
|
if (lpDevMode && lpDevMode->dmBitsPerPel == 8)
|
|
|
|
{
|
|
|
|
trace("Running at 8bpp, faking 16\n");
|
|
|
|
lpDevMode->dmBitsPerPel = 16;
|
|
|
|
}
|
|
|
|
if (lpDevMode && lpDevMode->dmPelsWidth == 640 && lpDevMode->dmPelsHeight == 480)
|
|
|
|
{
|
|
|
|
trace("Running at 640x480, faking 800x600\n");
|
|
|
|
lpDevMode->dmPelsWidth = 800;
|
|
|
|
lpDevMode->dmPelsHeight = 600;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (lpDevMode)
|
|
|
|
{
|
|
|
|
lpDevMode->dmBitsPerPel = 8;
|
|
|
|
lpDevMode->dmPelsWidth = 640;
|
|
|
|
lpDevMode->dmPelsHeight = 480;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-12-04 15:33:28 +00:00
|
|
|
static LONG g_ThemeCount;
|
|
|
|
static DWORD g_LastThemeFlags;
|
2016-12-03 21:24:47 +00:00
|
|
|
|
2016-12-04 15:33:28 +00:00
|
|
|
static void (WINAPI *pSetThemeAppProperties)(DWORD dwFlags);
|
|
|
|
void WINAPI mSetThemeAppProperties(DWORD dwFlags)
|
|
|
|
{
|
|
|
|
g_ThemeCount++;
|
|
|
|
g_LastThemeFlags = dwFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const WCHAR* shim_dll(const WCHAR* name)
|
|
|
|
{
|
|
|
|
static WCHAR buf[MAX_PATH];
|
|
|
|
pSdbGetAppPatchDir(NULL, buf, MAX_PATH);
|
|
|
|
StringCchCatW(buf, _countof(buf), name);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pre_8bit(void)
|
2016-12-03 21:24:47 +00:00
|
|
|
{
|
2016-12-14 19:19:57 +00:00
|
|
|
g_ChangeCount = 0;
|
2016-12-03 21:24:47 +00:00
|
|
|
memset(&g_LastDevmode, 0, sizeof(g_LastDevmode));
|
|
|
|
g_LastFlags = 0xffffffff;
|
2016-12-14 19:19:57 +00:00
|
|
|
g_EnumCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pre_8bit_2(void)
|
|
|
|
{
|
|
|
|
bFix = FALSE;
|
|
|
|
|
|
|
|
pre_8bit();
|
2016-12-03 21:24:47 +00:00
|
|
|
}
|
|
|
|
|
2016-12-04 15:33:28 +00:00
|
|
|
static void post_8bit(void)
|
2016-12-03 21:24:47 +00:00
|
|
|
{
|
2016-12-14 19:19:57 +00:00
|
|
|
ok_int(g_ChangeCount, 1);
|
2016-12-03 21:24:47 +00:00
|
|
|
ok_hex(g_LastDevmode.dmFields & DM_BITSPERPEL, DM_BITSPERPEL);
|
|
|
|
ok_int(g_LastDevmode.dmBitsPerPel, 8);
|
|
|
|
ok_hex(g_LastFlags, CDS_FULLSCREEN);
|
2016-12-14 19:19:57 +00:00
|
|
|
ok_int(g_EnumCount, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void post_8bit_2(void)
|
|
|
|
{
|
|
|
|
ok_int(g_ChangeCount, 0);
|
|
|
|
ok_hex(g_LastFlags, 0xffffffff);
|
|
|
|
ok_int(g_EnumCount, 1);
|
|
|
|
|
|
|
|
bFix = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void post_8bit_no(void)
|
|
|
|
{
|
|
|
|
if (g_Version == _WIN32_WINNT_WS03)
|
|
|
|
{
|
|
|
|
ok_int(g_ChangeCount, 1);
|
|
|
|
ok_hex(g_LastDevmode.dmFields & DM_BITSPERPEL, DM_BITSPERPEL);
|
|
|
|
ok_int(g_LastDevmode.dmBitsPerPel, 8);
|
|
|
|
ok_hex(g_LastFlags, CDS_FULLSCREEN);
|
|
|
|
ok_int(g_EnumCount, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok_int(g_ChangeCount, 0);
|
|
|
|
ok_hex(g_LastFlags, 0xffffffff);
|
|
|
|
ok_int(g_EnumCount, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
bFix = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void post_8bit_2_no(void)
|
|
|
|
{
|
|
|
|
if (g_Version == _WIN32_WINNT_WS03)
|
|
|
|
{
|
|
|
|
ok_int(g_ChangeCount, 0);
|
|
|
|
ok_hex(g_LastFlags, 0xffffffff);
|
|
|
|
ok_int(g_EnumCount, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok_int(g_ChangeCount, 0);
|
|
|
|
ok_hex(g_LastFlags, 0xffffffff);
|
|
|
|
ok_int(g_EnumCount, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
bFix = TRUE;
|
2016-12-03 21:24:47 +00:00
|
|
|
}
|
|
|
|
|
2016-12-04 15:33:28 +00:00
|
|
|
static void pre_640(void)
|
2016-12-03 21:24:47 +00:00
|
|
|
{
|
2016-12-14 19:19:57 +00:00
|
|
|
g_ChangeCount = 0;
|
2016-12-03 21:24:47 +00:00
|
|
|
memset(&g_LastDevmode, 0, sizeof(g_LastDevmode));
|
|
|
|
g_LastFlags = 0xffffffff;
|
2016-12-14 19:19:57 +00:00
|
|
|
g_EnumCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pre_640_2(void)
|
|
|
|
{
|
|
|
|
bFix = FALSE;
|
|
|
|
|
|
|
|
pre_640();
|
2016-12-03 21:24:47 +00:00
|
|
|
}
|
|
|
|
|
2016-12-04 15:33:28 +00:00
|
|
|
static void post_640(void)
|
2016-12-03 21:24:47 +00:00
|
|
|
{
|
2016-12-14 19:19:57 +00:00
|
|
|
ok_int(g_ChangeCount, 1);
|
2016-12-03 21:24:47 +00:00
|
|
|
ok_hex(g_LastDevmode.dmFields & (DM_PELSWIDTH | DM_PELSHEIGHT), (DM_PELSWIDTH | DM_PELSHEIGHT));
|
|
|
|
ok_int(g_LastDevmode.dmPelsWidth, 640);
|
|
|
|
ok_int(g_LastDevmode.dmPelsHeight, 480);
|
|
|
|
ok_hex(g_LastFlags, CDS_FULLSCREEN);
|
2016-12-14 19:19:57 +00:00
|
|
|
ok_int(g_EnumCount, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void post_640_2(void)
|
|
|
|
{
|
|
|
|
ok_int(g_ChangeCount, 0);
|
|
|
|
ok_hex(g_LastFlags, 0xffffffff);
|
|
|
|
ok_int(g_EnumCount, 1);
|
|
|
|
|
|
|
|
bFix = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void post_640_no(void)
|
|
|
|
{
|
|
|
|
if (g_Version == _WIN32_WINNT_WS03)
|
|
|
|
{
|
|
|
|
ok_int(g_ChangeCount, 1);
|
|
|
|
ok_hex(g_LastDevmode.dmFields & (DM_PELSWIDTH | DM_PELSHEIGHT), (DM_PELSWIDTH | DM_PELSHEIGHT));
|
|
|
|
ok_int(g_LastDevmode.dmPelsWidth, 640);
|
|
|
|
ok_int(g_LastDevmode.dmPelsHeight, 480);
|
|
|
|
ok_hex(g_LastFlags, CDS_FULLSCREEN);
|
|
|
|
ok_int(g_EnumCount, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok_int(g_ChangeCount, 0);
|
|
|
|
ok_hex(g_LastFlags, 0xffffffff);
|
|
|
|
ok_int(g_EnumCount, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
bFix = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void post_640_2_no(void)
|
|
|
|
{
|
|
|
|
if (g_Version == _WIN32_WINNT_WS03)
|
|
|
|
{
|
|
|
|
ok_int(g_ChangeCount, 0);
|
|
|
|
ok_hex(g_LastFlags, 0xffffffff);
|
|
|
|
ok_int(g_EnumCount, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok_int(g_ChangeCount, 0);
|
|
|
|
ok_hex(g_LastFlags, 0xffffffff);
|
|
|
|
ok_int(g_EnumCount, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
bFix = TRUE;
|
2016-12-03 21:24:47 +00:00
|
|
|
}
|
|
|
|
|
2016-12-04 15:33:28 +00:00
|
|
|
static void pre_theme(void)
|
|
|
|
{
|
|
|
|
g_ThemeCount = 0;
|
|
|
|
g_LastThemeFlags = 0xffffffff;
|
|
|
|
}
|
2016-12-03 21:24:47 +00:00
|
|
|
|
2016-12-04 15:33:28 +00:00
|
|
|
static void post_theme(void)
|
|
|
|
{
|
|
|
|
ok_int(g_ThemeCount, 1);
|
|
|
|
ok_hex(g_LastThemeFlags, 0);
|
|
|
|
}
|
2016-12-03 21:24:47 +00:00
|
|
|
|
2016-12-14 19:19:57 +00:00
|
|
|
static void post_theme_no(void)
|
|
|
|
{
|
|
|
|
if (g_Version == _WIN32_WINNT_WS03)
|
|
|
|
{
|
|
|
|
ok_int(g_ThemeCount, 1);
|
|
|
|
ok_hex(g_LastThemeFlags, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok_int(g_ThemeCount, 0);
|
|
|
|
ok_hex(g_LastThemeFlags, 0xffffffff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-03 21:24:47 +00:00
|
|
|
static PIMAGE_IMPORT_DESCRIPTOR FindImportDescriptor(PBYTE DllBase, PCSTR DllName)
|
|
|
|
{
|
|
|
|
ULONG Size;
|
|
|
|
PIMAGE_IMPORT_DESCRIPTOR ImportDescriptor = RtlImageDirectoryEntryToData((HMODULE)DllBase, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &Size);
|
|
|
|
while (ImportDescriptor->Name && ImportDescriptor->OriginalFirstThunk)
|
|
|
|
{
|
|
|
|
PCHAR Name = (PCHAR)(DllBase + ImportDescriptor->Name);
|
|
|
|
if (!lstrcmpiA(Name, DllName))
|
|
|
|
{
|
|
|
|
return ImportDescriptor;
|
|
|
|
}
|
|
|
|
ImportDescriptor++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL RedirectIat(HMODULE TargetDll, PCSTR DllName, PCSTR FunctionName, ULONG_PTR NewFunction, ULONG_PTR* OriginalFunction)
|
|
|
|
{
|
|
|
|
PBYTE DllBase = (PBYTE)TargetDll;
|
|
|
|
PIMAGE_IMPORT_DESCRIPTOR ImportDescriptor = FindImportDescriptor(DllBase, DllName);
|
|
|
|
if (ImportDescriptor)
|
|
|
|
{
|
|
|
|
// On loaded images, OriginalFirstThunk points to the name / ordinal of the function
|
|
|
|
PIMAGE_THUNK_DATA OriginalThunk = (PIMAGE_THUNK_DATA)(DllBase + ImportDescriptor->OriginalFirstThunk);
|
|
|
|
// FirstThunk points to the resolved address.
|
|
|
|
PIMAGE_THUNK_DATA FirstThunk = (PIMAGE_THUNK_DATA)(DllBase + ImportDescriptor->FirstThunk);
|
|
|
|
while (OriginalThunk->u1.AddressOfData && FirstThunk->u1.Function)
|
|
|
|
{
|
|
|
|
if (!IMAGE_SNAP_BY_ORDINAL32(OriginalThunk->u1.AddressOfData))
|
|
|
|
{
|
|
|
|
PIMAGE_IMPORT_BY_NAME ImportName = (PIMAGE_IMPORT_BY_NAME)(DllBase + OriginalThunk->u1.AddressOfData);
|
|
|
|
if (!lstrcmpiA((PCSTR)ImportName->Name, FunctionName))
|
|
|
|
{
|
|
|
|
DWORD dwOld;
|
|
|
|
VirtualProtect(&FirstThunk->u1.Function, sizeof(ULONG_PTR), PAGE_EXECUTE_READWRITE, &dwOld);
|
|
|
|
*OriginalFunction = FirstThunk->u1.Function;
|
|
|
|
FirstThunk->u1.Function = NewFunction;
|
|
|
|
VirtualProtect(&FirstThunk->u1.Function, sizeof(ULONG_PTR), dwOld, &dwOld);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OriginalThunk++;
|
|
|
|
FirstThunk++;
|
|
|
|
}
|
|
|
|
skip("Unable to find the Import %s!%s\n", DllName, FunctionName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skip("Unable to find the ImportDescriptor for %s\n", DllName);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-12-04 15:33:28 +00:00
|
|
|
static BOOL hook_disp(HMODULE dll)
|
|
|
|
{
|
2016-12-14 19:19:57 +00:00
|
|
|
return RedirectIat(dll, "user32.dll", "ChangeDisplaySettingsA", (ULONG_PTR)mChangeDisplaySettingsA, (ULONG_PTR*)&pChangeDisplaySettingsA) &&
|
|
|
|
RedirectIat(dll, "user32.dll", "EnumDisplaySettingsA", (ULONG_PTR)mEnumDisplaySettingsA, (ULONG_PTR*)&pEnumDisplaySettingsA);
|
2016-12-04 15:33:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL hook_theme(HMODULE dll)
|
|
|
|
{
|
|
|
|
return RedirectIat(dll, "uxtheme.dll", "SetThemeAppProperties", (ULONG_PTR)mSetThemeAppProperties, (ULONG_PTR*)&pSetThemeAppProperties);
|
|
|
|
}
|
2016-12-03 21:24:47 +00:00
|
|
|
|
|
|
|
|
2016-12-14 19:19:57 +00:00
|
|
|
static void test_one(LPCSTR shim, DWORD dwReason, void(*pre)(), void(*post)(), void(*second)(void))
|
2016-12-03 21:24:47 +00:00
|
|
|
{
|
|
|
|
DWORD num_shims = 0;
|
|
|
|
WCHAR wide_shim[50] = { 0 };
|
|
|
|
PVOID hook;
|
|
|
|
BOOL ret;
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, shim, -1, wide_shim, 50);
|
|
|
|
|
|
|
|
if (pre)
|
|
|
|
pre();
|
|
|
|
|
|
|
|
hook = pGetHookAPIs("", wide_shim, &num_shims);
|
|
|
|
if (hook == NULL)
|
|
|
|
{
|
2016-12-14 19:19:57 +00:00
|
|
|
skip("Skipping tests for layers (%s) not present in this os (0x%x)\n", shim, g_Version);
|
2016-12-03 21:24:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ok(hook != NULL, "Expected hook to be a valid pointer for %s\n", shim);
|
|
|
|
ok(num_shims == 0, "Expected not to find any apihooks, got: %u for %s\n", num_shims, shim);
|
|
|
|
|
|
|
|
ret = pNotifyShims(dwReason, NULL);
|
|
|
|
|
|
|
|
/* Win7 and Win10 return 1, w2k3 returns a pointer */
|
|
|
|
ok(ret != 0, "Expected pNotifyShims to succeed (%i)\n", ret);
|
|
|
|
|
|
|
|
if (post)
|
|
|
|
post();
|
2016-12-14 19:19:57 +00:00
|
|
|
|
|
|
|
/* Invoking it a second time does not call the init functions again! */
|
|
|
|
if (pre && second)
|
|
|
|
{
|
|
|
|
pre();
|
|
|
|
|
|
|
|
ret = pNotifyShims(dwReason, NULL);
|
|
|
|
ok(ret != 0, "Expected pNotifyShims to succeed (%i)\n", ret);
|
|
|
|
|
|
|
|
second();
|
|
|
|
}
|
2016-12-03 21:24:47 +00:00
|
|
|
}
|
|
|
|
|
2016-12-14 19:19:57 +00:00
|
|
|
/* In 2k3 0, 2, 4, 6, 8 are not guarded against re-initializations! */
|
2016-12-03 21:24:47 +00:00
|
|
|
static struct test_info
|
|
|
|
{
|
|
|
|
const char* name;
|
2016-12-04 15:33:28 +00:00
|
|
|
const WCHAR* dll;
|
2016-12-03 21:24:47 +00:00
|
|
|
DWORD winver;
|
|
|
|
DWORD reason;
|
2016-12-04 15:33:28 +00:00
|
|
|
BOOL(*hook)(HMODULE);
|
|
|
|
void(*pre)(void);
|
|
|
|
void(*post)(void);
|
2016-12-14 19:19:57 +00:00
|
|
|
void(*second)(void);
|
2016-12-03 21:24:47 +00:00
|
|
|
} tests[] =
|
|
|
|
{
|
2016-12-14 19:19:57 +00:00
|
|
|
/* Success */
|
|
|
|
{ "Force8BitColor", L"\\aclayers.dll", WINVER_ANY, 1, hook_disp, pre_8bit, post_8bit, post_8bit_no },
|
|
|
|
{ "Force8BitColor", L"\\aclayers.dll", _WIN32_WINNT_VISTA, 100, hook_disp, pre_8bit, post_8bit, post_8bit_no },
|
|
|
|
{ "Force640x480", L"\\aclayers.dll", WINVER_ANY, 1, hook_disp, pre_640, post_640, post_640_no },
|
|
|
|
{ "Force640x480", L"\\aclayers.dll", _WIN32_WINNT_VISTA, 100, hook_disp, pre_640, post_640, post_640_no },
|
|
|
|
{ "DisableThemes", L"\\acgenral.dll", WINVER_ANY, 1, hook_theme, pre_theme, post_theme, post_theme_no },
|
|
|
|
{ "DisableThemes", L"\\acgenral.dll", _WIN32_WINNT_VISTA, 100, hook_theme, pre_theme, post_theme, post_theme_no },
|
|
|
|
|
|
|
|
/* No need to change anything */
|
|
|
|
{ "Force8BitColor", L"\\aclayers.dll", WINVER_ANY, 1, hook_disp, pre_8bit_2, post_8bit_2, post_8bit_2_no },
|
|
|
|
{ "Force8BitColor", L"\\aclayers.dll", _WIN32_WINNT_VISTA, 100, hook_disp, pre_8bit_2, post_8bit_2, post_8bit_2_no },
|
|
|
|
{ "Force640x480", L"\\aclayers.dll", WINVER_ANY, 1, hook_disp, pre_640_2, post_640_2, post_640_2_no },
|
|
|
|
{ "Force640x480", L"\\aclayers.dll", _WIN32_WINNT_VISTA, 100, hook_disp, pre_640_2, post_640_2, post_640_2_no },
|
2016-12-03 21:24:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-12-04 15:33:28 +00:00
|
|
|
static void run_test(size_t n, BOOL unload)
|
2016-12-03 21:24:47 +00:00
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
HMODULE dll;
|
2016-12-04 15:33:28 +00:00
|
|
|
const WCHAR* buf = shim_dll(tests[n].dll);
|
2016-12-03 21:24:47 +00:00
|
|
|
|
2016-12-04 15:33:28 +00:00
|
|
|
dll = LoadLibraryW(shim_dll(tests[n].dll));
|
2016-12-03 21:24:47 +00:00
|
|
|
pGetHookAPIs = (void*)GetProcAddress(dll, "GetHookAPIs");
|
|
|
|
pNotifyShims = (void*)GetProcAddress(dll, "NotifyShims");
|
|
|
|
|
|
|
|
if (!pGetHookAPIs || !pNotifyShims)
|
|
|
|
{
|
|
|
|
skip("aclayers.dll not loaded, or does not export GetHookAPIs or pNotifyShims (%s, %p, %p)\n",
|
|
|
|
tests[n].name, pGetHookAPIs, pNotifyShims);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-12-14 19:19:57 +00:00
|
|
|
g_Version = get_module_version(dll);
|
|
|
|
|
|
|
|
if (!g_Version)
|
2016-12-03 21:24:47 +00:00
|
|
|
{
|
2016-12-14 19:19:57 +00:00
|
|
|
g_Version = _WIN32_WINNT_WS03;
|
|
|
|
trace("Module %s has no version, faking 2k3\n", wine_dbgstr_w(tests[n].dll));
|
2016-12-03 21:24:47 +00:00
|
|
|
}
|
2016-12-14 19:19:57 +00:00
|
|
|
|
|
|
|
if (g_Version >= tests[n].winver)
|
2016-12-03 21:24:47 +00:00
|
|
|
{
|
2016-12-14 19:19:57 +00:00
|
|
|
ret = tests[n].hook(dll);
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
test_one(tests[n].name, tests[n].reason, tests[n].pre, tests[n].post, tests[n].second);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(0, "Unable to redirect functions!\n");
|
|
|
|
}
|
2016-12-03 21:24:47 +00:00
|
|
|
}
|
|
|
|
FreeLibrary(dll);
|
|
|
|
if (unload)
|
|
|
|
{
|
|
|
|
dll = GetModuleHandleW(buf);
|
|
|
|
ok(dll == NULL, "Unable to unload %s\n", wine_dbgstr_w(buf));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
START_TEST(dispmode)
|
|
|
|
{
|
|
|
|
HMODULE dll = LoadLibraryA("apphelp.dll");
|
|
|
|
size_t n;
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
|
|
|
|
pSdbGetAppPatchDir = (void*)GetProcAddress(dll, "SdbGetAppPatchDir");
|
|
|
|
if (!pSdbGetAppPatchDir)
|
|
|
|
{
|
|
|
|
skip("apphelp.dll not loaded, or does not export SdbGetAppPatchDir\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
argc = winetest_get_mainargs(&argv);
|
|
|
|
if (argc < 3)
|
|
|
|
{
|
|
|
|
WCHAR path[MAX_PATH];
|
|
|
|
GetModuleFileNameW(NULL, path, _countof(path));
|
2016-12-04 15:33:28 +00:00
|
|
|
dll = GetModuleHandleW(shim_dll(L"\\aclayers.dll"));
|
|
|
|
if (!dll)
|
|
|
|
dll = GetModuleHandleW(shim_dll(L"\\acgenral.dll"));
|
2016-12-03 21:24:47 +00:00
|
|
|
if (dll != NULL)
|
|
|
|
trace("Loaded under a shim, running each test in it's own process\n");
|
|
|
|
|
|
|
|
for (n = 0; n < _countof(tests); ++n)
|
|
|
|
{
|
2016-12-04 15:33:28 +00:00
|
|
|
LONG failures = winetest_get_failures();
|
|
|
|
|
2016-12-03 21:24:47 +00:00
|
|
|
if (dll == NULL)
|
|
|
|
{
|
2016-12-04 15:33:28 +00:00
|
|
|
run_test(n, TRUE);
|
2016-12-03 21:24:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WCHAR buf[MAX_PATH+40];
|
|
|
|
STARTUPINFOW si = { sizeof(si) };
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
BOOL created;
|
|
|
|
|
|
|
|
StringCchPrintfW(buf, _countof(buf), L"\"%ls\" dispmode %u", path, n);
|
|
|
|
created = CreateProcessW(NULL, buf, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
|
|
|
|
ok(created, "Expected CreateProcess to succeed\n");
|
|
|
|
if (created)
|
|
|
|
{
|
|
|
|
winetest_wait_child_process(pi.hProcess);
|
|
|
|
CloseHandle(pi.hThread);
|
|
|
|
CloseHandle(pi.hProcess);
|
|
|
|
}
|
|
|
|
}
|
2016-12-04 15:33:28 +00:00
|
|
|
|
2016-12-14 19:19:57 +00:00
|
|
|
ok(failures == winetest_get_failures(), "Last %u failures are from %d (%s)\n",
|
|
|
|
winetest_get_failures() - failures, n, tests[n].name);
|
2016-12-03 21:24:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n = (size_t)atoi(argv[2]);
|
|
|
|
if (n >= 0 && n < _countof(tests))
|
|
|
|
{
|
2016-12-04 15:33:28 +00:00
|
|
|
run_test(n, FALSE);
|
2016-12-03 21:24:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok(0, "Test out of range: %u\n", n);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|