forked from enlightenment/efl
Evil: add RTLD_DEFAULT support for dlsym()
SVN revision: 63373
This commit is contained in:
parent
61b786c4e8
commit
585938123d
|
@ -1,3 +1,8 @@
|
||||||
|
2011-09-14 Vincent Torri <doursse at users dot sf dot net>
|
||||||
|
|
||||||
|
* src/lib/dlfcn/dlfcn.c:
|
||||||
|
add RTLD_DEFAULT support in dlsym()
|
||||||
|
|
||||||
2011-05-19 Vincent Torri <doursse at users dot sf dot net>
|
2011-05-19 Vincent Torri <doursse at users dot sf dot net>
|
||||||
|
|
||||||
* src/lib/dlfcn/dlfcn.c:
|
* src/lib/dlfcn/dlfcn.c:
|
||||||
|
|
|
@ -9,7 +9,7 @@ dist_stdheaders_DATA = dlfcn.h
|
||||||
|
|
||||||
libdl_la_SOURCES = dlfcn.c
|
libdl_la_SOURCES = dlfcn.c
|
||||||
|
|
||||||
libdl_la_CPPFLAGS = -DEFL_EVIL_DLFCN_BUILD
|
libdl_la_CPPFLAGS = @win32_cppflags@ -DEFL_EVIL_DLFCN_BUILD -DPSAPI_VERSION=1
|
||||||
libdl_la_CFLAGS = @win32_cflags@
|
libdl_la_CFLAGS = @win32_cflags@
|
||||||
libdl_la_LIBADD = $(top_builddir)/src/lib/libevil.la $(EFL_MPATROL_LIBS)
|
libdl_la_LIBADD = $(top_builddir)/src/lib/libevil.la $(EFL_MPATROL_LIBS) -lpsapi
|
||||||
libdl_la_LDFLAGS = -no-undefined -Wl,--enable-auto-import -version-info @version_info@
|
libdl_la_LDFLAGS = -no-undefined -Wl,--enable-auto-import -version-info @version_info@
|
||||||
|
|
|
@ -8,6 +8,9 @@
|
||||||
# include <limits.h>
|
# include <limits.h>
|
||||||
#endif /* __MINGW32CE__ || _MSC_VER */
|
#endif /* __MINGW32CE__ || _MSC_VER */
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <psapi.h> /* EnumProcessModules(Ex) */
|
||||||
|
|
||||||
#include "../Evil.h"
|
#include "../Evil.h"
|
||||||
|
|
||||||
#include "dlfcn.h"
|
#include "dlfcn.h"
|
||||||
|
@ -115,19 +118,41 @@ dlclose(void* handle)
|
||||||
void *
|
void *
|
||||||
dlsym(void *handle, const char *symbol)
|
dlsym(void *handle, const char *symbol)
|
||||||
{
|
{
|
||||||
FARPROC fp;
|
FARPROC fp = NULL;
|
||||||
|
LPCTSTR new_symbol;
|
||||||
|
|
||||||
|
if (!symbol || !*symbol) return NULL;
|
||||||
|
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
{
|
new_symbol = evil_char_to_wchar(symbol);
|
||||||
wchar_t *wsymbol;
|
|
||||||
|
|
||||||
wsymbol = evil_char_to_wchar(symbol);
|
|
||||||
fp = GetProcAddress(handle, wsymbol);
|
|
||||||
free(wsymbol);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
fp = GetProcAddress(handle, symbol);
|
new_symbol = symbol;
|
||||||
#endif /* ! UNICODE */
|
#endif /* UNICODE */
|
||||||
|
|
||||||
|
if (handle == RTLD_DEFAULT)
|
||||||
|
{
|
||||||
|
HMODULE modules[1024];
|
||||||
|
DWORD needed;
|
||||||
|
DWORD i;
|
||||||
|
|
||||||
|
/* TODO: use EnumProcessModulesEx() on Windows >= Vista */
|
||||||
|
if (!EnumProcessModules(GetCurrentProcess(),
|
||||||
|
modules, sizeof(modules), &needed))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < (needed / sizeof(HMODULE)); i++)
|
||||||
|
{
|
||||||
|
fp = GetProcAddress(modules[i], new_symbol);
|
||||||
|
if (fp) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fp = GetProcAddress(handle, new_symbol);
|
||||||
|
|
||||||
|
#ifdef UNICODE
|
||||||
|
free(new_symbol);
|
||||||
|
#endif /* UNICODE */
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
get_last_error("GetProcAddress returned: ");
|
get_last_error("GetProcAddress returned: ");
|
||||||
|
|
||||||
|
|
|
@ -59,12 +59,18 @@ extern "C" {
|
||||||
* Symbols in this dlopen'ed obj are visible to other dlopen'ed objs
|
* Symbols in this dlopen'ed obj are visible to other dlopen'ed objs
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def RTLD_DEFAULT
|
||||||
|
* Symbols are searched in all the DLL opened by the current process
|
||||||
|
*/
|
||||||
|
|
||||||
# define RTLD_LAZY 0x00001 /* lazy function call binding */
|
# define RTLD_LAZY 0x00001 /* lazy function call binding */
|
||||||
# define RTLD_NOW 0x00002 /* immediate function call binding */
|
# define RTLD_NOW 0x00002 /* immediate function call binding */
|
||||||
# define RTLD_GLOBAL 0x00100 /* symbols in this dlopen'ed obj are visible
|
# define RTLD_GLOBAL 0x00100 /* symbols in this dlopen'ed obj are visible
|
||||||
to other dlopen'ed objs */
|
to other dlopen'ed objs */
|
||||||
#define RTLD_NODELETE 0x01000 /* do not delete object when closed. */
|
#define RTLD_NODELETE 0x01000 /* do not delete object when closed. */
|
||||||
|
|
||||||
|
#define RTLD_DEFAULT ((void*)1) /* search the symbol on all the DLL of the current process */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef Dl_info
|
* @typedef Dl_info
|
||||||
|
|
|
@ -81,7 +81,7 @@ evil_format_message(long err)
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
str = evil_wchar_to_char(msg);
|
str = evil_wchar_to_char(msg);
|
||||||
#else
|
#else
|
||||||
str = strdup(msg);
|
str = msg;
|
||||||
#endif /* UNICODE */
|
#endif /* UNICODE */
|
||||||
|
|
||||||
LocalFree(msg);
|
LocalFree(msg);
|
||||||
|
@ -93,7 +93,9 @@ evil_format_message(long err)
|
||||||
snprintf(disp, strlen(str) + strlen("(00000) ") + 1,
|
snprintf(disp, strlen(str) + strlen("(00000) ") + 1,
|
||||||
"(%5ld) %s", err, str);
|
"(%5ld) %s", err, str);
|
||||||
|
|
||||||
|
#ifdef UNICODE
|
||||||
free(str);
|
free(str);
|
||||||
|
#endif /* UNICODE */
|
||||||
|
|
||||||
return disp;
|
return disp;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue