* autoload.cc (EnumProcessModules): Add.

* dlfcn.cc (dlsym): Handle RTLD_DEFAULT using EnumProcessModules().
	* include/dlfcn.h (RTLD_DEFAULT): Define to NULL.
This commit is contained in:
Corinna Vinschen 2004-09-14 08:29:12 +00:00
parent fc3a42749f
commit 599b41c4ec
4 changed files with 30 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2004-09-14 Sam Steingold <sds@gnu.org>
* autoload.cc (EnumProcessModules): Add.
* dlfcn.cc (dlsym): Handle RTLD_DEFAULT using EnumProcessModules().
* include/dlfcn.h (RTLD_DEFAULT): Define to NULL.
2004-09-13 Christopher Faylor <cgf@timesys.com>
* fork.cc (slow_pid_reuse): Temporarily double the number of pids held

View File

@ -391,6 +391,7 @@ LoadDLLfuncEx (RtlInitUnicodeString, 8, ntdll, 1)
LoadDLLfuncEx (RtlNtStatusToDosError, 4, ntdll, 1)
LoadDLLfuncEx (RtlIsDosDeviceName_U, 4, ntdll, 1)
LoadDLLfuncEx (EnumProcessModules, 16, psapi, 1)
LoadDLLfuncEx (GetProcessMemoryInfo, 12, psapi, 1)
LoadDLLfuncEx (LsaDeregisterLogonProcess, 4, secur32, 1)

View File

@ -9,6 +9,7 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <psapi.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@ -112,7 +113,27 @@ dlopen (const char *name, int)
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);

View File

@ -28,6 +28,7 @@ extern char *dlerror (void);
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 */