Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我得到了以下场景:
进程 A 创建进程 B,然后 B 尝试使用 OpenProcess() 获取 A 的句柄。我希望 B 拥有 A 的 PROCESS_ALL_ACCESS 权限。
我应该如何实现这一目标?
谢谢。
可能最简单的方法是让父母完全避免孩子不得不调用 OpenProcess。取而代之的是,让父级检索自身的句柄(它将自动拥有所有访问权限),然后使用 bInheritHandle = true 调用 DuplicateHandle。然后,当它创建进程 B 时,该句柄(对进程 A 具有完全访问权限)将已经在子进程中打开。进程 A 只需将句柄传递给进程 B,进程 B 就可以使用它。