Skip to content

Commit

Permalink
Add text trayicon support, Update View->Tray Icons menu
Browse files Browse the repository at this point in the history
  • Loading branch information
dmex committed Jan 19, 2018
1 parent 8348df1 commit 3f1572b
Show file tree
Hide file tree
Showing 17 changed files with 1,213 additions and 513 deletions.
1 change: 1 addition & 0 deletions ProcessHacker/ProcessHacker.def
Expand Up @@ -466,6 +466,7 @@ EXPORTS
; graph
PhDeleteGraphState
PhDrawGraphDirect
PhDrawTrayIconText
PhGetDrawInfoGraphBuffers
PhGraphStateGetDrawInfo
PhInitializeGraphState
Expand Down
9 changes: 1 addition & 8 deletions ProcessHacker/ProcessHacker.rc
Expand Up @@ -109,14 +109,7 @@ BEGIN
POPUP "&View"
BEGIN
MENUITEM "System &information\aCtrl+I", ID_VIEW_SYSTEMINFORMATION
POPUP "&Tray icons"
BEGIN
MENUITEM "CPU &history", ID_TRAYICONS_CPUHISTORY
MENUITEM "CPU &usage", ID_TRAYICONS_CPUUSAGE
MENUITEM "&I/O history", ID_TRAYICONS_IOHISTORY
MENUITEM "&Commit charge history", ID_TRAYICONS_COMMITHISTORY
MENUITEM "&Physical memory history", ID_TRAYICONS_PHYSICALMEMORYHISTORY
END
MENUITEM "&Tray icons", ID_VIEW_TRAYICONS
MENUITEM SEPARATOR
MENUITEM "<section placeholder>", ID_VIEW_SECTIONPLACEHOLDER
MENUITEM SEPARATOR
Expand Down
4 changes: 0 additions & 4 deletions ProcessHacker/include/mainwndp.h
Expand Up @@ -185,10 +185,6 @@ VOID PhMwpInitializeSubMenu(
_In_ ULONG Index
);

PPH_EMENU_ITEM PhMwpFindTrayIconsMenuItem(
_In_ PPH_EMENU Menu
);

VOID PhMwpInitializeSectionMenuItems(
_In_ PPH_EMENU Menu,
_In_ ULONG StartIndex
Expand Down
64 changes: 43 additions & 21 deletions ProcessHacker/include/notifico.h
@@ -1,14 +1,23 @@
#ifndef PH_NOTIFICO_H
#define PH_NOTIFICO_H

#define PH_ICON_MINIMUM 0x1
#define PH_ICON_CPU_HISTORY 0x1
#define PH_ICON_IO_HISTORY 0x2
#define PH_ICON_COMMIT_HISTORY 0x4
#define PH_ICON_PHYSICAL_HISTORY 0x8
#define PH_ICON_CPU_USAGE 0x10
#define PH_ICON_DEFAULT_MAXIMUM 0x20
#define PH_ICON_DEFAULT_ALL 0x1f
extern PPH_LIST PhTrayIconItemList;

typedef enum _PH_TRAY_ICON_ID
{
PH_TRAY_ICON_ID_NONE,
PH_TRAY_ICON_ID_CPU_USAGE,
PH_TRAY_ICON_ID_CPU_HISTORY,
PH_TRAY_ICON_ID_IO_HISTORY,
PH_TRAY_ICON_ID_COMMIT_HISTORY,
PH_TRAY_ICON_ID_PHYSICAL_HISTORY,
PH_TRAY_ICON_ID_CPU_TEXT,
PH_TRAY_ICON_ID_IO_TEXT,
PH_TRAY_ICON_ID_COMMIT_TEXT,
PH_TRAY_ICON_ID_PHYSICAL_TEXT
} PH_TRAY_ICON_ID;

#define PH_TRAY_ICON_ID_PLUGIN 0x80

#define PH_ICON_LIMIT 0x80000000
#define PH_ICON_ALL 0xffffffff
Expand All @@ -29,7 +38,6 @@ typedef VOID (NTAPI *PPH_NF_BEGIN_BITMAP)(

typedef struct _PH_NF_POINTERS
{
PPH_NF_UPDATE_REGISTERED_ICON UpdateRegisteredIcon;
PPH_NF_BEGIN_BITMAP BeginBitmap;
} PH_NF_POINTERS, *PPH_NF_POINTERS;

Expand Down Expand Up @@ -63,8 +71,9 @@ typedef struct _PH_NF_MSG_SHOWMINIINFOSECTION_DATA

// Structures and internal functions

#define PH_NF_ICON_UNAVAILABLE 0x1
#define PH_NF_ICON_SHOW_MINIINFO 0x2
#define PH_NF_ICON_ENABLED 0x1
#define PH_NF_ICON_UNAVAILABLE 0x2
#define PH_NF_ICON_NOSHOW_MINIINFO 0x4
// end_phapppub

// begin_phapppub
Expand All @@ -85,6 +94,9 @@ typedef struct _PH_NF_ICON
ULONG IconId;
PPH_NF_ICON_UPDATE_CALLBACK UpdateCallback;
PPH_NF_ICON_MESSAGE_CALLBACK MessageCallback;

PPH_STRING TextCache;

// begin_phapppub
} PH_NF_ICON, *PPH_NF_ICON;
// end_phapppub
Expand All @@ -110,16 +122,8 @@ VOID PhNfForwardMessage(
_In_ ULONG_PTR LParam
);

ULONG PhNfGetMaximumIconId(
VOID
);

ULONG PhNfTestIconMask(
_In_ ULONG Id
);

VOID PhNfSetVisibleIcon(
_In_ ULONG Id,
_In_ PPH_NF_ICON Icon,
_In_ BOOLEAN Visible
);

Expand All @@ -135,9 +139,18 @@ HICON PhNfBitmapToIcon(
_In_ HBITMAP Bitmap
);

struct _PH_NF_ICON *PhNfPluginRegisterIcon(
_In_ struct _PH_PLUGIN * Plugin,
_In_ ULONG SubId,
_In_opt_ PVOID Context,
_In_ PWSTR Text,
_In_ ULONG Flags,
_In_ struct _PH_NF_ICON_REGISTRATION_DATA *RegistrationData
);

PPH_NF_ICON PhNfRegisterIcon(
_In_ struct _PH_PLUGIN *Plugin,
_In_ ULONG SubId,
_In_ ULONG Id,
_In_opt_ PVOID Context,
_In_ PWSTR Text,
_In_ ULONG Flags,
Expand All @@ -154,6 +167,10 @@ PPH_NF_ICON PhNfFindIcon(
_In_ ULONG SubId
);

BOOLEAN PhNfIconsEnabled(
VOID
);

VOID PhNfNotifyMiniInfoPinned(
_In_ BOOLEAN Pinned
);
Expand All @@ -168,4 +185,9 @@ typedef struct _PH_NF_ICON_REGISTRATION_DATA
} PH_NF_ICON_REGISTRATION_DATA, *PPH_NF_ICON_REGISTRATION_DATA;
// end_phapppub


VOID PhShowTrayIconCustomizeDialog(
VOID
);

#endif
81 changes: 64 additions & 17 deletions ProcessHacker/include/notificop.h
Expand Up @@ -15,18 +15,18 @@ HICON PhNfpGetBlackIcon(
);

BOOLEAN PhNfpAddNotifyIcon(
_In_ ULONG Id
_In_ PPH_NF_ICON Icon
);

BOOLEAN PhNfpRemoveNotifyIcon(
_In_ ULONG Id
_In_ PPH_NF_ICON Icon
);

BOOLEAN PhNfpModifyNotifyIcon(
_In_ ULONG Id,
_In_ PPH_NF_ICON Icon,
_In_ ULONG Flags,
_In_opt_ PPH_STRING Text,
_In_opt_ HICON Icon
_In_opt_ HICON IconHandle
);

VOID PhNfpProcessesUpdatedHandler(
Expand Down Expand Up @@ -57,24 +57,71 @@ VOID PhNfpBeginBitmap2(
_Out_ HBITMAP *OldBitmap
);

VOID PhNfpUpdateIconCpuHistory(
VOID
VOID PhNfpCpuHistoryIconUpdateCallback(
_In_ struct _PH_NF_ICON *Icon,
_Out_ PVOID *NewIconOrBitmap,
_Out_ PULONG Flags,
_Out_ PPH_STRING *NewText,
_In_opt_ PVOID Context
);

VOID PhNfpUpdateIconIoHistory(
VOID
VOID PhNfpIoHistoryIconUpdateCallback(
_In_ struct _PH_NF_ICON *Icon,
_Out_ PVOID *NewIconOrBitmap,
_Out_ PULONG Flags,
_Out_ PPH_STRING *NewText,
_In_opt_ PVOID Context
);

VOID PhNfpUpdateIconCommitHistory(
VOID
VOID PhNfpCommitHistoryIconUpdateCallback(
_In_ struct _PH_NF_ICON *Icon,
_Out_ PVOID *NewIconOrBitmap,
_Out_ PULONG Flags,
_Out_ PPH_STRING *NewText,
_In_opt_ PVOID Context
);

VOID PhNfpUpdateIconPhysicalHistory(
VOID
VOID PhNfpPhysicalHistoryIconUpdateCallback(
_In_ struct _PH_NF_ICON *Icon,
_Out_ PVOID *NewIconOrBitmap,
_Out_ PULONG Flags,
_Out_ PPH_STRING *NewText,
_In_opt_ PVOID Context
);
VOID PhNfpCpuUsageIconUpdateCallback(
_In_ struct _PH_NF_ICON *Icon,
_Out_ PVOID *NewIconOrBitmap,
_Out_ PULONG Flags,
_Out_ PPH_STRING *NewText,
_In_opt_ PVOID Context
);

VOID PhNfpUpdateIconCpuUsage(
VOID
// Text icons

VOID PhNfpCpuUsageTextIconUpdateCallback(
_In_ struct _PH_NF_ICON *Icon,
_Out_ PVOID *NewIconOrBitmap,
_Out_ PULONG Flags,
_Out_ PPH_STRING *NewText,
_In_opt_ PVOID Context
);
VOID PhNfpIoUsageTextIconUpdateCallback(
_In_ struct _PH_NF_ICON *Icon,
_Out_ PVOID *NewIconOrBitmap,
_Out_ PULONG Flags,
_Out_ PPH_STRING *NewText,
_In_opt_ PVOID Context
);
VOID PhNfpCommitTextIconUpdateCallback(
_In_ struct _PH_NF_ICON *Icon,
_Out_ PVOID *NewIconOrBitmap,
_Out_ PULONG Flags,
_Out_ PPH_STRING *NewText,
_In_opt_ PVOID Context
);
VOID PhNfpPhysicalUsageTextIconUpdateCallback(
_In_ struct _PH_NF_ICON *Icon,
_Out_ PVOID *NewIconOrBitmap,
_Out_ PULONG Flags,
_Out_ PPH_STRING *NewText,
_In_opt_ PVOID Context
);

BOOLEAN PhNfpGetShowMiniInfoSectionData(
Expand Down
42 changes: 30 additions & 12 deletions ProcessHacker/include/phplug.h
Expand Up @@ -45,6 +45,7 @@ typedef enum _PH_GENERAL_CALLBACK
GeneralCallbackMiniInformationInitializing = 32, // PPH_PLUGIN_MINIINFO_POINTERS Data [main thread]
GeneralCallbackMiListSectionMenuInitializing = 33, // PPH_PLUGIN_MENU_INFORMATION Data [main thread]
GeneralCallbackOptionsWindowInitializing, // PPH_PLUGIN_OBJECT_PROPERTIES Data [main thread]
GeneralCallbackTrayIconsInitializing,
GeneralCallbackMaximum
} PH_GENERAL_CALLBACK, *PPH_GENERAL_CALLBACK;

Expand Down Expand Up @@ -327,6 +328,35 @@ typedef struct _PH_PLUGIN_MINIINFO_POINTERS
} PH_PLUGIN_MINIINFO_POINTERS, *PPH_PLUGIN_MINIINFO_POINTERS;
// end_phapppub

// begin_phapppub
/**
* Creates a notification icon.
*
* \param Plugin A plugin instance structure.
* \param SubId An identifier for the column. This should be unique within the
* plugin.
* \param Context A user-defined value.
* \param Text A string describing the notification icon.
* \param Flags A combination of flags.
* \li \c PH_NF_ICON_UNAVAILABLE The notification icon is currently unavailable.
* \param RegistrationData A \ref PH_NF_ICON_REGISTRATION_DATA structure that
* contains registration information.
*/
typedef struct _PH_NF_ICON * (NTAPI *PPH_REGISTER_TRAY_ICON)(
_In_ struct _PH_PLUGIN * Plugin,
_In_ ULONG SubId,
_In_opt_ PVOID Context,
_In_ PWSTR Text,
_In_ ULONG Flags,
_In_ struct _PH_NF_ICON_REGISTRATION_DATA *RegistrationData
);

typedef struct _PH_TRAY_ICON_POINTERS
{
PPH_REGISTER_TRAY_ICON RegisterTrayIcon;
} PH_TRAY_ICON_POINTERS, *PPH_TRAY_ICON_POINTERS;
// end_phapppub

// begin_phapppub
typedef struct _PH_OPTIONS_SECTION
{
Expand Down Expand Up @@ -661,18 +691,6 @@ PhPluginGetObjectExtension(
_In_ PH_EM_OBJECT_TYPE ObjectType
);

PHAPPAPI
struct _PH_NF_ICON *
NTAPI
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
);

PHAPPAPI
VOID
NTAPI
Expand Down

0 comments on commit 3f1572b

Please sign in to comment.