Skip to content

Commit

Permalink
fix #1662: QueryFullProcessImageNameW may fail with error code = 0 (W…
Browse files Browse the repository at this point in the history
…in API bug?)
  • Loading branch information
giampaolo committed Jan 14, 2020
1 parent bc0168a commit efaa9e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ XXXX-XX-XX
- 1656_: [Windows] Process.memory_full_info() raises AccessDenied even for the
current user and os.getpid().
- 1660_: [Windows] Process.open_files() complete rewrite + check of errors.
- 1662_: [Windows] process exe() may raise WinError 0.

5.6.7
=====
Expand Down
6 changes: 5 additions & 1 deletion psutil/_psutil_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,11 @@ psutil_proc_exe(PyObject *self, PyObject *args) {

memset(exe, 0, MAX_PATH);
if (QueryFullProcessImageNameW(hProcess, 0, exe, &size) == 0) {
PyErr_SetFromOSErrnoWithSyscall("QueryFullProcessImageNameW");
// https://github.com/giampaolo/psutil/issues/1662
if (GetLastError() == 0)
AccessDenied("QueryFullProcessImageNameW (forced EPERM)");
else
PyErr_SetFromOSErrnoWithSyscall("QueryFullProcessImageNameW");
CloseHandle(hProcess);
return NULL;
}
Expand Down

0 comments on commit efaa9e0

Please sign in to comment.