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 ( Local System .)

The user-mode process is required to run without aliasing, but UIAccess = "true" To be able to have your manifest.

So I run my user-mode process (from my service):

  // 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);   

This is the UIAccess = "false" in the manifest for user_process.exe .

But if I do the following:

  • Enable user_process.exe for UIAccess = "true" :

    Enter image details here

    • Sign it with your code-signing certificate

    • call it C: \ Program Files (x86) \ Company \ Software " place in the / code> folder.

      I get what CreateProcessAsUser is error ERROR_ELEVATION_REQUIRED .

      Can you suggest how to work it? To enable PS SE_DEBUG_NAME and SE_TCB_NAME I tried to adjust the privileges of my service, or did not help.

      PS2 \ Program Files (I just signed the code with my 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.)

      I have the answer here also that whosoever runs it in:

      After this, call 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

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -