mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
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:
@@ -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
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user