-
-
Notifications
You must be signed in to change notification settings - Fork 99
fix: undetected games when ran with administrator #109
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
base: main
Are you sure you want to change the base?
Conversation
wahfl2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, I know I'm new here but I saw some potential improvements, and I would really like to see this merged, since the current WMIC solution can cause quite a bit of CPU usage.
| if (NT_SUCCESS(result)) { | ||
| return buffer.subarray(0, buffer.length).toString('utf16le'); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (bufferSize >= 0xffff) { | |
| console.error(`NtQuerySystemInformation() failed with pid = ${pid}, result could not fit in buffer of size 0xffff`) | |
| return null; | |
| } | |
Just to prevent infinite loops
| MaximumLength: 'uint16', | ||
| Buffer: HANDLE | ||
| }); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // https://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/process_id.htm |
It's officially undocumented but you could put this here, it has some good information
|
Likely fixes #142 |
|
Evaluating this change on the basis of performance, I observed a big reduction in latency. Enabling the logging in Running clinic.js BeforeAfter(109+123)But, if you combine this work with the change done to scanning in #123, a lot of those charts become much less concerning. And the combined finished time of "got processed" and "scan", goes from a before of Great work on this change. |



Root Cause
Windows built-in tools such as wmic or gcim or gwmi doesn't have enough privilege even if those tools were running with administrator. Consequently, the game isn't detected due to the empty result when querying executable path.
Solution
This fix uses windows undocumented api calls
NtQuerySystemInformation()to get the ImageFileName of a process by supplying pid into the api. It useskoffipackage to load those windows libraries.Result
As a result, it can detect games that ran with administrator without the need to run arrpc with administrator.
This might also fix #33
Remark
The usage of NtQuerySystemInformation() may be altered or unavailable in future versions of Windows