https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0e9ca37517ee7ab224e94…
commit 0e9ca37517ee7ab224e940649a4cd058e1184c63
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Tue Apr 30 22:50:21 2019 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Wed May 1 19:22:19 2019 +0200
[ROSAPPS] Add a test application for shims
---
.../rosapps/applications/devutils/CMakeLists.txt | 1 +
.../devutils/shimtest_ros/CMakeLists.txt | 8 ++
.../devutils/shimtest_ros/shimtest_ros.c | 120 +++++++++++++++++++++
.../devutils/shimtest_ros/shimtest_ros.rc | 6 ++
4 files changed, 135 insertions(+)
diff --git a/modules/rosapps/applications/devutils/CMakeLists.txt
b/modules/rosapps/applications/devutils/CMakeLists.txt
index 5ea4b089d6..ccbc43e68e 100644
--- a/modules/rosapps/applications/devutils/CMakeLists.txt
+++ b/modules/rosapps/applications/devutils/CMakeLists.txt
@@ -5,6 +5,7 @@ add_subdirectory(gdihv)
add_subdirectory(genguid)
add_subdirectory(nls2txt)
add_subdirectory(shimdbg)
+add_subdirectory(shimtest_ros)
add_subdirectory(shlextdbg)
add_subdirectory(symdump)
add_subdirectory(syscalldump)
diff --git a/modules/rosapps/applications/devutils/shimtest_ros/CMakeLists.txt
b/modules/rosapps/applications/devutils/shimtest_ros/CMakeLists.txt
new file mode 100644
index 0000000000..d4fc95484c
--- /dev/null
+++ b/modules/rosapps/applications/devutils/shimtest_ros/CMakeLists.txt
@@ -0,0 +1,8 @@
+
+project(appcompat)
+
+add_executable(shimtest_ros shimtest_ros.c shimtest_ros.rc)
+
+set_module_type(shimtest_ros win32cui)
+add_importlibs(shimtest_ros shlwapi msvcrt kernel32 ntdll)
+add_cd_file(TARGET shimtest_ros DESTINATION reactos/bin FOR all)
diff --git a/modules/rosapps/applications/devutils/shimtest_ros/shimtest_ros.c
b/modules/rosapps/applications/devutils/shimtest_ros/shimtest_ros.c
new file mode 100644
index 0000000000..69592297e1
--- /dev/null
+++ b/modules/rosapps/applications/devutils/shimtest_ros/shimtest_ros.c
@@ -0,0 +1,120 @@
+/*
+ * PROJECT: Shim test application
+ * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE: Test application for the shim engine
+ * COPYRIGHT: Copyright 2019 Mark Jansen (mark.jansen(a)reactos.org)
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <ntndk.h>
+#include <winbase.h>
+
+NTSYSAPI ULONG NTAPI vDbgPrintEx(_In_ ULONG ComponentId, _In_ ULONG Level, _In_z_ PCCH
Format, _In_ va_list ap);
+#define DPFLTR_ERROR_LEVEL 0
+
+void xprintf(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ vDbgPrintEx(-1, DPFLTR_ERROR_LEVEL, fmt, ap);
+ va_end(ap);
+}
+
+void test_normal_imports()
+{
+ char buf[100];
+ DWORD dwSize;
+ HMODULE mod;
+ BOOL (WINAPI *p_GetComputerNameA)(LPSTR lpBuffer, LPDWORD lpnSize);
+
+ /* Call it directly */
+ ZeroMemory(buf, sizeof(buf));
+ dwSize = sizeof(buf);
+ if (!GetComputerNameA(buf, &dwSize))
+ {
+ xprintf("GetComputerNameA failed: %d\n", GetLastError());
+ }
+ else
+ {
+ xprintf("GetComputerNameA returned: '%s'\n", buf);
+ }
+
+ /* Call it using GetProcAddress */
+ mod = GetModuleHandleA("kernel32.dll");
+ p_GetComputerNameA = (void*)GetProcAddress(mod, "GetComputerNameA");
+ if (p_GetComputerNameA == NULL)
+ {
+ xprintf("GetProcAddress failed: %d\n", GetLastError());
+ }
+ else
+ {
+ ZeroMemory(buf, sizeof(buf));
+ dwSize = sizeof(buf);
+ if (!p_GetComputerNameA(buf, &dwSize))
+ {
+ xprintf("p_GetComputerNameA failed: %d\n", GetLastError());
+ }
+ else
+ {
+ xprintf("p_GetComputerNameA returned: '%s'\n", buf);
+ }
+ }
+}
+
+INT WINAPI SHStringFromGUIDA(REFGUID,LPSTR,INT);
+void test_ordinal_imports()
+{
+ GUID guid = { 0x11223344, 0x5566, 0x7788 };
+ char buf[100];
+ int r;
+ HMODULE mod;
+ INT (WINAPI *p_SHStringFromGUIDA)(REFGUID guid, LPSTR lpszDest, INT cchMax);
+
+ /* Call it directly */
+ ZeroMemory(buf, sizeof(buf));
+ r = SHStringFromGUIDA(&guid, buf, _countof(buf)-1);
+ if (r)
+ {
+ xprintf("SHStringFromGUIDA failed (%d)\n", r);
+ }
+ else
+ {
+ xprintf("SHStringFromGUIDA returned: '%s'\n", buf);
+ }
+
+ /* Call it using GetProcAddress */
+ mod = GetModuleHandleA("shlwapi.dll");
+ p_SHStringFromGUIDA = (void*)GetProcAddress(mod, (LPCSTR)23);
+ if (p_SHStringFromGUIDA == NULL)
+ {
+ xprintf("GetProcAddress failed: %d\n", GetLastError());
+ }
+ else
+ {
+ ZeroMemory(buf, sizeof(buf));
+ r = p_SHStringFromGUIDA(&guid, buf, _countof(buf)-1);
+ if (r)
+ {
+ xprintf("p_SHStringFromGUIDA failed (%d)\n", r);
+ }
+ else
+ {
+ xprintf("p_SHStringFromGUIDA returned: '%s'\n", buf);
+ }
+ }
+}
+
+
+int main(int argc, char* argv[])
+{
+ xprintf("Normal import (kernel32!GetComputerNameA)\n");
+ test_normal_imports();
+ xprintf("\nOrdinal import (shlwapi!#23)\n");
+ test_ordinal_imports();
+
+ return 0;
+}
diff --git a/modules/rosapps/applications/devutils/shimtest_ros/shimtest_ros.rc
b/modules/rosapps/applications/devutils/shimtest_ros/shimtest_ros.rc
new file mode 100644
index 0000000000..147e770cda
--- /dev/null
+++ b/modules/rosapps/applications/devutils/shimtest_ros/shimtest_ros.rc
@@ -0,0 +1,6 @@
+
+#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Shim Engine test utility"
+#define REACTOS_STR_INTERNAL_NAME "shimtest_ros"
+#define REACTOS_STR_ORIGINAL_FILENAME "shimtest_ros.exe"
+#define REACTOS_STR_COMPANY_NAME "ReactOS - test"
+#include <reactos/version.rc>