Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com To: cygwin AT cygwin DOT com Subject: Re: RTLD_DEFAULT & RTLD_NEXT Mail-Copies-To: never Reply-To: sds AT gnu DOT org X-Attribution: Sam X-Disclaimer: You should not expect anyone to agree with me. From: Sam Steingold In-Reply-To: <20040831083258.GA7517@cygbert.vinschen.de> (Corinna Vinschen's message of "Tue, 31 Aug 2004 10:32:58 +0200") References: <20040830143832 DOT GE17670 AT cygbert DOT vinschen DOT de> <20040831083258 DOT GA7517 AT cygbert DOT vinschen DOT de> Mail-Followup-To: cygwin AT cygwin DOT com Date: Tue, 31 Aug 2004 11:24:36 -0400 Message-ID: User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (windows-nt) MIME-Version: 1.0 Content-Type: text/plain > * Corinna Vinschen [2004-08-31 10:32:58 +0200]: > > On Aug 30 19:51, Sam Steingold wrote: >> > * Corinna Vinschen [2004-08-30 16:38:32 +0200]: >> > >> > On Aug 30 10:13, Sam Steingold wrote: >> >> >> >> Any plans to implement RTLD_DEFAULT & RTLD_NEXT? >> > >> > Nope, but you know http://cygwin.com/acronyms/#PTC , don't you? :-) >> >> looks like there is no way in win32 to get the list of all open >> libraries, is there? (and no analogue for RTLD_DEFAULT either). > > EnumProcessModules. This should also allow to implement RTLD_DEFAULT. 2004-08-31 Sam Steingold * dlfcn.cc (dlsym): Handle RTLD_DEFAULT using EnumProcessModules(). * include/dlfcn.h (RTLD_DEFAULT): Define to NULL. -- Sam Steingold (http://www.podval.org/~sds) running w2k Bill Gates is not god and Microsoft is not heaven. Index: src/winsup/cygwin/include/dlfcn.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/include/dlfcn.h,v retrieving revision 1.2 diff -u -w -b -r1.2 dlfcn.h --- src/winsup/cygwin/include/dlfcn.h 11 Sep 2001 20:01:01 -0000 1.2 +++ src/winsup/cygwin/include/dlfcn.h 31 Aug 2004 14:53:48 -0000 @@ -28,6 +28,7 @@ extern void dlfork (int); /* following doesn't exist in Win32 API .... */ +#define RTLD_DEFAULT NULL /* valid values for mode argument to dlopen */ #define RTLD_LAZY 1 /* lazy function call binding */ Index: src/winsup/cygwin/dlfcn.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/dlfcn.cc,v retrieving revision 1.23 diff -u -w -b -r1.23 dlfcn.cc --- src/winsup/cygwin/dlfcn.cc 9 Feb 2004 04:04:22 -0000 1.23 +++ src/winsup/cygwin/dlfcn.cc 31 Aug 2004 14:53:48 -0000 @@ -112,7 +112,19 @@ void * dlsym (void *handle, const char *name) { - void *ret = (void *) GetProcAddress ((HMODULE) handle, name); + void *ret = NULL; + if (handle == RTLD_DEFAULT) { /* search all modules */ + HANDLE cur_proc = GetCurrentProcess(); + HMODULE *modules; + DWORD needed, i; + EnumProcessModules(cur_proc,NULL,0,&needed); + modules = alloca(sizeof(HMODULE)*needed); + if (!EnumProcessModules(cur_proc,modules,needed,&needed)) + set_dl_error ("dlsym"); + for (i=0; i < needed/sizeof(HMODULE); i++) + if ((ret = (void*)GetProcAddress(modules[i],name))) + break; + } else ret = (void*)GetProcAddress((HMODULE)handle,name); if (!ret) set_dl_error ("dlsym"); debug_printf ("ret %p", ret); -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/