Commit 99db4743 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

winvlc: Try to load DLLs from system32 before any other folder

parent 9a2debd6
......@@ -78,7 +78,38 @@ static BOOL SetDefaultDllDirectories_(DWORD flags)
return SetDefaultDllDirectoriesReal(flags);
}
# define SetDefaultDllDirectories SetDefaultDllDirectories_
#endif
static void PrioritizeSystem32(void)
{
#ifndef HAVE_PROCESS_MITIGATION_IMAGE_LOAD_POLICY
typedef struct _PROCESS_MITIGATION_IMAGE_LOAD_POLICY {
union {
DWORD Flags;
struct {
DWORD NoRemoteImages :1;
DWORD NoLowMandatoryLabelImages :1;
DWORD PreferSystem32Images :1;
DWORD ReservedFlags :29;
};
};
} PROCESS_MITIGATION_IMAGE_LOAD_POLICY;
#endif
#if _WIN32_WINNT < _WIN32_WINNT_WIN8
BOOL WINAPI (*SetProcessMitigationPolicy)(PROCESS_MITIGATION_POLICY, PVOID, SIZE_T);
HINSTANCE h_Kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
if ( !h_Kernel32 )
return;
SetProcessMitigationPolicy = (BOOL (WINAPI *)(PROCESS_MITIGATION_POLICY, PVOID, SIZE_T))
GetProcAddress(h_Kernel32, "SetProcessMitigationPolicy");
if (SetProcessMitigationPolicy == NULL)
return;
#endif
PROCESS_MITIGATION_IMAGE_LOAD_POLICY m = { .Flags = 0 };
m.PreferSystem32Images = 1;
SetProcessMitigationPolicy( 10 /* ProcessImageLoadPolicy */, &m, sizeof( m ) );
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
......@@ -126,6 +157,10 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
* will search in SYSTEM32 only
* */
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32);
/***
* Load DLLs from system32 before any other folder (when possible)
*/
PrioritizeSystem32();
/* Args */
wchar_t **wargv = CommandLineToArgvW (GetCommandLine (), &argc);
......
......@@ -4119,6 +4119,14 @@ AS_IF([test "${with_kde_solid}" != "no"], [
AC_SUBST(soliddatadir)
AM_CONDITIONAL(KDE_SOLID, [test "x${soliddatadir}" != "x"])
dnl
dnl Check wether we have the PROCESS_MITIGATION_IMAGE_LOAD_POLICY
dnl It should only be available when building for win10, but some SDKs define it unconditionnaly
dnl
if test "${SYS}" = "mingw32"; then
AC_CHECK_TYPES([PROCESS_MITIGATION_IMAGE_LOAD_POLICY],,,[#include <windows.h>])
fi
EXTEND_HELP_STRING([Components:])
dnl
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment