Myah Caron : kernelbase: Use command_lineW for GetCommandLineW.

Alexandre Julliard julliard at winehq.org
Wed Oct 14 15:37:20 CDT 2020


Module: wine
Branch: master
Commit: d01d3b749d7d99c75f29396fd79fab735ced2b2d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d01d3b749d7d99c75f29396fd79fab735ced2b2d

Author: Myah Caron <qsniyg at protonmail.com>
Date:   Tue Oct 13 19:43:01 2020 +0000

kernelbase: Use command_lineW for GetCommandLineW.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48861
Signed-off-by: Myah Caron <qsniyg at protonmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 109322d684..7c6a0ff0a8 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 = cmdline_backup;
 }
 
 static void test_Directory(void)
diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c
index e7998c00f2..d5fedb4495 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;
 }
 
 




More information about the wine-cvs mailing list