Hugh McMaster : uninstaller: Add WriteFile fallback.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Aug 19 09:56:02 CDT 2015
Module: wine
Branch: master
Commit: 8432e7dd30b9598dab590f12ef57b2672fefbc35
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8432e7dd30b9598dab590f12ef57b2672fefbc35
Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date: Wed Aug 19 15:00:56 2015 +1000
uninstaller: Add WriteFile fallback.
---
programs/uninstaller/main.c | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/programs/uninstaller/main.c b/programs/uninstaller/main.c
index 899337d..a9aae73 100644
--- a/programs/uninstaller/main.c
+++ b/programs/uninstaller/main.c
@@ -59,10 +59,31 @@ static const WCHAR UninstallCommandlineW[] = {'U','n','i','n','s','t','a','l','l
static const WCHAR WindowsInstallerW[] = {'W','i','n','d','o','w','s','I','n','s','t','a','l','l','e','r',0};
static const WCHAR SystemComponentW[] = {'S','y','s','t','e','m','C','o','m','p','o','n','e','n','t',0};
+static void output_writeconsole(const WCHAR *str, DWORD len)
+{
+ DWORD written, ret, lenA;
+ char *strA;
+
+ ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, len, &written, NULL);
+ if (ret) return;
+
+ /* WriteConsole fails if its output is redirected to a file.
+ * If this occurs, we should use an OEM codepage and call WriteFile.
+ */
+ lenA = WideCharToMultiByte(GetConsoleOutputCP(), 0, str, len, NULL, 0, NULL, NULL);
+ strA = HeapAlloc(GetProcessHeap(), 0, lenA);
+ if (strA)
+ {
+ WideCharToMultiByte(GetConsoleOutputCP(), 0, str, len, strA, lenA, NULL, NULL);
+ WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), strA, lenA, &written, FALSE);
+ HeapFree(GetProcessHeap(), 0, strA);
+ }
+}
+
static void output_formatstring(const WCHAR *fmt, __ms_va_list va_args)
{
WCHAR *str;
- DWORD len, count;
+ DWORD len;
SetLastError(NO_ERROR);
len = FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ALLOCATE_BUFFER,
@@ -72,7 +93,7 @@ static void output_formatstring(const WCHAR *fmt, __ms_va_list va_args)
WINE_FIXME("Could not format string: le=%u, fmt=%s\n", GetLastError(), wine_dbgstr_w(fmt));
return;
}
- WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, len, &count, NULL);
+ output_writeconsole(str, len);
LocalFree(str);
}
More information about the wine-cvs
mailing list