VC++ 2008, OpenProcess always returning error 5 (Access Denied)

前端 未结 3 2036
遥遥无期
遥遥无期 2021-01-14 07:50

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

3条回答
  •  感动是毒
    2021-01-14 08:18

    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:

    To open a handle to another process and obtain full access rights, you must enable the SeDebugPrivilege privilege. For more information, see Changing Privileges in a Token.

    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.

提交回复
热议问题