From a586a26f8864bb759e322245664b7558bb5822a5 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Mon, 28 Mar 2016 00:48:44 +0200 Subject: [PATCH] Unicode processes must always pass CREATE_UNICODE_ENVIRONMENT to CreateProcess Signed-off-by: Sven Strickroth --- src/Git/Git.cpp | 4 ++-- src/TortoiseIDiff/MainWindow.cpp | 4 ++-- src/Utils/CommonAppUtils.cpp | 3 +-- src/Utils/CreateProcessHelper.h | 2 +- src/Utils/Hooks.cpp | 2 +- src/libgit2/system-call.c | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Git/Git.cpp b/src/Git/Git.cpp index f670ff0b0..42aa2f589 100644 --- a/src/Git/Git.cpp +++ b/src/Git/Git.cpp @@ -311,7 +311,7 @@ int CGit::RunAsync(CString cmd, PROCESS_INFORMATION *piOut, HANDLE *hReadOut, HA si.dwFlags=STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW; LPTSTR pEnv = m_Environment; - DWORD dwFlags = pEnv ? CREATE_UNICODE_ENVIRONMENT : 0; + DWORD dwFlags = CREATE_UNICODE_ENVIRONMENT; dwFlags |= CREATE_NEW_PROCESS_GROUP; @@ -1173,7 +1173,7 @@ int CGit::RunLogFile(CString cmd, const CString &filename, CString *stdErr) si.hStdError = hWriteErr; LPTSTR pEnv = m_Environment; - DWORD dwFlags = pEnv ? CREATE_UNICODE_ENVIRONMENT : 0; + DWORD dwFlags = CREATE_UNICODE_ENVIRONMENT; if(cmd.Find(_T("git")) == 0) cmd=CGit::ms_LastMsysGitDir+_T("\\")+cmd; diff --git a/src/TortoiseIDiff/MainWindow.cpp b/src/TortoiseIDiff/MainWindow.cpp index 908049cc2..f841dbc2d 100644 --- a/src/TortoiseIDiff/MainWindow.cpp +++ b/src/TortoiseIDiff/MainWindow.cpp @@ -1,6 +1,6 @@ // TortoiseIDiff - an image diff viewer in TortoiseSVN -// Copyright (C) 2015 - TortoiseGit +// Copyright (C) 2015-2016 - TortoiseGit // Copyright (C) 2006-2013, 2015 - TortoiseSVN // This program is free software; you can redistribute it and/or @@ -798,7 +798,7 @@ LRESULT CMainWindow::DoCommand(int id, LPARAM lParam) PROCESS_INFORMATION process = { 0 }; startup.cb = sizeof(startup); - if (!CreateProcess(nullptr, cmd.GetBuffer(), nullptr, nullptr, FALSE, 0, nullptr, nullptr, &startup, &process)) + if (!CreateProcess(nullptr, cmd.GetBuffer(), nullptr, nullptr, FALSE, CREATE_UNICODE_ENVIRONMENT, nullptr, nullptr, &startup, &process)) { cmd.ReleaseBuffer(); PostQuitMessage(resolveWith); diff --git a/src/Utils/CommonAppUtils.cpp b/src/Utils/CommonAppUtils.cpp index d318adade..0b76b8dbb 100644 --- a/src/Utils/CommonAppUtils.cpp +++ b/src/Utils/CommonAppUtils.cpp @@ -22,7 +22,6 @@ #include "CommonAppUtils.h" #include "PathUtils.h" #include "StringUtils.h" -#include "CreateProcessHelper.h" #include "FormatMessageWrapper.h" #include "registry.h" #include "SelectFileFilter.h" @@ -105,7 +104,7 @@ bool CCommonAppUtils::LaunchApplication(const CString& sCommandLine, UINT idErrM startup.cb = sizeof(startup); CString cleanCommandLine(sCommandLine); - if (CreateProcess(nullptr, const_cast((LPCTSTR)cleanCommandLine), nullptr, nullptr, FALSE, 0, nullptr, theCWD, &startup, &process) == 0) + if (CreateProcess(nullptr, const_cast((LPCTSTR)cleanCommandLine), nullptr, nullptr, FALSE, CREATE_UNICODE_ENVIRONMENT, nullptr, theCWD, &startup, &process) == 0) { if (idErrMessageFormat) { diff --git a/src/Utils/CreateProcessHelper.h b/src/Utils/CreateProcessHelper.h index 202c6a0f5..e50ff6a56 100644 --- a/src/Utils/CreateProcessHelper.h +++ b/src/Utils/CreateProcessHelper.h @@ -50,7 +50,7 @@ inline bool CCreateProcessHelper::CreateProcess(LPCTSTR applicationName, startupInfo.cb = sizeof(STARTUPINFO); memset(processInfo, 0, sizeof(PROCESS_INFORMATION)); - const BOOL result = ::CreateProcess(applicationName, commandLine, nullptr, nullptr, FALSE, 0, nullptr, currentDirectory, &startupInfo, processInfo); + const BOOL result = ::CreateProcess(applicationName, commandLine, nullptr, nullptr, FALSE, CREATE_UNICODE_ENVIRONMENT, nullptr, currentDirectory, &startupInfo, processInfo); return result != 0; } diff --git a/src/Utils/Hooks.cpp b/src/Utils/Hooks.cpp index 05f88b580..9431ae755 100644 --- a/src/Utils/Hooks.cpp +++ b/src/Utils/Hooks.cpp @@ -391,7 +391,7 @@ DWORD CHooks::RunScript(CString cmd, LPCTSTR currentDir, CString& error, bool bW si.wShowWindow = bShow ? SW_SHOW : SW_HIDE; PROCESS_INFORMATION pi = { 0 }; - if (!CreateProcess(nullptr, cmd.GetBuffer(), nullptr, nullptr, TRUE, 0, nullptr, currentDir, &si, &pi)) + if (!CreateProcess(nullptr, cmd.GetBuffer(), nullptr, nullptr, TRUE, CREATE_UNICODE_ENVIRONMENT, nullptr, currentDir, &si, &pi)) { const DWORD err = GetLastError(); // preserve the CreateProcess error error = CFormatMessageWrapper(err); diff --git a/src/libgit2/system-call.c b/src/libgit2/system-call.c index bd72744da..9af937fb7 100644 --- a/src/libgit2/system-call.c +++ b/src/libgit2/system-call.c @@ -180,7 +180,7 @@ int command_start(wchar_t *cmd, COMMAND_HANDLE *commandHandle, LPWSTR* pEnv, DWO si.wShowWindow = SW_HIDE; si.dwFlags = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW; - if (!CreateProcessW(NULL, cmd, NULL, NULL, TRUE, (pEnv && *pEnv ? CREATE_UNICODE_ENVIRONMENT : 0) | flags, pEnv ? *pEnv : NULL, NULL, &si, &pi)) { + if (!CreateProcessW(NULL, cmd, NULL, NULL, TRUE, CREATE_UNICODE_ENVIRONMENT | flags, pEnv ? *pEnv : NULL, NULL, &si, &pi)) { giterr_set(GITERR_OS, "Could not start external tool"); CloseHandle(hReadOut); CloseHandle(hWriteOut); -- 2.11.4.GIT