Improve icon cache cleanup
@@ -3009,29 +3009,32 @@ VOID PhpImageListItemDeleteProcedure(
_In_ ULONG Flags
)
{
- PPH_IMAGELIST_ITEM entry = (PPH_IMAGELIST_ITEM)Object;
- ULONG LargeIconIndex = entry->LargeIconIndex;
- ULONG SmallIconIndex = entry->SmallIconIndex;
- PPH_PROCESS_ITEM* processes;
- ULONG numberOfProcesses;
+ PPH_IMAGELIST_ITEM item = (PPH_IMAGELIST_ITEM)Object;
+ ULONG LargeIconIndex = item->LargeIconIndex;
+ ULONG SmallIconIndex = item->SmallIconIndex;
+ PPH_HASH_ENTRY entry;
+ PPH_PROCESS_ITEM processItem;
- PhEnumProcessItems(&processes, &numberOfProcesses);
+ PhAcquireQueuedLockShared(&PhProcessHashSetLock);
- for (ULONG i = 0; i < numberOfProcesses; i++)
+ for (ULONG i = 0; i < PH_HASH_SET_SIZE(PhProcessHashSet); i++)
+ {
+ for (entry = PhProcessHashSet[i]; entry; entry = entry->Next)
{
- PPH_PROCESS_ITEM process = processes[i];
+ processItem = CONTAINING_RECORD(entry, PH_PROCESS_ITEM, HashEntry);
if (
- process->LargeIconIndex > LargeIconIndex &&
- process->SmallIconIndex > SmallIconIndex
+ processItem->LargeIconIndex > LargeIconIndex &&
+ processItem->SmallIconIndex > SmallIconIndex
)
{
- process->LargeIconIndex -= 1;
- process->SmallIconIndex -= 1;
+ processItem->LargeIconIndex -= 1;
+ processItem->SmallIconIndex -= 1;
+ }
}
}
- PhFree(processes);
+ PhReleaseQueuedLockShared(&PhProcessHashSetLock);
ImageList_Remove(PhProcessLargeImageList, LargeIconIndex);
ImageList_Remove(PhProcessSmallImageList, SmallIconIndex);
