Author: hpoussin Date: Wed Oct 24 11:45:44 2007 New Revision: 29845
URL: http://svn.reactos.org/svn/reactos?rev=29845&view=rev Log: Duplicate the user token before calling CreateProcessAsUser() See issue #2569 for more details.
Modified: trunk/reactos/dll/win32/msgina/msgina.c
Modified: trunk/reactos/dll/win32/msgina/msgina.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msgina/msgina.c?r... ============================================================================== --- trunk/reactos/dll/win32/msgina/msgina.c (original) +++ trunk/reactos/dll/win32/msgina/msgina.c Wed Oct 24 11:45:44 2007 @@ -203,8 +203,16 @@ STARTUPINFOW StartupInfo; PROCESS_INFORMATION ProcessInformation; WCHAR CurrentDirectory[MAX_PATH]; + HANDLE hAppToken; UINT len; 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)); StartupInfo.cb = sizeof(STARTUPINFOW); @@ -218,10 +226,11 @@ if (len > MAX_PATH) { WARN("GetWindowsDirectoryW() failed\n"); + CloseHandle(hAppToken); return FALSE; } ret = CreateProcessAsUserW( - pgContext->UserToken, + hAppToken, pszCmdLine, NULL, NULL, @@ -232,6 +241,7 @@ CurrentDirectory, &StartupInfo, &ProcessInformation); + CloseHandle(hAppToken); if (!ret) WARN("CreateProcessAsUserW() failed with error %lu\n", GetLastError()); return ret;