[ACLAYERS] Add stubplemented IgnoreLoadLibrary shim
authorMark Jansen <mark.jansen@reactos.org>
Sun, 10 Mar 2019 23:04:13 +0000 (00:04 +0100)
committerMark Jansen <mark.jansen@reactos.org>
Thu, 14 Mar 2019 19:02:00 +0000 (20:02 +0100)
CORE-15845

dll/appcompat/shims/layer/CMakeLists.txt
dll/appcompat/shims/layer/ignoreloadlibrary.c [new file with mode: 0644]
media/sdb/sysmain.xml

index 92b168f..d2b70b2 100644 (file)
@@ -6,6 +6,7 @@ spec2def(aclayers.dll layer.spec)
 list(APPEND SOURCE
     dispmode.c
     forcedxsetupsuccess.c
+    ignoreloadlibrary.c
     versionlie.c
     vmhorizon.c
     main.c
diff --git a/dll/appcompat/shims/layer/ignoreloadlibrary.c b/dll/appcompat/shims/layer/ignoreloadlibrary.c
new file mode 100644 (file)
index 0000000..43f236f
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * PROJECT:     ReactOS 'Layers' Shim library
+ * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
+ * PURPOSE:     IgnoreLoadLibrary shim
+ * COPYRIGHT:   Copyright 2019 Mark Jansen (mark.jansen@reactos.org)
+ */
+
+#define WIN32_NO_STATUS
+#include <windef.h>
+#include <winbase.h>
+#include <shimlib.h>
+#include "ntndk.h"
+
+typedef HMODULE(WINAPI* LOADLIBRARYAPROC)(LPCSTR lpLibFileName);
+typedef HMODULE(WINAPI* LOADLIBRARYEXAPROC)(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
+typedef HMODULE(WINAPI* LOADLIBRARYWPROC)(LPCWSTR lpLibFileName);
+typedef HMODULE(WINAPI* LOADLIBRARYEXWPROC)(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
+
+
+#define SHIM_NS         IgnoreLoadLibrary
+#include <setup_shim.inl>
+
+
+HMODULE WINAPI SHIM_OBJ_NAME(APIHook_LoadLibraryA)(LPCSTR lpLibFileName)
+{
+    HMODULE Module;
+    DWORD dwOldErrorMode;
+
+    dwOldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
+    Module = CALL_SHIM(0, LOADLIBRARYAPROC)(lpLibFileName);
+    SetErrorMode(dwOldErrorMode);
+
+    return Module;
+}
+
+HMODULE WINAPI SHIM_OBJ_NAME(APIHook_LoadLibraryExA)(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
+{
+    HMODULE Module;
+    DWORD dwOldErrorMode;
+
+    dwOldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
+    Module = CALL_SHIM(1, LOADLIBRARYEXAPROC)(lpLibFileName, hFile, dwFlags);
+    SetErrorMode(dwOldErrorMode);
+
+    return Module;
+}
+
+HMODULE WINAPI SHIM_OBJ_NAME(APIHook_LoadLibraryW)(LPCWSTR lpLibFileName)
+{
+    HMODULE Module;
+    DWORD dwOldErrorMode;
+
+    dwOldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
+    Module = CALL_SHIM(2, LOADLIBRARYWPROC)(lpLibFileName);
+    SetErrorMode(dwOldErrorMode);
+
+    return Module;
+}
+
+HMODULE WINAPI SHIM_OBJ_NAME(APIHook_LoadLibraryExW)(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
+{
+    HMODULE Module;
+    DWORD dwOldErrorMode;
+
+    dwOldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
+    Module = CALL_SHIM(3, LOADLIBRARYEXWPROC)(lpLibFileName, hFile, dwFlags);
+    SetErrorMode(dwOldErrorMode);
+
+    return Module;
+}
+
+
+#define SHIM_NUM_HOOKS  4
+#define SHIM_SETUP_HOOKS \
+    SHIM_HOOK(0, "KERNEL32.DLL", "LoadLibraryA", SHIM_OBJ_NAME(APIHook_LoadLibraryA)) \
+    SHIM_HOOK(1, "KERNEL32.DLL", "LoadLibraryExA", SHIM_OBJ_NAME(APIHook_LoadLibraryExA)) \
+    SHIM_HOOK(2, "KERNEL32.DLL", "LoadLibraryW", SHIM_OBJ_NAME(APIHook_LoadLibraryW)) \
+    SHIM_HOOK(3, "KERNEL32.DLL", "LoadLibraryExW", SHIM_OBJ_NAME(APIHook_LoadLibraryExW))
+
+#include <implement_shim.inl>
index c5123e9..de87df7 100644 (file)
             <SHIM NAME="IgnoreFreeLibrary">
                 <DLLFILE>acgenral.dll</DLLFILE>
             </SHIM>
+            <SHIM NAME="IgnoreLoadLibrary">
+                <DLLFILE>aclayers.dll</DLLFILE>
+            </SHIM>
             <SHIM NAME="VMHorizonSetup">
                 <DLLFILE>aclayers.dll</DLLFILE>
             </SHIM>
         <LAYER NAME="WIN95">
             <SHIM_REF NAME="Win95VersionLie" />
             <SHIM_REF NAME="ForceDXSetupSuccess" />
+            <SHIM_REF NAME="IgnoreLoadLibrary" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
         <LAYER NAME="WIN98">
             <SHIM_REF NAME="Win98VersionLie" />
             <SHIM_REF NAME="ForceDXSetupSuccess" />
+            <SHIM_REF NAME="IgnoreLoadLibrary" />
             <!-- TODO: Add more fixes! -->
         </LAYER>
         <LAYER NAME="NT4SP5">