Fix imagelist crash #1726

This commit is contained in:
dmex
2023-05-23 22:10:55 +10:00
parent 34e626125b
commit 642c3e11cf
3 changed files with 28 additions and 26 deletions
+2 -1
View File
@@ -479,7 +479,8 @@ PHAPPAPI
VOID
NTAPI
PhProcessImageListInitialization(
_In_ HWND hwnd
_In_ HWND WindowHandle,
_In_ LONG WindowDpi
);
PHAPPAPI
+2 -5
View File
@@ -280,11 +280,6 @@ LRESULT CALLBACK PhMwpWndProc(
{
switch (uMsg)
{
case WM_CREATE:
{
PhProcessImageListInitialization(hWnd);
}
break;
case WM_DESTROY:
{
PhMwpOnDestroy(hWnd);
@@ -478,6 +473,8 @@ VOID PhMwpInitializeMetrics(
{
LayoutWindowDpi = PhGetWindowDpi(WindowHandle);
LayoutBorderSize = PhGetSystemMetrics(SM_CXBORDER, LayoutWindowDpi);
PhProcessImageListInitialization(WindowHandle, LayoutWindowDpi);
}
VOID PhMwpInitializeControls(
+24 -20
View File
@@ -3423,39 +3423,41 @@ VOID PhpImageListItemDeleteProcedure(
}
VOID PhProcessImageListInitialization(
_In_ HWND hwnd
_In_ HWND WindowHandle,
_In_ LONG WindowDpi
)
{
HICON iconSmall;
HICON iconLarge;
PPH_LIST fileNames = NULL;
PhAcquireQueuedLockExclusive(&PhImageListCacheHashtableLock);
if (!PhImageListItemType)
PhImageListItemType = PhCreateObjectType(L"ImageListItem", 0, PhpImageListItemDeleteProcedure);
PhProcessImageListWindowDpi = PhGetWindowDpi(hwnd);
PhProcessImageListWindowDpi = WindowDpi;
PH_HASHTABLE_ENUM_CONTEXT enumContext;
PPH_IMAGELIST_ITEM* entry;
PPH_LIST fileNames = NULL;
if (PhImageListCacheHashtable)
{
fileNames = PhCreateList(PhImageListCacheHashtable->Count);
PH_HASHTABLE_ENUM_CONTEXT enumContext;
PPH_IMAGELIST_ITEM* entry;
PhAcquireQueuedLockExclusive(&PhImageListCacheHashtableLock);
PhBeginEnumHashtable(PhImageListCacheHashtable, &enumContext);
while (entry = PhNextEnumHashtable(&enumContext))
if (PhImageListCacheHashtable)
{
PPH_IMAGELIST_ITEM item = *entry;
PhAddItemList(fileNames, PhReferenceObject(item->FileName));
PhDereferenceObject(item);
fileNames = PhCreateList(PhImageListCacheHashtable->Count);
PhBeginEnumHashtable(PhImageListCacheHashtable, &enumContext);
while (entry = PhNextEnumHashtable(&enumContext))
{
PPH_IMAGELIST_ITEM item = *entry;
PhAddItemList(fileNames, PhReferenceObject(item->FileName));
PhDereferenceObject(item);
}
PhDereferenceObject(PhImageListCacheHashtable);
PhImageListCacheHashtable = NULL;
}
PhDereferenceObject(PhImageListCacheHashtable);
PhImageListCacheHashtable = NULL;
PhReleaseQueuedLockExclusive(&PhImageListCacheHashtableLock);
}
if (PhProcessLargeImageList) PhImageListDestroy(PhProcessLargeImageList);
@@ -3525,6 +3527,8 @@ VOID PhProcessImageListInitialization(
PhDereferenceObjects(fileNames->Items, fileNames->Count);
PhDereferenceObject(fileNames);
}
PhReleaseQueuedLockExclusive(&PhImageListCacheHashtableLock);
}
BOOLEAN PhImageListCacheHashtableEqualFunction(