https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f4f4466ffd1efece8c6b7…
commit f4f4466ffd1efece8c6b7d42fe18986a143ed55c
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Mon Jan 8 22:58:42 2018 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Jan 21 21:13:08 2018 +0100
[APPSHIM_APITEST] Add test for shims in AcLayers
---
modules/rostests/apitests/appshim/CMakeLists.txt | 1 +
modules/rostests/apitests/appshim/layer_hooks.c | 128 +++++++++++++++++++++++
modules/rostests/apitests/appshim/testlist.c | 2 +
3 files changed, 131 insertions(+)
diff --git a/modules/rostests/apitests/appshim/CMakeLists.txt
b/modules/rostests/apitests/appshim/CMakeLists.txt
index fa7a76527b..8884ce2606 100644
--- a/modules/rostests/apitests/appshim/CMakeLists.txt
+++ b/modules/rostests/apitests/appshim/CMakeLists.txt
@@ -4,6 +4,7 @@ add_definitions(-D__ROS_LONG64__)
list(APPEND SOURCE
dispmode.c
genral_hooks.c
+ layer_hooks.c
versionlie.c
testlist.c
appshim_apitest.h)
diff --git a/modules/rostests/apitests/appshim/layer_hooks.c
b/modules/rostests/apitests/appshim/layer_hooks.c
new file mode 100644
index 0000000000..e47d9aad29
--- /dev/null
+++ b/modules/rostests/apitests/appshim/layer_hooks.c
@@ -0,0 +1,128 @@
+/*
+ * PROJECT: appshim_apitest
+ * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE: Test to document the hooks used by various shims in AcLayers
+ * COPYRIGHT: Copyright 2018 Mark Jansen (mark.jansen(a)reactos.org)
+ */
+
+#include <ntstatus.h>
+#define WIN32_NO_STATUS
+#include <windows.h>
+#include <ndk/rtlfuncs.h>
+#include <strsafe.h>
+#include "wine/test.h"
+
+#include "appshim_apitest.h"
+
+static DWORD g_WinVersion;
+
+
+typedef struct expect_shim_hook
+{
+ const char* Library;
+ const char* Function;
+} expect_shim_hook;
+
+typedef struct expect_shim_data
+{
+ const WCHAR* ShimName;
+ DWORD MinVersion;
+ expect_shim_hook hooks[4];
+} expect_shim_data;
+
+
+static expect_shim_data data[] =
+{
+ {
+ L"VerifyVersionInfoLite",
+ 0,
+ {
+ { "KERNEL32.DLL", "VerifyVersionInfoA" },
+ { "KERNEL32.DLL", "VerifyVersionInfoW" },
+ }
+ },
+};
+
+static DWORD count_shims(expect_shim_data* data)
+{
+ DWORD num;
+ for (num = 0; num < _countof(data->hooks) &&
data->hooks[num].Library;)
+ {
+ ++num;
+ }
+ return num;
+}
+
+static const char* safe_str(const char* ptr)
+{
+ static char buffer[2][30];
+ static int index = 0;
+ if (HIWORD(ptr))
+ return ptr;
+
+ index ^= 1;
+ StringCchPrintfA(buffer[index], _countof(buffer[index]), "#%d", (int)ptr);
+ return buffer[index];
+}
+
+START_TEST(layer_hooks)
+{
+ RTL_OSVERSIONINFOEXW rtlinfo = {0};
+ size_t n, h;
+
+ tGETHOOKAPIS pGetHookAPIs = LoadShimDLL2(L"AcLayers.dll");
+ if (!pGetHookAPIs)
+ return;
+
+ rtlinfo.dwOSVersionInfoSize = sizeof(rtlinfo);
+ RtlGetVersion((PRTL_OSVERSIONINFOW)&rtlinfo);
+ g_WinVersion = (rtlinfo.dwMajorVersion << 8) | rtlinfo.dwMinorVersion;
+
+
+
+ for (n = 0; n < _countof(data); ++n)
+ {
+ expect_shim_data* current = data + n;
+ DWORD num_shims = 0, expected_shims = count_shims(current);
+
+ PHOOKAPI hook = pGetHookAPIs("", current->ShimName,
&num_shims);
+
+ if (current->MinVersion > g_WinVersion && !hook)
+ continue;
+
+ ok(!!hook, "Expected a valid pointer, got nothing for %s\n",
wine_dbgstr_w(current->ShimName));
+ ok(num_shims == expected_shims, "Expected %u shims, got %u for %s\n",
+ expected_shims, num_shims, wine_dbgstr_w(current->ShimName));
+ for (h = 0; h < min(num_shims, expected_shims); ++h)
+ {
+ expect_shim_hook* expect_hk = current->hooks + h;
+ PHOOKAPI got_hk = hook+h;
+ int lib = lstrcmpA(expect_hk->Library, got_hk->LibraryName);
+ int fn = lstrcmpA(safe_str(expect_hk->Function),
safe_str(got_hk->FunctionName));
+ ok(lib == 0, "Expected LibraryName to be %s, was: %s for %s\n",
+ expect_hk->Library, got_hk->LibraryName,
wine_dbgstr_w(current->ShimName));
+ ok(fn == 0, "Expected FunctionName to be %s, was: %s for %s\n",
+ safe_str(expect_hk->Function), safe_str(got_hk->FunctionName),
wine_dbgstr_w(current->ShimName));
+ }
+ if (num_shims > expected_shims)
+ {
+ for (h = expected_shims; h < num_shims; ++h)
+ {
+ PHOOKAPI got_hk = hook+h;
+
+ ok(0, "Extra shim: %s!%s for %s\n",
+ got_hk->LibraryName, safe_str(got_hk->FunctionName),
wine_dbgstr_w(current->ShimName));
+ }
+ }
+ else
+ {
+ for (h = num_shims; h < expected_shims; ++h)
+ {
+ expect_shim_hook* expect_hk = current->hooks + h;
+
+ ok(0, "Missing shim: %s!%s for %s\n",
+ expect_hk->Library, safe_str(expect_hk->Function),
wine_dbgstr_w(current->ShimName));
+ }
+ }
+ }
+}
diff --git a/modules/rostests/apitests/appshim/testlist.c
b/modules/rostests/apitests/appshim/testlist.c
index 2b2e692a3d..45275de5cd 100644
--- a/modules/rostests/apitests/appshim/testlist.c
+++ b/modules/rostests/apitests/appshim/testlist.c
@@ -5,12 +5,14 @@
extern void func_dispmode(void);
extern void func_genral_hooks(void);
+extern void func_layer_hooks(void);
extern void func_versionlie(void);
const struct test winetest_testlist[] =
{
{ "dispmode", func_dispmode },
{ "genral_hooks", func_genral_hooks },
+ { "layer_hooks", func_layer_hooks },
{ "versionlie", func_versionlie },
{ 0, 0 }
};