Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows / speeup: load libraries only on startup only #1418

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
port process_info.c
  • Loading branch information
giampaolo committed Feb 20, 2019
commit 613466d3c8ac831db70493b63be89a6b6fdfa6c8
17 changes: 7 additions & 10 deletions psutil/arch/windows/process_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,12 +1013,6 @@ psutil_get_proc_info(DWORD pid, PSYSTEM_PROCESS_INFORMATION *retProcess,
ULONG bufferSize;
PSYSTEM_PROCESS_INFORMATION process;
typedef DWORD (_stdcall * NTQSI_PROC) (int, PVOID, ULONG, PULONG);
NTQSI_PROC NtQuerySystemInformation;

NtQuerySystemInformation = \
psutil_GetProcAddressFromLib("ntdll.dll", "NtQuerySystemInformation");
if (NtQuerySystemInformation == NULL)
goto error;

bufferSize = initialBufferSize;
buffer = malloc(bufferSize);
Expand All @@ -1028,8 +1022,11 @@ psutil_get_proc_info(DWORD pid, PSYSTEM_PROCESS_INFORMATION *retProcess,
}

while (TRUE) {
status = NtQuerySystemInformation(SystemProcessInformation, buffer,
bufferSize, &bufferSize);
status = psutil_NtQuerySystemInformation(
SystemProcessInformation,
buffer,
bufferSize,
&bufferSize);
if (status == STATUS_BUFFER_TOO_SMALL ||
status == STATUS_INFO_LENGTH_MISMATCH)
{
Expand All @@ -1046,8 +1043,8 @@ psutil_get_proc_info(DWORD pid, PSYSTEM_PROCESS_INFORMATION *retProcess,
}

if (status != 0) {
PyErr_Format(
PyExc_RuntimeError, "NtQuerySystemInformation() syscall failed");
PyErr_Format(PyExc_RuntimeError,
"NtQuerySystemInformation() syscall failed");
goto error;
}

Expand Down