views:

35

answers:

2

I need to perform certain operations on a process started with ShellExecuteEx - like waiting for it, duplicating handles, querying and setting information etc. Now I am wondering if I can do all these things on the hProcess member which is returned in the SHELLEXECUTEINFO structure I pass to ShellExecuteEx. Does anybody know this?

Does the process that called ShellExecuteEx have rights like PROCESS_DUP_HANDLE, SYNCHRONIZE, PROCESS_SET_INFORMATION, PROCESS_QUERY_INFORMATION (and so on) by default, when using the returned hProcess?

A: 

Yes. The online time you need to worry about access rights is if you do any task that trigger the uac, then u need to set the requestedExecutionLevel= 'highestAvailable'

techiesguy
A: 

I would guess that it is the same as what you get from CreateProcess, though even that documentation doesn't say (I would venture PROCESS_ALL_ACCESS). In any event, you could always do GetProcessId() and OpenProcess() to open it with whatever access you need.

Luke
But wouldn't OpenProcess fail if the started process required elevation (>=Vista)? If the calling process is not elevated it won't have the rights to access the elevated process. But the handle is already there... probably giving access to the elevated process even if the process that called ShellExecuteEx is not elevated?
Heinrich Ulbricht
I guess it might fail due to integrity levels; I don't remember all the UAC details exactly. Anyway, there is some documentation on it here (http://msdn.microsoft.com/en-us/library/ms684880.aspx) stating the handle returned from CreateProcess() has PROCESS_ALL_ACCESS. ShellExecuteEx almost certainly gives you that exact handle (or a duplicate of it); unfortunately I couldn't find any documentation that states this explicitly, but it seems extremely likely.
Luke