From 3a663092cfacd3da93ace684f792885710f98a12 Mon Sep 17 00:00:00 2001 From: SeokYeon Hwang Date: Tue, 21 Oct 2014 19:29:15 +0900 Subject: [PATCH] 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 --- src/lib/platform/MSWindowsSession.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lib/platform/MSWindowsSession.cpp b/src/lib/platform/MSWindowsSession.cpp index 0a7e63ac..0e453092 100644 --- a/src/lib/platform/MSWindowsSession.cpp +++ b/src/lib/platform/MSWindowsSession.cpp @@ -69,20 +69,23 @@ CMSWindowsSession::isProcessInSession(const char* name, PHANDLE process = NULL) entry.th32ProcessID, &processSessionId); 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)); - throw XArch(new XArchEvalWindows()); } + else { + // only pay attention to processes in the active session + if (processSessionId == m_activeSessionId) { - // only pay attention to processes in the active session - if (processSessionId == m_activeSessionId) { + // store the names so we can record them for debug + nameList.push_back(entry.szExeFile); - // store the names so we can record them for debug - nameList.push_back(entry.szExeFile); - - if (_stricmp(entry.szExeFile, name) == 0) { - pid = entry.th32ProcessID; + if (_stricmp(entry.szExeFile, name) == 0) { + pid = entry.th32ProcessID; + } } } + } // now move on to the next entry (if we're not at the end)