I have a system service which creates a helper interactive process as administrator so that it can access some desktop-related resources, including the BlockInput() function and NVIDIA's NVAPI functions, which cannot be run from a service. When the logged on user was a member of Administrators, the following worked:
- Set privilege levels, including SE_TCB_NAME
- Get active session ID with WTSGetActiveConsoleSessionId()
- Get logged on user from session ID with WTSQueryUserToken()
- GetTokenInformation() with TokenLinkedToken
- DuplicateTokenEx() with SecurityImpersonation
- Launch process with CreateProcessAsUser()
However, when I have the current logged on session be a standard user instead of one in Administrators, step 4. fails, presumably because the standard user doesn't have an administrative level token linked with it. What's the solution here? I assume I need to get the token of one of the administrator users, but how do I do that? And if that user is not the logged on one, can it still access functionality interactive with the current desktop?