Brendan Shanks : whoami: Add semi-stub application to display username.
Alexandre Julliard
julliard at winehq.org
Tue Nov 10 13:46:22 CST 2020
Module: wine
Branch: stable
Commit: 1177517eceae1c11962cd30883dd43930569addc
URL: https://source.winehq.org/git/wine.git/?a=commit;h=1177517eceae1c11962cd30883dd43930569addc
Author: Brendan Shanks <bshanks at codeweavers.com>
Date: Mon Mar 9 11:09:52 2020 -0700
whoami: Add semi-stub application to display username.
Fixes GTA V hang experienced by some users.
Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit b36a10596a868e690e32c70f4487c3dc6b9bda7c)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
configure | 2 +
configure.ac | 1 +
programs/whoami/Makefile.in | 7 ++++
programs/whoami/main.c | 95 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 105 insertions(+)
diff --git a/configure b/configure
index 05194a51d2f..454cf7b4d35 100755
--- a/configure
+++ b/configure
@@ -1785,6 +1785,7 @@ enable_uninstaller
enable_unlodctr
enable_view
enable_wevtutil
+enable_whoami
enable_wineboot
enable_winebrowser
enable_winecfg
@@ -21148,6 +21149,7 @@ wine_fn_config_makefile programs/uninstaller enable_uninstaller
wine_fn_config_makefile programs/unlodctr enable_unlodctr
wine_fn_config_makefile programs/view enable_view
wine_fn_config_makefile programs/wevtutil enable_wevtutil
+wine_fn_config_makefile programs/whoami enable_whoami
wine_fn_config_makefile programs/wineboot enable_wineboot
wine_fn_config_makefile programs/winebrowser enable_winebrowser
wine_fn_config_makefile programs/winecfg enable_winecfg
diff --git a/configure.ac b/configure.ac
index 95730668e92..abcaaa50f78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3959,6 +3959,7 @@ WINE_CONFIG_MAKEFILE(programs/uninstaller)
WINE_CONFIG_MAKEFILE(programs/unlodctr)
WINE_CONFIG_MAKEFILE(programs/view)
WINE_CONFIG_MAKEFILE(programs/wevtutil)
+WINE_CONFIG_MAKEFILE(programs/whoami)
WINE_CONFIG_MAKEFILE(programs/wineboot)
WINE_CONFIG_MAKEFILE(programs/winebrowser)
WINE_CONFIG_MAKEFILE(programs/winecfg)
diff --git a/programs/whoami/Makefile.in b/programs/whoami/Makefile.in
new file mode 100644
index 00000000000..a003b0afaa7
--- /dev/null
+++ b/programs/whoami/Makefile.in
@@ -0,0 +1,7 @@
+MODULE = whoami.exe
+IMPORTS = secur32
+
+EXTRADLLFLAGS = -mconsole -municode -mno-cygwin
+
+C_SRCS = \
+ main.c
diff --git a/programs/whoami/main.c b/programs/whoami/main.c
new file mode 100644
index 00000000000..297f12c9a91
--- /dev/null
+++ b/programs/whoami/main.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2020 Brendan Shanks for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#define SECURITY_WIN32
+#include <windows.h>
+#include <security.h>
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(whoami);
+
+static int output_write(const WCHAR* str, int len)
+{
+ DWORD ret, count;
+ ret = WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), str, len, &count, NULL);
+ if (!ret)
+ {
+ DWORD lenA;
+ char* strA;
+
+ /* On Windows WriteConsoleW() fails if the output is redirected. So fall
+ * back to WriteFile(), assuming the console encoding is still the right
+ * one in that case.
+ */
+ lenA = WideCharToMultiByte(GetConsoleOutputCP(), 0, str, len,
+ NULL, 0, NULL, NULL);
+ strA = HeapAlloc(GetProcessHeap(), 0, lenA);
+ if (!strA)
+ return 0;
+
+ WideCharToMultiByte(GetConsoleOutputCP(), 0, str, len, strA, lenA,
+ NULL, NULL);
+ WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), strA, lenA, &count, FALSE);
+ HeapFree(GetProcessHeap(), 0, strA);
+ }
+ return count;
+}
+
+int __cdecl wmain(int argc, WCHAR *argv[])
+{
+ WCHAR *buf = NULL;
+ ULONG size = 0;
+ BOOL result;
+
+ if (argc > 1)
+ {
+ int i;
+
+ WINE_FIXME("unsupported arguments:");
+ for (i = 0; i < argc; i++)
+ WINE_FIXME(" %s", wine_dbgstr_w(argv[i]));
+ WINE_FIXME("\n");
+ }
+
+ result = GetUserNameExW(NameSamCompatible, NULL, &size);
+ if (result || GetLastError() != ERROR_MORE_DATA)
+ {
+ WINE_ERR("GetUserNameExW failed, result %d, error %d\n", result, GetLastError());
+ return 1;
+ }
+
+ buf = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR));
+ if (!buf)
+ {
+ WINE_ERR("Memory allocation failed\n");
+ return 1;
+ }
+
+ result = GetUserNameExW(NameSamCompatible, buf, &size);
+ if (result)
+ {
+ output_write(buf, size);
+ output_write(L"\r\n", 2);
+ }
+ else
+ WINE_ERR("GetUserNameExW failed, error %d\n", GetLastError());
+
+ HeapFree(GetProcessHeap(), 0, buf);
+ return 0;
+}
More information about the wine-cvs
mailing list