https://git.reactos.org/?p=reactos.git;a=commitdiff;h=575ab6c760ccc1439cf82…
commit 575ab6c760ccc1439cf829824b5721c0426cb88c
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Tue Apr 30 22:51:28 2019 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Wed May 1 19:22:19 2019 +0200
[ACGENRAL] Add a test shim
---
dll/appcompat/shims/genral/CMakeLists.txt | 1 +
dll/appcompat/shims/genral/shimtest.c | 88 +++++++++++++++++++++++++++++++
media/sdb/sysmain.xml | 14 +++++
3 files changed, 103 insertions(+)
diff --git a/dll/appcompat/shims/genral/CMakeLists.txt
b/dll/appcompat/shims/genral/CMakeLists.txt
index da6a55d998..bc2c1d083f 100644
--- a/dll/appcompat/shims/genral/CMakeLists.txt
+++ b/dll/appcompat/shims/genral/CMakeLists.txt
@@ -7,6 +7,7 @@ list(APPEND SOURCE
ignoredbgout.c
ignorefreelib.c
main.c
+ shimtest.c
themes.c
genral.spec)
diff --git a/dll/appcompat/shims/genral/shimtest.c
b/dll/appcompat/shims/genral/shimtest.c
new file mode 100644
index 0000000000..630b04263b
--- /dev/null
+++ b/dll/appcompat/shims/genral/shimtest.c
@@ -0,0 +1,88 @@
+/*
+ * PROJECT: ReactOS 'General' Shim library
+ * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE: Test shim used to verify the inner working of the shim engine
+ * COPYRIGHT: Copyright 2019 Mark Jansen (mark.jansen(a)reactos.org)
+ */
+
+#define WIN32_NO_STATUS
+#include <windef.h>
+#include <winbase.h>
+#include <shimlib.h>
+#include <strsafe.h>
+
+
+#define SHIM_NS ShimTest
+#include <setup_shim.inl>
+
+
+typedef BOOL (WINAPI *tGetComputerNameA)(LPSTR lpBuffer, LPDWORD lpnSize);
+
+BOOL WINAPI SHIM_OBJ_NAME(GetComputerNameA)(LPSTR lpBuffer, LPDWORD lpnSize)
+{
+ CHAR Buffer[100] = {0};
+ DWORD dwSize = sizeof(Buffer) - 1;
+ size_t cchLen;
+
+ if (CALL_SHIM(0, tGetComputerNameA)(Buffer, &dwSize))
+ {
+ SHIM_INFO("Original function returned: '%s'\n", Buffer);
+ }
+ else
+ {
+ SHIM_INFO("Original function failed\n");
+ Buffer[0] = '\0';
+ }
+
+ if (!lpnSize)
+ {
+ SHIM_WARN("No lpnSize\n");
+ return FALSE;
+ }
+
+ StringCchCopyA(lpBuffer, *lpnSize, "ShimTest:");
+ StringCchCatA(lpBuffer, *lpnSize, Buffer);
+ StringCchLengthA(lpBuffer, *lpnSize, &cchLen);
+ *lpnSize = (DWORD)cchLen;
+ return TRUE;
+}
+
+typedef INT (WINAPI *tSHStringFromGUIDA)(REFGUID guid, LPSTR lpszDest, INT cchMax);
+int WINAPI SHIM_OBJ_NAME(SHStringFromGUIDA)(REFGUID guid, LPSTR lpszDest, INT cchMax)
+{
+ CHAR Buffer[100] = {0};
+
+ if (CALL_SHIM(1, tSHStringFromGUIDA)(guid, Buffer, sizeof(Buffer)-1))
+ {
+ SHIM_INFO("Original function returned: '%s'\n", Buffer);
+ }
+ else
+ {
+ SHIM_INFO("Original function failed\n");
+ Buffer[0] = '\0';
+ }
+
+ StringCchCopyA(lpszDest, cchMax, "ShimTest:");
+ StringCchCatA(lpszDest, cchMax, Buffer);
+ return 0;
+}
+
+
+BOOL WINAPI SHIM_OBJ_NAME(Notify)(DWORD fdwReason, PVOID ptr)
+{
+ if (fdwReason == SHIM_REASON_INIT)
+ {
+ SHIM_MSG("SHIM_REASON_INIT\n");
+ }
+ return TRUE;
+}
+
+#define SHIM_NOTIFY_FN SHIM_OBJ_NAME(Notify)
+#define SHIM_NUM_HOOKS 2
+#define SHIM_SETUP_HOOKS \
+ SHIM_HOOK(0, "KERNEL32.DLL", "GetComputerNameA",
SHIM_OBJ_NAME(GetComputerNameA)) \
+ SHIM_HOOK(1, "SHLWAPI.DLL", (PCSTR)23, SHIM_OBJ_NAME(SHStringFromGUIDA))
+
+
+#include <implement_shim.inl>
+
diff --git a/media/sdb/sysmain.xml b/media/sdb/sysmain.xml
index de87df7c0d..7afab95388 100644
--- a/media/sdb/sysmain.xml
+++ b/media/sdb/sysmain.xml
@@ -225,6 +225,10 @@
<SHIM NAME="IgnoreLoadLibrary">
<DLLFILE>aclayers.dll</DLLFILE>
</SHIM>
+ <SHIM NAME="ShimTest">
+ <DLLFILE>acgenral.dll</DLLFILE>
+ <DESCRIPTION>Shim used to test ReactOS shim engine
functionality</DESCRIPTION>
+ </SHIM>
<SHIM NAME="VMHorizonSetup">
<DLLFILE>aclayers.dll</DLLFILE>
</SHIM>
@@ -405,5 +409,15 @@
<SHIM_REF NAME="IgnoreFreeLibrary"
COMMAND_LINE="libpng12.dll" />
</EXE>
+ <!-- ReactOS shim used to test the shim engine -->
+ <EXE NAME="shimtest_ros.exe" APP_NAME="Shim test
application" VENDOR="ReactOS">
+ <MATCHING_FILE NAME="*">
+ <FILE_DESCRIPTION>ReactOS Shim Engine test
utility</FILE_DESCRIPTION>
+ <ORIGINAL_FILENAME>shimtest_ros.exe</ORIGINAL_FILENAME>
+ <INTERNAL_NAME>shimtest_ros</INTERNAL_NAME>
+ <COMPANY_NAME>ReactOS - test</COMPANY_NAME>
+ </MATCHING_FILE>
+ <SHIM_REF NAME="ShimTest" />
+ </EXE>
</DATABASE>
</SDB>
\ No newline at end of file