https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6fe704b0f0bdd8b2351d5ca94f6502232f067024

commit 6fe704b0f0bdd8b2351d5ca94f6502232f067024
Author:     Stanislav Motylkov <[email protected]>
AuthorDate: Tue Jul 21 17:04:17 2020 +0300
Commit:     Stanislav Motylkov <[email protected]>
CommitDate: Tue Jul 21 17:28:48 2020 +0300

    [EXPLORER] Fix auto startup behavior
    
    Command line should be expanded only for REG_EXPAND_SZ values.
    
    CORE-17168
---
 base/shell/explorer/startup.cpp | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/base/shell/explorer/startup.cpp b/base/shell/explorer/startup.cpp
index f4f064e266a..5153deb9f13 100644
--- a/base/shell/explorer/startup.cpp
+++ b/base/shell/explorer/startup.cpp
@@ -62,9 +62,6 @@ static int runCmd(LPWSTR cmdline, LPCWSTR dir, BOOL wait, 
BOOL minimized)
     STARTUPINFOW si;
     PROCESS_INFORMATION info;
     DWORD exit_code = 0;
-    WCHAR szCmdLineExp[MAX_PATH+1] = L"\0";
-
-    ExpandEnvironmentStringsW(cmdline, szCmdLineExp, _countof(szCmdLineExp));
 
     memset(&si, 0, sizeof(si));
     si.cb = sizeof(si);
@@ -75,7 +72,7 @@ static int runCmd(LPWSTR cmdline, LPCWSTR dir, BOOL wait, 
BOOL minimized)
     }
     memset(&info, 0, sizeof(info));
 
-    if (!CreateProcessW(NULL, szCmdLineExp, NULL, NULL, FALSE, 0, NULL, dir, 
&si, &info))
+    if (!CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, dir, &si, 
&info))
     {
         TRACE("Failed to run command (%lu)\n", GetLastError());
 
@@ -260,13 +257,21 @@ static BOOL ProcessRunKeys(HKEY hkRoot, LPCWSTR 
szKeyName, BOOL bDelete,
             TRACE("Couldn't delete value - %lu, %ld. Running command 
anyways.\n", i, res);
         }
 
-        if (type != REG_SZ)
+        if (type != REG_SZ && type != REG_EXPAND_SZ)
         {
             TRACE("Incorrect type of value #%lu (%lu)\n", i, type);
 
             continue;
         }
 
+        if (type == REG_EXPAND_SZ)
+        {
+            WCHAR szCmdLineExp[MAX_PATH + 1] = L"\0";
+
+            if (ExpandEnvironmentStringsW(szCmdLine, szCmdLineExp, 
_countof(szCmdLineExp)))
+                StringCbCopyW(szCmdLine, cbMaxCmdLine, szCmdLineExp);
+        }
+
         res = runCmd(szCmdLine, NULL, bSynchronous, FALSE);
         if (res == INVALID_RUNCMD_RETURN)
         {

Reply via email to