implement cache for session ID checking in HandleFilter.cs

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@446 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2008-12-28 07:07:32 +00:00
parent c5cfc47d69
commit 4a2fa1dfb2
2 changed files with 16 additions and 3 deletions
+15 -2
View File
@@ -36,6 +36,7 @@ namespace ProcessHacker.FormHelper
public event MatchProgressEvent MatchProgress;
private string strFilter;
private List<ListViewItem> listViewItemContainer = new List<ListViewItem>(100);
private Dictionary<int, bool> isCurrentSessionIdCache = new Dictionary<int, bool>();
public HandleFilter(ISynchronizeInvoke isi, string strFilter)
: base(isi)
@@ -88,8 +89,20 @@ namespace ProcessHacker.FormHelper
{
try
{
if (Win32.GetProcessSessionId(currhandle.ProcessId) != Program.CurrentSessionId)
return;
if (isCurrentSessionIdCache.ContainsKey(currhandle.ProcessId))
{
if (!isCurrentSessionIdCache[currhandle.ProcessId])
return;
}
else
{
bool isCurrentSessionId = Win32.GetProcessSessionId(currhandle.ProcessId) == Program.CurrentSessionId;
isCurrentSessionIdCache.Add(currhandle.ProcessId, isCurrentSessionId);
if (!isCurrentSessionId)
return;
}
}
catch
{
+1 -1
View File
@@ -567,7 +567,7 @@ namespace ProcessHacker
}
catch
{
using (ProcessHandle phandle = new ProcessHandle(ProcessId, PROCESS_RIGHTS.PROCESS_QUERY_INFORMATION))
using (ProcessHandle phandle = new ProcessHandle(ProcessId, Program.MinProcessQueryRights))
{
return phandle.GetToken(TOKEN_RIGHTS.TOKEN_QUERY).GetSessionId();
}