[ACGENRAL] Add a test shim 1534/head
authorMark Jansen <mark.jansen@reactos.org>
Tue, 30 Apr 2019 20:51:28 +0000 (22:51 +0200)
committerMark Jansen <mark.jansen@reactos.org>
Wed, 1 May 2019 17:22:19 +0000 (19:22 +0200)
dll/appcompat/shims/genral/CMakeLists.txt
dll/appcompat/shims/genral/shimtest.c [new file with mode: 0644]
media/sdb/sysmain.xml

index da6a55d..bc2c1d0 100644 (file)
@@ -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 (file)
index 0000000..630b042
--- /dev/null
@@ -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@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>
+
index de87df7..7afab95 100644 (file)
             <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>
             <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