mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
55914f752b
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@3768 21ef857c-d57f-4fe0-8362-d861dc6d29cd
243 lines
6.9 KiB
C
243 lines
6.9 KiB
C
/*
|
|
* Process Hacker Extended Tools -
|
|
* main program
|
|
*
|
|
* Copyright (C) 2010 wj32
|
|
*
|
|
* 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/>.
|
|
*/
|
|
|
|
#include "extendedtools.h"
|
|
#include "resource.h"
|
|
|
|
VOID NTAPI LoadCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
);
|
|
|
|
VOID NTAPI ShowOptionsCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
);
|
|
|
|
VOID NTAPI MenuItemCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
);
|
|
|
|
VOID NTAPI MainWindowShowingCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
);
|
|
|
|
VOID NTAPI HandlePropertiesInitializingCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
);
|
|
|
|
VOID NTAPI ProcessMenuInitializingCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
);
|
|
|
|
VOID NTAPI ThreadMenuInitializingCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
);
|
|
|
|
PPH_PLUGIN PluginInstance;
|
|
PH_CALLBACK_REGISTRATION PluginLoadCallbackRegistration;
|
|
PH_CALLBACK_REGISTRATION PluginShowOptionsCallbackRegistration;
|
|
PH_CALLBACK_REGISTRATION PluginMenuItemCallbackRegistration;
|
|
PH_CALLBACK_REGISTRATION MainWindowShowingCallbackRegistration;
|
|
PH_CALLBACK_REGISTRATION HandlePropertiesInitializingCallbackRegistration;
|
|
PH_CALLBACK_REGISTRATION ProcessMenuInitializingCallbackRegistration;
|
|
PH_CALLBACK_REGISTRATION ThreadMenuInitializingCallbackRegistration;
|
|
|
|
LOGICAL DllMain(
|
|
__in HINSTANCE Instance,
|
|
__in ULONG Reason,
|
|
__reserved PVOID Reserved
|
|
)
|
|
{
|
|
switch (Reason)
|
|
{
|
|
case DLL_PROCESS_ATTACH:
|
|
{
|
|
PH_PLUGIN_INFORMATION info;
|
|
|
|
info.DisplayName = L"Extended Tools";
|
|
info.Author = L"wj32";
|
|
info.Description = L"Extended functionality for Windows Vista and above.";
|
|
info.HasOptions = FALSE;
|
|
|
|
PluginInstance = PhRegisterPlugin(L"ProcessHacker.ExtendedTools", Instance, &info);
|
|
|
|
if (!PluginInstance)
|
|
return FALSE;
|
|
|
|
//PhRegisterCallback(
|
|
// PhGetPluginCallback(PluginInstance, PluginCallbackLoad),
|
|
// LoadCallback,
|
|
// NULL,
|
|
// &PluginLoadCallbackRegistration
|
|
// );
|
|
//PhRegisterCallback(
|
|
// PhGetPluginCallback(PluginInstance, PluginCallbackShowOptions),
|
|
// ShowOptionsCallback,
|
|
// NULL,
|
|
// &PluginShowOptionsCallbackRegistration
|
|
// );
|
|
PhRegisterCallback(
|
|
PhGetPluginCallback(PluginInstance, PluginCallbackMenuItem),
|
|
MenuItemCallback,
|
|
NULL,
|
|
&PluginMenuItemCallbackRegistration
|
|
);
|
|
|
|
//PhRegisterCallback(
|
|
// PhGetGeneralCallback(GeneralCallbackMainWindowShowing),
|
|
// MainWindowShowingCallback,
|
|
// NULL,
|
|
// &MainWindowShowingCallbackRegistration
|
|
// );
|
|
PhRegisterCallback(
|
|
PhGetGeneralCallback(GeneralCallbackHandlePropertiesInitializing),
|
|
HandlePropertiesInitializingCallback,
|
|
NULL,
|
|
&HandlePropertiesInitializingCallbackRegistration
|
|
);
|
|
PhRegisterCallback(
|
|
PhGetGeneralCallback(GeneralCallbackProcessMenuInitializing),
|
|
ProcessMenuInitializingCallback,
|
|
NULL,
|
|
&ProcessMenuInitializingCallbackRegistration
|
|
);
|
|
PhRegisterCallback(
|
|
PhGetGeneralCallback(GeneralCallbackThreadMenuInitializing),
|
|
ThreadMenuInitializingCallback,
|
|
NULL,
|
|
&ThreadMenuInitializingCallbackRegistration
|
|
);
|
|
}
|
|
break;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
VOID NTAPI LoadCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
)
|
|
{
|
|
// Nothing
|
|
}
|
|
|
|
VOID NTAPI ShowOptionsCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
)
|
|
{
|
|
// Nothing
|
|
}
|
|
|
|
VOID NTAPI MenuItemCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
)
|
|
{
|
|
PPH_PLUGIN_MENU_ITEM menuItem = Parameter;
|
|
|
|
switch (menuItem->Id)
|
|
{
|
|
case ID_PROCESS_UNLOADEDMODULES:
|
|
{
|
|
EtShowUnloadedDllsDialog(PhMainWndHandle, menuItem->Context);
|
|
}
|
|
break;
|
|
case ID_THREAD_CANCELIO:
|
|
{
|
|
EtUiCancelIoThread(menuItem->OwnerWindow, menuItem->Context);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
VOID NTAPI MainWindowShowingCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
)
|
|
{
|
|
// Nothing
|
|
}
|
|
|
|
VOID NTAPI HandlePropertiesInitializingCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
)
|
|
{
|
|
EtHandlePropertiesInitializing(Parameter);
|
|
}
|
|
|
|
VOID NTAPI ProcessMenuInitializingCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
)
|
|
{
|
|
PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter;
|
|
PPH_PROCESS_ITEM processItem;
|
|
PPH_EMENU_ITEM miscMenu;
|
|
|
|
if (menuInfo->u.Process.NumberOfProcesses == 1)
|
|
processItem = menuInfo->u.Process.Processes[0];
|
|
else
|
|
processItem = NULL;
|
|
|
|
miscMenu = PhFindEMenuItem(menuInfo->Menu, 0, L"Miscellaneous", 0);
|
|
|
|
if (miscMenu)
|
|
{
|
|
PhInsertEMenuItem(miscMenu, PhPluginCreateEMenuItem(PluginInstance, 0, ID_PROCESS_UNLOADEDMODULES, L"Unloaded Modules", processItem), -1);
|
|
}
|
|
}
|
|
|
|
VOID NTAPI ThreadMenuInitializingCallback(
|
|
__in_opt PVOID Parameter,
|
|
__in_opt PVOID Context
|
|
)
|
|
{
|
|
PPH_PLUGIN_MENU_INFORMATION menuInfo = Parameter;
|
|
PPH_THREAD_ITEM threadItem;
|
|
ULONG insertIndex;
|
|
PPH_EMENU_ITEM menuItem;
|
|
|
|
if (menuInfo->u.Thread.NumberOfThreads == 1)
|
|
threadItem = menuInfo->u.Thread.Threads[0];
|
|
else
|
|
threadItem = NULL;
|
|
|
|
if (menuItem = PhFindEMenuItem(menuInfo->Menu, 0, L"Resume", 0))
|
|
insertIndex = PhIndexOfEMenuItem(menuInfo->Menu, menuItem) + 1;
|
|
else
|
|
insertIndex = 0;
|
|
|
|
PhInsertEMenuItem(menuInfo->Menu, menuItem = PhPluginCreateEMenuItem(PluginInstance, 0, ID_THREAD_CANCELIO,
|
|
L"Cancel I/O", threadItem), insertIndex);
|
|
|
|
if (!threadItem) menuItem->Flags |= PH_EMENU_DISABLED;
|
|
}
|