ReactOS 0.4.15-dev-7681-g776c3a3
ignoreloadlibrary.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS 'Layers' Shim library
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: IgnoreLoadLibrary shim
5 * COPYRIGHT: Copyright 2019 Mark Jansen (mark.jansen@reactos.org)
6 */
7
8#define WIN32_NO_STATUS
9#include <windef.h>
10#include <winbase.h>
11#include <shimlib.h>
12#include "ntndk.h"
13
14typedef HMODULE(WINAPI* LOADLIBRARYAPROC)(LPCSTR lpLibFileName);
16typedef HMODULE(WINAPI* LOADLIBRARYWPROC)(LPCWSTR lpLibFileName);
18
19
20#define SHIM_NS IgnoreLoadLibrary
21#include <setup_shim.inl>
22
23
24HMODULE WINAPI SHIM_OBJ_NAME(APIHook_LoadLibraryA)(LPCSTR lpLibFileName)
25{
26 HMODULE Module;
27 DWORD dwOldErrorMode;
28
30 Module = CALL_SHIM(0, LOADLIBRARYAPROC)(lpLibFileName);
31 SetErrorMode(dwOldErrorMode);
32
33 return Module;
34}
35
37{
38 HMODULE Module;
39 DWORD dwOldErrorMode;
40
42 Module = CALL_SHIM(1, LOADLIBRARYEXAPROC)(lpLibFileName, hFile, dwFlags);
43 SetErrorMode(dwOldErrorMode);
44
45 return Module;
46}
47
48HMODULE WINAPI SHIM_OBJ_NAME(APIHook_LoadLibraryW)(LPCWSTR lpLibFileName)
49{
50 HMODULE Module;
51 DWORD dwOldErrorMode;
52
54 Module = CALL_SHIM(2, LOADLIBRARYWPROC)(lpLibFileName);
55 SetErrorMode(dwOldErrorMode);
56
57 return Module;
58}
59
61{
62 HMODULE Module;
63 DWORD dwOldErrorMode;
64
66 Module = CALL_SHIM(3, LOADLIBRARYEXWPROC)(lpLibFileName, hFile, dwFlags);
67 SetErrorMode(dwOldErrorMode);
68
69 return Module;
70}
71
72
73#define SHIM_NUM_HOOKS 4
74#define SHIM_SETUP_HOOKS \
75 SHIM_HOOK(0, "KERNEL32.DLL", "LoadLibraryA", SHIM_OBJ_NAME(APIHook_LoadLibraryA)) \
76 SHIM_HOOK(1, "KERNEL32.DLL", "LoadLibraryExA", SHIM_OBJ_NAME(APIHook_LoadLibraryExA)) \
77 SHIM_HOOK(2, "KERNEL32.DLL", "LoadLibraryW", SHIM_OBJ_NAME(APIHook_LoadLibraryW)) \
78 SHIM_HOOK(3, "KERNEL32.DLL", "LoadLibraryExW", SHIM_OBJ_NAME(APIHook_LoadLibraryExW))
79
80#include <implement_shim.inl>
UINT WINAPI SetErrorMode(IN UINT uMode)
Definition: except.c:751
unsigned long DWORD
Definition: ntddk_ex.h:95
HMODULE(WINAPI * LOADLIBRARYEXAPROC)(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
HMODULE WINAPI SHIM_OBJ_NAME() APIHook_LoadLibraryW(LPCWSTR lpLibFileName)
HMODULE WINAPI SHIM_OBJ_NAME() APIHook_LoadLibraryExW(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
HMODULE(WINAPI * LOADLIBRARYWPROC)(LPCWSTR lpLibFileName)
HMODULE WINAPI SHIM_OBJ_NAME() APIHook_LoadLibraryA(LPCSTR lpLibFileName)
HMODULE(WINAPI * LOADLIBRARYAPROC)(LPCSTR lpLibFileName)
HMODULE(WINAPI * LOADLIBRARYEXWPROC)(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
HMODULE WINAPI SHIM_OBJ_NAME() APIHook_LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
_In_ HANDLE hFile
Definition: mswsock.h:90
#define SEM_FAILCRITICALERRORS
Definition: rtltypes.h:69
#define SEM_NOGPFAULTERRORBOX
Definition: rtltypes.h:70
#define SEM_NOOPENFILEERRORBOX
Definition: rtltypes.h:72
HANDLE HMODULE
Definition: typedefs.h:77
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define WINAPI
Definition: msvc.h:6
const char * LPCSTR
Definition: xmlstorage.h:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185