[vlc-devel] [PATCH] winvlc: Try to load DLLs from system32 before any other folder

Rémi Denis-Courmont remi at remlab.net
Fri Mar 10 17:46:28 CET 2017


Le perjantaina 10. maaliskuuta 2017, 14.49.42 EET Hugo Beauzée-Luyssen a 
écrit :
> ---
>  bin/winvlc.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/bin/winvlc.c b/bin/winvlc.c
> index ce44f5dd29..085a908fed 100644
> --- a/bin/winvlc.c
> +++ b/bin/winvlc.c
> @@ -78,7 +78,39 @@ static BOOL SetDefaultDllDirectories_(DWORD flags)
>      return SetDefaultDllDirectoriesReal(flags);
>  }
>  # define SetDefaultDllDirectories SetDefaultDllDirectories_
> +
> +#endif
> +
> +static void PrioritizeSystem32()

Sigh. This is not C++.

> +{
> +#if _WIN32_WINNT < _WIN32_WINNT_WIN10
> +    typedef struct _PROCESS_MITIGATION_IMAGE_LOAD_POLICY {
> +      union {
> +        DWORD  Flags;
> +        struct {
> +          DWORD NoRemoteImages  :1;
> +          DWORD NoLowMandatoryLabelImages  :1;
> +          DWORD PreferSystem32Images  :1;
> +          DWORD ReservedFlags  :29;

I´d use flag macros rather than bit fields but it looks like a Microsoft 
rather than Hugo problem.

> +        };
> +      };
> +    } PROCESS_MITIGATION_IMAGE_LOAD_POLICY;
> +#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
>  #endif
> +    PROCESS_MITIGATION_IMAGE_LOAD_POLICY m;

Incomplete initialization??

> +    m.Flags = 0;
> +    m.PreferSystem32Images = 1;
> +    SetProcessMitigationPolicy( 10 /* ProcessImageLoadPolicy */, &m,
> sizeof( m ) ); +}
> 
>  int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
>                      LPSTR lpCmdLine,
> @@ -126,6 +158,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);


-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list