-
-
Notifications
You must be signed in to change notification settings - Fork 305
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
Process data inconsistency between refresh_processes_specifics
and refresh_process_specifics
#881
Comments
First, thanks for the issue and the very complete explanations. Both |
OK, I'll try to have a look at it. Which path do you think would make most sense?
I haven't read at Microsoft's documentation yet, maybe the second solution is not possible at all. |
I'd favour the solution which is the less CPU intensive as it is already quite big (a lot more than I'd liked it to be). |
Hm, it turns out the OpenProcess/NtQueryInformationProcess/EnumProcessModulesEx/GetModuleBaseNameW way is not as reliable, as it sometimes even fails at retrieving a process name. Here is the list of all the processes currently running on my machine where both process names mismatch:
So, I'll probably use NT APIs as much as I can (well, in case I can find a suitable one that gives information for a single process) |
Something important to be noted: windows files are case insensitive. So it should be the same whether or not you have capital letters in it. At this point it's just display. |
That's right (that's one of the notes I wrote in my initial post as well). However, having variable process names could cause trouble when trying to match names (that is how I discovered this bug). I am now working around by comparing case-insentively, but having a consistent output from sysinfo would be better anyway. |
Absolutely! It's a shame that windows API provide non-coherent names... |
Summary of what we currently have
So, we're using inconsistent APIs. What other APIs are there?I looked up at possible Microsoft APIs to list and get infos about processes For single process retrieval:
There are other options for batch retrieval, but the current
What are possible solutions?Since we cannot improve data obtained for a single process, we'll have to do it the other way round (list all processes and filter out the only one that interests us).
Advantages:
Disadvantages: we ask Windows to collect data for all processes and only keep one :-/
With all this said (sorry for this long message, I wrote it as I researched, but now you have all the info): how much are you willing to trade performance for correctness? |
I think performance impact is too important to make this solution viable unfortunately. What I suggest is to simply mention that the process name comparison on windows should be done case insensitively. |
That could be an easy addition. The issue is not limited to case unfortunately, as I wrote there is also the "missing data" problem (missing names on some processes, missing memory/virtual_memory on every process). |
There is also an issue of right access. Some system calls require more so I didn't use them. But if you can find a way to get the same information without having a huge performance regression or needing more rights, then I'm all for it. |
NtQuerySystemInformation can be used to retrieve a process name by PID with class SystemProcessIdInformation which is described here https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/query.htm |
Thanks for the information! Of course if you're interested into adding it... ;) |
Thanks for all your work on sysinfo!
I have found a way to get inconsistent data (or at least inconsistent process names) regarding a given process:
system.refresh_processes_specifics()
(without any PID given) usesNtQuerySystemInformation
and usesSYSTEM_PROCESS_INFORMATION.ImageName
as their process namessystem.refresh_process_specifics(pid)
usesOpenProcess
/NtQueryInformationProcess
/EnumProcessModulesEx
/GetModuleBaseNameW
These two code paths may end up getting different results.
See this minimal reproducer:
This can display
Mind the lower/uppercase inconsistency for process 4576 (which may be due to the erroneous command-line for a file that is actually named a lowercase
C:\\Windows\\syswow64\\msiexec.exe
)This is not a critical issue, because:
System
instances. Re-using the same instance would probably detect it knows this PID already and avoid the wholeOpenProcess
/NtQueryInformationProcess
/EnumProcessModulesEx
/GetModuleBaseNameW
But still, having two different code paths to get the same data may look like something to avoid (if ever that would be possible).
What's your opinion on this?
I may try to fix it myself in case you'd like me to (although I'm not familiar (yet?) with sysinfo).
The text was updated successfully, but these errors were encountered: