Код: Выделить всё
// usrToken has the following
// Is in session 1
// Obtained by calling LogonUser and then user profile is loaded and user environment is created.
// Has generic read and write access to session 1 winsta0 and default desktop. I added these explicitly by modifying ACLs
// trying to launch notepad.exe in the new user session. I have tried with cmd.exe as well but could not see any UI window
BOOL InjectProcess2(HANDLE usrToken)
{
BOOL ret;
DWORD err;
PROCESS_INFORMATION pi = {};
DWORD sessionId = WTSGetActiveConsoleSessionId();
// i think this may be redundant
if (!SetTokenInformation(usrToken, TokenSessionId,
&sessionId, sizeof(sessionId)))
{
err = GetLastError();
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79698035/createprocessasuser-succeeds-and-process-is-created-but-ui-is-not-visible[/url]