[PATCH 1/2] kernelbase: Use command_lineW for GetCommandLineW.
Myah Caron
qsniyg at protonmail.com
Fri Oct 9 07:06:45 CDT 2020
Wine-bug: https://bugs.winehq.org/show_bug.cgi?id=48861
Signed-off-by: Myah Caron <qsniyg at protonmail.com>
---
dlls/kernel32/tests/process.c | 11 +++++++++++
dlls/kernelbase/process.c | 2 +-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index 109322d6844..33f2e14a086 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -872,6 +872,7 @@ static void test_CommandLine(void)
PROCESS_INFORMATION info;
STARTUPINFOA startup;
BOOL ret;
+ LPWSTR cmdline, cmdline_backup;
memset(&startup, 0, sizeof(startup));
startup.cb = sizeof(startup);
@@ -1074,6 +1075,16 @@ static void test_CommandLine(void)
ret = CreateProcessA(NULL, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info);
ok(!ret, "CreateProcessA unexpectedly succeeded\n");
ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", GetLastError());
+
+ /* Test whether GetCommandLineW reads directly from TEB or from a cached address */
+ cmdline = GetCommandLineW();
+ ok(cmdline == NtCurrentTeb()->Peb->ProcessParameters->CommandLine.Buffer, "Expected address from TEB, got %p\n", cmdline);
+
+ cmdline_backup = cmdline;
+ NtCurrentTeb()->Peb->ProcessParameters->CommandLine.Buffer = NULL;
+ cmdline = GetCommandLineW();
+ ok(cmdline == cmdline_backup, "Expected cached address from TEB, got %p\n", cmdline);
+ NtCurrentTeb()->Peb->ProcessParameters->CommandLine.Buffer = p;
}
static void test_Directory(void)
diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c
index e7998c00f28..d5fedb4495c 100644
--- a/dlls/kernelbase/process.c
+++ b/dlls/kernelbase/process.c
@@ -1289,7 +1289,7 @@ LPSTR WINAPI DECLSPEC_HOTPATCH GetCommandLineA(void)
*/
LPWSTR WINAPI DECLSPEC_HOTPATCH GetCommandLineW(void)
{
- return NtCurrentTeb()->Peb->ProcessParameters->CommandLine.Buffer;
+ return command_lineW;
}
--
2.28.0
More information about the wine-devel
mailing list