Do not throw exception if ProcessIdToSessionId() is failed.

Many security solutions forbid other program from accessing their own process. So if ProcessIdToSessionId() is failed, simply ignore it.

Signed-off-by: SeokYeon Hwang <caramis@gmail.com>
This commit is contained in:
SeokYeon Hwang 2014-10-21 19:29:15 +09:00
parent 8b4a3a8b92
commit 3a663092cf
1 changed files with 11 additions and 8 deletions

View File

@ -69,10 +69,11 @@ CMSWindowsSession::isProcessInSession(const char* name, PHANDLE process = NULL)
entry.th32ProcessID, &processSessionId); entry.th32ProcessID, &processSessionId);
if (!pidToSidRet) { if (!pidToSidRet) {
// if we can not acquire session associated with a specified process,
// simply ignore it
LOG((CLOG_ERR "could not get session id for process id %i", entry.th32ProcessID)); LOG((CLOG_ERR "could not get session id for process id %i", entry.th32ProcessID));
throw XArch(new XArchEvalWindows());
} }
else {
// only pay attention to processes in the active session // only pay attention to processes in the active session
if (processSessionId == m_activeSessionId) { if (processSessionId == m_activeSessionId) {
@ -85,6 +86,8 @@ CMSWindowsSession::isProcessInSession(const char* name, PHANDLE process = NULL)
} }
} }
}
// now move on to the next entry (if we're not at the end) // now move on to the next entry (if we're not at the end)
gotEntry = Process32Next(snapshot, &entry); gotEntry = Process32Next(snapshot, &entry);
if (!gotEntry) { if (!gotEntry) {