From 1eaa7159a6416640bccf3cc3541adedcde2649b0 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sat, 26 Mar 2022 13:20:34 +0100 Subject: More work around steam and proton/SteamPlay (working, but need also latest box86) --- src/steam.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/steam.c (limited to 'src/steam.c') diff --git a/src/steam.c b/src/steam.c new file mode 100644 index 00000000..ddbb7c6a --- /dev/null +++ b/src/steam.c @@ -0,0 +1,93 @@ +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "box64context.h" +#include "fileutils.h" + +void pressure_vessel(int argc, const char** argv, int nextarg) +{ + // skip all the parameter, but parse some of them + if(argv[nextarg][0]=='-' && argv[nextarg][1]=='-') + while(argv[nextarg][0]=='-' && argv[nextarg][1]=='-') { + if(strstr(argv[nextarg], "--env-if-host=PRESSURE_VESSEL_APP_LD_LIBRARY_PATH=")==argv[nextarg]) { + // transform RESSURE_VESSEL_APP_LD_LIBRARY_PATH to BOX86_ / BOX64_ LD_LIBRARY_PATH + char tmp[strlen(argv[nextarg])]; + strcpy(tmp, ""); + strcat(tmp, argv[nextarg]+strlen("--env-if-host=PRESSURE_VESSEL_APP_")); + char *p = strchr(tmp, '='); + *p ='\0'; ++p; + setenv(tmp, p, 1); + printf_log(/*LOG_DEBUG*/LOG_INFO, "setenv(%s, %s, 1)\n", tmp, p); + } else if(strstr(argv[nextarg], "--env-if-host=STEAM_RUNTIME_LIBRARY_PATH=")==argv[nextarg]) { + // transform RESSURE_VESSEL_APP_LD_LIBRARY_PATH to BOX86_ / BOX64_ LD_LIBRARY_PATH + char tmp[strlen(argv[nextarg])]; + strcpy(tmp, "BOX86_LD_"); + strcat(tmp, argv[nextarg]+strlen("--env-if-host=STEAM_RUNTIME_")); + char *p = strchr(tmp, '='); + *p ='\0'; ++p; + setenv(tmp, p, 1); + printf_log(/*LOG_DEBUG*/LOG_INFO, "setenv(%s, %s, 1)\n", tmp, p); + tmp[3] = '6'; + tmp[4] = '4'; + setenv(tmp, p, 1); + printf_log(/*LOG_DEBUG*/LOG_INFO, "setenv(%s, %s, 1)\n", tmp, p); + } else if(!strcmp(argv[nextarg], "--")) { + printf_log(/*LOG_DEBUG*/LOG_INFO, "End of pressure-vessel-wrap parameters\n"); + }else { + printf_log(/*LOG_DEBUG*/LOG_INFO, "Ignored parameter: \"%s\"\n", argv[nextarg]); + } + ++nextarg; + } + printf_log(/*LOG_DEBUG*/LOG_INFO, "Ready to launch \"%s\", nextarg=%d, argc=%d\n", argv[nextarg], nextarg, argc); + const char* prog = argv[nextarg]; + my_context = NewBox64Context(argc - nextarg); + int x86 = my_context->box86path?FileIsX86ELF(argv[nextarg]):0; + int x64 = my_context->box64path?FileIsX64ELF(argv[nextarg]):0; + // create the new argv array + const char** newargv = (const char**)calloc((argc-nextarg)+1+((x86 || x64)?1:0), sizeof(char*)); + if(x86 || x64) { + newargv[0] = x64?my_context->box64path:my_context->box86path; + printf_log(/*LOG_DEBUG*/LOG_INFO, "argv[%d]=\"%s\"\n", 0, newargv[0]); + for(int i=nextarg; i