MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / execve

Method execve

source/kernel/kprocess.cpp:709–812  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

707}
708
709U32 KProcess::execve(KThread* thread, BString path, std::vector<BString>& args, const std::vector<BString>& envs) {
710 std::shared_ptr<FsNode> node;
711 FsOpenNode* openNode = nullptr;
712 BString interpreter;
713 std::vector<BString> interpreterArgs;
714 BString loader;
715 BString name;
716 std::vector<BString> cmdLine;
717
718 this->systemProcess = false;
719 for (auto& s : args) {
720 if (s.endsWith("wineboot.exe", true)) {
721 this->systemProcess = true;
722 } else if (s.endsWith("winemenubuilder.exe", true)) {
723 this->systemProcess = true;
724 } else if (s.endsWith("services.exe", true)) {
725 this->systemProcess = true;
726 } else if (s.endsWith("plugplay.exe", true)) {
727 this->systemProcess = true;
728 } else if (s.endsWith("winedevice.exe", true)) {
729 this->systemProcess = true;
730 } else if (s.endsWith("explorer.exe", true)) {
731 this->systemProcess = true;
732 } else if (s.endsWith("wineserver", true)) {
733 Platform::setCurrentThreadPriorityHigh();
734 this->systemProcess = true;
735 }
736 }
737 node = this->findInPath(path);
738 if (!node) {
739 return -K_ENOENT;
740 }
741 openNode = ElfLoader::inspectNode(this->currentDirectory, node, loader, interpreter, interpreterArgs);
742 if (!openNode) {
743 return -K_ENOEXEC;
744 }
745#ifdef BOXEDWINE_MULTI_THREADED
746 if (KSystem::cpuAffinityCountForApp) {
747 Platform::setCpuAffinityForThread(thread, this->isSystemProcess()?0:KSystem::cpuAffinityCountForApp);
748 }
749#endif
750 if (interpreter.length()) {
751 args.insert(args.begin(), interpreterArgs.begin(), interpreterArgs.end());
752 args.insert(args.begin(), interpreter);
753 this->exe = interpreter;
754 } else {
755 if (path != "/proc/self/exe" && path != "/proc/" + BString::valueOf(id) + "/exe") {
756 // :TODO: why does this need to be changed, seems like a bug
757 args[0] = BString(Fs::getFullPath(currentDirectory, path)); // if path is a link, we should use the link not the actual path
758 this->exe = path;
759 } else {
760 // :TODO: why does this need to be changed, seems like a bug
761 args[0] = BString(Fs::getFullPath(currentDirectory, this->exe));
762 }
763 }
764 if (loader.length()) {
765 args.insert(args.begin(), loader);
766 }

Callers 1

syscall_execveFunction · 0.80

Calls 15

findInPathMethod · 0.95
isSystemProcessMethod · 0.95
onExecMethod · 0.95
BStringClass · 0.85
vectorContainsIgnoreCaseFunction · 0.85
BFunction · 0.85
kpanicFunction · 0.85
setupThreadStackFunction · 0.85
endsWithMethod · 0.80
substrMethod · 0.80
restartMethod · 0.80
closeMethod · 0.65

Tested by

no test coverage detected