delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/07/16:53:17

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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
Cc: cygwin-patches 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 <sds AT gnu DOT org>
In-Reply-To: <20040901094429.GY17670@cygbert.vinschen.de> (Corinna Vinschen's message of "Wed, 1 Sep 2004 11:44:29 +0200")
References: <u65704sup DOT fsf AT gnu DOT org> <20040830143832 DOT GE17670 AT cygbert DOT vinschen DOT de> <uisb018x4 DOT fsf AT gnu DOT org> <20040831083258 DOT GA7517 AT cygbert DOT vinschen DOT de> <u1xhn1gaz DOT fsf AT gnu DOT org> <20040831190826 DOT GV17670 AT cygbert DOT vinschen DOT de> <uoekrxfqx DOT fsf AT gnu DOT org> <20040901094429 DOT GY17670 AT cygbert DOT vinschen DOT de>
Mail-Followup-To: cygwin AT cygwin DOT com, cygwin-patches AT cygwin DOT com
Date: Tue, 07 Sep 2004 16:52:46 -0400
Message-ID: <uoekhx0m9.fsf@gnu.org>
User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (windows-nt)
MIME-Version: 1.0

the (C) assignment is in the mail.

2004-08-31  Sam Steingold  <sds AT gnu DOT org>

	* 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>
Don't use force -- get a bigger hammer.


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 -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	7 Sep 2004 20:47:33 -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.24
diff -u -w -r1.24 dlfcn.cc
--- src/winsup/cygwin/dlfcn.cc	3 Sep 2004 01:53:11 -0000	1.24
+++ src/winsup/cygwin/dlfcn.cc	7 Sep 2004 20:47:33 -0000
@@ -112,7 +112,27 @@
 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;
+      if (!EnumProcessModules(cur_proc,NULL,0,&needed))
+        {
+         dlsym_fail:
+          set_dl_error ("dlsym");
+          return NULL;
+        }
+      modules = (HMODULE*)alloca(needed);
+      if (!EnumProcessModules(cur_proc,modules,needed,&needed))
+        goto dlsym_fail;
+      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);
Index: src/winsup/cygwin/autoload.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/autoload.cc,v
retrieving revision 1.87
diff -u -w -r1.87 autoload.cc
--- src/winsup/cygwin/autoload.cc	3 Sep 2004 01:32:02 -0000	1.87
+++ src/winsup/cygwin/autoload.cc	7 Sep 2004 20:47:33 -0000
@@ -309,6 +309,7 @@
 LoadDLLfunc (DeregisterEventSource, 4, advapi32)
 LoadDLLfunc (DuplicateToken, 12, advapi32)
 LoadDLLfuncEx (DuplicateTokenEx, 24, advapi32, 1)
+LoadDLLfuncEx (EnumProcessModules, 16, psapi, 1)
 LoadDLLfunc (EqualSid, 8, advapi32)
 LoadDLLfunc (FindFirstFreeAce, 8, advapi32)
 LoadDLLfunc (GetAce, 12, advapi32)

--
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/

- Raw text -


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