diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2013-04-23 09:44:36 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2013-04-23 09:44:36 +0000 |
commit | 61522196c71593da09572fce9af9e0d7dad61bc3 (patch) | |
tree | 9bf74facd67974fa2f780d6ce68b14eb7a94e371 /winsup/cygwin/dlfcn.cc | |
parent | 1875ee55d31d3673059373c8f9837bf98f93c713 (diff) | |
download | cygnal-61522196c71593da09572fce9af9e0d7dad61bc3.tar.gz cygnal-61522196c71593da09572fce9af9e0d7dad61bc3.tar.bz2 cygnal-61522196c71593da09572fce9af9e0d7dad61bc3.zip |
* Merge in cygwin-64bit-branch.
Diffstat (limited to 'winsup/cygwin/dlfcn.cc')
-rw-r--r-- | winsup/cygwin/dlfcn.cc | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc index 0e664afca..c27adf675 100644 --- a/winsup/cygwin/dlfcn.cc +++ b/winsup/cygwin/dlfcn.cc @@ -1,7 +1,7 @@ /* dlfcn.cc Copyright 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, - 2010, 2011 Red Hat, Inc. + 2010, 2011, 2013 Red Hat, Inc. This file is part of Cygwin. @@ -155,33 +155,9 @@ dlopen (const char *name, int flags) || (ret = GetModuleHandleW (path)) != NULL) { ret = (void *) LoadLibraryW (path); - if (ret && (flags & RTLD_NODELETE) - && !GetModuleHandleExW (GET_MODULE_HANDLE_EX_FLAG_PIN, path, - (HMODULE *) &ret)) - { - /* Windows 2000 is missing the GetModuleHandleEx call, so we - use a non-documented way to set the DLL to "don't free". - This is how it works: Fetch the Windows Loader data from - the PEB. Iterate backwards through the list of loaded - DLLs and compare the DllBase address with the address - returned by LoadLibrary. If they are equal we found the - right entry. Now set the LoadCount to -1, which is the - marker for a DLL which should never be free'd. */ - PPEB_LDR_DATA ldr = NtCurrentTeb ()->Peb->Ldr; - - for (PLDR_DATA_TABLE_ENTRY entry = (PLDR_DATA_TABLE_ENTRY) - ldr->InLoadOrderModuleList.Blink; - entry && entry->DllBase; - entry = (PLDR_DATA_TABLE_ENTRY) - entry->InLoadOrderLinks.Blink) - { - if (entry->DllBase == ret) - { - entry->LoadCount = (WORD) -1; - break; - } - } - } + if (ret && (flags & RTLD_NODELETE)) + GetModuleHandleExW (GET_MODULE_HANDLE_EX_FLAG_PIN, path, + (HMODULE *) &ret); } /* Restore original cxx_malloc pointer. */ |