VC++ 2008,OpenProcess 总是返回错误 5(访问被拒绝)
有人知道为什么当我尝试使用 PROCESS_ALL_ACCESS 作为我所需的访问权限调用 OpenProcess 时,MSVC++ 2008 总是在 GetLastError() 上返回错误 5 吗? PROCESS_VM_READ 工作得很好。 我是这台计算机的管理员,它在 Dev C++ 中运行良好。
我需要在某处设置一个选项吗?
Would anyone know why MSVC++ 2008 always returns error 5 on GetLastError() when I try to call OpenProcess with PROCESS_ALL_ACCESS as my desired access? PROCESS_VM_READ works just fine. I'm an administrator on this computer and it is working fine in Dev C++.
Do I need to set an option somewhere?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果一个进程不是在您的凭据下或在您的登录会话中运行,则打开具有完全访问权限的进程可能是一项高特权操作 - 您需要遵循 MSDN 中的以下文档:
请记住,即使您拥有权限,在大多数情况下该权限也不会启用 - 必须在尝试使用该权限的代码中专门启用它。
Opening a process with full access rights can be a highly privileged operation if it's not a process running under you credentials or in your logon session - you'll need to follow this bit of documentation from MSDN:
Remember that even if you have a privilege, in most cases the privilege is not enabled - it has to be specifically enabled in the code that's attempting to use the privilege.
可能导致此问题的另一件事对于 Vista 来说是新的:
Another thing that might be causing this is new to Vista:
是哪一个流程呢? 在另一个用户会话中打开服务或进程可能会返回拒绝访问 (5)。 另一个会话中的进程将打开以供读取,但您无法对其进行调试。 这就是 Windbg 具有非侵入式连接的原因之一。 它可以跨用户会话工作。 你实际上并没有在调试。 它挂起所有线程并正在读取内存。
Which process is it? Opening a service or a process in another user session is likely to return Access Denied (5). A process in another session will open for read but you wouldn't be able to debug it. It's one reason why Windbg has the non-intrusive attach. It works across user sessions. You're not actually debugging. It suspends all the threads and is reading the memory.