[vlc-devel] [PATCH] winvlc: Try to load DLLs from system32 before any other folder
Hugo Beauzée-Luyssen
hugo at beauzee.fr
Fri Mar 10 17:58:54 CET 2017
On Fri, Mar 10, 2017, at 05:46 PM, Rémi Denis-Courmont wrote:
> 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++.
>
I'm not sure I understand your point.
> > +{
> > +#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.
>
Yep, I don't get to decide Microsoft's structure layout/usage
> > + };
> > + };
> > + } 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??
I'll assume you mean that it would be cleaner with partial
initialization of the struct and will replace with
PROCESS_MITIGATION_IMAGE_LOAD_POLICY m = { 0 };
>
> > + 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/
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
--
Hugo Beauzée-Luyssen
hugo at beauzee.fr
More information about the vlc-devel
mailing list