From a79d7ab71ae4b35b4309dfa93961f768cf51132c Mon Sep 17 00:00:00 2001 From: Moddimation Date: Sat, 7 Mar 2026 14:15:14 +0100 Subject: [PATCH] Exclude cmd.exe from process spawning --- dll/kernel32/processthreadsapi.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/dll/kernel32/processthreadsapi.cpp b/dll/kernel32/processthreadsapi.cpp index 46e4a8d..8414374 100644 --- a/dll/kernel32/processthreadsapi.cpp +++ b/dll/kernel32/processthreadsapi.cpp @@ -635,9 +635,22 @@ BOOL WINAPI CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECU bool useSearchPath = lpApplicationName == nullptr; std::string application; - std::string commandLine = lpCommandLine ? lpCommandLine : ""; - if (lpApplicationName) { - application = lpApplicationName; + std::string commandLine = ""; + bool findNewApp = false; + + if (lpCommandLine) { + commandLine = lpCommandLine; + + std::string toRemove = "cmd.exe /c "; + size_t pos = commandLine.find(toRemove); + if (pos != std::string::npos) { + commandLine.erase(pos, toRemove.length()); + findNewApp = true; + } + } + + if (lpApplicationName && !findNewApp) { + application = lpApplicationName; } else { std::vector arguments = wibo::splitCommandLine(commandLine.c_str()); if (arguments.empty()) {