diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2016-08-20 00:56:20 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-05-19 03:43:17 +0200 |
commit | 2872098f75b348c33deba2be3665317b76ce69a9 (patch) | |
tree | f14f34aff5a9714efa889791a9d09256a4d5b075 /onlineupdate | |
parent | 60ae0924bb2b68cd12e5d1f9c748ee4dc1aa12c2 (diff) |
make the winhelper library compile on windows
Change-Id: I4bfa678b6a028a91a63b79a24f6db3a3644d086a
Diffstat (limited to 'onlineupdate')
-rw-r--r-- | onlineupdate/Executable_updater.mk | 3 | ||||
-rw-r--r-- | onlineupdate/Module_onlineupdate.mk | 1 | ||||
-rw-r--r-- | onlineupdate/inc/winhelper/windowsStart.hxx | 5 | ||||
-rw-r--r-- | onlineupdate/source/winhelper/windowsStart.cxx | 57 |
4 files changed, 12 insertions, 54 deletions
diff --git a/onlineupdate/Executable_updater.mk b/onlineupdate/Executable_updater.mk index 019eb8deb4ca..b03d97fcc515 100644 --- a/onlineupdate/Executable_updater.mk +++ b/onlineupdate/Executable_updater.mk @@ -10,6 +10,7 @@ $(eval $(call gb_Executable_Executable,updater)) $(eval $(call gb_Executable_set_include,updater,\ + -I$(SRCDIR)/onlineupdate/inc \ -I$(SRCDIR)/onlineupdate/source/update/common \ -I$(SRCDIR)/onlineupdate/source/update/updater/xpcom/glue \ $$(INCLUDE) \ @@ -18,7 +19,7 @@ $(eval $(call gb_Executable_set_include,updater,\ $(eval $(call gb_Executable_use_static_libraries,updater,\ libmar \ $(if $(filter WNT,$(OS)), \ - winhelper \ + winhelper )\ )) ifeq ($(OS),WNT) diff --git a/onlineupdate/Module_onlineupdate.mk b/onlineupdate/Module_onlineupdate.mk index 2611faa595e7..fa066016cc32 100644 --- a/onlineupdate/Module_onlineupdate.mk +++ b/onlineupdate/Module_onlineupdate.mk @@ -13,6 +13,7 @@ $(eval $(call gb_Module_Module,onlineupdate)) ifneq ($(ENABLE_ONLINE_UPDATE_MAR),) $(eval $(call gb_Module_add_targets,onlineupdate,\ StaticLibrary_libmar \ + StaticLibrary_winhelper \ Executable_mar \ Executable_updater \ )) diff --git a/onlineupdate/inc/winhelper/windowsStart.hxx b/onlineupdate/inc/winhelper/windowsStart.hxx index 9305ebec43b5..5baedc840416 100644 --- a/onlineupdate/inc/winhelper/windowsStart.hxx +++ b/onlineupdate/inc/winhelper/windowsStart.hxx @@ -12,6 +12,11 @@ BOOL WinLaunchChild(const wchar_t *exePath, int argc, + wchar_t **argv, HANDLE userToken = nullptr, + HANDLE *hProcess = nullptr); + +BOOL +WinLaunchChild(const wchar_t *exePath, int argc, char **argv, HANDLE userToken = nullptr, HANDLE *hProcess = nullptr); diff --git a/onlineupdate/source/winhelper/windowsStart.cxx b/onlineupdate/source/winhelper/windowsStart.cxx index f2c31afc8629..7237e06da58b 100644 --- a/onlineupdate/source/winhelper/windowsStart.cxx +++ b/onlineupdate/source/winhelper/windowsStart.cxx @@ -2,8 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <windows.h> #include <shellapi.h> +#include <cstddef> +#include <cwchar> + // Needed for CreateEnvironmentBlock #include <userenv.h> #pragma comment(lib, "userenv.lib") @@ -138,36 +142,6 @@ MakeCommandLine(int argc, wchar_t **argv) } /** - * Convert UTF8 to UTF16 without using the normal XPCOM goop, which we - * can't link to updater.exe. - */ -static char16_t* -AllocConvertUTF8toUTF16(const char *arg) -{ - // UTF16 can't be longer in units than UTF8 - int len = strlen(arg); - char16_t *s = new char16_t[(len + 1) * sizeof(char16_t)]; - if (!s) - return nullptr; - - ConvertUTF8toUTF16 convert(s); - convert.write(arg, len); - convert.write_terminator(); - return s; -} - -static void -FreeAllocStrings(int argc, wchar_t **argv) -{ - while (argc) { - --argc; - delete [] argv[argc]; - } - - delete [] argv; -} - -/** * Launch a child process with the specified arguments. * @note argv[0] is ignored * @note The form of this function that takes char **argv expects UTF-8 @@ -180,29 +154,6 @@ WinLaunchChild(const wchar_t *exePath, BOOL WinLaunchChild(const wchar_t *exePath, - int argc, char **argv, - HANDLE userToken, - HANDLE *hProcess) -{ - wchar_t** argvConverted = new wchar_t*[argc]; - if (!argvConverted) - return FALSE; - - for (int i = 0; i < argc; ++i) { - argvConverted[i] = reinterpret_cast<wchar_t*>(AllocConvertUTF8toUTF16(argv[i])); - if (!argvConverted[i]) { - FreeAllocStrings(i, argvConverted); - return FALSE; - } - } - - BOOL ok = WinLaunchChild(exePath, argc, argvConverted, userToken, hProcess); - FreeAllocStrings(argc, argvConverted); - return ok; -} - -BOOL -WinLaunchChild(const wchar_t *exePath, int argc, wchar_t **argv, HANDLE userToken, |