views:

59

answers:

1

In my manager.exe, I'm trying to change the CPU usage of my worker.exe, which is started by my service.exe. Service.exe is running under the System Account, while manager.exe is running under the logged in user's account.

When I call OpenProcess in manager.exe with worker.exe's PID, I get NULL for procHandle:

HANDLE procHandle = OpenProcess(PROCESS_SET_INFORMATION, 0, pid);

Using GetLastError() I see that I got an Access Denied error.

Any ways around this? Can I somehow modify worker.exe to grant other processes full control over itself?

A: 

You shouldn't have to call OpenProcess.

The service should already have a full-permission handle to the worker from when it called CreateProcessAsUser or CreateProcessWithLogonW. Use DuplicateHandle to make a version of that handle suitable for use by the manager process, and then have the service send that handle to the manager. The service already has a handle to the manager, right? It will need that for DuplicateHandle.

Or have the manager ask the service to change the worker process.

Rob Kennedy
Service.exe started the process. I'm trying to modify it from Manager.exe.
Martin
Right, sorry. I noticed that afterward. I've updated my answer accordingly.
Rob Kennedy
Another possibility would be to have service.exe grant the logged in user PROCESS_SET_INFORMATION right in the ACL on the worker.exe process when it creates it.
Michael