mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 09:23:06 +00:00
Duplicate the user token before calling CreateProcessAsUser()
See issue #2569 for more details. svn path=/trunk/; revision=29845
This commit is contained in:
parent
ff15530f99
commit
9fdfadf2fa
1 changed files with 11 additions and 1 deletions
|
@ -203,9 +203,17 @@ WlxStartApplication(
|
||||||
STARTUPINFOW StartupInfo;
|
STARTUPINFOW StartupInfo;
|
||||||
PROCESS_INFORMATION ProcessInformation;
|
PROCESS_INFORMATION ProcessInformation;
|
||||||
WCHAR CurrentDirectory[MAX_PATH];
|
WCHAR CurrentDirectory[MAX_PATH];
|
||||||
|
HANDLE hAppToken;
|
||||||
UINT len;
|
UINT len;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
|
ret = DuplicateTokenEx(pgContext->UserToken, MAXIMUM_ALLOWED, NULL, SecurityImpersonation, TokenPrimary, &hAppToken);
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
WARN("DuplicateTokenEx() failed with error %lu\n", GetLastError());
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
|
ZeroMemory(&StartupInfo, sizeof(STARTUPINFOW));
|
||||||
StartupInfo.cb = sizeof(STARTUPINFOW);
|
StartupInfo.cb = sizeof(STARTUPINFOW);
|
||||||
StartupInfo.lpTitle = pszCmdLine;
|
StartupInfo.lpTitle = pszCmdLine;
|
||||||
|
@ -218,10 +226,11 @@ WlxStartApplication(
|
||||||
if (len > MAX_PATH)
|
if (len > MAX_PATH)
|
||||||
{
|
{
|
||||||
WARN("GetWindowsDirectoryW() failed\n");
|
WARN("GetWindowsDirectoryW() failed\n");
|
||||||
|
CloseHandle(hAppToken);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ret = CreateProcessAsUserW(
|
ret = CreateProcessAsUserW(
|
||||||
pgContext->UserToken,
|
hAppToken,
|
||||||
pszCmdLine,
|
pszCmdLine,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -232,6 +241,7 @@ WlxStartApplication(
|
||||||
CurrentDirectory,
|
CurrentDirectory,
|
||||||
&StartupInfo,
|
&StartupInfo,
|
||||||
&ProcessInformation);
|
&ProcessInformation);
|
||||||
|
CloseHandle(hAppToken);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
WARN("CreateProcessAsUserW() failed with error %lu\n", GetLastError());
|
WARN("CreateProcessAsUserW() failed with error %lu\n", GetLastError());
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue