Question for JKR, ImpersonateInteractiveUser() does not work after SP4...
Posted on 2004-03-31
JKR or to whom anyone who has an answer,
About 1 week ago I posted a question asking how to impersonate the interactive user so I could launch a process that wrote to the users desktop. Well during testing I was getting some inconsistent results, after an extremely long amount of testing I figured out it was Windows 2000 SP4 breaks it, most likely its something microsoft has tightened down on to make the system more secure, I believe my weakness relies in how I am obtaining the Process ID of the interactive user, however I have not done enough testing to verify this. The below code is the ENTIRE snippet I am using to Impersonate the interactive user. Do you have any information regarding any new methods of doing this after SP4?
NOTE: Works fine in WindowsXP with all SP/Patches...
DWORD ImpersonateInteractiveUser() //Impersonates the logged in user to create an instance in the users context...
HANDLE hToken = NULL;
HANDLE hProcess = NULL;
DWORD processID = GetExplorerProcessID();
CloseHandle( hToken );
CloseHandle( hProcess );
DWORD GetExplorerProcessID() //Needed to impersonate the logged in user...
DWORD temp = NULL;
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,NULL);
pe32.dwSize = sizeof(PROCESSENTRY32);
temp = pe32.th32ProcessID;