1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-24 12:40:52 +03:00

monitor: Comment about 'as this User' not actually being true

Both the current `develop` code and this PR's new code share this behaviour.
What the code does is look for windows/processes *in the current Windows
session*, no matter if they're owned by the session user or not.

Neither version will find a process, that would match, if it's running in
another session, i.e. you'd need to switch to it via the windows Login screen.
This commit is contained in:
Athanasius 2023-01-13 11:07:15 +00:00
parent 4f017a77e8
commit 95b52bff01
No known key found for this signature in database
GPG Key ID: 772697E181BB2767

View File

@ -2035,7 +2035,15 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below
# <https://mhammond.github.io/pywin32/win32api__OpenProcess_meth.html>
# The first arg can't simply be `0`, and `win32con.PROCESS_TERMINATE` works
handle = win32api.OpenProcess(win32con.PROCESS_TERMINATE, False, process_id)
if handle: # If OpenProcess succeeds then the app is already running as this user
if handle:
# If OpenProcess succeeds then the app is already running in this User session
# That *specifically* means "either this exact user, in this session, or another user via
# `runas`, but in this session", i.e. visible in the windows UI.
# If the process is running *in another session*, such that it's not actually visible right
# now, then this code will not find it.
#
# Checking if the process User matches that of the current session is trickier.
# There's a method using `wmi`, but it's **VERY SLOW**, so not appropriate here.
hwnds.append(hwnd)
return True