Closed MarkRx closed 2 years ago
It seems surprising since this behaviour is tested in this test: https://github.com/GuillaumeGomez/sysinfo/blob/master/src/system.rs#L24-L40
In some cases, windows needs a small delay to be able to get a process information. Can you try with adding a small delay maybe (even though, since you need to enter the PID by hand, I expect there is a "human" delay already) please?
I ran it in the debugger and it seems to be because OpenProcess used by refresh_process(pid) is returning NULL when in a non-elevated shell due to a swallowed Access Denied error. Curiously the NtQureySystemInformation call used by refresh_processes doesn't seem to have the same access restrictions. Hence the inconsistent behavior between the two functions.
Oddly enough refresh_process works inconsistently in the situation where the process is launched before the rust process starts. Here is what I found:
Perhaps the code needs to revert to using PROCESS_QUERY_LIMITED_INFORMATION here in the case that PROCESS_QUERY_INFORMATION fails due to an access restriction?
In case the first call returns NULL
, we can always get the handle with PROCESS_QUERY_LIMITED_INFORMATION
as you suggested. I think all functions are checked so it would be just changing that. Want to send a PR?
The System.refresh_process(pid) function does not load a newly launched process in Windows. According to the documentation it should be added to the list of in-memory process information if it hasn't been added yet.
Steps to reproduce
Code
Expected Result
The System.refresh_process(pid) call loads information about an individual process.
Actual Results
The System.refresh_process(pid) call fails.