#6383 Refactor set startup info to a function

This commit is contained in:
Nick Bolton 2018-08-02 18:04:32 +01:00
parent aca2605cb8
commit 8ef2e7edbc
2 changed files with 16 additions and 14 deletions

View File

@ -351,19 +351,25 @@ MSWindowsWatchdog::startProcess()
}
}
void
MSWindowsWatchdog::setStartupInfo(STARTUPINFO& si)
{
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.lpDesktop = "winsta0\\Default"; // TODO: maybe this should be \winlogon if we have logonui.exe?
si.hStdError = m_stdOutWrite;
si.hStdOutput = m_stdOutWrite;
si.dwFlags |= STARTF_USESTDHANDLES;
}
BOOL
MSWindowsWatchdog::startProcessInForeground(String& command)
{
// clear, as we're reusing process info struct
ZeroMemory(&m_processInfo, sizeof(PROCESS_INFORMATION));
STARTUPINFO si;
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.lpDesktop = "winsta0\\Default"; // TODO: maybe this should be \winlogon if we have logonui.exe?
si.hStdError = m_stdOutWrite;
si.hStdOutput = m_stdOutWrite;
si.dwFlags |= STARTF_USESTDHANDLES;
STARTUPINFO si;
setStartupInfo(si);
return CreateProcess(
NULL, LPSTR(command.c_str()), NULL, NULL,
@ -376,13 +382,8 @@ MSWindowsWatchdog::startProcessAsUser(String& command, HANDLE userToken, LPSECUR
// clear, as we're reusing process info struct
ZeroMemory(&m_processInfo, sizeof(PROCESS_INFORMATION));
STARTUPINFO si;
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.lpDesktop = "winsta0\\Default"; // TODO: maybe this should be \winlogon if we have logonui.exe?
si.hStdError = m_stdOutWrite;
si.hStdOutput = m_stdOutWrite;
si.dwFlags |= STARTF_USESTDHANDLES;
STARTUPINFO si;
setStartupInfo(si);
LPVOID environment;
BOOL blockRet = CreateEnvironmentBlock(&environment, userToken, FALSE);

View File

@ -61,6 +61,7 @@ private:
void sendSas();
void getActiveDesktop(LPSECURITY_ATTRIBUTES security);
void testOutput(String buffer);
void setStartupInfo(STARTUPINFO& si);
private:
Thread* m_thread;