summaryrefslogtreecommitdiffstats
path: root/crypto/dso
diff options
context:
space:
mode:
authorRich Salz <rsalz@openssl.org>2016-03-22 14:33:00 -0400
committerRich Salz <rsalz@openssl.org>2016-03-23 08:34:33 -0400
commit3d8b2ec42bcb1cfe2f6f502ea8c6f098202a2906 (patch)
treec6b33600fafbb424e4ccbeb0e93f8dc620521d00 /crypto/dso
parentde7058241083e9ec80c4ad27e7bb4f2bd79e36f2 (diff)
Remove several unused undocumented functions.
Removed the following: DSO_bind_var, DSO_bind_var, DSO_get_default_method, DSO_get_loaded_filename, DSO_get_loaded_filename, DSO_get_method, DSO_new_method, DSO_pathbyaddr, DSO_set_default_method, DSO_set_method, DSO_set_name_converter, DSO_set_name_converter Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/dso')
-rw-r--r--crypto/dso/dso_dl.c62
-rw-r--r--crypto/dso/dso_dlfcn.c62
-rw-r--r--crypto/dso/dso_err.c15
-rw-r--r--crypto/dso/dso_lib.c95
-rw-r--r--crypto/dso/dso_locl.h4
-rw-r--r--crypto/dso/dso_vms.c9
-rw-r--r--crypto/dso/dso_win32.c138
7 files changed, 7 insertions, 378 deletions
diff --git a/crypto/dso/dso_dl.c b/crypto/dso/dso_dl.c
index 72ca4544aa..5a138b3082 100644
--- a/crypto/dso/dso_dl.c
+++ b/crypto/dso/dso_dl.c
@@ -67,26 +67,22 @@
static int dl_load(DSO *dso);
static int dl_unload(DSO *dso);
-static void *dl_bind_var(DSO *dso, const char *symname);
static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname);
static char *dl_name_converter(DSO *dso, const char *filename);
static char *dl_merger(DSO *dso, const char *filespec1,
const char *filespec2);
-static int dl_pathbyaddr(void *addr, char *path, int sz);
static void *dl_globallookup(const char *name);
static DSO_METHOD dso_meth_dl = {
"OpenSSL 'dl' shared library method",
dl_load,
dl_unload,
- dl_bind_var,
dl_bind_func,
NULL, /* ctrl */
dl_name_converter,
dl_merger,
NULL, /* init */
NULL, /* finish */
- dl_pathbyaddr,
dl_globallookup
};
@@ -164,32 +160,6 @@ static int dl_unload(DSO *dso)
return (1);
}
-static void *dl_bind_var(DSO *dso, const char *symname)
-{
- shl_t ptr;
- void *sym;
-
- if ((dso == NULL) || (symname == NULL)) {
- DSOerr(DSO_F_DL_BIND_VAR, ERR_R_PASSED_NULL_PARAMETER);
- return (NULL);
- }
- if (sk_num(dso->meth_data) < 1) {
- DSOerr(DSO_F_DL_BIND_VAR, DSO_R_STACK_ERROR);
- return (NULL);
- }
- ptr = (shl_t) sk_value(dso->meth_data, sk_num(dso->meth_data) - 1);
- if (ptr == NULL) {
- DSOerr(DSO_F_DL_BIND_VAR, DSO_R_NULL_HANDLE);
- return (NULL);
- }
- if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0) {
- DSOerr(DSO_F_DL_BIND_VAR, DSO_R_SYM_FAILURE);
- ERR_add_error_data(4, "symname(", symname, "): ", strerror(errno));
- return (NULL);
- }
- return (sym);
-}
-
static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname)
{
shl_t ptr;
@@ -310,38 +280,6 @@ static char *dl_name_converter(DSO *dso, const char *filename)
return (translated);
}
-static int dl_pathbyaddr(void *addr, char *path, int sz)
-{
- struct shl_descriptor inf;
- int i, len;
-
- if (addr == NULL) {
- union {
- int (*f) (void *, char *, int);
- void *p;
- } t = {
- dl_pathbyaddr
- };
- addr = t.p;
- }
-
- for (i = -1; shl_get_r(i, &inf) == 0; i++) {
- if (((size_t)addr >= inf.tstart && (size_t)addr < inf.tend) ||
- ((size_t)addr >= inf.dstart && (size_t)addr < inf.dend)) {
- len = (int)strlen(inf.filename);
- if (sz <= 0)
- return len + 1;
- if (len >= sz)
- len = sz - 1;
- memcpy(path, inf.filename, len);
- path[len++] = 0;
- return len;
- }
- }
-
- return -1;
-}
-
static void *dl_globallookup(const char *name)
{
void *ret;
diff --git a/crypto/dso/dso_dlfcn.c b/crypto/dso/dso_dlfcn.c
index 09a49131ea..f1773c85da 100644
--- a/crypto/dso/dso_dlfcn.c
+++ b/crypto/dso/dso_dlfcn.c
@@ -89,26 +89,22 @@
static int dlfcn_load(DSO *dso);
static int dlfcn_unload(DSO *dso);
-static void *dlfcn_bind_var(DSO *dso, const char *symname);
static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname);
static char *dlfcn_name_converter(DSO *dso, const char *filename);
static char *dlfcn_merger(DSO *dso, const char *filespec1,
const char *filespec2);
-static int dlfcn_pathbyaddr(void *addr, char *path, int sz);
static void *dlfcn_globallookup(const char *name);
static DSO_METHOD dso_meth_dlfcn = {
"OpenSSL 'dlfcn' shared library method",
dlfcn_load,
dlfcn_unload,
- dlfcn_bind_var,
dlfcn_bind_func,
NULL, /* ctrl */
dlfcn_name_converter,
dlfcn_merger,
NULL, /* init */
NULL, /* finish */
- dlfcn_pathbyaddr,
dlfcn_globallookup
};
@@ -203,32 +199,6 @@ static int dlfcn_unload(DSO *dso)
return (1);
}
-static void *dlfcn_bind_var(DSO *dso, const char *symname)
-{
- void *ptr, *sym;
-
- if ((dso == NULL) || (symname == NULL)) {
- DSOerr(DSO_F_DLFCN_BIND_VAR, ERR_R_PASSED_NULL_PARAMETER);
- return (NULL);
- }
- if (sk_void_num(dso->meth_data) < 1) {
- DSOerr(DSO_F_DLFCN_BIND_VAR, DSO_R_STACK_ERROR);
- return (NULL);
- }
- ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
- if (ptr == NULL) {
- DSOerr(DSO_F_DLFCN_BIND_VAR, DSO_R_NULL_HANDLE);
- return (NULL);
- }
- sym = dlsym(ptr, symname);
- if (sym == NULL) {
- DSOerr(DSO_F_DLFCN_BIND_VAR, DSO_R_SYM_FAILURE);
- ERR_add_error_data(4, "symname(", symname, "): ", dlerror());
- return (NULL);
- }
- return (sym);
-}
-
static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
{
void *ptr;
@@ -385,38 +355,6 @@ static int dladdr(void *address, Dl_info *dl)
}
# endif /* __sgi */
-static int dlfcn_pathbyaddr(void *addr, char *path, int sz)
-{
-# ifdef HAVE_DLINFO
- Dl_info dli;
- int len;
-
- if (addr == NULL) {
- union {
- int (*f) (void *, char *, int);
- void *p;
- } t = {
- dlfcn_pathbyaddr
- };
- addr = t.p;
- }
-
- if (dladdr(addr, &dli)) {
- len = (int)strlen(dli.dli_fname);
- if (sz <= 0)
- return len + 1;
- if (len >= sz)
- len = sz - 1;
- memcpy(path, dli.dli_fname, len);
- path[len++] = 0;
- return len;
- }
-
- ERR_add_error_data(2, "dlfcn_pathbyaddr(): ", dlerror());
-# endif
- return -1;
-}
-
static void *dlfcn_globallookup(const char *name)
{
void *ret = NULL, *handle = dlopen(NULL, RTLD_LAZY);
diff --git a/crypto/dso/dso_err.c b/crypto/dso/dso_err.c
index e47f5cdbef..750807c990 100644
--- a/crypto/dso/dso_err.c
+++ b/crypto/dso/dso_err.c
@@ -67,53 +67,38 @@
# define ERR_REASON(reason) ERR_PACK(ERR_LIB_DSO,0,reason)
static ERR_STRING_DATA DSO_str_functs[] = {
- {ERR_FUNC(DSO_F_BEOS_BIND_FUNC), "BEOS_BIND_FUNC"},
- {ERR_FUNC(DSO_F_BEOS_BIND_VAR), "BEOS_BIND_VAR"},
- {ERR_FUNC(DSO_F_BEOS_LOAD), "BEOS_LOAD"},
- {ERR_FUNC(DSO_F_BEOS_NAME_CONVERTER), "BEOS_NAME_CONVERTER"},
- {ERR_FUNC(DSO_F_BEOS_UNLOAD), "BEOS_UNLOAD"},
{ERR_FUNC(DSO_F_DLFCN_BIND_FUNC), "dlfcn_bind_func"},
- {ERR_FUNC(DSO_F_DLFCN_BIND_VAR), "dlfcn_bind_var"},
{ERR_FUNC(DSO_F_DLFCN_LOAD), "dlfcn_load"},
{ERR_FUNC(DSO_F_DLFCN_MERGER), "dlfcn_merger"},
{ERR_FUNC(DSO_F_DLFCN_NAME_CONVERTER), "dlfcn_name_converter"},
{ERR_FUNC(DSO_F_DLFCN_UNLOAD), "dlfcn_unload"},
{ERR_FUNC(DSO_F_DL_BIND_FUNC), "dl_bind_func"},
- {ERR_FUNC(DSO_F_DL_BIND_VAR), "dl_bind_var"},
{ERR_FUNC(DSO_F_DL_LOAD), "dl_load"},
{ERR_FUNC(DSO_F_DL_MERGER), "dl_merger"},
{ERR_FUNC(DSO_F_DL_NAME_CONVERTER), "dl_name_converter"},
{ERR_FUNC(DSO_F_DL_UNLOAD), "dl_unload"},
{ERR_FUNC(DSO_F_DSO_BIND_FUNC), "DSO_bind_func"},
- {ERR_FUNC(DSO_F_DSO_BIND_VAR), "DSO_bind_var"},
{ERR_FUNC(DSO_F_DSO_CONVERT_FILENAME), "DSO_convert_filename"},
{ERR_FUNC(DSO_F_DSO_CTRL), "DSO_ctrl"},
{ERR_FUNC(DSO_F_DSO_FREE), "DSO_free"},
{ERR_FUNC(DSO_F_DSO_GET_FILENAME), "DSO_get_filename"},
- {ERR_FUNC(DSO_F_DSO_GET_LOADED_FILENAME), "DSO_get_loaded_filename"},
{ERR_FUNC(DSO_F_DSO_GLOBAL_LOOKUP), "DSO_global_lookup"},
{ERR_FUNC(DSO_F_DSO_LOAD), "DSO_load"},
{ERR_FUNC(DSO_F_DSO_MERGE), "DSO_merge"},
- {ERR_FUNC(DSO_F_DSO_NEW_METHOD), "DSO_new_method"},
- {ERR_FUNC(DSO_F_DSO_PATHBYADDR), "DSO_pathbyaddr"},
{ERR_FUNC(DSO_F_DSO_SET_FILENAME), "DSO_set_filename"},
- {ERR_FUNC(DSO_F_DSO_SET_NAME_CONVERTER), "DSO_set_name_converter"},
{ERR_FUNC(DSO_F_DSO_UP_REF), "DSO_up_ref"},
{ERR_FUNC(DSO_F_GLOBAL_LOOKUP_FUNC), "GLOBAL_LOOKUP_FUNC"},
- {ERR_FUNC(DSO_F_PATHBYADDR), "PATHBYADDR"},
{ERR_FUNC(DSO_F_VMS_BIND_SYM), "vms_bind_sym"},
{ERR_FUNC(DSO_F_VMS_LOAD), "vms_load"},
{ERR_FUNC(DSO_F_VMS_MERGER), "vms_merger"},
{ERR_FUNC(DSO_F_VMS_UNLOAD), "vms_unload"},
{ERR_FUNC(DSO_F_WIN32_BIND_FUNC), "win32_bind_func"},
- {ERR_FUNC(DSO_F_WIN32_BIND_VAR), "win32_bind_var"},
{ERR_FUNC(DSO_F_WIN32_GLOBALLOOKUP), "win32_globallookup"},
{ERR_FUNC(DSO_F_WIN32_GLOBALLOOKUP_FUNC), "WIN32_GLOBALLOOKUP_FUNC"},
{ERR_FUNC(DSO_F_WIN32_JOINER), "win32_joiner"},
{ERR_FUNC(DSO_F_WIN32_LOAD), "win32_load"},
{ERR_FUNC(DSO_F_WIN32_MERGER), "win32_merger"},
{ERR_FUNC(DSO_F_WIN32_NAME_CONVERTER), "win32_name_converter"},
- {ERR_FUNC(DSO_F_WIN32_PATHBYADDR), "win32_pathbyaddr"},
{ERR_FUNC(DSO_F_WIN32_SPLITTER), "win32_splitter"},
{ERR_FUNC(DSO_F_WIN32_UNLOAD), "win32_unload"},
{0, NULL}
diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c
index f464fab7d5..a6cc700b28 100644
--- a/crypto/dso/dso_lib.c
+++ b/crypto/dso/dso_lib.c
@@ -60,35 +60,7 @@
static DSO_METHOD *default_DSO_meth = NULL;
-DSO *DSO_new(void)
-{
- return (DSO_new_method(NULL));
-}
-
-void DSO_set_default_method(DSO_METHOD *meth)
-{
- default_DSO_meth = meth;
-}
-
-DSO_METHOD *DSO_get_default_method(void)
-{
- return (default_DSO_meth);
-}
-
-DSO_METHOD *DSO_get_method(DSO *dso)
-{
- return (dso->meth);
-}
-
-DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth)
-{
- DSO_METHOD *mtmp;
- mtmp = dso->meth;
- dso->meth = meth;
- return (mtmp);
-}
-
-DSO *DSO_new_method(DSO_METHOD *meth)
+static DSO *DSO_new_method(DSO_METHOD *meth)
{
DSO *ret;
@@ -112,12 +84,8 @@ DSO *DSO_new_method(DSO_METHOD *meth)
OPENSSL_free(ret);
return (NULL);
}
- if (meth == NULL)
- ret->meth = default_DSO_meth;
- else
- ret->meth = meth;
+ ret->meth = default_DSO_meth;
ret->references = 1;
-
ret->lock = CRYPTO_THREAD_lock_new();
if (ret->lock == NULL) {
sk_void_free(ret->meth_data);
@@ -133,6 +101,11 @@ DSO *DSO_new_method(DSO_METHOD *meth)
return ret;
}
+DSO *DSO_new(void)
+{
+ return DSO_new_method(NULL);
+}
+
int DSO_free(DSO *dso)
{
int i;
@@ -242,26 +215,6 @@ DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags)
return (NULL);
}
-void *DSO_bind_var(DSO *dso, const char *symname)
-{
- void *ret = NULL;
-
- if ((dso == NULL) || (symname == NULL)) {
- DSOerr(DSO_F_DSO_BIND_VAR, ERR_R_PASSED_NULL_PARAMETER);
- return (NULL);
- }
- if (dso->meth->dso_bind_var == NULL) {
- DSOerr(DSO_F_DSO_BIND_VAR, DSO_R_UNSUPPORTED);
- return (NULL);
- }
- if ((ret = dso->meth->dso_bind_var(dso, symname)) == NULL) {
- DSOerr(DSO_F_DSO_BIND_VAR, DSO_R_SYM_FAILURE);
- return (NULL);
- }
- /* Success */
- return (ret);
-}
-
DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname)
{
DSO_FUNC_TYPE ret = NULL;
@@ -320,19 +273,6 @@ long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg)
return (dso->meth->dso_ctrl(dso, cmd, larg, parg));
}
-int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb,
- DSO_NAME_CONVERTER_FUNC *oldcb)
-{
- if (dso == NULL) {
- DSOerr(DSO_F_DSO_SET_NAME_CONVERTER, ERR_R_PASSED_NULL_PARAMETER);
- return (0);
- }
- if (oldcb)
- *oldcb = dso->name_converter;
- dso->name_converter = cb;
- return (1);
-}
-
const char *DSO_get_filename(DSO *dso)
{
if (dso == NULL) {
@@ -412,27 +352,6 @@ char *DSO_convert_filename(DSO *dso, const char *filename)
return (result);
}
-const char *DSO_get_loaded_filename(DSO *dso)
-{
- if (dso == NULL) {
- DSOerr(DSO_F_DSO_GET_LOADED_FILENAME, ERR_R_PASSED_NULL_PARAMETER);
- return (NULL);
- }
- return (dso->loaded_filename);
-}
-
-int DSO_pathbyaddr(void *addr, char *path, int sz)
-{
- DSO_METHOD *meth = default_DSO_meth;
- if (meth == NULL)
- meth = DSO_METHOD_openssl();
- if (meth->pathbyaddr == NULL) {
- DSOerr(DSO_F_DSO_PATHBYADDR, DSO_R_UNSUPPORTED);
- return -1;
- }
- return (*meth->pathbyaddr) (addr, path, sz);
-}
-
void *DSO_global_lookup(const char *name)
{
DSO_METHOD *meth = default_DSO_meth;
diff --git a/crypto/dso/dso_locl.h b/crypto/dso/dso_locl.h
index 3d7d669d47..a4c54a7691 100644
--- a/crypto/dso/dso_locl.h
+++ b/crypto/dso/dso_locl.h
@@ -72,8 +72,6 @@ struct dso_meth_st {
int (*dso_load) (DSO *dso);
/* Unloads a shared library */
int (*dso_unload) (DSO *dso);
- /* Binds a variable */
- void *(*dso_bind_var) (DSO *dso, const char *symname);
/*
* Binds a function - assumes a return type of DSO_FUNC_TYPE. This should
* be cast to the real function prototype by the caller. Platforms that
@@ -100,8 +98,6 @@ struct dso_meth_st {
/* [De]Initialisation handlers. */
int (*init) (DSO *dso);
int (*finish) (DSO *dso);
- /* Return pathname of the module containing location */
- int (*pathbyaddr) (void *addr, char *path, int sz);
/* Perform global symbol lookup, i.e. among *all* modules */
void *(*globallookup) (const char *symname);
};
diff --git a/crypto/dso/dso_vms.c b/crypto/dso/dso_vms.c
index 79e9963a26..5b8dc9198d 100644
--- a/crypto/dso/dso_vms.c
+++ b/crypto/dso/dso_vms.c
@@ -84,7 +84,6 @@ void *_malloc32(__size_t);
static int vms_load(DSO *dso);
static int vms_unload(DSO *dso);
-static void *vms_bind_var(DSO *dso, const char *symname);
static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname);
static char *vms_name_converter(DSO *dso, const char *filename);
static char *vms_merger(DSO *dso, const char *filespec1,
@@ -94,7 +93,6 @@ static DSO_METHOD dso_meth_vms = {
"OpenSSL 'VMS' shared library method",
vms_load,
NULL, /* unload */
- vms_bind_var,
vms_bind_func,
NULL, /* ctrl */
vms_name_converter,
@@ -404,13 +402,6 @@ void vms_bind_sym(DSO *dso, const char *symname, void **sym)
return;
}
-static void *vms_bind_var(DSO *dso, const char *symname)
-{
- void *sym = 0;
- vms_bind_sym(dso, symname, &sym);
- return sym;
-}
-
static DSO_FUNC_TYPE vms_bind_func(DSO *dso, const char *symname)
{
DSO_FUNC_TYPE sym = 0;
diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c
index e378d68946..01d2a72020 100644
--- a/crypto/dso/dso_win32.c
+++ b/crypto/dso/dso_win32.c
@@ -108,12 +108,10 @@ static HINSTANCE LoadLibraryA(LPCSTR lpLibFileName)
static int win32_load(DSO *dso);
static int win32_unload(DSO *dso);
-static void *win32_bind_var(DSO *dso, const char *symname);
static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname);
static char *win32_name_converter(DSO *dso, const char *filename);
static char *win32_merger(DSO *dso, const char *filespec1,
const char *filespec2);
-static int win32_pathbyaddr(void *addr, char *path, int sz);
static void *win32_globallookup(const char *name);
static const char *openssl_strnchr(const char *string, int c, size_t len);
@@ -122,14 +120,12 @@ static DSO_METHOD dso_meth_win32 = {
"OpenSSL 'win32' shared library method",
win32_load,
win32_unload,
- win32_bind_var,
win32_bind_func,
NULL, /* ctrl */
win32_name_converter,
win32_merger,
NULL, /* init */
NULL, /* finish */
- win32_pathbyaddr,
win32_globallookup
};
@@ -208,40 +204,6 @@ static int win32_unload(DSO *dso)
return (1);
}
-/*
- * Using GetProcAddress for variables? TODO: Check this out in the Win32 API
- * docs, there's probably a variant for variables.
- */
-static void *win32_bind_var(DSO *dso, const char *symname)
-{
- HINSTANCE *ptr;
- union {
- void *p;
- FARPROC f;
- } sym;
-
- if ((dso == NULL) || (symname == NULL)) {
- DSOerr(DSO_F_WIN32_BIND_VAR, ERR_R_PASSED_NULL_PARAMETER);
- return (NULL);
- }
- if (sk_void_num(dso->meth_data) < 1) {
- DSOerr(DSO_F_WIN32_BIND_VAR, DSO_R_STACK_ERROR);
- return (NULL);
- }
- ptr = sk_void_value(dso->meth_data, sk_void_num(dso->meth_data) - 1);
- if (ptr == NULL) {
- DSOerr(DSO_F_WIN32_BIND_VAR, DSO_R_NULL_HANDLE);
- return (NULL);
- }
- sym.f = GetProcAddress(*ptr, symname);
- if (sym.p == NULL) {
- DSOerr(DSO_F_WIN32_BIND_VAR, DSO_R_SYM_FAILURE);
- ERR_add_error_data(3, "symname(", symname, ")");
- return (NULL);
- }
- return (sym.p);
-}
-
static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname)
{
HINSTANCE *ptr;
@@ -593,106 +555,6 @@ typedef HANDLE(WINAPI *CREATETOOLHELP32SNAPSHOT) (DWORD, DWORD);
typedef BOOL(WINAPI *CLOSETOOLHELP32SNAPSHOT) (HANDLE);
typedef BOOL(WINAPI *MODULE32) (HANDLE, MODULEENTRY32 *);
-static int win32_pathbyaddr(void *addr, char *path, int sz)
-{
- HMODULE dll;
- HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
- MODULEENTRY32 me32;
- CREATETOOLHELP32SNAPSHOT create_snap;
- CLOSETOOLHELP32SNAPSHOT close_snap;
- MODULE32 module_first, module_next;
-
- if (addr == NULL) {
- union {
- int (*f) (void *, char *, int);
- void *p;
- } t = {
- win32_pathbyaddr
- };
- addr = t.p;
- }
-
- dll = LoadLibrary(TEXT(DLLNAME));
- if (dll == NULL) {
- DSOerr(DSO_F_WIN32_PATHBYADDR, DSO_R_UNSUPPORTED);
- return -1;
- }
-
- create_snap = (CREATETOOLHELP32SNAPSHOT)
- GetProcAddress(dll, "CreateToolhelp32Snapshot");
- if (create_snap == NULL) {
- FreeLibrary(dll);
- DSOerr(DSO_F_WIN32_PATHBYADDR, DSO_R_UNSUPPORTED);
- return -1;
- }
- /* We take the rest for granted... */
-# ifdef _WIN32_WCE
- close_snap = (CLOSETOOLHELP32SNAPSHOT)
- GetProcAddress(dll, "CloseToolhelp32Snapshot");
-# else
- close_snap = (CLOSETOOLHELP32SNAPSHOT) CloseHandle;
-# endif
- module_first = (MODULE32) GetProcAddress(dll, "Module32First");
- module_next = (MODULE32) GetProcAddress(dll, "Module32Next");
-
- hModuleSnap = (*create_snap) (TH32CS_SNAPMODULE, 0);
- if (hModuleSnap == INVALID_HANDLE_VALUE) {
- FreeLibrary(dll);
- DSOerr(DSO_F_WIN32_PATHBYADDR, DSO_R_UNSUPPORTED);
- return -1;
- }
-
- me32.dwSize = sizeof(me32);
-
- if (!(*module_first) (hModuleSnap, &me32)) {
- (*close_snap) (hModuleSnap);
- FreeLibrary(dll);
- DSOerr(DSO_F_WIN32_PATHBYADDR, DSO_R_FAILURE);
- return -1;
- }
-
- do {
- if ((BYTE *) addr >= me32.modBaseAddr &&
- (BYTE *) addr < me32.modBaseAddr + me32.modBaseSize) {
- (*close_snap) (hModuleSnap);
- FreeLibrary(dll);
-# ifdef _WIN32_WCE
-# if _WIN32_WCE >= 101
- return WideCharToMultiByte(CP_ACP, 0, me32.szExePath, -1,
- path, sz, NULL, NULL);
-# else
- {
- int i, len = (int)wcslen(me32.szExePath);
- if (sz <= 0)
- return len + 1;
- if (len >= sz)
- len = sz - 1;
- for (i = 0; i < len; i++)
- path[i] = (char)me32.szExePath[i];
- path[len++] = 0;
- return len;
- }
-# endif
-# else
- {
- int len = (int)strlen(me32.szExePath);
- if (sz <= 0)
- return len + 1;
- if (len >= sz)
- len = sz - 1;
- memcpy(path, me32.szExePath, len);
- path[len++] = 0;
- return len;
- }
-# endif
- }
- } while ((*module_next) (hModuleSnap, &me32));
-
- (*close_snap) (hModuleSnap);
- FreeLibrary(dll);
- return 0;
-}
-
static void *win32_globallookup(const char *name)
{
HMODULE dll;