[WRITE/SETUP/RUNONCE/SERVICES/MMSYS/MSGINA/SYSSETUP]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 23 Dec 2012 23:17:10 +0000 (23:17 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 23 Dec 2012 23:17:10 +0000 (23:17 +0000)
- Use in some places ZeroMemory instead of memset(..., 0, ...).
- Fix way of initializing the STARTUPINFO structure before call to CreateProcess: in particular, when using the wShowWindow field, also use the STARTF_USESHOWWINDOW flag.

[USERINIT]
- Fix way of initializing the STARTUPINFO structure before call to CreateProcess: in particular, when using the wShowWindow field, also use the STARTF_USESHOWWINDOW flag.
- This fixes CORE-5735.

CORE-5735 #resolve #comment Command-line launching fixed in revision r57986.

svn path=/trunk/; revision=57986

reactos/base/applications/rapps/loaddlg.c
reactos/base/applications/rapps/misc.c
reactos/base/applications/write/write.c
reactos/base/setup/welcome/welcome.c
reactos/base/system/runonce/runonce.c
reactos/base/system/services/database.c
reactos/base/system/userinit/userinit.c
reactos/dll/cpl/mmsys/audio.c
reactos/dll/win32/msgina/msgina.c
reactos/dll/win32/syssetup/install.c
reactos/dll/win32/syssetup/wizard.c

index ab40223..382d3ea 100644 (file)
@@ -260,7 +260,7 @@ ThreadFunc(LPVOID Context)
     ShowWindow(Dlg, SW_HIDE);
 
     /* run it */
-    memset(&si, 0, sizeof(si));
+    ZeroMemory(&si, sizeof(si));
     si.cb = sizeof(si);
     r = CreateProcessW(path, NULL, NULL, NULL, 0, 0, NULL, NULL, &si, &pi);
     if (0 == r) goto end;
index b0c01e9..836a3b2 100644 (file)
@@ -168,6 +168,7 @@ StartProcess(LPWSTR lpPath, BOOL Wait)
 
     ZeroMemory(&si, sizeof(si));
     si.cb = sizeof(si);
+    si.dwFlags = STARTF_USESHOWWINDOW;
     si.wShowWindow = SW_SHOW;
 
     if (!CreateProcessW(NULL, lpPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
index 56cd370..da145c2 100644 (file)
@@ -35,16 +35,20 @@ int CALLBACK wWinMain(HINSTANCE hInstance, HINSTANCE hOldInstance, LPWSTR szCmdP
     PROCESS_INFORMATION info;
 
     if (!GetSystemDirectoryW(path, MAX_PATH - 1 - lstrlenW(SZ_WORDPAD)))
-       goto failed;
+        goto failed;
+
     if (path[lstrlenW(path) - 1] != '\\')
-       lstrcatW(path, SZ_BACKSLASH);
+        lstrcatW(path, SZ_BACKSLASH);
+
     lstrcatW(path, SZ_WORDPAD);
 
-    stinf.cb = sizeof(STARTUPINFOW);
+    ZeroMemory(&stinf, sizeof(stinf));
+    stinf.cb = sizeof(stinf);
     GetStartupInfoW(&stinf);
 
     if (!CreateProcessW(path, GetCommandLineW(), NULL, NULL, FALSE, 0, NULL, NULL, &stinf, &info))
-       goto failed;
+        goto failed;
+
     CloseHandle(info.hProcess);
     CloseHandle(info.hThread);
     return 0;
index 486074c..832ed0b 100644 (file)
@@ -261,8 +261,8 @@ RunApplication(int nTopic)
       _tcscat(AppName, CurrentDir);
     }
 
-  memset(&StartupInfo, 0, sizeof(STARTUPINFO));
-  StartupInfo.cb = sizeof(STARTUPINFO);
+  ZeroMemory(&StartupInfo, sizeof(StartupInfo));
+  StartupInfo.cb = sizeof(StartupInfo);
   StartupInfo.lpTitle = TEXT("Test");
   StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
   StartupInfo.wShowWindow = SW_SHOWNORMAL;
index 3bd6051..3cbd7b7 100644 (file)
@@ -25,6 +25,7 @@ StartApplication(LPVOID lpDlg)
 
         ZeroMemory(&si, sizeof(si));
         si.cb = sizeof(si);
+        si.dwFlags = STARTF_USESHOWWINDOW;
         si.wShowWindow = SW_SHOW;
 
         if (!CreateProcess(NULL, szData, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
@@ -156,6 +157,7 @@ _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
 
                     ZeroMemory(&si, sizeof(si));
                     si.cb = sizeof(si);
+                    si.dwFlags = STARTF_USESHOWWINDOW;
                     si.wShowWindow = SW_SHOW;
 
                     if (!CreateProcess(NULL, szData, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
index e30697c..989c41e 100644 (file)
@@ -1512,13 +1512,9 @@ ScmStartUserModeService(PSERVICE Service,
         return ScmSendStartCommand(Service, argc, argv);
     }
 
+    ZeroMemory(&StartupInfo, sizeof(StartupInfo));
     StartupInfo.cb = sizeof(StartupInfo);
-    StartupInfo.lpReserved = NULL;
-    StartupInfo.lpDesktop = NULL;
-    StartupInfo.lpTitle = NULL;
-    StartupInfo.dwFlags = 0;
-    StartupInfo.cbReserved2 = 0;
-    StartupInfo.lpReserved2 = 0;
+    ZeroMemory(&ProcessInformation, sizeof(ProcessInformation));
 
     Result = CreateProcessW(NULL,
                             Service->lpImage->szImagePath,
index d19dda5..3f9d97b 100644 (file)
@@ -241,9 +241,11 @@ TryToStartShell(
 
     TRACE("(%s)\n", debugstr_w(Shell));
 
-    ZeroMemory(&si, sizeof(STARTUPINFO));
-    si.cb = sizeof(STARTUPINFO);
-    ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
+    ZeroMemory(&si, sizeof(si));
+    si.cb = sizeof(si);
+    si.dwFlags = STARTF_USESHOWWINDOW;
+    si.wShowWindow = SW_SHOWNORMAL;
+    ZeroMemory(&pi, sizeof(pi));
 
     ExpandEnvironmentStrings(Shell, ExpandedShell, MAX_PATH);
 
index d190c94..59908a2 100644 (file)
@@ -204,6 +204,7 @@ AudioDlgProc(HWND hwndDlg,
 
                     ZeroMemory(&si, sizeof(si));
                     si.cb = sizeof(si);
+                    si.dwFlags = STARTF_USESHOWWINDOW;
                     si.wShowWindow = SW_SHOW;
 
                     CreateProcess(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
@@ -223,6 +224,7 @@ AudioDlgProc(HWND hwndDlg,
 
                     ZeroMemory(&si, sizeof(si));
                     si.cb = sizeof(si);
+                    si.dwFlags = STARTF_USESHOWWINDOW;
                     si.wShowWindow = SW_SHOW;
 
                     CreateProcess(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
@@ -242,6 +244,7 @@ AudioDlgProc(HWND hwndDlg,
 
                     ZeroMemory(&si, sizeof(si));
                     si.cb = sizeof(si);
+                    si.dwFlags = STARTF_USESHOWWINDOW;
                     si.wShowWindow = SW_SHOW;
 
                     CreateProcess(NULL, szPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
index 1760da7..9419839 100644 (file)
@@ -218,12 +218,11 @@ WlxStartApplication(
                return FALSE;
        }
 
-       ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
-       ZeroMemory(&ProcessInformation, sizeof(PROCESS_INFORMATION));
-       StartupInfo.cb = sizeof(STARTUPINFOW);
+       ZeroMemory(&StartupInfo, sizeof(StartupInfo));
+       ZeroMemory(&ProcessInformation, sizeof(ProcessInformation));
+       StartupInfo.cb = sizeof(StartupInfo);
        StartupInfo.lpTitle = pszCmdLine;
-       StartupInfo.dwX = StartupInfo.dwY = StartupInfo.dwXSize = StartupInfo.dwYSize = 0L;
-       StartupInfo.dwFlags = 0;
+       StartupInfo.dwFlags = STARTF_USESHOWWINDOW;
        StartupInfo.wShowWindow = SW_SHOW;
        StartupInfo.lpDesktop = pszDesktopName;
 
index 7e671bb..43867e2 100644 (file)
@@ -678,13 +678,8 @@ InstallLiveCD(IN HINSTANCE hInstance)
     SetupCloseInfFile(hSysSetupInf);
 
     /* Run the shell */
-    StartupInfo.cb = sizeof(STARTUPINFOW);
-    StartupInfo.lpReserved = NULL;
-    StartupInfo.lpDesktop = NULL;
-    StartupInfo.lpTitle = NULL;
-    StartupInfo.dwFlags = 0;
-    StartupInfo.cbReserved2 = 0;
-    StartupInfo.lpReserved2 = 0;
+    ZeroMemory(&StartupInfo, sizeof(StartupInfo));
+    StartupInfo.cb = sizeof(StartupInfo);
     bRes = CreateProcessW(
         L"userinit.exe",
         NULL,
index 2ec3352..b53ce26 100644 (file)
@@ -794,7 +794,7 @@ RunControlPanelApplet(HWND hwnd, PCWSTR pwszCPLParameters)
         PROCESS_INFORMATION ProcessInformation;
         WCHAR CmdLine[MAX_PATH] = L"rundll32.exe shell32.dll,Control_RunDLL ";
 
-        ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
+        ZeroMemory(&StartupInfo, sizeof(StartupInfo));
         StartupInfo.cb = sizeof(STARTUPINFOW);
 
         ASSERT(_countof(CmdLine) > wcslen(CmdLine) + wcslen(pwszCPLParameters));