Skip to content

Commit

Permalink
Update libhookexecv.c
Browse files Browse the repository at this point in the history
  • Loading branch information
probonopd committed Dec 18, 2018
1 parent 2be4525 commit 6eb2646
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions libhookexecv.c
Expand Up @@ -4,7 +4,7 @@
#include <stdlib.h>

/* Author: https://github.com/Hackerl/
* https://github.com/Hackerl/Wine_Appimage/issues/11#issuecomment-445724165
* https://github.com/Hackerl/Wine_Appimage/issues/11#issuecomment-447834456
* sudo apt-get -y install gcc-multilib
* gcc -shared -fPIC -ldl libhookexecv.c -o libhookexecv.so
* for i386: gcc -shared -fPIC -m32 -ldl libhookexecv.c -o libhookexecv.so
Expand Down Expand Up @@ -35,7 +35,7 @@ int execv(char *path, char ** argv)

char * wineloader = getenv("WINELDLIBRARY");

if (wineloader == NULL || strendswith(path, "wine-preloader"))
if (wineloader == NULL)
{
return old_execv(path, argv);
}
Expand All @@ -45,11 +45,22 @@ int execv(char *path, char ** argv)
char ** new_argv = (char **) malloc( (last_arg - argv + 2) * sizeof(*argv) );
memcpy( new_argv + 1, argv, (last_arg - argv + 1) * sizeof(*argv) );

new_argv[0] = wineloader;
char * pathname = NULL;

int res = old_execv(wineloader, new_argv);
char hookpath[256];
memset(hookpath, 0, 256);

if (strendswith(path, "wine-preloader"))
{
strcat(hookpath, path);
strcat(hookpath, "_hook");

wineloader = hookpath;
}

new_argv[0] = wineloader;
int res = old_execv(wineloader, new_argv);
free( new_argv );

return res;
}
}

0 comments on commit 6eb2646

Please sign in to comment.