MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / GetApplicationNames

Function GetApplicationNames

Source/Common/Config.cpp:403–449  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401}
402
403ApplicationNames GetApplicationNames(const fextl::vector<fextl::string>& Args, bool ExecFDInterp, int ProgramFDFromEnv) {
404 if (Args.empty()) {
405 // Early exit if we weren't passed an argument
406 return {};
407 }
408
409 fextl::string Program {};
410 fextl::string ProgramName {};
411
412 Program = RecoverGuestProgramFilename(Args[0], ExecFDInterp, ProgramFDFromEnv);
413
414 bool Wine = false;
415 for (size_t CurrentProgramNameIndex = 0; CurrentProgramNameIndex < Args.size(); ++CurrentProgramNameIndex) {
416 auto CurrentProgramName = FHU::Filesystem::GetFilename(Args[CurrentProgramNameIndex]);
417
418 if (CurrentProgramName == "wine-preloader" || CurrentProgramName == "wine64-preloader") {
419 // Wine preloader is required to be in the format of `wine-preloader <wine executable>`
420 // The preloader doesn't execve the executable, instead maps it directly itself
421 // Skip the next argument since we know it is wine (potentially with custom wine executable name)
422 ++CurrentProgramNameIndex;
423 Wine = true;
424 } else if (CurrentProgramName == "wine" || CurrentProgramName == "wine64") {
425 // Next argument, this isn't the program we want
426 //
427 // If we are running wine or wine64 then we should check the next argument for the application name instead.
428 // wine will change the active program name with `setprogname` or `prctl(PR_SET_NAME`.
429 // Since FEX needs this data far earlier than libraries we need a different check.
430 Wine = true;
431 } else {
432 if (Wine == true) {
433 // If this was path separated with '\' then we need to check that.
434 auto WinSeparator = CurrentProgramName.find_last_of('\\');
435 if (WinSeparator != CurrentProgramName.npos) {
436 // Used windows separators
437 CurrentProgramName = CurrentProgramName.substr(WinSeparator + 1);
438 }
439 }
440
441 ProgramName = std::move(CurrentProgramName);
442
443 // Past any wine program names
444 break;
445 }
446 }
447
448 return ApplicationNames {std::move(Program), std::move(ProgramName)};
449}
450
451void LoadConfig(fextl::unique_ptr<FEX::ArgLoader::ArgLoader> ArgsLoader, fextl::string ProgramName, char** const envp,
452 const PortableInformation& PortableInfo) {

Callers 1

mainFunction · 0.85

Calls 3

GetFilenameFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected