Process Hacker
emenu.h File Reference

Go to the source code of this file.

Data Structures

struct  _PH_EMENU_ITEM
 
struct  _PH_EMENU_DATA
 

Macros

#define PH_EMENU_DISABLED   0x1
 
#define PH_EMENU_CHECKED   0x2
 
#define PH_EMENU_HIGHLIGHT   0x4
 
#define PH_EMENU_MENUBARBREAK   0x8
 
#define PH_EMENU_MENUBREAK   0x10
 
#define PH_EMENU_DEFAULT   0x20
 
#define PH_EMENU_MOUSESELECT   0x40
 
#define PH_EMENU_RADIOCHECK   0x80
 
#define PH_EMENU_SEPARATECHECKSPACE   0x100000
 
#define PH_EMENU_SEPARATOR   0x200000
 
#define PH_EMENU_TEXT_OWNED   0x80000000
 
#define PH_EMENU_BITMAP_OWNED   0x40000000
 
#define PH_EMENU_FIND_DESCEND   0x1
 
#define PH_EMENU_FIND_STARTSWITH   0x2
 
#define PH_EMENU_FIND_LITERAL   0x4
 
#define PH_EMENU_CONVERT_ID   0x1
 
#define PH_EMENU_SHOW_SEND_COMMAND   0x1
 
#define PH_EMENU_SHOW_LEFTRIGHT   0x2
 
#define PH_EMENU_MODIFY_TEXT   0x1
 
#define PH_EMENU_MODIFY_BITMAP   0x2
 

Typedefs

typedef struct _PH_EMENU_ITEM PH_EMENU_ITEM
 
typedef struct _PH_EMENU_ITEMPPH_EMENU_ITEM
 
typedef struct _PH_EMENU_ITEM PH_EMENU
 
typedef struct _PH_EMENU_ITEMPPH_EMENU
 
typedef struct _PH_EMENU_DATA PH_EMENU_DATA
 
typedef struct _PH_EMENU_DATAPPH_EMENU_DATA
 

Functions

typedef VOID (NTAPI *PPH_EMENU_ITEM_DELETE_FUNCTION)(_In_ struct _PH_EMENU_ITEM *Item)
 
PHLIBAPI PPH_EMENU_ITEM PhCreateEMenuItem (_In_ ULONG Flags, _In_ ULONG Id, _In_ PWSTR Text, _In_opt_ HBITMAP Bitmap, _In_opt_ PVOID Context)
 Creates a menu item.
 
PHLIBAPI VOID PhDestroyEMenuItem (_In_ PPH_EMENU_ITEM Item)
 Frees resources used by a menu item and its children.
 
PHLIBAPI PPH_EMENU_ITEM PhFindEMenuItem (_In_ PPH_EMENU_ITEM Item, _In_ ULONG Flags, _In_opt_ PWSTR Text, _In_opt_ ULONG Id)
 Finds a child menu item.
 
PPH_EMENU_ITEM PhFindEMenuItemEx (_In_ PPH_EMENU_ITEM Item, _In_ ULONG Flags, _In_opt_ PWSTR Text, _In_opt_ ULONG Id, _Out_opt_ PPH_EMENU_ITEM *FoundParent, _Out_opt_ PULONG FoundIndex)
 Finds a child menu item.
 
PHLIBAPI ULONG PhIndexOfEMenuItem (_In_ PPH_EMENU_ITEM Parent, _In_ PPH_EMENU_ITEM Item)
 Determines the index of a menu item.
 
PHLIBAPI VOID PhInsertEMenuItem (_Inout_ PPH_EMENU_ITEM Parent, _Inout_ PPH_EMENU_ITEM Item, _In_ ULONG Index)
 Inserts a menu item into a parent menu item.
 
PHLIBAPI BOOLEAN PhRemoveEMenuItem (_Inout_opt_ PPH_EMENU_ITEM Parent, _In_opt_ PPH_EMENU_ITEM Item, _In_opt_ ULONG Index)
 Removes a menu item from its parent.
 
PHLIBAPI VOID PhRemoveAllEMenuItems (_Inout_ PPH_EMENU_ITEM Parent)
 Removes all children from a menu item.
 
PHLIBAPI PPH_EMENU PhCreateEMenu (VOID)
 Creates a root menu.
 
PHLIBAPI VOID PhDestroyEMenu (_In_ PPH_EMENU Menu)
 Frees resources used by a root menu and its children.
 
VOID PhInitializeEMenuData (_Out_ PPH_EMENU_DATA Data)
 Initializes a data structure containing additional information resulting from a call to PhEMenuToHMenu().
 
VOID PhDeleteEMenuData (_Inout_ PPH_EMENU_DATA Data)
 Frees resources used by a data structure initialized by PhInitializeEMenuData().
 
HMENU PhEMenuToHMenu (_In_ PPH_EMENU_ITEM Menu, _In_ ULONG Flags, _Inout_opt_ PPH_EMENU_DATA Data)
 Converts an EMENU to a Windows menu object.
 
VOID PhEMenuToHMenu2 (_In_ HMENU MenuHandle, _In_ PPH_EMENU_ITEM Menu, _In_ ULONG Flags, _Inout_opt_ PPH_EMENU_DATA Data)
 Converts an EMENU to a Windows menu object.
 
VOID PhHMenuToEMenuItem (_Inout_ PPH_EMENU_ITEM MenuItem, _In_ HMENU MenuHandle)
 Converts a Windows menu object to an EMENU.
 
PHLIBAPI VOID PhLoadResourceEMenuItem (_Inout_ PPH_EMENU_ITEM MenuItem, _In_ HINSTANCE InstanceHandle, _In_ PWSTR Resource, _In_ ULONG SubMenuIndex)
 Loads a menu resource and converts it to an EMENU.
 
PHLIBAPI PPH_EMENU_ITEM PhShowEMenu (_In_ PPH_EMENU Menu, _In_ HWND WindowHandle, _In_ ULONG Flags, _In_ ULONG Align, _In_ ULONG X, _In_ ULONG Y)
 Displays a menu.
 
PHLIBAPI BOOLEAN PhSetFlagsEMenuItem (_Inout_ PPH_EMENU_ITEM Item, _In_ ULONG Id, _In_ ULONG Mask, _In_ ULONG Value)
 Sets the flags of a menu item.
 
FORCEINLINE BOOLEAN PhEnableEMenuItem (_Inout_ PPH_EMENU_ITEM Item, _In_ ULONG Id, _In_ BOOLEAN Enable)
 
PHLIBAPI VOID PhSetFlagsAllEMenuItems (_In_ PPH_EMENU_ITEM Item, _In_ ULONG Mask, _In_ ULONG Value)
 Sets flags for all children of a menu item.
 
PHLIBAPI VOID PhModifyEMenuItem (_Inout_ PPH_EMENU_ITEM Item, _In_ ULONG ModifyFlags, _In_ ULONG OwnedFlags, _In_opt_ PWSTR Text, _In_opt_ HBITMAP Bitmap)
 

Macro Definition Documentation

#define PH_EMENU_BITMAP_OWNED   0x40000000

Definition at line 17 of file emenu.h.

#define PH_EMENU_CHECKED   0x2

Definition at line 5 of file emenu.h.

#define PH_EMENU_CONVERT_ID   0x1

Definition at line 113 of file emenu.h.

#define PH_EMENU_DEFAULT   0x20

Definition at line 9 of file emenu.h.

#define PH_EMENU_DISABLED   0x1

Definition at line 4 of file emenu.h.

#define PH_EMENU_FIND_DESCEND   0x1

Definition at line 57 of file emenu.h.

#define PH_EMENU_FIND_LITERAL   0x4

Definition at line 59 of file emenu.h.

#define PH_EMENU_FIND_STARTSWITH   0x2

Definition at line 58 of file emenu.h.

#define PH_EMENU_HIGHLIGHT   0x4

Definition at line 6 of file emenu.h.

#define PH_EMENU_MENUBARBREAK   0x8

Definition at line 7 of file emenu.h.

#define PH_EMENU_MENUBREAK   0x10

Definition at line 8 of file emenu.h.

#define PH_EMENU_MODIFY_BITMAP   0x2

Definition at line 194 of file emenu.h.

#define PH_EMENU_MODIFY_TEXT   0x1

Definition at line 193 of file emenu.h.

#define PH_EMENU_MOUSESELECT   0x40

Definition at line 10 of file emenu.h.

#define PH_EMENU_RADIOCHECK   0x80

Definition at line 11 of file emenu.h.

#define PH_EMENU_SEPARATECHECKSPACE   0x100000

Definition at line 13 of file emenu.h.

#define PH_EMENU_SEPARATOR   0x200000

Definition at line 14 of file emenu.h.

#define PH_EMENU_SHOW_LEFTRIGHT   0x2

Definition at line 155 of file emenu.h.

#define PH_EMENU_SHOW_SEND_COMMAND   0x1

Definition at line 154 of file emenu.h.

#define PH_EMENU_TEXT_OWNED   0x80000000

Definition at line 16 of file emenu.h.

Typedef Documentation

typedef struct _PH_EMENU_ITEM PH_EMENU

Definition at line 41 of file emenu.h.

typedef struct _PH_EMENU_DATA PH_EMENU_DATA
typedef struct _PH_EMENU_ITEM PH_EMENU_ITEM
typedef struct _PH_EMENU_ITEM * PPH_EMENU

Definition at line 41 of file emenu.h.

typedef struct _PH_EMENU_DATA * PPH_EMENU_DATA
typedef struct _PH_EMENU_ITEM * PPH_EMENU_ITEM

Function Documentation

PHLIBAPI PPH_EMENU PhCreateEMenu ( VOID  )

Creates a root menu.

Definition at line 404 of file emenu.c.

PHLIBAPI PPH_EMENU_ITEM PhCreateEMenuItem ( _In_ ULONG  Flags,
_In_ ULONG  Id,
_In_ PWSTR  Text,
_In_opt_ HBITMAP  Bitmap,
_In_opt_ PVOID  Context 
)

Creates a menu item.

Parameters
FlagsA combination of the following:
  • PH_EMENU_DISABLED The menu item is greyed and cannot be selected.
  • PH_EMENU_CHECKED A check mark is displayed.
  • PH_EMENU_HIGHLIGHT The menu item is highlighted.
  • PH_EMENU_MENUBARBREAK Places the menu item in a new column, separated by a vertical line.
  • PH_EMENU_MENUBREAK Places the menu item in a new column, with no vertical line.
  • PH_EMENU_DEFAULT The menu item is displayed as the default item. This causes the text to be bolded.
  • PH_EMENU_RADIOCHECK Uses a radio-button mark instead of a check mark.
IdA unique identifier for the menu item.
TextThe text displayed for the menu item.
BitmapA bitmap image for the menu item.
ContextA user-defined value.

Definition at line 72 of file emenu.c.

VOID PhDeleteEMenuData ( _Inout_ PPH_EMENU_DATA  Data)

Frees resources used by a data structure initialized by PhInitializeEMenuData().

Definition at line 452 of file emenu.c.

PHLIBAPI VOID PhDestroyEMenu ( _In_ PPH_EMENU  Menu)

Frees resources used by a root menu and its children.

Parameters
MenuA root menu.

Definition at line 422 of file emenu.c.

PHLIBAPI VOID PhDestroyEMenuItem ( _In_ PPH_EMENU_ITEM  Item)

Frees resources used by a menu item and its children.

Parameters
ItemThe menu item.
Remarks
The menu item is automatically removed from its parent.

Definition at line 136 of file emenu.c.

HMENU PhEMenuToHMenu ( _In_ PPH_EMENU_ITEM  Menu,
_In_ ULONG  Flags,
_Inout_opt_ PPH_EMENU_DATA  Data 
)

Converts an EMENU to a Windows menu object.

Parameters
MenuThe menu item to convert.
FlagsA combination of the following:
  • PH_EMENU_CONVERT_ID Automatically assigns a unique identifier to each converted menu item. The resulting mappings are placed in Data.
DataAdditional data resulting from the conversion. The data structure must be initialized by PhInitializeEMenuData() prior to calling this function.
Returns
A menu handle. The menu object must be destroyed using DestroyMenu() when it is no longer needed.

Definition at line 474 of file emenu.c.

VOID PhEMenuToHMenu2 ( _In_ HMENU  MenuHandle,
_In_ PPH_EMENU_ITEM  Menu,
_In_ ULONG  Flags,
_Inout_opt_ PPH_EMENU_DATA  Data 
)

Converts an EMENU to a Windows menu object.

Parameters
MenuHandleA handle to a Windows menu object.
MenuThe menu item to convert. The items are appended to MenuHandle.
FlagsA combination of the following:
  • PH_EMENU_CONVERT_ID Automatically assigns a unique identifier to each converted menu item. The resulting mappings are placed in Data.
DataAdditional data resulting from the conversion. The data structure must be initialized by PhInitializeEMenuData() prior to calling this function.

Definition at line 517 of file emenu.c.

FORCEINLINE BOOLEAN PhEnableEMenuItem ( _Inout_ PPH_EMENU_ITEM  Item,
_In_ ULONG  Id,
_In_ BOOLEAN  Enable 
)

Definition at line 177 of file emenu.h.

PHLIBAPI PPH_EMENU_ITEM PhFindEMenuItem ( _In_ PPH_EMENU_ITEM  Item,
_In_ ULONG  Flags,
_In_opt_ PWSTR  Text,
_In_opt_ ULONG  Id 
)

Finds a child menu item.

Parameters
ItemThe parent menu item.
FlagsA combination of the following:
  • PH_EMENU_FIND_DESCEND Searches recursively within child menu items.
  • PH_EMENU_FIND_STARTSWITH Performs a partial text search instead of an exact search.
  • PH_EMENU_FIND_LITERAL Performs a literal search instead of ignoring prefix characters (ampersands).
TextThe text of the menu item to find. If NULL, the text is ignored.
IdThe identifier of the menu item to find. If 0, the identifier is ignored.
Returns
The found menu item, or NULL if the menu item could not be found.

Definition at line 166 of file emenu.c.

PPH_EMENU_ITEM PhFindEMenuItemEx ( _In_ PPH_EMENU_ITEM  Item,
_In_ ULONG  Flags,
_In_opt_ PWSTR  Text,
_In_opt_ ULONG  Id,
_Out_opt_ PPH_EMENU_ITEM FoundParent,
_Out_opt_ PULONG  FoundIndex 
)

Finds a child menu item.

Parameters
ItemThe parent menu item.
FlagsA combination of the following:
  • PH_EMENU_FIND_DESCEND Searches recursively within child menu items.
  • PH_EMENU_FIND_STARTSWITH Performs a partial text search instead of an exact search.
  • PH_EMENU_FIND_LITERAL Performs a literal search instead of ignoring prefix characters (ampersands).
TextThe text of the menu item to find. If NULL, the text is ignored.
IdThe identifier of the menu item to find. If 0, the identifier is ignored.
FoundParentA variable which receives the parent of the found menu item.
FoundIndexA variable which receives the index of the found menu item.
Returns
The found menu item, or NULL if the menu item could not be found.

Definition at line 199 of file emenu.c.

VOID PhHMenuToEMenuItem ( _Inout_ PPH_EMENU_ITEM  MenuItem,
_In_ HMENU  MenuHandle 
)

Converts a Windows menu object to an EMENU.

Parameters
MenuItemThe menu item in which the converted menu items will be placed.
MenuHandleA menu handle.

Definition at line 622 of file emenu.c.

PHLIBAPI ULONG PhIndexOfEMenuItem ( _In_ PPH_EMENU_ITEM  Parent,
_In_ PPH_EMENU_ITEM  Item 
)

Determines the index of a menu item.

Parameters
ParentThe parent menu item.
ItemThe child menu item.
Returns
The index of the menu item, or -1 if the menu item was not found in the parent menu item.

Definition at line 292 of file emenu.c.

VOID PhInitializeEMenuData ( _Out_ PPH_EMENU_DATA  Data)

Initializes a data structure containing additional information resulting from a call to PhEMenuToHMenu().

Definition at line 441 of file emenu.c.

PHLIBAPI VOID PhInsertEMenuItem ( _Inout_ PPH_EMENU_ITEM  Parent,
_Inout_ PPH_EMENU_ITEM  Item,
_In_ ULONG  Index 
)

Inserts a menu item into a parent menu item.

Parameters
ParentThe parent menu item.
ItemThe menu item to insert.
IndexThe index at which to insert the menu item. If the index is too large, the menu item is inserted at the last position.

Definition at line 312 of file emenu.c.

PHLIBAPI VOID PhLoadResourceEMenuItem ( _Inout_ PPH_EMENU_ITEM  MenuItem,
_In_ HINSTANCE  InstanceHandle,
_In_ PWSTR  Resource,
_In_ ULONG  SubMenuIndex 
)

Loads a menu resource and converts it to an EMENU.

Parameters
MenuItemThe menu item in which the converted menu items will be placed.
InstanceHandleThe module containing the menu resource.
ResourceThe resource identifier.
SubMenuIndexThe index of the sub menu to use, or -1 to use the root menu.

Definition at line 690 of file emenu.c.

PHLIBAPI VOID PhModifyEMenuItem ( _Inout_ PPH_EMENU_ITEM  Item,
_In_ ULONG  ModifyFlags,
_In_ ULONG  OwnedFlags,
_In_opt_ PWSTR  Text,
_In_opt_ HBITMAP  Bitmap 
)

Definition at line 855 of file emenu.c.

PHLIBAPI VOID PhRemoveAllEMenuItems ( _Inout_ PPH_EMENU_ITEM  Parent)

Removes all children from a menu item.

Parameters
ParentThe parent menu item.

Definition at line 384 of file emenu.c.

PHLIBAPI BOOLEAN PhRemoveEMenuItem ( _Inout_opt_ PPH_EMENU_ITEM  Parent,
_In_opt_ PPH_EMENU_ITEM  Item,
_In_opt_ ULONG  Index 
)

Removes a menu item from its parent.

Parameters
ParentThe parent menu item. If Item is NULL, this parameter must be specified.
ItemThe child menu item. This may be NULL if Index is specified.
IndexThe index of the menu item to remove. If Item is specified, this parameter is ignored.

Definition at line 346 of file emenu.c.

PHLIBAPI VOID PhSetFlagsAllEMenuItems ( _In_ PPH_EMENU_ITEM  Item,
_In_ ULONG  Mask,
_In_ ULONG  Value 
)

Sets flags for all children of a menu item.

Parameters
ItemThe parent menu item.
MaskThe flags to modify.
ValueThe new value of the flags.

Definition at line 838 of file emenu.c.

PHLIBAPI BOOLEAN PhSetFlagsEMenuItem ( _Inout_ PPH_EMENU_ITEM  Item,
_In_ ULONG  Id,
_In_ ULONG  Mask,
_In_ ULONG  Value 
)

Sets the flags of a menu item.

Parameters
ItemThe parent menu item.
IdThe identifier of the child menu item.
MaskThe flags to modify.
ValueThe new value of the flags.

Definition at line 807 of file emenu.c.

PHLIBAPI PPH_EMENU_ITEM PhShowEMenu ( _In_ PPH_EMENU  Menu,
_In_ HWND  WindowHandle,
_In_ ULONG  Flags,
_In_ ULONG  Align,
_In_ ULONG  X,
_In_ ULONG  Y 
)

Displays a menu.

Parameters
MenuA menu.
WindowHandleThe window that owns the popup menu.
FlagsA combination of the following:
  • PH_EMENU_SHOW_SEND_COMMAND A WM_COMMAND message is sent to the window when the user clicks on a menu item.
  • PH_EMENU_SHOW_LEFTRIGHT The user can select menu items with both the left and right mouse buttons.
AlignThe alignment of the menu.
XThe horizontal location of the menu.
YThe vertical location of the menu.
Returns
The selected menu item, or NULL if the menu was cancelled.

Definition at line 728 of file emenu.c.

typedef VOID ( NTAPI *  PPH_EMENU_ITEM_DELETE_FUNCTION)