Small changed to command line argument handling

This commit is contained in:
ptitSeb 2024-10-10 08:37:59 +02:00
parent d1c5cd7b0a
commit 21b5f90a33
2 changed files with 16 additions and 14 deletions

View File

@ -1891,19 +1891,22 @@ int initialize(int argc, const char **argv, char** env, x64emu_t** emulator, elf
if(!box64_nobanner)
PrintBox64Version();
// precheck, for win-preload
if(strstr(prog, "wine-preloader")==(prog+strlen(prog)-strlen("wine-preloader"))
|| strstr(prog, "wine64-preloader")==(prog+strlen(prog)-strlen("wine64-preloader"))) {
const char* prog_ = strrchr(prog, '/');
if(!prog_) prog_ = prog; else ++prog_;
if(!strcmp(prog_, "wine-preloader") || !strcmp(prog_, "wine64-preloader")) {
// wine-preloader detecter, skipping it if next arg exist and is an x86 binary
int x64 = (nextarg<argc)?FileIsX64ELF(argv[nextarg]):0;
if(x64) {
prog = argv[++nextarg];
printf_log(LOG_INFO, "BOX64: Wine preloader detected, loading \"%s\" directly\n", prog);
wine_preloaded = 1;
prog_ = strrchr(prog, '/');
if(!prog_) prog_ = prog; else ++prog;
}
}
#ifndef STATICBUILD
// pre-check for pressure-vessel-wrap
if(strstr(prog, "pressure-vessel-wrap")==(prog+strlen(prog)-strlen("pressure-vessel-wrap"))) {
if(!strcmp(prog_, "pressure-vessel-wrap")) {
printf_log(LOG_INFO, "BOX64: pressure-vessel-wrap detected\n");
pressure_vessel(argc, argv, nextarg+1, prog);
}
@ -1912,11 +1915,9 @@ int initialize(int argc, const char **argv, char** env, x64emu_t** emulator, elf
int is_custom_gstreamer = 0;
const char* wine_prog = NULL;
// check if this is wine
if(!strcmp(prog, "wine64")
|| !strcmp(prog, "wine64-development")
|| !strcmp(prog, "wine")
|| (strrchr(prog, '/') && !strcmp(strrchr(prog,'/'), "/wine"))
|| (strrchr(prog, '/') && !strcmp(strrchr(prog,'/'), "/wine64"))) {
if(!strcmp(prog_, "wine64")
|| !strcmp(prog_, "wine64-development")
|| !strcmp(prog_, "wine")) {
const char* prereserve = getenv("WINEPRELOADRESERVE");
printf_log(LOG_INFO, "BOX64: Wine64 detected, WINEPRELOADRESERVE=\"%s\"\n", prereserve?prereserve:"");
if(wine_preloaded || 1) {
@ -1977,13 +1978,13 @@ int initialize(int argc, const char **argv, char** env, x64emu_t** emulator, elf
}
++nextarg;
prog = argv[nextarg];
} else if(!strcmp(prog, "steam") || (strrchr(prog, '/') && !strcmp(strrchr(prog,'/'), "/steam"))) {
} else if(!strcmp(prog_, "steam") ) {
printf_log(LOG_INFO, "steam detected\n");
box64_steam = 1;
} else if(!strcmp(prog, "steamcmd") || (strrchr(prog, '/') && !strcmp(strrchr(prog,'/'), "/steamcmd"))) {
} else if(!strcmp(prog_, "steamcmd")) {
printf_log(LOG_INFO, "steamcmd detected\n");
box64_steamcmd = 1;
} else if(!strcmp(prog, "wineserver") || !strcmp(prog, "wineserver64") || (strlen(prog)>9 && !strcmp(prog+strlen(prog)-strlen("/wineserver"), "/wineserver"))) {
} else if(!strcmp(prog_, "wineserver")) {
// check if this is wineserver
box64_wine = 1;
}
@ -1995,7 +1996,7 @@ int initialize(int argc, const char **argv, char** env, x64emu_t** emulator, elf
// Append ld_list if it exist
if(ld_libs_args!=-1)
PrependList(&my_context->box64_ld_lib, argv[ld_libs_args], 1);
if(is_custom_gstreamer)
if(is_custom_gstreamer) //TODO: is this still needed?
AddPath("libwayland-client.so.0", &my_context->box64_emulated_libs, 0);
my_context->box64path = ResolveFile(argv[0], &my_context->box64_path);

View File

@ -137,10 +137,11 @@ void pressure_vessel(int argc, const char** argv, int nextarg, const char* prog)
my_context = NewBox64Context(argc - nextarg);
int x86 = my_context->box86path?FileIsX86ELF(argv[nextarg]):0;
int x64 = my_context->box64path?FileIsX64ELF(argv[nextarg]):0;
int sh = my_context->bashpath?FileIsShell(argv[nextarg]):0;
// create the new argv array
const char** newargv = (const char**)box_calloc((argc-nextarg)+1+((x86 || x64)?1:0), sizeof(char*));
if(x86 || x64) {
newargv[0] = x64?my_context->box64path:my_context->box86path;
if(x86 || x64 || sh) {
newargv[0] = x86?my_context->box86path:my_context->box64path;
printf_log(LOG_DEBUG, "argv[%d]=\"%s\"\n", 0, newargv[0]);
for(int i=nextarg; i<argc; ++i) {
printf_log(LOG_DEBUG, "argv[%d]=\"%s\"\n", 1+i-nextarg, argv[i]);