[WRITE/SETUP/RUNONCE/SERVICES/MMSYS/MSGINA/SYSSETUP]

- 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
This commit is contained in:
Hermès Bélusca-Maïto 2012-12-23 23:17:10 +00:00
parent c963ccf7c2
commit 879883c38d
11 changed files with 31 additions and 29 deletions

View 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;

View 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))

View 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;

View 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;

View 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))

View 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,

View 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);

View 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);

View 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;

View 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,

View 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));