> * Corinna Vinschen <[EMAIL PROTECTED]> [2004-08-31 10:32:58 +0200]: > > On Aug 30 19:51, Sam Steingold wrote: >> > * Corinna Vinschen <[EMAIL PROTECTED]> [2004-08-30 16:38:32 +0200]: >> > >> > On Aug 30 10:13, Sam Steingold wrote: >> >> <http://www.opengroup.org/onlinepubs/009695399/functions/dlsym.html> >> >> 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 <[EMAIL PROTECTED]> * 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 <http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/> <http://www.mideasttruth.com/> <http://www.honestreporting.com> 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/