From da6be80f18014a3972eedf05099cd0066e9eae04 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 3 Dec 2021 11:45:01 -0500 Subject: Split out ExecutableLocation (#2041) * #include an absolute path didn't work - because paths were taken to always be relative. * Split out ExecutableLocation. * Fixes for changes to ExecutableLocation. * Fix issues around Process on windows. * Improve comments. Kick CI. --- source/core/windows/slang-win-process.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'source/core/windows/slang-win-process.cpp') diff --git a/source/core/windows/slang-win-process.cpp b/source/core/windows/slang-win-process.cpp index e0e38f2d4..215904938 100644 --- a/source/core/windows/slang-win-process.cpp +++ b/source/core/windows/slang-win-process.cpp @@ -453,12 +453,12 @@ void WinProcess::kill(int32_t returnCode) OSString pathBuffer; LPCWSTR path = nullptr; - if (commandLine.m_executableType == CommandLine::ExecutableType::Path) + const auto& exe = commandLine.m_executableLocation; + if (exe.m_type == ExecutableLocation::Type::Path) { - StringBuilder cmd; - StringEscapeUtil::appendMaybeQuoted(getEscapeHandler(), commandLine.m_executable.getUnownedSlice(), cmd); - - pathBuffer = cmd.toWString(); + // If it 'Path' specified we pass in as the lpApplicationName to limit + // searching. + pathBuffer = exe.m_pathOrName.toWString(); path = pathBuffer.begin(); } @@ -479,6 +479,14 @@ void WinProcess::kill(int32_t returnCode) createFlags |= CREATE_SUSPENDED; } + // From docs: + // If both lpApplicationName and lpCommandLine are non-NULL, the null-terminated string pointed to by lpApplicationName + // specifies the module to execute, and the null-terminated string pointed to by lpCommandLine specifies the command line. + + // JS: + // Somewhat confusingly this means that even if lpApplicationName is specified, it muse *ALSO* be included as the first + // whitespace delimited arg must *also* be the (possibly) quoted executable + // https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-createprocessa // `CreateProcess` requires write access to this, for some reason... BOOL success = CreateProcessW( -- cgit v1.2.3