[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 18:26:32 CET 2017


Le perjantaina 10. maaliskuuta 2017, 17.58.54 EET Hugo Beauzée-Luyssen a 
écrit :
> 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.

The protoyype might be correct in C++. But it is incomplete in C syntax.

> 
> > > +{
> > > +#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 };

I misread the code because the structure layout is confusing.

Still I´d use named initializers here.

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



More information about the vlc-devel mailing list