delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/11/11/18:39:04

From: gvaughan AT oranda DOT demon DOT co DOT uk (Gary V. Vaughan)
Subject: dlopen patch [was Re: dlopen]
11 Nov 1998 18:39:04 -0800 :
Message-ID: <364883FA.B4BB64EA.cygnus.gnu-win32@oranda.demon.co.uk>
References: <36386742 DOT E14F6F22 AT uz DOT kuleuven DOT ac DOT be>
Mime-Version: 1.0
To: Geoffrey Noer <noer AT cygnus DOT com>
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>

This is a multi-part message in MIME format.
--------------3CCD973B6A887E0AB8B4B2DB
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

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
--------------3CCD973B6A887E0AB8B4B2DB
Content-Type: text/plain; charset=us-ascii;
 name="dlopen-gvv-19981110"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="dlopen-gvv-19981110"

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

--------------3CCD973B6A887E0AB8B4B2DB--

-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019