This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

dlopen patch [was Re: dlopen]


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);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]