Question
I am monitoring a directory using ReadDirectoryChangesExW. I have this code working fine and was wondering if anyone knows of a method to determine what user on windows could be associated with a given file system change (in the form of FILE_NOTIFY_EXTENDED_INFORMATION).
Approaches
My initial research has been based on querying a fileid to determine the last user who touched the file--but I could not find much on MSDN. Admittedly I could just be failing to find the relevant info I need in the sea of information that is MSDN.
I have also researched iterating sessions and determining an active session. My problem is what about the possibility of multiple sessions being open? I feel like assuming only one active session would be a bad assumption, but maybe it holds even with RDP?
The other issue I have is Disconnected Sessions having no real information associated with them. I have two sessions on my dev machine, my user account (sessions id 1) which I expect and a session ID 0 which has no userName associated with it and shows up WTS_STATE::Disconnected
I found another question where someone had similar output with their session 0:
session=0, stationName = Services
WTSQuerySessionInformationW - session 0 - WTSInitialProgram failed - error=87 - The parameter is incorrect.
WTSQuerySessionInformationW - session 0 - WTSApplicationName failed - error=87 - The parameter is incorrect.
WTSQuerySessionInformationW - session 0 - WTSWorkingDirectory returned ""
WTSQuerySessionInformationW - session 0 - WTSOEMId returned ""
WTSQuerySessionInformationW - session 0 - WTSSessionId returned ""
WTSQuerySessionInformationW - session 0 - WTSUserName returned ""
WTSQuerySessionInformationW - session 0 - WTSWinStationName returned "Services"
WTSQuerySessionInformationW - session 0 - WTSDomainName returned ""
WTSQuerySessionInformationW - session 0 - WTSConnectState returned "♦"
WTSQuerySessionInformationW - session 0 - WTSClientBuildNumber returned ""
WTSQuerySessionInformationW - session 0 - WTSClientName returned ""
WTSQuerySessionInformationW - session 0 - WTSClientDirectory returned ""
WTSQuerySessionInformationW - session 0 - WTSClientProductId returned ""
WTSQuerySessionInformationW - session 0 - WTSClientHardwareId returned ""
WTSQuerySessionInformationW - session 0 - WTSClientAddress returned ""
WTSQuerySessionInformationW - session 0 - WTSClientDisplay returned ""
WTSQuerySessionInformationW - session 0 - WTSClientProtocolType returned ""
GetShellProcessNameFromUserPolicy - Error: Unable to open policy key - returned [2]
GetShellProcessName succeseded - explorer.exe
Is there any reason why I would be getting this sort of output for session 0?