[PATCH 0/2] Drop pointless loadlib.h use in utilities

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Feb 28 09:39:34 GMT 2022


On Feb 26 16:40, Jon Turney wrote:
> The only remaining uses of loadlib.h are in cygcheck and strace, where it's
> used to load cygwin1.dll in both.
> 
> Things could be further simplified, but it's probably worth keeping it
> around in it's present form since it's quite likely that
> LoadLibrary()/GetProcAddress() might be used again in future.
> 
> Jon Turney (2):
>   Cygwin: Drop pointless loadlib.h includes in utilities
>   Cygwin: Drop use of loadlib.h in regtool
> 
>  winsup/utils/cygpath.cc     |  1 -
>  winsup/utils/module_info.cc |  1 -
>  winsup/utils/path.cc        |  1 -
>  winsup/utils/ps.cc          |  1 -
>  winsup/utils/regtool.cc     | 13 +------------
>  5 files changed, 1 insertion(+), 16 deletions(-)
> 
> -- 
> 2.35.1

Good idea!

Shouldn't we actually remove loadlib.h as well?  What this code does is
to provide a safety measure to make sure the files are not stealthy
loaded from another dir.  This should not be necessary anymore, because
Windows itself provides matching functionality.

First of all, the system has an internal list of DLLs it always
loads from the system32 dir.  In Cygwin, see the content of
/proc/sys/KnownDlls/ and /proc/sys/KnownDlls32/

And for all other cases we can use LoadLibraryEx flags introduced a
couple of years ago, e. g.  LOAD_LIBRARY_SEARCH_SYSTEM32.  See
https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexa


Thanks,
Corinna


More information about the Cygwin-patches mailing list