HANDLE
hTokenThis
=
NULL
;
HANDLE
hTokenDup
=
NULL
;
HANDLE
hThisProcess
=
GetCurrentProcess
();
OpenProcessToken
(
hThisProcess
,
TOKEN_ALL_ACCESS
, &
hTokenThis
);
DuplicateTokenEx
(
hTokenThis
,
MAXIMUM_ALLOWED
,
NULL
, SecurityIdentification, TokenPrimary, &
hTokenDup
);
DWORD
dwSessionId
= WTSGetActiveConsoleSessionId();
SetTokenInformation
(
hTokenDup
, TokenSessionId, &
dwSessionId
,
sizeof
(
DWORD
));
STARTUPINFO
si
;
PROCESS_INFORMATION
pi
;
ZeroMemory
(&
si
,
sizeof
(
STARTUPINFO
));
ZeroMemory
(&
pi
,
sizeof
(PROCESS_INFORMATION));
si
.
cb
=
sizeof
(
STARTUPINFO
);
si
.
lpDesktop
= "WinSta0//Default";
LPVOID
pEnv
=
NULL
;
DWORD
dwCreationFlag
=
NORMAL_PRIORITY_CLASS
|
CREATE_NEW_CONSOLE
;
CreateEnvironmentBlock(&
pEnv
,
hTokenDup
,
FALSE
);
CreateProcessAsUser
(
hTokenDup
,
NULL
,
(
char
*)"notepad",
NULL
,
NULL
,
FALSE
,
dwCreationFlag
,
pEnv
,
NULL
,
&
si
,
&
pi
);
|