libwine: Make the dlopen() wrapper functions obsolete.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0f53fca321
commit
b87256cd1d
|
@ -55,9 +55,6 @@ extern void wine_exec_wine_binary( const char *name, char **argv, const char *en
|
||||||
|
|
||||||
typedef void (*load_dll_callback_t)( void *, const char * );
|
typedef void (*load_dll_callback_t)( void *, const char * );
|
||||||
|
|
||||||
extern void *wine_dlopen( const char *filename, int flag, char *error, size_t errorsize );
|
|
||||||
extern void *wine_dlsym( void *handle, const char *symbol, char *error, size_t errorsize );
|
|
||||||
extern int wine_dlclose( void *handle, char *error, size_t errorsize );
|
|
||||||
extern void wine_dll_set_callback( load_dll_callback_t load );
|
extern void wine_dll_set_callback( load_dll_callback_t load );
|
||||||
extern const char *wine_dll_enum_load_path( unsigned int index );
|
extern const char *wine_dll_enum_load_path( unsigned int index );
|
||||||
|
|
||||||
|
|
|
@ -56,26 +56,4 @@ const char *wine_dll_enum_load_path( unsigned int index )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *wine_dlopen( const char *filename, int flag, char *error, size_t errorsize )
|
|
||||||
{
|
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
static const char msg[] = "no dlopen support on Windows";
|
|
||||||
size_t len = min( errorsize, sizeof(msg) );
|
|
||||||
memcpy( error, msg, len );
|
|
||||||
error[len - 1] = 0;
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *wine_dlsym( void *handle, const char *symbol, char *error, size_t errorsize )
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int wine_dlclose( void *handle, char *error, size_t errorsize )
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* _WIN32 */
|
#endif /* _WIN32 */
|
||||||
|
|
|
@ -508,6 +508,128 @@ const char *wine_dll_enum_load_path( unsigned int index )
|
||||||
|
|
||||||
#ifdef __ASM_OBSOLETE
|
#ifdef __ASM_OBSOLETE
|
||||||
|
|
||||||
|
/*
|
||||||
|
* These functions provide wrappers around dlopen() and associated
|
||||||
|
* functions. They work around a bug in glibc 2.1.x where calling
|
||||||
|
* a dl*() function after a previous dl*() function has failed
|
||||||
|
* without a dlerror() call between the two will cause a crash.
|
||||||
|
* They all take a pointer to a buffer that
|
||||||
|
* will receive the error description (from dlerror()). This
|
||||||
|
* parameter may be NULL if the error description is not required.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RTLD_FIRST
|
||||||
|
#define RTLD_FIRST 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* wine_dlopen
|
||||||
|
*/
|
||||||
|
void *wine_dlopen_obsolete( const char *filename, int flag, char *error, size_t errorsize )
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
/* the Mac OS loader pretends to be able to load PE files, so avoid them here */
|
||||||
|
unsigned char magic[2];
|
||||||
|
int fd = open( filename, O_RDONLY );
|
||||||
|
if (fd != -1)
|
||||||
|
{
|
||||||
|
if (pread( fd, magic, 2, 0 ) == 2 && magic[0] == 'M' && magic[1] == 'Z')
|
||||||
|
{
|
||||||
|
if (error && errorsize)
|
||||||
|
{
|
||||||
|
static const char msg[] = "MZ format";
|
||||||
|
size_t len = min( errorsize, sizeof(msg) );
|
||||||
|
memcpy( error, msg, len );
|
||||||
|
error[len - 1] = 0;
|
||||||
|
}
|
||||||
|
close( fd );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
close( fd );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
dlerror(); dlerror();
|
||||||
|
#ifdef __sun
|
||||||
|
if (strchr( filename, ':' ))
|
||||||
|
{
|
||||||
|
char path[PATH_MAX];
|
||||||
|
/* Solaris' brain damaged dlopen() treats ':' as a path separator */
|
||||||
|
realpath( filename, path );
|
||||||
|
ret = dlopen( path, flag | RTLD_FIRST );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
ret = dlopen( filename, flag | RTLD_FIRST );
|
||||||
|
s = dlerror();
|
||||||
|
if (error && errorsize)
|
||||||
|
{
|
||||||
|
if (s)
|
||||||
|
{
|
||||||
|
size_t len = strlen(s);
|
||||||
|
if (len >= errorsize) len = errorsize - 1;
|
||||||
|
memcpy( error, s, len );
|
||||||
|
error[len] = 0;
|
||||||
|
}
|
||||||
|
else error[0] = 0;
|
||||||
|
}
|
||||||
|
dlerror();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* wine_dlsym
|
||||||
|
*/
|
||||||
|
void *wine_dlsym_obsolete( void *handle, const char *symbol, char *error, size_t errorsize )
|
||||||
|
{
|
||||||
|
void *ret;
|
||||||
|
const char *s;
|
||||||
|
dlerror(); dlerror();
|
||||||
|
ret = dlsym( handle, symbol );
|
||||||
|
s = dlerror();
|
||||||
|
if (error && errorsize)
|
||||||
|
{
|
||||||
|
if (s)
|
||||||
|
{
|
||||||
|
size_t len = strlen(s);
|
||||||
|
if (len >= errorsize) len = errorsize - 1;
|
||||||
|
memcpy( error, s, len );
|
||||||
|
error[len] = 0;
|
||||||
|
}
|
||||||
|
else error[0] = 0;
|
||||||
|
}
|
||||||
|
dlerror();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* wine_dlclose
|
||||||
|
*/
|
||||||
|
int wine_dlclose_obsolete( void *handle, char *error, size_t errorsize )
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
const char *s;
|
||||||
|
dlerror(); dlerror();
|
||||||
|
ret = dlclose( handle );
|
||||||
|
s = dlerror();
|
||||||
|
if (error && errorsize)
|
||||||
|
{
|
||||||
|
if (s)
|
||||||
|
{
|
||||||
|
size_t len = strlen(s);
|
||||||
|
if (len >= errorsize) len = errorsize - 1;
|
||||||
|
memcpy( error, s, len );
|
||||||
|
error[len] = 0;
|
||||||
|
}
|
||||||
|
else error[0] = 0;
|
||||||
|
}
|
||||||
|
dlerror();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* check if the library is the correct architecture */
|
/* check if the library is the correct architecture */
|
||||||
/* only returns false for a valid library of the wrong arch */
|
/* only returns false for a valid library of the wrong arch */
|
||||||
static int check_library_arch( int fd )
|
static int check_library_arch( int fd )
|
||||||
|
@ -570,7 +692,7 @@ static void *dlopen_dll( const char *name, char *error, int errorsize,
|
||||||
*exists = 0;
|
*exists = 0;
|
||||||
for (path = first_dll_path( name, 0, &context ); path; path = next_dll_path( &context ))
|
for (path = first_dll_path( name, 0, &context ); path; path = next_dll_path( &context ))
|
||||||
{
|
{
|
||||||
if (!test_only && (ret = wine_dlopen( path, RTLD_NOW, error, errorsize ))) break;
|
if (!test_only && (ret = wine_dlopen_obsolete( path, RTLD_NOW, error, errorsize ))) break;
|
||||||
if ((*exists = file_exists( path ))) break; /* exists but cannot be loaded, return the error */
|
if ((*exists = file_exists( path ))) break; /* exists but cannot be loaded, return the error */
|
||||||
}
|
}
|
||||||
free_dll_path( &context );
|
free_dll_path( &context );
|
||||||
|
@ -616,7 +738,7 @@ void *wine_dll_load_obsolete( const char *filename, char *error, int errorsize,
|
||||||
void wine_dll_unload_obsolete( void *handle )
|
void wine_dll_unload_obsolete( void *handle )
|
||||||
{
|
{
|
||||||
if (handle != (void *)1)
|
if (handle != (void *)1)
|
||||||
wine_dlclose( handle, NULL, 0 );
|
wine_dlclose_obsolete( handle, NULL, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -664,6 +786,9 @@ int wine_dll_get_owner_obsolete( const char *name, char *buffer, int size, int *
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__ASM_OBSOLETE(wine_dlopen);
|
||||||
|
__ASM_OBSOLETE(wine_dlsym);
|
||||||
|
__ASM_OBSOLETE(wine_dlclose);
|
||||||
__ASM_OBSOLETE(wine_dll_get_owner);
|
__ASM_OBSOLETE(wine_dll_get_owner);
|
||||||
__ASM_OBSOLETE(wine_dll_load);
|
__ASM_OBSOLETE(wine_dll_load);
|
||||||
__ASM_OBSOLETE(wine_dll_load_main_exe);
|
__ASM_OBSOLETE(wine_dll_load_main_exe);
|
||||||
|
@ -983,7 +1108,7 @@ void wine_init( int argc, char *argv[], char *error, int error_size )
|
||||||
|
|
||||||
for (path = first_dll_path( "ntdll.dll", 0, &context ); path; path = next_dll_path( &context ))
|
for (path = first_dll_path( "ntdll.dll", 0, &context ); path; path = next_dll_path( &context ))
|
||||||
{
|
{
|
||||||
if ((ntdll = wine_dlopen( path, RTLD_NOW, error, error_size )))
|
if ((ntdll = dlopen( path, RTLD_NOW )))
|
||||||
{
|
{
|
||||||
/* if we didn't use the default dll dir, remove it from the search path */
|
/* if we didn't use the default dll dir, remove it from the search path */
|
||||||
if (default_dlldir[0] && context.index < nb_dll_paths + 2) nb_dll_paths--;
|
if (default_dlldir[0] && context.index < nb_dll_paths + 2) nb_dll_paths--;
|
||||||
|
@ -992,133 +1117,23 @@ void wine_init( int argc, char *argv[], char *error, int error_size )
|
||||||
}
|
}
|
||||||
free_dll_path( &context );
|
free_dll_path( &context );
|
||||||
|
|
||||||
if (!ntdll) return;
|
if (!ntdll || !(init_func = dlsym( ntdll, "__wine_process_init" )))
|
||||||
if (!(init_func = wine_dlsym( ntdll, "__wine_process_init", error, error_size ))) return;
|
{
|
||||||
|
if (error && error_size)
|
||||||
|
{
|
||||||
|
const char *s = dlerror();
|
||||||
|
if (s)
|
||||||
|
{
|
||||||
|
size_t len = min( strlen(s), error_size - 1 );
|
||||||
|
memcpy( error, s, len );
|
||||||
|
error[len] = 0;
|
||||||
|
}
|
||||||
|
else error[0] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
apple_main_thread( init_func );
|
apple_main_thread( init_func );
|
||||||
#else
|
#else
|
||||||
init_func();
|
init_func();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These functions provide wrappers around dlopen() and associated
|
|
||||||
* functions. They work around a bug in glibc 2.1.x where calling
|
|
||||||
* a dl*() function after a previous dl*() function has failed
|
|
||||||
* without a dlerror() call between the two will cause a crash.
|
|
||||||
* They all take a pointer to a buffer that
|
|
||||||
* will receive the error description (from dlerror()). This
|
|
||||||
* parameter may be NULL if the error description is not required.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef RTLD_FIRST
|
|
||||||
#define RTLD_FIRST 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* wine_dlopen
|
|
||||||
*/
|
|
||||||
void *wine_dlopen( const char *filename, int flag, char *error, size_t errorsize )
|
|
||||||
{
|
|
||||||
void *ret;
|
|
||||||
const char *s;
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
/* the Mac OS loader pretends to be able to load PE files, so avoid them here */
|
|
||||||
unsigned char magic[2];
|
|
||||||
int fd = open( filename, O_RDONLY );
|
|
||||||
if (fd != -1)
|
|
||||||
{
|
|
||||||
if (pread( fd, magic, 2, 0 ) == 2 && magic[0] == 'M' && magic[1] == 'Z')
|
|
||||||
{
|
|
||||||
if (error && errorsize)
|
|
||||||
{
|
|
||||||
static const char msg[] = "MZ format";
|
|
||||||
size_t len = min( errorsize, sizeof(msg) );
|
|
||||||
memcpy( error, msg, len );
|
|
||||||
error[len - 1] = 0;
|
|
||||||
}
|
|
||||||
close( fd );
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
close( fd );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
dlerror(); dlerror();
|
|
||||||
#ifdef __sun
|
|
||||||
if (strchr( filename, ':' ))
|
|
||||||
{
|
|
||||||
char path[PATH_MAX];
|
|
||||||
/* Solaris' brain damaged dlopen() treats ':' as a path separator */
|
|
||||||
realpath( filename, path );
|
|
||||||
ret = dlopen( path, flag | RTLD_FIRST );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
ret = dlopen( filename, flag | RTLD_FIRST );
|
|
||||||
s = dlerror();
|
|
||||||
if (error && errorsize)
|
|
||||||
{
|
|
||||||
if (s)
|
|
||||||
{
|
|
||||||
size_t len = strlen(s);
|
|
||||||
if (len >= errorsize) len = errorsize - 1;
|
|
||||||
memcpy( error, s, len );
|
|
||||||
error[len] = 0;
|
|
||||||
}
|
|
||||||
else error[0] = 0;
|
|
||||||
}
|
|
||||||
dlerror();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* wine_dlsym
|
|
||||||
*/
|
|
||||||
void *wine_dlsym( void *handle, const char *symbol, char *error, size_t errorsize )
|
|
||||||
{
|
|
||||||
void *ret;
|
|
||||||
const char *s;
|
|
||||||
dlerror(); dlerror();
|
|
||||||
ret = dlsym( handle, symbol );
|
|
||||||
s = dlerror();
|
|
||||||
if (error && errorsize)
|
|
||||||
{
|
|
||||||
if (s)
|
|
||||||
{
|
|
||||||
size_t len = strlen(s);
|
|
||||||
if (len >= errorsize) len = errorsize - 1;
|
|
||||||
memcpy( error, s, len );
|
|
||||||
error[len] = 0;
|
|
||||||
}
|
|
||||||
else error[0] = 0;
|
|
||||||
}
|
|
||||||
dlerror();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* wine_dlclose
|
|
||||||
*/
|
|
||||||
int wine_dlclose( void *handle, char *error, size_t errorsize )
|
|
||||||
{
|
|
||||||
int ret;
|
|
||||||
const char *s;
|
|
||||||
dlerror(); dlerror();
|
|
||||||
ret = dlclose( handle );
|
|
||||||
s = dlerror();
|
|
||||||
if (error && errorsize)
|
|
||||||
{
|
|
||||||
if (s)
|
|
||||||
{
|
|
||||||
size_t len = strlen(s);
|
|
||||||
if (len >= errorsize) len = errorsize - 1;
|
|
||||||
memcpy( error, s, len );
|
|
||||||
error[len] = 0;
|
|
||||||
}
|
|
||||||
else error[0] = 0;
|
|
||||||
}
|
|
||||||
dlerror();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
|
@ -9,11 +9,8 @@ WINE_1.0
|
||||||
wine_anon_mmap;
|
wine_anon_mmap;
|
||||||
wine_casemap_lower;
|
wine_casemap_lower;
|
||||||
wine_casemap_upper;
|
wine_casemap_upper;
|
||||||
wine_dlclose;
|
|
||||||
wine_dll_enum_load_path;
|
wine_dll_enum_load_path;
|
||||||
wine_dll_set_callback;
|
wine_dll_set_callback;
|
||||||
wine_dlopen;
|
|
||||||
wine_dlsym;
|
|
||||||
wine_exec_wine_binary;
|
wine_exec_wine_binary;
|
||||||
wine_get_build_dir;
|
wine_get_build_dir;
|
||||||
wine_get_build_id;
|
wine_get_build_id;
|
||||||
|
@ -88,10 +85,13 @@ WINE_1.0
|
||||||
wine_dbg_sprintf;
|
wine_dbg_sprintf;
|
||||||
wine_dbgstr_an;
|
wine_dbgstr_an;
|
||||||
wine_dbgstr_wn;
|
wine_dbgstr_wn;
|
||||||
|
wine_dlclose;
|
||||||
wine_dll_get_owner;
|
wine_dll_get_owner;
|
||||||
wine_dll_load;
|
wine_dll_load;
|
||||||
wine_dll_load_main_exe;
|
wine_dll_load_main_exe;
|
||||||
wine_dll_unload;
|
wine_dll_unload;
|
||||||
|
wine_dlopen;
|
||||||
|
wine_dlsym;
|
||||||
wine_fold_string;
|
wine_fold_string;
|
||||||
wine_get_cs;
|
wine_get_cs;
|
||||||
wine_get_ds;
|
wine_get_ds;
|
||||||
|
|
Loading…
Reference in New Issue