Process Hacker
phplug.h
Go to the documentation of this file.
1 #ifndef PH_PHPLUG_H
2 #define PH_PHPLUG_H
3 
4 #include <extmgr.h>
5 #include <sysinfo.h>
6 #include <miniinfo.h>
7 
8 // begin_phapppub
9 // Callbacks
10 
12 {
13  GeneralCallbackMainWindowShowing = 0, // INT ShowCommand [main thread]
14  GeneralCallbackProcessesUpdated = 1, // [main thread]
15  GeneralCallbackGetProcessHighlightingColor = 2, // PPH_PLUGIN_GET_HIGHLIGHTING_COLOR Data [main thread]
16  GeneralCallbackGetProcessTooltipText = 3, // PPH_PLUGIN_GET_TOOLTIP_TEXT Data [main thread]
17  GeneralCallbackProcessPropertiesInitializing = 4, // PPH_PLUGIN_PROCESS_PROPCONTEXT Data [properties thread]
18  GeneralCallbackMainMenuInitializing = 5, // PPH_PLUGIN_MENU_INFORMATION Data [main thread]
19  GeneralCallbackNotifyEvent = 6, // PPH_PLUGIN_NOTIFY_EVENT Data [main thread]
20  GeneralCallbackServicePropertiesInitializing = 7, // PPH_PLUGIN_OBJECT_PROPERTIES Data [properties thread]
21  GeneralCallbackHandlePropertiesInitializing = 8, // PPH_PLUGIN_OBJECT_PROPERTIES Data [properties thread]
22  GeneralCallbackProcessMenuInitializing = 9, // PPH_PLUGIN_MENU_INFORMATION Data [main thread]
23  GeneralCallbackServiceMenuInitializing = 10, // PPH_PLUGIN_MENU_INFORMATION Data [main thread]
24  GeneralCallbackNetworkMenuInitializing = 11, // PPH_PLUGIN_MENU_INFORMATION Data [main thread]
25  GeneralCallbackIconMenuInitializing = 12, // PPH_PLUGIN_MENU_INFORMATION Data [main thread]
26  GeneralCallbackThreadMenuInitializing = 13, // PPH_PLUGIN_MENU_INFORMATION Data [properties thread]
27  GeneralCallbackModuleMenuInitializing = 14, // PPH_PLUGIN_MENU_INFORMATION Data [properties thread]
28  GeneralCallbackMemoryMenuInitializing = 15, // PPH_PLUGIN_MENU_INFORMATION Data [properties thread]
29  GeneralCallbackHandleMenuInitializing = 16, // PPH_PLUGIN_MENU_INFORMATION Data [properties thread]
30  GeneralCallbackProcessTreeNewInitializing = 17, // PPH_PLUGIN_TREENEW_INFORMATION Data [main thread]
31  GeneralCallbackServiceTreeNewInitializing = 18, // PPH_PLUGIN_TREENEW_INFORMATION Data [main thread]
32  GeneralCallbackNetworkTreeNewInitializing = 19, // PPH_PLUGIN_TREENEW_INFORMATION Data [main thread]
33  GeneralCallbackModuleTreeNewInitializing = 20, // PPH_PLUGIN_TREENEW_INFORMATION Data [properties thread]
34  GeneralCallbackModuleTreeNewUninitializing = 21, // PPH_PLUGIN_TREENEW_INFORMATION Data [properties thread]
35  GeneralCallbackThreadTreeNewInitializing = 22, // PPH_PLUGIN_TREENEW_INFORMATION Data [properties thread]
36  GeneralCallbackThreadTreeNewUninitializing = 23, // PPH_PLUGIN_TREENEW_INFORMATION Data [properties thread]
37  GeneralCallbackHandleTreeNewInitializing = 24, // PPH_PLUGIN_TREENEW_INFORMATION Data [properties thread]
38  GeneralCallbackHandleTreeNewUninitializing = 25, // PPH_PLUGIN_TREENEW_INFORMATION Data [properties thread]
39  GeneralCallbackThreadStackControl = 26, // PPH_PLUGIN_THREAD_STACK_CONTROL Data [properties thread]
40  GeneralCallbackSystemInformationInitializing = 27, // PPH_PLUGIN_SYSINFO_POINTERS Data [system information thread]
41  GeneralCallbackMainWindowTabChanged = 28, // INT NewIndex [main thread]
42  GeneralCallbackMemoryTreeNewInitializing = 29, // PPH_PLUGIN_TREENEW_INFORMATION Data [properties thread]
43  GeneralCallbackMemoryTreeNewUninitializing = 30, // PPH_PLUGIN_TREENEW_INFORMATION Data [properties thread]
44  GeneralCallbackMemoryItemListControl = 31, // PPH_PLUGIN_MEMORY_ITEM_LIST_CONTROL Data [properties thread]
45  GeneralCallbackMiniInformationInitializing = 32, // PPH_PLUGIN_MINIINFO_POINTERS Data [main thread]
46  GeneralCallbackMiListSectionMenuInitializing = 33, // PPH_PLUGIN_MENU_INFORMATION Data [main thread]
49 
50 typedef enum _PH_PLUGIN_CALLBACK
51 {
52  PluginCallbackLoad = 0, // PPH_LIST Parameters [main thread] // list of strings, might be NULL
53  PluginCallbackUnload = 1, // [main thread]
54  PluginCallbackShowOptions = 2, // HWND ParentWindowHandle [main thread]
55  PluginCallbackMenuItem = 3, // PPH_PLUGIN_MENU_ITEM MenuItem [main/properties thread]
56  PluginCallbackTreeNewMessage = 4, // PPH_PLUGIN_TREENEW_MESSAGE Message [main/properties thread]
57  PluginCallbackPhSvcRequest = 5, // PPH_PLUGIN_PHSVC_REQUEST Message [phsvc thread]
58  PluginCallbackMenuHook = 6, // PH_PLUGIN_MENU_HOOK_INFORMATION MenuHookInfo [menu thread]
61 
63 {
64  // Parameter is:
65  // PPH_PROCESS_ITEM for GeneralCallbackGetProcessHighlightingColor
66 
67  PVOID Parameter;
68  COLORREF BackColor;
69  BOOLEAN Handled;
70  BOOLEAN Cache;
72 
74 {
75  // Parameter is:
76  // PPH_PROCESS_ITEM for GeneralCallbackGetProcessTooltipText
77 
78  PVOID Parameter;
80  ULONG ValidForMs;
82 
84 {
88 
90 {
91  // Parameter is:
92  // PPH_PROCESS_ITEM for Type = PH_NOTIFY_PROCESS_*
93  // PPH_SERVICE_ITEM for Type = PH_NOTIFY_SERVICE_*
94 
95  ULONG Type;
96  BOOLEAN Handled;
97  PVOID Parameter;
99 
101 {
102  // Parameter is:
103  // PPH_SERVICE_ITEM for GeneralCallbackServicePropertiesInitializing
104  // PPH_PLUGIN_HANDLE_PROPERTIES_CONTEXT for GeneralCallbackHandlePropertiesInitializing
105 
106  PVOID Parameter;
109  HPROPSHEETPAGE *Pages;
111 
113 {
114  HANDLE ProcessId;
117 
119 
120 #define PH_PLUGIN_MENU_DISALLOW_HOOKS 0x1
121 
123 {
124  PPH_EMENU Menu;
126 
127  union
128  {
129  struct
130  {
131  PVOID Reserved[8]; // Reserve space for future expansion of this union
132  } DoNotUse;
133  struct
134  {
136  } MainMenu;
137  struct
138  {
141  } Process;
142  struct
143  {
146  } Service;
147  struct
148  {
151  } Network;
152  struct
153  {
154  HANDLE ProcessId;
157  } Thread;
158  struct
159  {
160  HANDLE ProcessId;
163  } Module;
164  struct
165  {
166  HANDLE ProcessId;
169  } Memory;
170  struct
171  {
172  HANDLE ProcessId;
175  } Handle;
176  struct
177  {
180  } MiListSection;
181  } u;
182 
183  ULONG Flags;
186 
187 C_ASSERT(RTL_FIELD_SIZE(PH_PLUGIN_MENU_INFORMATION, u) == RTL_FIELD_SIZE(PH_PLUGIN_MENU_INFORMATION, u.DoNotUse));
188 
190 {
191  PPH_PLUGIN_MENU_INFORMATION MenuInfo;
192  PPH_EMENU SelectedItem;
193  PVOID Context;
194  BOOLEAN Handled;
196 
198 {
200  PVOID CmData;
201  PVOID SystemContext; // e.g. PPH_THREADS_CONTEXT
203 
205 {
215 
218 
219 typedef BOOLEAN (NTAPI *PPH_PLUGIN_WALK_THREAD_STACK_CALLBACK)(
220  _In_ PPH_THREAD_STACK_FRAME StackFrame,
221  _In_opt_ PVOID Context
222  );
223 
225 {
227  PVOID UniqueKey;
228 
229  union
230  {
231  struct
232  {
233  HANDLE ProcessId;
234  HANDLE ThreadId;
235  HANDLE ThreadHandle;
236  PPH_SYMBOL_PROVIDER SymbolProvider;
237  BOOLEAN CustomWalk;
238  } Initializing;
239  struct
240  {
241  PPH_THREAD_STACK_FRAME StackFrame;
243  } ResolveSymbol;
244  struct
245  {
246  PPH_THREAD_STACK_FRAME StackFrame;
248  } GetTooltip;
249  struct
250  {
251  NTSTATUS Status;
252  HANDLE ThreadHandle;
255  ULONG Flags;
258  } WalkStack;
259  } u;
261 
263 {
267 
269 {
271 
272  union
273  {
274  struct
275  {
277  } Initialized;
278  } u;
280 
282  _In_ PPH_SYSINFO_SECTION Template
283  );
284 
286  _In_ PPH_STRINGREF Name
287  );
288 
290  _In_ PPH_SYSINFO_SECTION NewSection
291  );
292 
294  VOID
295  );
296 
298 {
305 
307  _In_ PPH_MINIINFO_SECTION Template
308  );
309 
311  _In_ PPH_STRINGREF Name
312  );
313 
315  _In_ PWSTR Name,
316  _In_ ULONG Flags,
317  _In_ PPH_MINIINFO_LIST_SECTION Template
318  );
319 
321 {
327 
329 {
332  PVOID Parameter1;
333  PVOID Parameter2;
334  ULONG SubId;
335  PVOID Context;
337 
339  _In_ PVOID Node1,
340  _In_ PVOID Node2,
341  _In_ ULONG SubId,
342  _In_ PVOID Context
343  );
344 
345 typedef NTSTATUS (NTAPI *PPHSVC_SERVER_PROBE_BUFFER)(
346  _In_ PPH_RELATIVE_STRINGREF String,
347  _In_ ULONG Alignment,
348  _In_ BOOLEAN AllowNull,
349  _Out_ PVOID *Pointer
350  );
351 
352 typedef NTSTATUS (NTAPI *PPHSVC_SERVER_CAPTURE_BUFFER)(
353  _In_ PPH_RELATIVE_STRINGREF String,
354  _In_ BOOLEAN AllowNull,
355  _Out_ PVOID *CapturedBuffer
356  );
357 
358 typedef NTSTATUS (NTAPI *PPHSVC_SERVER_CAPTURE_STRING)(
359  _In_ PPH_RELATIVE_STRINGREF String,
360  _In_ BOOLEAN AllowNull,
361  _Out_ PPH_STRING *CapturedString
362  );
363 
365 {
366  ULONG SubId;
367  NTSTATUS ReturnStatus;
368  PVOID InBuffer;
369  ULONG InLength;
370  PVOID OutBuffer;
371  ULONG OutLength;
372 
377 
378 typedef VOID (NTAPI *PPHSVC_CLIENT_FREE_HEAP)(
379  _In_ PVOID Memory
380  );
381 
382 typedef PVOID (NTAPI *PPHSVC_CLIENT_CREATE_STRING)(
383  _In_opt_ PVOID String,
384  _In_ SIZE_T Length,
385  _Out_ PPH_RELATIVE_STRINGREF StringRef
386  );
387 
389 {
394 
395 // Plugin structures
396 
398 {
399  PWSTR DisplayName;
400  PWSTR Author;
401  PWSTR Description;
402  PWSTR Url;
403  BOOLEAN HasOptions;
404  BOOLEAN Reserved1[3];
405  PVOID Interface;
407 
408 #define PH_PLUGIN_FLAG_RESERVED 0x1
409 // end_phapppub
410 
411 // begin_phapppub
412 typedef struct _PH_PLUGIN
413 {
414  // Public
415 
417 
418  PVOID Reserved;
419  PVOID DllBase;
420 // end_phapppub
421 
422  // Private
423 
425  ULONG Flags;
428 
431 // begin_phapppub
433 // end_phapppub
434 
435 // begin_phapppub
436 // Plugin API
437 
438 PHAPPAPI
439 PPH_PLUGIN
440 NTAPI
442  _In_ PWSTR Name,
443  _In_ PVOID DllBase,
444  _Out_opt_ PPH_PLUGIN_INFORMATION *Information
445  );
446 
447 PHAPPAPI
448 PPH_PLUGIN
449 NTAPI
451  _In_ PWSTR Name
452  );
453 
454 PHAPPAPI
455 PPH_PLUGIN_INFORMATION
456 NTAPI
458  _In_ PPH_PLUGIN Plugin
459  );
460 
461 PHAPPAPI
463 NTAPI
465  _In_ PPH_PLUGIN Plugin,
466  _In_ PH_PLUGIN_CALLBACK Callback
467  );
468 
469 PHAPPAPI
471 NTAPI
473  _In_ PH_GENERAL_CALLBACK Callback
474  );
475 
476 PHAPPAPI
477 ULONG
478 NTAPI
480  _In_ ULONG Count
481  );
482 
484  _In_ struct _PH_PLUGIN_MENU_ITEM *MenuItem
485  );
486 
487 typedef struct _PH_PLUGIN_MENU_ITEM
488 {
489  PPH_PLUGIN Plugin;
490  ULONG Id;
491  ULONG Reserved1;
492  PVOID Context;
493 
494  HWND OwnerWindow; // valid only when the menu item is chosen
495  PVOID Reserved2;
496  PVOID Reserved3;
497  PPH_PLUGIN_MENU_ITEM_DELETE_FUNCTION DeleteFunction; // valid only for EMENU-based menu items
499 
500 // Location
501 #define PH_MENU_ITEM_LOCATION_VIEW 1
502 #define PH_MENU_ITEM_LOCATION_TOOLS 2
503 
504 // Id flags (non-functional)
505 #define PH_MENU_ITEM_SUB_MENU 0x80000000
506 #define PH_MENU_ITEM_RETURN_MENU 0x40000000
507 #define PH_MENU_ITEM_VALID_FLAGS 0xc0000000
508 
509 PHAPPAPI
510 ULONG_PTR
511 NTAPI
513  _In_ PPH_PLUGIN Plugin,
514  _In_ ULONG_PTR Location,
515  _In_opt_ PWSTR InsertAfter,
516  _In_ ULONG Id,
517  _In_ PWSTR Text,
518  _In_opt_ PVOID Context
519  );
520 
522 {
524 
528 
531 
535 
536  ULONG CommitPages;
538 
541 
542  PPH_CIRCULAR_BUFFER_FLOAT CpuKernelHistory;
543  PPH_CIRCULAR_BUFFER_FLOAT CpuUserHistory;
544  PPH_CIRCULAR_BUFFER_FLOAT *CpusKernelHistory;
545  PPH_CIRCULAR_BUFFER_FLOAT *CpusUserHistory;
546  PPH_CIRCULAR_BUFFER_ULONG64 IoReadHistory;
547  PPH_CIRCULAR_BUFFER_ULONG64 IoWriteHistory;
548  PPH_CIRCULAR_BUFFER_ULONG64 IoOtherHistory;
549  PPH_CIRCULAR_BUFFER_ULONG CommitHistory;
550  PPH_CIRCULAR_BUFFER_ULONG PhysicalHistory;
551  PPH_CIRCULAR_BUFFER_ULONG MaxCpuHistory; // ID of max. CPU process
552  PPH_CIRCULAR_BUFFER_ULONG MaxIoHistory; // ID of max. I/O process
553  PPH_CIRCULAR_BUFFER_FLOAT MaxCpuUsageHistory;
554  PPH_CIRCULAR_BUFFER_ULONG64 MaxIoReadOtherHistory;
555  PPH_CIRCULAR_BUFFER_ULONG64 MaxIoWriteHistory;
557 
558 PHAPPAPI
559 VOID
560 NTAPI
562  _Out_ PPH_PLUGIN_SYSTEM_STATISTICS Statistics
563  );
564 
565 PHAPPAPI
566 PPH_EMENU_ITEM
567 NTAPI
569  _In_ PPH_PLUGIN Plugin,
570  _In_ ULONG Flags,
571  _In_ ULONG Id,
572  _In_ PWSTR Text,
573  _In_opt_ PVOID Context
574  );
575 
576 PHAPPAPI
577 BOOLEAN
578 NTAPI
580  _Inout_ PPH_PLUGIN_MENU_INFORMATION MenuInfo,
581  _In_ PPH_PLUGIN Plugin,
582  _In_opt_ PVOID Context
583  );
584 // end_phapppub
585 
586 VOID
587 NTAPI
589  _Out_ PPH_PLUGIN_MENU_INFORMATION MenuInfo,
590  _In_opt_ PPH_EMENU Menu,
591  _In_ HWND OwnerWindow,
592  _In_ ULONG Flags
593  );
594 
595 BOOLEAN
596 NTAPI
598  _In_ PPH_PLUGIN_MENU_INFORMATION MenuInfo,
599  _In_ PPH_EMENU_ITEM Item
600  );
601 
602 // begin_phapppub
603 PHAPPAPI
604 BOOLEAN
605 NTAPI
607  _In_ PPH_PLUGIN Plugin,
608  _In_ PVOID CmData,
609  _In_ PPH_TREENEW_COLUMN Column,
610  _In_ ULONG SubId,
611  _In_opt_ PVOID Context,
612  _In_opt_ PPH_PLUGIN_TREENEW_SORT_FUNCTION SortFunction
613  );
614 
615 PHAPPAPI
616 VOID
617 NTAPI
619  _In_ PPH_PLUGIN Plugin,
620  _In_ PH_EM_OBJECT_TYPE ObjectType,
621  _In_ ULONG ExtensionSize,
622  _In_opt_ PPH_EM_OBJECT_CALLBACK CreateCallback,
623  _In_opt_ PPH_EM_OBJECT_CALLBACK DeleteCallback
624  );
625 
626 PHAPPAPI
627 PVOID
628 NTAPI
630  _In_ PPH_PLUGIN Plugin,
631  _In_ PVOID Object,
632  _In_ PH_EM_OBJECT_TYPE ObjectType
633  );
634 
635 PHAPPAPI
636 struct _PH_NF_ICON *
637 NTAPI
639  _In_ PPH_PLUGIN Plugin,
640  _In_ ULONG SubId,
641  _In_opt_ PVOID Context,
642  _In_ PWSTR Text,
643  _In_ ULONG Flags,
644  _In_ struct _PH_NF_ICON_REGISTRATION_DATA *RegistrationData
645  );
646 
647 PHAPPAPI
648 VOID
649 NTAPI
651  _In_ PPH_PLUGIN Plugin,
652  _In_ PVOID CmData
653  );
654 
655 PHAPPAPI
656 BOOLEAN
657 NTAPI
659  _Out_ PPH_PLUGIN_PHSVC_CLIENT Client
660  );
661 
662 PHAPPAPI
663 NTSTATUS
664 NTAPI
666  _In_ PPH_PLUGIN Plugin,
667  _In_ ULONG SubId,
668  _In_reads_bytes_opt_(InLength) PVOID InBuffer,
669  _In_ ULONG InLength,
670  _Out_writes_bytes_opt_(OutLength) PVOID OutBuffer,
671  _In_ ULONG OutLength
672  );
673 // end_phapppub
674 
675 #endif