eeeb419645
Adds drag-and-drop reordering support to toolbar/status-bar customization dialogs, including drag images, insertion markers, and shared drag callbacks for add/remove/move actions. Refactors ToolStatus command bar rendering and menu bar behavior: introduces shared toolbar/menu drawing helpers, better accelerator visibility handling, improved keyboard/menu tracking, and consistent themed/light rendering. Also fixes DPI/layout behavior by centralizing command-bar height calculations and updating rebar/graph/search band sizing so rows resize correctly across DPI/font changes. Includes related robustness fixes such as linking gdiplus, correcting tab-info hashtable storage to use stable pointers, and updating signatures/prototypes for const-correctness and shared exports.
177 lines
3.9 KiB
C
177 lines
3.9 KiB
C
/*
|
|
* Copyright (c) 2022 Winsider Seminars & Solutions, Inc. All rights reserved.
|
|
*
|
|
* This file is part of System Informer.
|
|
*
|
|
* Authors:
|
|
*
|
|
* wj32 2010-2016
|
|
* dmex 2011-2023
|
|
*
|
|
*/
|
|
|
|
#include "toolstatus.h"
|
|
#include <toolstatusintf.h>
|
|
|
|
_Function_class_(PH_HASHTABLE_EQUAL_FUNCTION)
|
|
BOOLEAN PluginInterfaceTabInfoHashtableEqualFunction(
|
|
_In_ PVOID Entry1,
|
|
_In_ PVOID Entry2
|
|
);
|
|
|
|
_Function_class_(PH_HASHTABLE_HASH_FUNCTION)
|
|
ULONG PluginInterfaceTabInfoHashtableHashFunction(
|
|
_In_ PVOID Entry
|
|
);
|
|
|
|
ULONG_PTR PluginInterfaceGetSearchMatchHandle(
|
|
VOID
|
|
);
|
|
|
|
VOID PluginInterfaceRegisterTabSearch(
|
|
_In_ LONG TabIndex,
|
|
_In_ PCPH_STRINGREF BannerText
|
|
);
|
|
|
|
PTOOLSTATUS_TAB_INFO PluginInterfaceRegisterTabInfo(
|
|
_In_ LONG TabIndex,
|
|
_In_opt_ PCPH_STRINGREF BannerText
|
|
);
|
|
|
|
static PPH_HASHTABLE TabInfoHashtable = NULL;
|
|
static PH_CALLBACK_DECLARE(PluginInterfaceSearchChangedEvent);
|
|
|
|
CONST TOOLSTATUS_INTERFACE PluginInterface =
|
|
{
|
|
TOOLSTATUS_INTERFACE_VERSION,
|
|
PluginInterfaceGetSearchMatchHandle,
|
|
SearchWordMatchStringRefCallback,
|
|
PluginInterfaceRegisterTabSearch,
|
|
&PluginInterfaceSearchChangedEvent,
|
|
PluginInterfaceRegisterTabInfo,
|
|
ToolbarRegisterGraph
|
|
};
|
|
|
|
VOID PluginInterfaceInitialize(
|
|
VOID
|
|
)
|
|
{
|
|
TabInfoHashtable = PhCreateHashtable(
|
|
sizeof(PTOOLSTATUS_TAB_INFO),
|
|
PluginInterfaceTabInfoHashtableEqualFunction,
|
|
PluginInterfaceTabInfoHashtableHashFunction,
|
|
3
|
|
);
|
|
}
|
|
|
|
_Function_class_(PH_HASHTABLE_EQUAL_FUNCTION)
|
|
BOOLEAN PluginInterfaceTabInfoHashtableEqualFunction(
|
|
_In_ PVOID Entry1,
|
|
_In_ PVOID Entry2
|
|
)
|
|
{
|
|
PTOOLSTATUS_TAB_INFO entry1 = *(PTOOLSTATUS_TAB_INFO *)Entry1;
|
|
PTOOLSTATUS_TAB_INFO entry2 = *(PTOOLSTATUS_TAB_INFO *)Entry2;
|
|
|
|
return entry1->Index == entry2->Index;
|
|
}
|
|
|
|
_Function_class_(PH_HASHTABLE_HASH_FUNCTION)
|
|
ULONG PluginInterfaceTabInfoHashtableHashFunction(
|
|
_In_ PVOID Entry
|
|
)
|
|
{
|
|
PTOOLSTATUS_TAB_INFO entry = *(PTOOLSTATUS_TAB_INFO *)Entry;
|
|
|
|
return PhHashInt32(entry->Index);
|
|
}
|
|
|
|
ULONG_PTR PluginInterfaceGetSearchMatchHandle(
|
|
VOID
|
|
)
|
|
{
|
|
return SearchMatchHandle;
|
|
}
|
|
|
|
VOID PluginInterfaceInvokeSearchChangedEvent(
|
|
_In_ ULONG_PTR Context
|
|
)
|
|
{
|
|
PhInvokeCallback(&PluginInterfaceSearchChangedEvent, (PVOID)Context);
|
|
}
|
|
|
|
VOID PluginInterfaceRegisterTabSearch(
|
|
_In_ LONG TabIndex,
|
|
_In_ PCPH_STRINGREF BannerText
|
|
)
|
|
{
|
|
PluginInterfaceRegisterTabInfo(TabIndex, BannerText);
|
|
}
|
|
|
|
PTOOLSTATUS_TAB_INFO PluginInterfaceRegisterTabInfo(
|
|
_In_ LONG TabIndex,
|
|
_In_opt_ PCPH_STRINGREF BannerText
|
|
)
|
|
{
|
|
PTOOLSTATUS_TAB_INFO entry;
|
|
|
|
// Keep published tab information at a stable address for the process lifetime. (dmex)
|
|
entry = PhAllocateZero(sizeof(TOOLSTATUS_TAB_INFO));
|
|
entry->Index = TabIndex;
|
|
entry->BannerText = BannerText;
|
|
|
|
if (PhAddEntryHashtable(TabInfoHashtable, &entry))
|
|
return entry;
|
|
|
|
PhFree(entry);
|
|
return NULL;
|
|
}
|
|
|
|
PTOOLSTATUS_TAB_INFO FindTabInfo(
|
|
_In_ LONG TabIndex
|
|
)
|
|
{
|
|
TOOLSTATUS_TAB_INFO lookupEntry;
|
|
PTOOLSTATUS_TAB_INFO lookupEntryPtr = &lookupEntry;
|
|
PTOOLSTATUS_TAB_INFO *entry;
|
|
|
|
lookupEntry.Index = TabIndex;
|
|
|
|
if (entry = PhFindEntryHashtable(TabInfoHashtable, &lookupEntryPtr))
|
|
return *entry;
|
|
|
|
return NULL;
|
|
}
|
|
|
|
HWND GetTabIndexTreeNewHandle(
|
|
_In_ LONG TabIndex
|
|
)
|
|
{
|
|
PTOOLSTATUS_TAB_INFO tabInfo;
|
|
|
|
if (tabInfo = FindTabInfo(TabIndex))
|
|
{
|
|
return tabInfo->GetTreeNewHandle();
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
PPH_STRING GetTabIndexBannerText(
|
|
_In_ LONG TabIndex,
|
|
_In_opt_ PCPH_STRINGREF AppendString
|
|
)
|
|
{
|
|
PTOOLSTATUS_TAB_INFO tabInfo;
|
|
|
|
if ((tabInfo = FindTabInfo(TabIndex)) && tabInfo->BannerText)
|
|
{
|
|
if (AppendString)
|
|
return PhConcatStringRef2(tabInfo->BannerText, AppendString);
|
|
else
|
|
return PhCreateString2(tabInfo->BannerText);
|
|
}
|
|
|
|
return NULL;
|
|
}
|