diff options
author | EccoTheFlintstone <32797240+EccoTheFlintstone@users.noreply.github.com> | 2018-12-03 07:51:01 -0500 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2018-12-03 13:51:01 +0100 |
commit | b2dbcbc407920a39a0e0087ef3f507e6dab747cb (patch) | |
tree | 4da8015384e88e657840440d41c30ea525559d92 | |
parent | 3ea94c1b8589891a8d1a5781f0445cb5080b7c3e (diff) | |
download | psutil-b2dbcbc407920a39a0e0087ef3f507e6dab747cb.tar.gz |
fix ionice set not working on windows x64 due to LENGTH_MISMATCH (#1368)
Fix Process().ionice(0/1/2) length mismatch on Windows
-rw-r--r-- | psutil/_psutil_windows.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c index edb5996c..29311992 100644 --- a/psutil/_psutil_windows.c +++ b/psutil/_psutil_windows.c @@ -2098,7 +2098,7 @@ static PyObject * psutil_proc_io_priority_get(PyObject *self, PyObject *args) { long pid; HANDLE hProcess; - PULONG IoPriority; + DWORD IoPriority; _NtQueryInformationProcess NtQueryInformationProcess = (_NtQueryInformationProcess)GetProcAddress( @@ -2114,7 +2114,7 @@ psutil_proc_io_priority_get(PyObject *self, PyObject *args) { hProcess, ProcessIoPriority, &IoPriority, - sizeof(ULONG), + sizeof(DWORD), NULL ); CloseHandle(hProcess); @@ -2128,8 +2128,9 @@ psutil_proc_io_priority_get(PyObject *self, PyObject *args) { static PyObject * psutil_proc_io_priority_set(PyObject *self, PyObject *args) { long pid; - int prio; + DWORD prio; HANDLE hProcess; + DWORD dwDesiredAccess = PROCESS_QUERY_INFORMATION | PROCESS_SET_INFORMATION; _NtSetInformationProcess NtSetInformationProcess = (_NtSetInformationProcess)GetProcAddress( @@ -2143,7 +2144,7 @@ psutil_proc_io_priority_set(PyObject *self, PyObject *args) { if (! PyArg_ParseTuple(args, "li", &pid, &prio)) return NULL; - hProcess = psutil_handle_from_pid_waccess(pid, PROCESS_ALL_ACCESS); + hProcess = psutil_handle_from_pid_waccess(pid, dwDesiredAccess); if (hProcess == NULL) return NULL; @@ -2151,7 +2152,7 @@ psutil_proc_io_priority_set(PyObject *self, PyObject *args) { hProcess, ProcessIoPriority, (PVOID)&prio, - sizeof((PVOID)prio) + sizeof(DWORD) ); CloseHandle(hProcess); |