This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
dlopen patch [was Re: dlopen]
- To: Geoffrey Noer <noer at cygnus dot com>
- Subject: dlopen patch [was Re: dlopen]
- From: "Gary V. Vaughan" <gvaughan at oranda dot demon dot co dot uk>
- Date: Tue, 10 Nov 1998 18:20:42 +0000
- CC: Jorrit Tyberghein <Jorrit dot Tyberghein at uz dot kuleuven dot ac dot be>, gnu-win32 at cygnus dot com, Christian Jullien <Eligis at wanadoo dot fr>
- Organization: Aethos Communication Systems ltd.
- References: <36386742.E14F6F22@uz.kuleuven.ac.be> <3639AEEB.855AC45C@oranda.demon.co.uk> <19981030161916.56800@cygnus.com>
Geoffrey Noer wrote:
>
> On Fri, Oct 30, 1998 at 12:19:55PM +0000, Gary V. Vaughan wrote:
> >
> > Geoffrey, I notice that the dlopen emulation doesn't handle a NULL
> > argument as per the POSIX spec (i.e. return an introspective handle
> > to the current process), yet the win32 GetModuleHandle does... will
> > this be fixed for b20? Too late for a patch?
>
> Yep, much too late. I will gladly take a patch after b20 is out
> however...
Better late than never? Diffs attached. Interestingly, this doesn't
seem to fix my particular problem -- but unless there is funkiness with
casting from HMODULE (dlopen) to void* (dlsym) to HINSTANCE
(GetProcAddress), then by inspection it really ought to work, according
to the Borland Win32 API docs.
I guess my implementation is awry somehow.
Cheers,
Gary V. Vaughan
--- dlfcn.cc.orig Tue Nov 10 11:58:45 1998
+++ dlfcn.cc Tue Nov 10 12:07:11 1998
@@ -127,9 +127,21 @@ get_full_path_of_dll (const char* str)
void *
dlopen (const char *name, int)
{
- const char *fullpath = get_full_path_of_dll (name);
- DllList::the().currentDlOpenedLib (fullpath);
- void *ret = (void *) LoadLibrary (fullpath);
+ void *ret = 0;
+
+ if (!name)
+ {
+ // handle for the current module
+ ret = (void *) GetModuleHandle (0);
+ }
+ else
+ {
+ // handle for the named library
+ const char *fullpath = get_full_path_of_dll (name);
+ DllList::the().currentDlOpenedLib (fullpath);
+ ret = (void *) LoadLibrary (fullpath);
+ }
+
if (!ret)
set_dl_error ("dlopen");
debug_printf ("ret %p", ret);