add plugins-extra
This commit is contained in:
122
plugins-extra/AtomTablePlugin/AtomTablePlugin.rc
Normal file
122
plugins-extra/AtomTablePlugin/AtomTablePlugin.rc
Normal file
@@ -0,0 +1,122 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winres.h"
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (Australia) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENA)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
|
||||
#pragma code_page(1252)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "0c0904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "dmex"
|
||||
VALUE "FileDescription", "Atom Table Plugin for Process Hacker"
|
||||
VALUE "FileVersion", "1.0"
|
||||
VALUE "InternalName", "dmex.AtomTablePlugin"
|
||||
VALUE "LegalCopyright", "Licensed under the GNU GPL, v3."
|
||||
VALUE "OriginalFilename", "AtomTablePlugin.dll"
|
||||
VALUE "ProductName", "Atom Table plugin for Process Hacker"
|
||||
VALUE "ProductVersion", "1.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0xc09, 1200
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ATOMDIALOG DIALOGEX 0, 0, 325, 180
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
EXSTYLE WS_EX_APPWINDOW
|
||||
CAPTION "Global Atom Table"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Close",IDOK,269,160,50,14
|
||||
CONTROL "",IDC_ATOMLIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,5,312,152
|
||||
PUSHBUTTON "Refresh",IDRETRY,7,160,50,14
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_ATOMDIALOG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 318
|
||||
TOPMARGIN, 5
|
||||
BOTTOMMARGIN, 174
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""winres.h""\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (Australia) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
108
plugins-extra/AtomTablePlugin/AtomTablePlugin.vcxproj
Normal file
108
plugins-extra/AtomTablePlugin/AtomTablePlugin.vcxproj
Normal file
@@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{12390643-F40D-411F-A2E8-BF85F90223DF}</ProjectGuid>
|
||||
<RootNamespace>AtomTablePlugin</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectName>AtomTablePlugin</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\ExtraPlugins.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\ExtraPlugins.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\ExtraPlugins.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\ExtraPlugins.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;C:\Users\AirDog46\Downloads\processhacker-2.39-src\bin\Debug32</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\Users\AirDog46\Downloads\processhacker-2.39-src\bin\Release64</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LibraryPath>$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;$(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;C:\Users\AirDog46\Downloads\processhacker-2.39-src\bin\Release32</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="AtomTablePlugin.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CHANGELOG.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClInclude Include="resource.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CHANGELOG.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{802108be-ae96-47c3-8d93-884ed6dd096a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{3e65ffb8-3f3e-40d7-b3ca-d55cae8edb16}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{b98dd849-bbfe-4b41-8c48-f65680da5c00}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="AtomTablePlugin.rc">
|
||||
<Filter>Resource Files</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
2
plugins-extra/AtomTablePlugin/CHANGELOG.txt
Normal file
2
plugins-extra/AtomTablePlugin/CHANGELOG.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
1.0
|
||||
* Initial release
|
||||
455
plugins-extra/AtomTablePlugin/main.c
Normal file
455
plugins-extra/AtomTablePlugin/main.c
Normal file
@@ -0,0 +1,455 @@
|
||||
/*
|
||||
* Process Hacker Extra Plugins -
|
||||
* NT Atom Table Plugin
|
||||
*
|
||||
* Copyright (C) 2015 dmex
|
||||
*
|
||||
* This file is part of Process Hacker.
|
||||
*
|
||||
* Process Hacker is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Process Hacker is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Process Hacker. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define CINTERFACE
|
||||
#define COBJMACROS
|
||||
#include <phdk.h>
|
||||
#include <phappresource.h>
|
||||
#include "resource.h"
|
||||
|
||||
#define ATOM_TABLE_MENUITEM 1000
|
||||
#define PLUGIN_NAME L"dmex.AtomTablePlugin"
|
||||
#define SETTING_NAME_WINDOW_POSITION (PLUGIN_NAME L".WindowPosition")
|
||||
#define SETTING_NAME_WINDOW_SIZE (PLUGIN_NAME L".WindowSize")
|
||||
#define SETTING_NAME_LISTVIEW_COLUMNS (PLUGIN_NAME L".ListViewColumns")
|
||||
|
||||
static PH_CALLBACK_REGISTRATION PluginMenuItemCallbackRegistration;
|
||||
static PH_CALLBACK_REGISTRATION MainMenuInitializingCallbackRegistration;
|
||||
static PH_CALLBACK_REGISTRATION PluginShowOptionsCallbackRegistration;
|
||||
static HWND ListViewWndHandle;
|
||||
static PH_LAYOUT_MANAGER LayoutManager;
|
||||
static PPH_PLUGIN PluginInstance;
|
||||
|
||||
NTSTATUS PhEnumAtomTable(
|
||||
_Out_ PATOM_TABLE_INFORMATION* AtomTable
|
||||
)
|
||||
{
|
||||
NTSTATUS status;
|
||||
PVOID buffer;
|
||||
ULONG bufferSize = 0x1000;
|
||||
|
||||
buffer = PhAllocate(bufferSize);
|
||||
memset(buffer, 0, bufferSize);
|
||||
|
||||
status = NtQueryInformationAtom(
|
||||
RTL_ATOM_INVALID_ATOM,
|
||||
AtomTableInformation,
|
||||
buffer,
|
||||
bufferSize,
|
||||
&bufferSize // Not used...
|
||||
);
|
||||
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
PhFree(buffer);
|
||||
return status;
|
||||
}
|
||||
|
||||
*AtomTable = buffer;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
NTSTATUS PhQueryAtomTableEntry(
|
||||
_In_ RTL_ATOM Atom,
|
||||
_Out_ PATOM_BASIC_INFORMATION* AtomInfo
|
||||
)
|
||||
{
|
||||
NTSTATUS status;
|
||||
PVOID buffer;
|
||||
ULONG bufferSize = 0x1000;
|
||||
|
||||
buffer = PhAllocate(bufferSize);
|
||||
memset(buffer, 0, bufferSize);
|
||||
|
||||
status = NtQueryInformationAtom(
|
||||
Atom,
|
||||
AtomBasicInformation,
|
||||
buffer,
|
||||
bufferSize,
|
||||
&bufferSize // Not used...
|
||||
);
|
||||
|
||||
if (!NT_SUCCESS(status))
|
||||
{
|
||||
PhFree(buffer);
|
||||
return status;
|
||||
}
|
||||
|
||||
*AtomInfo = buffer;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
VOID LoadAtomTable(VOID)
|
||||
{
|
||||
PATOM_TABLE_INFORMATION atomTable = NULL;
|
||||
|
||||
if (!NT_SUCCESS(PhEnumAtomTable(&atomTable)))
|
||||
return;
|
||||
|
||||
ExtendedListView_SetRedraw(ListViewWndHandle, FALSE);
|
||||
ListView_DeleteAllItems(ListViewWndHandle);
|
||||
|
||||
for (ULONG i = 0; i < atomTable->NumberOfAtoms; i++)
|
||||
{
|
||||
PATOM_BASIC_INFORMATION atomInfo = NULL;
|
||||
|
||||
if (!NT_SUCCESS(PhQueryAtomTableEntry(atomTable->Atoms[i], &atomInfo)))
|
||||
{
|
||||
PhAddListViewItem(ListViewWndHandle, MAXINT, PhaFormatString(L"(Error) #%lu", i)->Buffer, NULL);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((atomInfo->Flags & RTL_ATOM_PINNED) == RTL_ATOM_PINNED)
|
||||
{
|
||||
INT index = PhAddListViewItem(
|
||||
ListViewWndHandle,
|
||||
MAXINT,
|
||||
PhaFormatString(L"%s (Pinned)", atomInfo->Name)->Buffer,
|
||||
NULL
|
||||
);
|
||||
PhSetListViewSubItem(
|
||||
ListViewWndHandle,
|
||||
index,
|
||||
1,
|
||||
PhaFormatString(L"%u", atomInfo->UsageCount)->Buffer
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
INT index = PhAddListViewItem(
|
||||
ListViewWndHandle,
|
||||
MAXINT,
|
||||
atomInfo->Name,
|
||||
NULL
|
||||
);
|
||||
PhSetListViewSubItem(
|
||||
ListViewWndHandle,
|
||||
index,
|
||||
1,
|
||||
PhaFormatString(L"%u", atomInfo->UsageCount)->Buffer
|
||||
);
|
||||
}
|
||||
|
||||
PhFree(atomInfo);
|
||||
}
|
||||
|
||||
ExtendedListView_SetRedraw(ListViewWndHandle, TRUE);
|
||||
|
||||
PhFree(atomTable);
|
||||
}
|
||||
|
||||
PPH_STRING PhGetSelectedListViewItemText(
|
||||
_In_ HWND hWnd
|
||||
)
|
||||
{
|
||||
INT index = PhFindListViewItemByFlags(
|
||||
hWnd,
|
||||
-1,
|
||||
LVNI_SELECTED
|
||||
);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
WCHAR textBuffer[MAX_PATH] = L"";
|
||||
|
||||
LVITEM item;
|
||||
item.mask = LVIF_TEXT;
|
||||
item.iItem = index;
|
||||
item.iSubItem = 0;
|
||||
item.pszText = textBuffer;
|
||||
item.cchTextMax = MAX_PATH;
|
||||
|
||||
if (ListView_GetItem(hWnd, &item))
|
||||
return PhCreateString(textBuffer);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VOID ShowStatusMenu(
|
||||
_In_ HWND hwndDlg
|
||||
)
|
||||
{
|
||||
PPH_STRING cacheEntryName;
|
||||
|
||||
cacheEntryName = PhGetSelectedListViewItemText(ListViewWndHandle);
|
||||
|
||||
if (cacheEntryName)
|
||||
{
|
||||
POINT cursorPos;
|
||||
PPH_EMENU menu;
|
||||
PPH_EMENU_ITEM selectedItem;
|
||||
|
||||
GetCursorPos(&cursorPos);
|
||||
|
||||
menu = PhCreateEMenu();
|
||||
PhInsertEMenuItem(menu, PhCreateEMenuItem(0, 1, L"Remove", NULL, NULL), -1);
|
||||
|
||||
selectedItem = PhShowEMenu(
|
||||
menu,
|
||||
ListViewWndHandle,
|
||||
PH_EMENU_SHOW_LEFTRIGHT,
|
||||
PH_ALIGN_LEFT | PH_ALIGN_TOP,
|
||||
cursorPos.x,
|
||||
cursorPos.y
|
||||
);
|
||||
|
||||
if (selectedItem && selectedItem->Id != -1)
|
||||
{
|
||||
switch (selectedItem->Id)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
INT lvItemIndex = PhFindListViewItemByFlags(
|
||||
ListViewWndHandle,
|
||||
-1,
|
||||
LVNI_SELECTED
|
||||
);
|
||||
|
||||
if (lvItemIndex != -1)
|
||||
{
|
||||
if (!PhGetIntegerSetting(L"EnableWarnings") || PhShowConfirmMessage(
|
||||
hwndDlg,
|
||||
L"remove",
|
||||
cacheEntryName->Buffer,
|
||||
NULL,
|
||||
FALSE
|
||||
))
|
||||
{
|
||||
PATOM_TABLE_INFORMATION atomTable = NULL;
|
||||
|
||||
if (!NT_SUCCESS(PhEnumAtomTable(&atomTable)))
|
||||
return;
|
||||
|
||||
for (ULONG i = 0; i < atomTable->NumberOfAtoms; i++)
|
||||
{
|
||||
PATOM_BASIC_INFORMATION atomInfo = NULL;
|
||||
|
||||
if (!NT_SUCCESS(PhQueryAtomTableEntry(atomTable->Atoms[i], &atomInfo)))
|
||||
continue;
|
||||
|
||||
if (!PhEqualStringZ(atomInfo->Name, cacheEntryName->Buffer, TRUE))
|
||||
continue;
|
||||
|
||||
do
|
||||
{
|
||||
if (!NT_SUCCESS(NtDeleteAtom(atomTable->Atoms[i])))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
PhFree(atomInfo);
|
||||
atomInfo = NULL;
|
||||
|
||||
if (!NT_SUCCESS(PhQueryAtomTableEntry(atomTable->Atoms[i], &atomInfo)))
|
||||
break;
|
||||
|
||||
} while (atomInfo->UsageCount >= 1);
|
||||
|
||||
ListView_DeleteItem(ListViewWndHandle, lvItemIndex);
|
||||
|
||||
if (atomInfo)
|
||||
{
|
||||
PhFree(atomInfo);
|
||||
}
|
||||
}
|
||||
|
||||
PhFree(atomTable);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PhDestroyEMenu(menu);
|
||||
PhDereferenceObject(cacheEntryName);
|
||||
}
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK MainWindowDlgProc(
|
||||
_In_ HWND hwndDlg,
|
||||
_In_ UINT uMsg,
|
||||
_In_ WPARAM wParam,
|
||||
_In_ LPARAM lParam
|
||||
)
|
||||
{
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
PhCenterWindow(hwndDlg, PhMainWndHandle);
|
||||
ListViewWndHandle = GetDlgItem(hwndDlg, IDC_ATOMLIST);
|
||||
|
||||
PhInitializeLayoutManager(&LayoutManager, hwndDlg);
|
||||
PhAddLayoutItem(&LayoutManager, ListViewWndHandle, NULL, PH_ANCHOR_ALL);
|
||||
PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDRETRY), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_LEFT);
|
||||
PhAddLayoutItem(&LayoutManager, GetDlgItem(hwndDlg, IDOK), NULL, PH_ANCHOR_BOTTOM | PH_ANCHOR_RIGHT);
|
||||
|
||||
PhRegisterDialog(hwndDlg);
|
||||
PhLoadWindowPlacementFromSetting(SETTING_NAME_WINDOW_POSITION, SETTING_NAME_WINDOW_SIZE, hwndDlg);
|
||||
|
||||
PhSetListViewStyle(ListViewWndHandle, FALSE, TRUE);
|
||||
PhSetControlTheme(ListViewWndHandle, L"explorer");
|
||||
PhAddListViewColumn(ListViewWndHandle, 0, 0, 0, LVCFMT_LEFT, 370, L"Atom Name");
|
||||
PhAddListViewColumn(ListViewWndHandle, 1, 1, 1, LVCFMT_LEFT, 70, L"Ref Count");
|
||||
PhSetExtendedListView(ListViewWndHandle);
|
||||
PhLoadListViewColumnsFromSetting(SETTING_NAME_LISTVIEW_COLUMNS, ListViewWndHandle);
|
||||
|
||||
LoadAtomTable();
|
||||
}
|
||||
break;
|
||||
case WM_SIZE:
|
||||
PhLayoutManagerLayout(&LayoutManager);
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PhSaveWindowPlacementToSetting(SETTING_NAME_WINDOW_POSITION, SETTING_NAME_WINDOW_SIZE, hwndDlg);
|
||||
PhSaveListViewColumnsToSetting(SETTING_NAME_LISTVIEW_COLUMNS, ListViewWndHandle);
|
||||
PhDeleteLayoutManager(&LayoutManager);
|
||||
PhUnregisterDialog(hwndDlg);
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
{
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDCANCEL:
|
||||
case IDOK:
|
||||
EndDialog(hwndDlg, IDOK);
|
||||
break;
|
||||
case IDRETRY:
|
||||
LoadAtomTable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
LPNMHDR hdr = (LPNMHDR)lParam;
|
||||
|
||||
switch (hdr->code)
|
||||
{
|
||||
case NM_RCLICK:
|
||||
{
|
||||
if (hdr->hwndFrom == ListViewWndHandle)
|
||||
ShowStatusMenu(hwndDlg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
VOID NTAPI MainMenuInitializingCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
)
|
||||
{
|
||||
PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter;
|
||||
PPH_EMENU_ITEM systemMenu;
|
||||
|
||||
if (menuInfo->u.MainMenu.SubMenuIndex != PH_MENU_ITEM_LOCATION_TOOLS)
|
||||
return;
|
||||
|
||||
if (!(systemMenu = PhFindEMenuItem(menuInfo->Menu, 0, L"System", 0)))
|
||||
{
|
||||
PhInsertEMenuItem(menuInfo->Menu, PhPluginCreateEMenuItem(PluginInstance, PH_EMENU_SEPARATOR, 0, L"", NULL), -1);
|
||||
PhInsertEMenuItem(menuInfo->Menu, systemMenu = PhPluginCreateEMenuItem(PluginInstance, 0, 0, L"System", NULL), -1);
|
||||
}
|
||||
|
||||
PhInsertEMenuItem(systemMenu, PhPluginCreateEMenuItem(PluginInstance, 0, ATOM_TABLE_MENUITEM, L"Atom Table", NULL), -1);
|
||||
}
|
||||
|
||||
VOID NTAPI MenuItemCallback(
|
||||
_In_opt_ PVOID Parameter,
|
||||
_In_opt_ PVOID Context
|
||||
)
|
||||
{
|
||||
PPH_PLUGIN_MENU_ITEM menuItem = (PPH_PLUGIN_MENU_ITEM)Parameter;
|
||||
|
||||
switch (menuItem->Id)
|
||||
{
|
||||
case ATOM_TABLE_MENUITEM:
|
||||
{
|
||||
DialogBox(
|
||||
PluginInstance->DllBase,
|
||||
MAKEINTRESOURCE(IDD_ATOMDIALOG),
|
||||
NULL,
|
||||
MainWindowDlgProc
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOGICAL DllMain(
|
||||
_In_ HINSTANCE Instance,
|
||||
_In_ ULONG Reason,
|
||||
_Reserved_ PVOID Reserved
|
||||
)
|
||||
{
|
||||
switch (Reason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
{
|
||||
PPH_PLUGIN_INFORMATION info;
|
||||
PH_SETTING_CREATE settings[] =
|
||||
{
|
||||
{ IntegerPairSettingType, SETTING_NAME_WINDOW_POSITION, L"350,350" },
|
||||
{ ScalableIntegerPairSettingType, SETTING_NAME_WINDOW_SIZE, L"@96|510,380" },
|
||||
{ StringSettingType, SETTING_NAME_LISTVIEW_COLUMNS, L"" }
|
||||
};
|
||||
|
||||
PluginInstance = PhRegisterPlugin(PLUGIN_NAME, Instance, &info);
|
||||
|
||||
if (!PluginInstance)
|
||||
return FALSE;
|
||||
|
||||
info->Author = L"dmex";
|
||||
info->DisplayName = L"Global Atom Table";
|
||||
info->Description = L"Plugin for viewing the Global Atom Table via the Tools menu.";
|
||||
info->HasOptions = FALSE;
|
||||
|
||||
PhRegisterCallback(
|
||||
PhGetGeneralCallback(GeneralCallbackMainMenuInitializing),
|
||||
MainMenuInitializingCallback,
|
||||
NULL,
|
||||
&MainMenuInitializingCallbackRegistration
|
||||
);
|
||||
PhRegisterCallback(
|
||||
PhGetPluginCallback(PluginInstance, PluginCallbackMenuItem),
|
||||
MenuItemCallback,
|
||||
NULL,
|
||||
&PluginMenuItemCallbackRegistration
|
||||
);
|
||||
|
||||
PhAddSettings(settings, ARRAYSIZE(settings));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
17
plugins-extra/AtomTablePlugin/resource.h
Normal file
17
plugins-extra/AtomTablePlugin/resource.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by AtomTablePlugin.rc
|
||||
//
|
||||
#define IDD_ATOMDIALOG 101
|
||||
#define IDC_ATOMLIST 1001
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 103
|
||||
#define _APS_NEXT_COMMAND_VALUE 40006
|
||||
#define _APS_NEXT_CONTROL_VALUE 1002
|
||||
#define _APS_NEXT_SYMED_VALUE 103
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user