c++ - CreateProcessAsUser fails with ERROR_ELEVATION_REQUIRED for a process with UIAccess="true" -
I'm trying to use the following code to run a user-mode process from my service application ( The user-mode process is required to run without aliasing, but So I run my user-mode process (from my service): This is the But if I do the following: Sign it with your code-signing certificate call it C: \ Program Files (x86) \ Company \ Software " place in the / code> folder. I get what Can you suggest how to work it? To enable PS PS2 \ Program Files (I just signed the code with my I have the answer here also that whosoever runs it in: After this, call Local System .)
UIAccess = "true" To be able to have your manifest.
// Note: Check for error left for readability the // 'dwSessionID' = user-mode user session ID to run the process 'Piusrpikrap' = L "C: \\ program files (x86) \ \ software \ \ user_process.exe" handle HToken = NULL; WTSQueryUserToken ( DwSessionID, and HT token); Handle HTCon 2; DuplicateTokenX (HT, MAXIMUM_ALLOWED, NULL, Security Scheduling, T Knpramiri, and Actiken 2); Elpiviod Piianviblok = NULL; CreateEnvironmentBlock (& amp; pEnvBlock, hToken2, FALSE); STARTUPINFO C; Jhoremori (& amp; si, size (STARTUPINFO)); Si.cb = size (STARTUPINFO) ; si.lpDesktop = L "winsta0 \\ default"; PROCESS_INFORMATION pi; Jiromori (S & P, Akarf (PI)); // ImpersonateLoggedOnUser (hToken2); // PVOID OldRedir is not necessarily as suggested below; Wow64DisableWow64FsRedirection (& amp; OldRedir); BOOL bSuccess = CreateProcessAsUser (hToken2, // client access token pUserProcPath, // file SECURITY_ATTRIBUTES to execute zero to process null, // command line shun If, // pointer, // pointer pairing wrong SECURITY_ATTRIBUTES formula // handles are not inheritable NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE | CREATE_UNICODE_ENVIRONMENT, // creation flags pEnvBlock, // new environment block to pointer, // name of current directory &; C, // STARTUPINFO structure & amp; pointer; Exemplary // receives information about new process); Int nOSError = :: GetLastError (); Wow64RevertWow64FsRedirection (OldRedir); // RevertToSelf (); // CloseHandle (pi.hProcess) is not necessarily as suggestive; CloseHandle (pi.hThread); DestroyEnvironmentBlock (pEnvBlock); CloseHandle (hToken2); CloseHandle (hToken);
UIAccess = "false" in the manifest for
user_process.exe .
user_process.exe for UIAccess = "true" :
CreateProcessAsUser is error
ERROR_ELEVATION_REQUIRED .
SE_DEBUG_NAME and
SE_TCB_NAME I tried to adjust the privileges of my service, or did not help.
double-clicking user_process.exe process with
UIAccess = "true" ) , And compiled X code in the
C) \ Company \ Software \ / code> folder, it starts & amp; Just runs (not high.)
duplicate tokenx :
handle html 2; DuplicateTokenX (HTN, MAXIMUM_ALLOWED, NULL, Security Identification, TokenPamiri, and HTTK 2); // Only if UIAccess is required! DWORD dwUIAccess = 1; :: SetTokenInformation (hToken2, TokenUIAccess, and dwUIAccess, sizeof (dwUIAccess));
Comments
Post a Comment