Process Hacker
plugin.c File Reference
#include <phapp.h>
#include <settings.h>
#include <emenu.h>
#include <phplug.h>
#include <extmgri.h>
#include <notifico.h>
#include <phsvccl.h>

Go to the source code of this file.

Typedefs

typedef struct
_PHP_PLUGIN_LOAD_ERROR 
PHP_PLUGIN_LOAD_ERROR
 
typedef struct
_PHP_PLUGIN_LOAD_ERROR * 
PPHP_PLUGIN_LOAD_ERROR
 
typedef struct
_PHP_PLUGIN_MENU_HOOK 
PHP_PLUGIN_MENU_HOOK
 
typedef struct
_PHP_PLUGIN_MENU_HOOK * 
PPHP_PLUGIN_MENU_HOOK
 

Functions

INT NTAPI PhpPluginsCompareFunction (_In_ PPH_AVL_LINKS Links1, _In_ PPH_AVL_LINKS Links2)
 
BOOLEAN PhLoadPlugin (_In_ PPH_STRING FileName)
 Loads a plugin.
 
VOID PhpExecuteCallbackForAllPlugins (_In_ PH_PLUGIN_CALLBACK Callback, _In_ BOOLEAN StartupParameters)
 
VOID PhPluginsInitialization (VOID)
 
BOOLEAN PhpLocateDisabledPlugin (_In_ PPH_STRING List, _In_ PPH_STRINGREF BaseName, _Out_opt_ PULONG FoundIndex)
 
BOOLEAN PhIsPluginDisabled (_In_ PPH_STRINGREF BaseName)
 
VOID PhSetPluginDisabled (_In_ PPH_STRINGREF BaseName, _In_ BOOLEAN Disable)
 
VOID PhLoadPlugins (VOID)
 Loads plugins from the default plugins directory.
 
VOID PhUnloadPlugins (VOID)
 Notifies all plugins that the program is shutting down.
 
BOOLEAN PhpValidatePluginName (_In_ PPH_STRINGREF Name)
 
PPH_PLUGIN PhRegisterPlugin (_In_ PWSTR Name, _In_ PVOID DllBase, _Out_opt_ PPH_PLUGIN_INFORMATION *Information)
 Registers a plugin with the host.
 
PPH_PLUGIN PhFindPlugin (_In_ PWSTR Name)
 Locates a plugin instance structure.
 
PPH_PLUGIN PhFindPlugin2 (_In_ PPH_STRINGREF Name)
 Locates a plugin instance structure.
 
PPH_PLUGIN_INFORMATION PhGetPluginInformation (_In_ PPH_PLUGIN Plugin)
 Gets a pointer to a plugin's additional information block.
 
PPH_CALLBACK PhGetPluginCallback (_In_ PPH_PLUGIN Plugin, _In_ PH_PLUGIN_CALLBACK Callback)
 Retrieves a pointer to a plugin callback.
 
PPH_CALLBACK PhGetGeneralCallback (_In_ PH_GENERAL_CALLBACK Callback)
 Retrieves a pointer to a general callback.
 
ULONG PhPluginReserveIds (_In_ ULONG Count)
 Reserves unique GUI identifiers.
 
ULONG_PTR PhPluginAddMenuItem (_In_ PPH_PLUGIN Plugin, _In_ ULONG_PTR Location, _In_opt_ PWSTR InsertAfter, _In_ ULONG Id, _In_ PWSTR Text, _In_opt_ PVOID Context)
 Adds a menu item to the program's main menu.
 
VOID PhPluginGetSystemStatistics (_Out_ PPH_PLUGIN_SYSTEM_STATISTICS Statistics)
 Retrieves current system statistics.
 
PPH_EMENU_ITEM PhPluginCreateEMenuItem (_In_ PPH_PLUGIN Plugin, _In_ ULONG Flags, _In_ ULONG Id, _In_ PWSTR Text, _In_opt_ PVOID Context)
 Creates a menu item.
 
BOOLEAN PhPluginAddMenuHook (_Inout_ PPH_PLUGIN_MENU_INFORMATION MenuInfo, _In_ PPH_PLUGIN Plugin, _In_opt_ PVOID Context)
 Adds a menu hook.
 
VOID PhPluginInitializeMenuInfo (_Out_ PPH_PLUGIN_MENU_INFORMATION MenuInfo, _In_opt_ PPH_EMENU Menu, _In_ HWND OwnerWindow, _In_ ULONG Flags)
 Initializes a plugin menu information structure.
 
BOOLEAN PhPluginTriggerEMenuItem (_In_ PPH_PLUGIN_MENU_INFORMATION MenuInfo, _In_ PPH_EMENU_ITEM Item)
 Triggers a plugin menu item.
 
BOOLEAN PhPluginAddTreeNewColumn (_In_ PPH_PLUGIN Plugin, _In_ PVOID CmData, _In_ PPH_TREENEW_COLUMN Column, _In_ ULONG SubId, _In_opt_ PVOID Context, _In_opt_ PPH_PLUGIN_TREENEW_SORT_FUNCTION SortFunction)
 Adds a column to a tree new control.
 
VOID PhPluginSetObjectExtension (_In_ PPH_PLUGIN Plugin, _In_ PH_EM_OBJECT_TYPE ObjectType, _In_ ULONG ExtensionSize, _In_opt_ PPH_EM_OBJECT_CALLBACK CreateCallback, _In_opt_ PPH_EM_OBJECT_CALLBACK DeleteCallback)
 Sets the object extension size and callbacks for an object type.
 
PVOID PhPluginGetObjectExtension (_In_ PPH_PLUGIN Plugin, _In_ PVOID Object, _In_ PH_EM_OBJECT_TYPE ObjectType)
 Gets the object extension for an object.
 
struct _PH_NF_ICONPhPluginRegisterIcon (_In_ PPH_PLUGIN Plugin, _In_ ULONG SubId, _In_opt_ PVOID Context, _In_ PWSTR Text, _In_ ULONG Flags, _In_ struct _PH_NF_ICON_REGISTRATION_DATA *RegistrationData)
 Creates a notification icon.
 
VOID PhPluginEnableTreeNewNotify (_In_ PPH_PLUGIN Plugin, _In_ PVOID CmData)
 Allows a plugin to receive all treenew messages, not just column-related ones.
 
BOOLEAN PhPluginQueryPhSvc (_Out_ PPH_PLUGIN_PHSVC_CLIENT Client)
 
NTSTATUS PhPluginCallPhSvc (_In_ PPH_PLUGIN Plugin, _In_ ULONG SubId, _In_reads_bytes_opt_(InLength) PVOID InBuffer, _In_ ULONG InLength, _Out_writes_bytes_opt_(OutLength) PVOID OutBuffer, _In_ ULONG OutLength)
 

Variables

PH_AVL_TREE PhPluginsByName = PH_AVL_TREE_INIT(PhpPluginsCompareFunction)
 

Typedef Documentation

typedef struct _PHP_PLUGIN_LOAD_ERROR PHP_PLUGIN_LOAD_ERROR
typedef struct _PHP_PLUGIN_MENU_HOOK PHP_PLUGIN_MENU_HOOK
typedef struct _PHP_PLUGIN_LOAD_ERROR * PPHP_PLUGIN_LOAD_ERROR
typedef struct _PHP_PLUGIN_MENU_HOOK * PPHP_PLUGIN_MENU_HOOK

Function Documentation

PPH_PLUGIN PhFindPlugin ( _In_ PWSTR  Name)

Locates a plugin instance structure.

Parameters
NameThe name of the plugin.
Returns
A plugin instance structure, or NULL if the plugin was not found.

Definition at line 526 of file plugin.c.

PPH_PLUGIN PhFindPlugin2 ( _In_ PPH_STRINGREF  Name)
read

Locates a plugin instance structure.

Parameters
NameThe name of the plugin.
Returns
A plugin instance structure, or NULL if the plugin was not found.

Definition at line 544 of file plugin.c.

PPH_CALLBACK PhGetGeneralCallback ( _In_ PH_GENERAL_CALLBACK  Callback)

Retrieves a pointer to a general callback.

Parameters
CallbackThe type of callback.
Remarks
The program invokes general callbacks for system-wide notifications.

Definition at line 602 of file plugin.c.

PPH_CALLBACK PhGetPluginCallback ( _In_ PPH_PLUGIN  Plugin,
_In_ PH_PLUGIN_CALLBACK  Callback 
)

Retrieves a pointer to a plugin callback.

Parameters
PluginA plugin instance structure.
CallbackThe type of callback.
Remarks
The program invokes plugin callbacks for notifications specific to a plugin.

Definition at line 583 of file plugin.c.

PPH_PLUGIN_INFORMATION PhGetPluginInformation ( _In_ PPH_PLUGIN  Plugin)

Gets a pointer to a plugin's additional information block.

Parameters
PluginThe plugin instance structure.
Returns
The plugin's additional information block.

Definition at line 567 of file plugin.c.

BOOLEAN PhIsPluginDisabled ( _In_ PPH_STRINGREF  BaseName)

Definition at line 121 of file plugin.c.

BOOLEAN PhLoadPlugin ( _In_ PPH_STRING  FileName)

Loads a plugin.

Parameters
FileNameThe full file name of the plugin.

Definition at line 335 of file plugin.c.

VOID PhLoadPlugins ( VOID  )

Loads plugins from the default plugins directory.

Definition at line 231 of file plugin.c.

VOID PhpExecuteCallbackForAllPlugins ( _In_ PH_PLUGIN_CALLBACK  Callback,
_In_ BOOLEAN  StartupParameters 
)

Definition at line 378 of file plugin.c.

BOOLEAN PhpLocateDisabledPlugin ( _In_ PPH_STRING  List,
_In_ PPH_STRINGREF  BaseName,
_Out_opt_ PULONG  FoundIndex 
)

Definition at line 94 of file plugin.c.

BOOLEAN PhPluginAddMenuHook ( _Inout_ PPH_PLUGIN_MENU_INFORMATION  MenuInfo,
_In_ PPH_PLUGIN  Plugin,
_In_opt_ PVOID  Context 
)

Adds a menu hook.

Parameters
MenuInfoThe plugin menu information structure.
PluginA plugin instance structure.
ContextA user-defined value that is later accessible from the callback.
Remarks
The PluginCallbackMenuHook callback is invoked when any menu item from the menu is chosen.

Definition at line 802 of file plugin.c.

ULONG_PTR PhPluginAddMenuItem ( _In_ PPH_PLUGIN  Plugin,
_In_ ULONG_PTR  Location,
_In_opt_ PWSTR  InsertAfter,
_In_ ULONG  Id,
_In_ PWSTR  Text,
_In_opt_ PVOID  Context 
)

Adds a menu item to the program's main menu.

This function is deprecated. Use GeneralCallbackMainMenuInitializing instead.

Parameters
PluginA plugin instance structure.
LocationA handle to the parent menu, or one of the following:
  • PH_MENU_ITEM_LOCATION_VIEW The "View" menu.
  • PH_MENU_ITEM_LOCATION_TOOLS The "Tools" menu.
InsertAfterThe text of the menu item to insert the new menu item after. The search is a case-insensitive prefix search that ignores prefix characters (ampersands).
IdAn identifier for the menu item. This should be unique within the plugin.
TextThe text of the menu item.
ContextA user-defined value for the menu item.
Returns
TRUE if the function succeeded, otherwise FALSE.
Remarks
The PluginCallbackMenuItem callback is invoked when the menu item is chosen, and the PH_PLUGIN_MENU_ITEM structure will contain the Id and Context values passed to this function.

Definition at line 656 of file plugin.c.

BOOLEAN PhPluginAddTreeNewColumn ( _In_ PPH_PLUGIN  Plugin,
_In_ PVOID  CmData,
_In_ PPH_TREENEW_COLUMN  Column,
_In_ ULONG  SubId,
_In_opt_ PVOID  Context,
_In_opt_ PPH_PLUGIN_TREENEW_SORT_FUNCTION  SortFunction 
)

Adds a column to a tree new control.

Parameters
PluginA plugin instance structure.
CmDataThe CmData value from the PH_PLUGIN_TREENEW_INFORMATION structure.
ColumnThe column properties.
SubIdAn identifier for the column. This should be unique within the plugin.
ContextA user-defined value.
SortFunctionThe sort function for the column.

Definition at line 905 of file plugin.c.

NTSTATUS PhPluginCallPhSvc ( _In_ PPH_PLUGIN  Plugin,
_In_ ULONG  SubId,
_In_reads_bytes_opt_(InLength) PVOID  InBuffer,
_In_ ULONG  InLength,
_Out_writes_bytes_opt_(OutLength) PVOID  OutBuffer,
_In_ ULONG  OutLength 
)

Definition at line 1032 of file plugin.c.

PPH_EMENU_ITEM PhPluginCreateEMenuItem ( _In_ PPH_PLUGIN  Plugin,
_In_ ULONG  Flags,
_In_ ULONG  Id,
_In_ PWSTR  Text,
_In_opt_ PVOID  Context 
)

Creates a menu item.

Parameters
PluginA plugin instance structure.
FlagsA combination of flags.
IdAn identifier for the menu item. This should be unique within the plugin.
TextThe text of the menu item.
ContextA user-defined value for the menu item.
Returns
A menu item object. This can then be inserted into another menu using PhInsertEMenuItem().
Remarks
The PluginCallbackMenuItem callback is invoked when the menu item is chosen, and the PH_PLUGIN_MENU_ITEM structure will contain the Id and Context values passed to this function.

Definition at line 767 of file plugin.c.

VOID PhPluginEnableTreeNewNotify ( _In_ PPH_PLUGIN  Plugin,
_In_ PVOID  CmData 
)

Allows a plugin to receive all treenew messages, not just column-related ones.

Parameters
PluginA plugin instance structure.
CmDataThe CmData value from the PH_PLUGIN_TREENEW_INFORMATION structure.

Definition at line 1010 of file plugin.c.

PVOID PhPluginGetObjectExtension ( _In_ PPH_PLUGIN  Plugin,
_In_ PVOID  Object,
_In_ PH_EM_OBJECT_TYPE  ObjectType 
)

Gets the object extension for an object.

Parameters
PluginA plugin instance structure.
ObjectThe object.
ObjectTypeThe type of object for which an extension has been registered.

Definition at line 957 of file plugin.c.

VOID PhPluginGetSystemStatistics ( _Out_ PPH_PLUGIN_SYSTEM_STATISTICS  Statistics)

Retrieves current system statistics.

Definition at line 691 of file plugin.c.

VOID PhPluginInitializeMenuInfo ( _Out_ PPH_PLUGIN_MENU_INFORMATION  MenuInfo,
_In_opt_ PPH_EMENU  Menu,
_In_ HWND  OwnerWindow,
_In_ ULONG  Flags 
)

Initializes a plugin menu information structure.

Parameters
MenuInfoThe structure to initialize.
MenuThe menu being shown.
OwnerWindowThe window that owns the menu.
FlagsAdditional flags.
Remarks
This function is reserved for internal use.

Definition at line 834 of file plugin.c.

BOOLEAN PhPluginQueryPhSvc ( _Out_ PPH_PLUGIN_PHSVC_CLIENT  Client)

Definition at line 1018 of file plugin.c.

struct _PH_NF_ICON* PhPluginRegisterIcon ( _In_ PPH_PLUGIN  Plugin,
_In_ ULONG  SubId,
_In_opt_ PVOID  Context,
_In_ PWSTR  Text,
_In_ ULONG  Flags,
_In_ struct _PH_NF_ICON_REGISTRATION_DATA RegistrationData 
)
read

Creates a notification icon.

Parameters
PluginA plugin instance structure.
SubIdAn identifier for the column. This should be unique within the plugin.
ContextA user-defined value.
TextA string describing the notification icon.
FlagsA combination of flags.
  • PH_NF_ICON_UNAVAILABLE The notification icon is currently unavailable.
RegistrationDataA PH_NF_ICON_REGISTRATION_DATA structure that contains registration information.

Definition at line 983 of file plugin.c.

ULONG PhPluginReserveIds ( _In_ ULONG  Count)

Reserves unique GUI identifiers.

Parameters
CountThe number of identifiers to reserve.
Returns
The start of the reserved range.
Remarks
The identifiers reserved by this function are guaranteed to be unique throughout the program.

Definition at line 622 of file plugin.c.

VOID PhPluginSetObjectExtension ( _In_ PPH_PLUGIN  Plugin,
_In_ PH_EM_OBJECT_TYPE  ObjectType,
_In_ ULONG  ExtensionSize,
_In_opt_ PPH_EM_OBJECT_CALLBACK  CreateCallback,
_In_opt_ PPH_EM_OBJECT_CALLBACK  DeleteCallback 
)

Sets the object extension size and callbacks for an object type.

Parameters
PluginA plugin instance structure.
ObjectTypeThe type of object for which the extension is being registered.
ExtensionSizeThe size of the extension, in bytes.
CreateCallbackThe object creation callback.
DeleteCallbackThe object deletion callback.

Definition at line 933 of file plugin.c.

VOID PhPluginsInitialization ( VOID  )

Definition at line 64 of file plugin.c.

BOOLEAN PhPluginTriggerEMenuItem ( _In_ PPH_PLUGIN_MENU_INFORMATION  MenuInfo,
_In_ PPH_EMENU_ITEM  Item 
)

Triggers a plugin menu item.

Parameters
MenuInfoThe plugin menu information structure.
ItemThe menu item chosen by the user.
Remarks
This function is reserved for internal use.

Definition at line 855 of file plugin.c.

INT NTAPI PhpPluginsCompareFunction ( _In_ PPH_AVL_LINKS  Links1,
_In_ PPH_AVL_LINKS  Links2 
)

Definition at line 83 of file plugin.c.

BOOLEAN PhpValidatePluginName ( _In_ PPH_STRINGREF  Name)

Definition at line 431 of file plugin.c.

PPH_PLUGIN PhRegisterPlugin ( _In_ PWSTR  Name,
_In_ PVOID  DllBase,
_Out_opt_ PPH_PLUGIN_INFORMATION Information 
)

Registers a plugin with the host.

Parameters
NameA unique identifier for the plugin. The function fails if another plugin has already been registered with the same name. The name must only contain alphanumeric characters, spaces, dots and underscores.
DllBaseThe base address of the plugin DLL. This is passed to the DllMain function.
InformationA variable which receives a pointer to the plugin's additional information block. This should be filled in after the function returns.
Returns
A pointer to the plugin instance structure, or NULL if the function failed.

Definition at line 469 of file plugin.c.

VOID PhSetPluginDisabled ( _In_ PPH_STRINGREF  BaseName,
_In_ BOOLEAN  Disable 
)

Definition at line 135 of file plugin.c.

VOID PhUnloadPlugins ( VOID  )

Notifies all plugins that the program is shutting down.

Definition at line 323 of file plugin.c.

Variable Documentation

Definition at line 57 of file plugin.c.