该坚持的时候坚持,该妥协的时候妥协,该放弃的时候放弃
分类: C/C++
2014-09-09 22:19:29
loader/main -> wine_exec_wine_binary ->preloader_exec整理
/* exec a binary using the preloader if requested; helper for wine_exec_wine_binary */
static void preloader_exec( char **argv, int use_preloader )
{
if (use_preloader)
{
static const char preloader[] = "wine-preloader";
static const char preloader64[] = "wine64-preloader";
char *p, *full_name;
char **last_arg = argv, **new_argv;
if (!(p = strrchr( argv[0], '/' ))) p = argv[0];
else p++;
此时是argv[0]最后的运行程序名
full_name = xmalloc( p - argv[0] + sizeof(preloader64) );
memcpy( full_name, argv[0], p - argv[0] );
full_name现在只是运行文件的路径,不包含文件名
if (strendswith( p, "64" ))
判断是不是64位的
memcpy( full_name + (p - argv[0]), preloader64, sizeof(preloader64) );
else
memcpy( full_name + (p - argv[0]), preloader, sizeof(preloader) );
/* make a copy of argv */
while (*last_arg) last_arg++;
这里又加2了,分配了3个*argv
new_argv = xmalloc( (last_arg - argv + 2) * sizeof(*argv) );
赋值了2个*argv的大小,到第三个argv中。
memcpy( new_argv + 1, argv, (last_arg - argv + 1) * sizeof(*argv) );
new_argv[0] = full_name;
执行wine
execv( full_name, new_argv );
free( new_argv );
free( full_name );
}
execv( argv[0], argv );
}