[ros-diffs] [hpoussin] 29845: Duplicate the user token before calling CreateProcessAsUser() See issue #2569 for more details.

hpoussin at svn.reactos.org hpoussin at svn.reactos.org
Wed Oct 24 09:45:45 CEST 2007


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?rev=29845&r1=29844&r2=29845&view=diff
==============================================================================
--- 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;




More information about the Ros-diffs mailing list