I don't have any experience in WINAPI. I'm using visual c++ to create a service. I have a service which creates a process(notepad.exe) under the SYSTEM account. This service has to launch the process under the user account(currently logged on user account).
1.Get the process_id of a process(OneDrive.exe or explorer.exe) which is ran by a logged on user.
2.Use processHandle = OpenProcess(PROCESS_ALL_ACCESS,TRUE,process_id) function to get the handle to the process.
3.Use OpenProcessToken(processHandle , TOKEN_QUERY | TOKEN_IMPERSONATE | TOKEN_DUPLICATE, hToken) to get a user token.(I can get the token, but I don't know whether this token is valid or not!)
4.Then use ImpersonateLoggedOnUser(hToken) function to create the process under the user account.(this step always fails in my case)
Can anyone please help me to get out from this issue...??
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)