diff options
Diffstat (limited to 'C/DllSecur.c')
-rw-r--r-- | C/DllSecur.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/C/DllSecur.c b/C/DllSecur.c index 02a0f97..bbbfc0a 100644 --- a/C/DllSecur.c +++ b/C/DllSecur.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* DllSecur.c -- DLL loading security | 1 | /* DllSecur.c -- DLL loading security |
2 | 2023-04-02 : Igor Pavlov : Public domain */ | 2 | 2023-12-03 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
5 | 5 | ||
@@ -11,19 +11,7 @@ | |||
11 | 11 | ||
12 | #ifndef UNDER_CE | 12 | #ifndef UNDER_CE |
13 | 13 | ||
14 | #if (defined(__GNUC__) && (__GNUC__ >= 8)) || defined(__clang__) | 14 | Z7_DIAGNOSTIC_IGNORE_CAST_FUNCTION |
15 | // #pragma GCC diagnostic ignored "-Wcast-function-type" | ||
16 | #endif | ||
17 | |||
18 | #if defined(__clang__) || defined(__GNUC__) | ||
19 | typedef void (*Z7_voidFunction)(void); | ||
20 | #define MY_CAST_FUNC (Z7_voidFunction) | ||
21 | #elif defined(_MSC_VER) && _MSC_VER > 1920 | ||
22 | #define MY_CAST_FUNC (void *) | ||
23 | // #pragma warning(disable : 4191) // 'type cast': unsafe conversion from 'FARPROC' to 'void (__cdecl *)()' | ||
24 | #else | ||
25 | #define MY_CAST_FUNC | ||
26 | #endif | ||
27 | 15 | ||
28 | typedef BOOL (WINAPI *Func_SetDefaultDllDirectories)(DWORD DirectoryFlags); | 16 | typedef BOOL (WINAPI *Func_SetDefaultDllDirectories)(DWORD DirectoryFlags); |
29 | 17 | ||
@@ -61,7 +49,7 @@ static const char * const g_Dlls = | |||
61 | if ((UInt16)GetVersion() != 6) { \ | 49 | if ((UInt16)GetVersion() != 6) { \ |
62 | const \ | 50 | const \ |
63 | Func_SetDefaultDllDirectories setDllDirs = \ | 51 | Func_SetDefaultDllDirectories setDllDirs = \ |
64 | (Func_SetDefaultDllDirectories) MY_CAST_FUNC GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), \ | 52 | (Func_SetDefaultDllDirectories) Z7_CAST_FUNC_C GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), \ |
65 | "SetDefaultDllDirectories"); \ | 53 | "SetDefaultDllDirectories"); \ |
66 | if (setDllDirs) if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS)) return; } | 54 | if (setDllDirs) if (setDllDirs(MY_LOAD_LIBRARY_SEARCH_SYSTEM32 | MY_LOAD_LIBRARY_SEARCH_USER_DIRS)) return; } |
67 | 55 | ||