Skip to content

Commit

Permalink
Add Wine LD Library Environment Support
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackerl committed Dec 12, 2018
1 parent 33cfaac commit 4f7f784
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
21 changes: 20 additions & 1 deletion libs/wine/config.c
Expand Up @@ -562,7 +562,26 @@ static void preloader_exec( char **argv, int use_preloader )
free( new_argv );
free( full_name );
}
execv( argv[0], argv );
else
{
char * wineloader = getenv("WINELDLIBRARY");

if (wineloader == NULL)
execv( argv[0], argv );

char **last_arg = argv;

while (*last_arg) last_arg++;

char ** new_argv = xmalloc( (last_arg - argv + 2) * sizeof(*argv) );
memcpy( new_argv + 1, argv, (last_arg - argv + 1) * sizeof(*argv) );

new_argv[0] = wineloader;

execv(wineloader, new_argv);

free( new_argv );
}
}

/* exec a wine internal binary (either the wine loader or the wine server) */
Expand Down
10 changes: 7 additions & 3 deletions loader/preloader.c
Expand Up @@ -1255,7 +1255,7 @@ void* wld_start( void **stack )
{
long i, *pargc;
char **argv, **p;
char *interp, *reserve = NULL;
char *interp = NULL, *reserve = NULL;
struct wld_auxv new_av[8], delete_av[3], *av;
struct wld_link_map main_binary_map, ld_so_map;
struct wine_preload_info **wine_main_preload_info;
Expand All @@ -1270,8 +1270,11 @@ void* wld_start( void **stack )
/* skip over the environment */
while (*p)
{
static const char res[] = "WINEPRELOADRESERVE=";
static const char res[] = "WINEPRELOADRESERVE=", loader[] = "WINELDLIBRARY=";

if (!wld_strncmp( *p, res, sizeof(res)-1 )) reserve = *p + sizeof(res) - 1;
if (!wld_strncmp( *p, loader, sizeof(loader)-1 )) interp = *p + sizeof(loader) - 1;

p++;
}

Expand Down Expand Up @@ -1323,7 +1326,8 @@ void* wld_start( void **stack )
map_so_lib( argv[1], &main_binary_map );

/* load the ELF interpreter */
interp = (char *)main_binary_map.l_addr + main_binary_map.l_interp;
if (interp == NULL)
interp = (char *)main_binary_map.l_addr + main_binary_map.l_interp;
map_so_lib( interp, &ld_so_map );

/* store pointer to the preload info into the appropriate main binary variable */
Expand Down

0 comments on commit 4f7f784

Please sign in to comment.