由我的服务启动的进程上的 OpenProcess / SetProcessAffinityMask
在我的 manager.exe 中,我试图更改由我的 service.exe 启动的worker.exe 的CPU 使用率。 Service.exe 在系统帐户下运行,而manager.exe 在登录用户帐户下运行。
当我使用worker.exe的PID在manager.exe中调用OpenProcess时,我得到的procHandle为NULL:
HANDLE procHandle = OpenProcess(PROCESS_SET_INFORMATION, 0, pid);
使用 GetLastError() 我发现出现了“拒绝访问”错误。
有什么办法解决这个问题吗?我可以以某种方式修改worker.exe以授予其他进程对其自身的完全控制权吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不必调用
OpenProcess
。当服务调用
CreateProcessAsUser
或CreateProcessWithLogonW
时,它应该已经拥有工作线程的完全权限句柄。使用 DuplicateHandle 制作适合管理器进程使用的句柄版本,然后让服务将该句柄发送给管理器。该服务已经有了经理的句柄,对吗?DuplicateHandle
需要它。或者让经理要求服务更改工作进程。
You shouldn't have to call
OpenProcess
.The service should already have a full-permission handle to the worker from when it called
CreateProcessAsUser
orCreateProcessWithLogonW
. UseDuplicateHandle
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 forDuplicateHandle
.Or have the manager ask the service to change the worker process.