Use correct encoding when calling external updater

This commit is contained in:
Lukas Matena 2021-11-03 10:57:45 +01:00 committed by David Kocik
parent 9994e0bcbc
commit 262304c777

View File

@ -679,14 +679,18 @@ bool CLI::setup(int argc, char **argv)
#ifdef _WIN32 #ifdef _WIN32
// find updater exe // find updater exe
for (auto& dir_entry : boost::filesystem::directory_iterator(path_to_binary.parent_path())) { for (const auto& dir_entry : boost::filesystem::directory_iterator(path_to_binary.parent_path())) {
if (dir_entry.path().filename() == "prusaslicer-updater.exe") { if (dir_entry.path().filename() == "prusaslicer-updater.exe") {
// run updater. Original args: /silent -restartapp prusa-slicer.exe -startappfirst // run updater. Original args: /silent -restartapp prusa-slicer.exe -startappfirst
std::string args = dir_entry.path().string();
args += " /silent"; // Using quoted string as mentioned in CreateProcessW docs.
std::wstring wcmd = L"\"" + dir_entry.path().wstring() + L"\"";
wcmd += L" /silent";
// additional information // additional information
STARTUPINFOA si; STARTUPINFOW si;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
// set the size of the structures // set the size of the structures
@ -695,8 +699,8 @@ bool CLI::setup(int argc, char **argv)
ZeroMemory(&pi, sizeof(pi)); ZeroMemory(&pi, sizeof(pi));
// start the program up // start the program up
CreateProcessA(NULL, // the path if (CreateProcessW(NULL, // the path
const_cast<char*>(args.c_str()), // Command line wcmd.data(), // Command line
NULL, // Process handle not inheritable NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE FALSE, // Set handle inheritance to FALSE
@ -705,11 +709,11 @@ bool CLI::setup(int argc, char **argv)
NULL, // Use parent's starting directory NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure &si, // Pointer to STARTUPINFO structure
&pi // Pointer to PROCESS_INFORMATION structure (removed extra parentheses) &pi // Pointer to PROCESS_INFORMATION structure (removed extra parentheses)
); )) {
// Close process and thread handles. // Close process and thread handles.
CloseHandle(pi.hProcess); CloseHandle(pi.hProcess);
CloseHandle(pi.hThread); CloseHandle(pi.hThread);
}
break; break;
} }
} }