diff --git a/trunk/CHANGELOG.txt b/trunk/CHANGELOG.txt
index 1887af7bd..48589ae97 100644
--- a/trunk/CHANGELOG.txt
+++ b/trunk/CHANGELOG.txt
@@ -2,8 +2,10 @@ Process Hacker
1.3.2.5
* NEW:
+ * Process termination now uses KProcessHacker
* CSR Processes tool - displays hidden processes (this does not detect Hacker
Defender but does detect simple kernel-mode rootkits)
+ * Processes list in the notification icon menu, for quick actions on processes
* Options window has a detailed description for each setting
* Process window has descriptions for each field
* File processing (signature verification, checks for packed images) is now
@@ -11,7 +13,6 @@ Process Hacker
certain programs.
* Slightly different notification icon
* GDI and USER handle counts
- * Process termination now uses KProcessHacker
* FIXED:
* Disables "Show one graph per CPU" if there is only one CPU
* Process tree weirdness for users with limited privileges
diff --git a/trunk/ProcessHacker/Components/ProcessTree/ProcessNode.cs b/trunk/ProcessHacker/Components/ProcessTree/ProcessNode.cs
index 35dad3917..36a9fc685 100644
--- a/trunk/ProcessHacker/Components/ProcessTree/ProcessNode.cs
+++ b/trunk/ProcessHacker/Components/ProcessTree/ProcessNode.cs
@@ -20,13 +20,14 @@
* along with Process Hacker. If not, see .
*/
+using System;
using System.Collections.Generic;
using System.Drawing;
using Aga.Controls.Tree;
namespace ProcessHacker
{
- public class ProcessNode : Node
+ public class ProcessNode : Node, IDisposable
{
private List _children = new List();
private ProcessItem _pitem;
@@ -49,6 +50,12 @@ namespace ProcessHacker
}
}
+ public void Dispose()
+ {
+ if (_icon != null)
+ _icon.Dispose();
+ }
+
public ProcessItem ProcessItem
{
get { return _pitem; }
@@ -58,7 +65,14 @@ namespace ProcessHacker
if (_wasNoIcon && _pitem.Icon != null)
{
- _icon = _pitem.Icon.ToBitmap();
+ if (_icon != null)
+ _icon.Dispose();
+
+ _icon = new Bitmap(16, 16);
+
+ using (Graphics g = Graphics.FromImage(_icon))
+ g.DrawIcon(_pitem.Icon, new Rectangle(0, 0, 16, 16));
+
_wasNoIcon = false;
}
}
diff --git a/trunk/ProcessHacker/Components/ProcessTree/ProcessTreeModel.cs b/trunk/ProcessHacker/Components/ProcessTree/ProcessTreeModel.cs
index f690d1fc0..f079a0d39 100644
--- a/trunk/ProcessHacker/Components/ProcessTree/ProcessTreeModel.cs
+++ b/trunk/ProcessHacker/Components/ProcessTree/ProcessTreeModel.cs
@@ -83,6 +83,8 @@ namespace ProcessHacker
ProcessNode[] nodes = _roots.ToArray();
ProcessNode[] targetChildren = null;
+ targetNode.Dispose();
+
foreach (ProcessNode node in nodes)
{
if (node.PID == item.PID)
diff --git a/trunk/ProcessHacker/Components/VistaMenu/OwnerDrawnMenu.cs b/trunk/ProcessHacker/Components/VistaMenu/OwnerDrawnMenu.cs
index 6c0cd3ecf..9127584c2 100644
--- a/trunk/ProcessHacker/Components/VistaMenu/OwnerDrawnMenu.cs
+++ b/trunk/ProcessHacker/Components/VistaMenu/OwnerDrawnMenu.cs
@@ -1,35 +1,35 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.ComponentModel;
-using System.Windows.Forms;
-using System.Drawing;
-using System.Runtime.InteropServices;
using System.ComponentModel.Design;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
namespace wyDay.Controls
{
- public partial class VistaMenu : System.ComponentModel.Component, IExtenderProvider, ISupportInitialize
+ public partial class VistaMenu
{
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
private static extern int SendMessage(HandleRef hWnd, int Msg, IntPtr wParam, IntPtr lParam);
- ContainerControl ownerForm = null;
+ ContainerControl ownerForm;
//conditionally draw the little lines under menu items with keyboard accelators on Win 2000+
- private bool isUsingKeyboardAccel = false;
+ private bool isUsingKeyboardAccel;
public VistaMenu(ContainerControl parentControl)
: this()
{
- this.ownerForm = parentControl;
+ ownerForm = parentControl;
}
public ContainerControl ContainerControl
{
- get { return this.ownerForm; }
- set { this.ownerForm = value; }
+ get { return ownerForm; }
+ set { ownerForm = value; }
}
public override ISite Site
{
@@ -41,7 +41,7 @@ namespace wyDay.Controls
IDesignerHost service = value.GetService(typeof(IDesignerHost)) as IDesignerHost;
if (service == null) return;
IComponent rootComponent = service.RootComponent;
- this.ContainerControl = rootComponent as ContainerControl;
+ ContainerControl = rootComponent as ContainerControl;
}
}
@@ -58,7 +58,7 @@ namespace wyDay.Controls
//#define WM_QUERYUISTATE 0x0129
//int ret = SendMessage(new HandleRef(((Menu)sender).GetMainMenu().GetForm(), ((Menu)sender).GetMainMenu().GetForm().Handle), 0x0129, IntPtr.Zero, IntPtr.Zero);
int ret = SendMessage(new HandleRef(ownerForm, ownerForm.Handle), 0x0129, IntPtr.Zero, IntPtr.Zero);
-
+
/*
The return value is NULL if the focus indicators and the keyboard accelerators are visible.
@@ -71,15 +71,12 @@ namespace wyDay.Controls
//#define UISF_HIDEACCEL 0x2
- if ((ret & 0x2) != 0)
- isUsingKeyboardAccel = false;
- else
- isUsingKeyboardAccel = true;
+ isUsingKeyboardAccel = (ret & 0x2) == 0;
}
- const int SEPARATOR_HEIGHT = 8;
- const int BORDER_VERTICAL = 2;
+ const int SEPARATOR_HEIGHT = 9;
+ const int BORDER_VERTICAL = 4;
const int LEFT_MARGIN = 4;
const int RIGHT_MARGIN = 6;
const int SHORTCUT_MARGIN = 20;
@@ -87,52 +84,52 @@ namespace wyDay.Controls
const int ICON_SIZE = 16;
- void MenuItem_MeasureItem(object sender, MeasureItemEventArgs e)
+ static void MenuItem_MeasureItem(object sender, MeasureItemEventArgs e)
{
+ Font font = ((MenuItem)sender).DefaultItem
+ ? new Font(SystemFonts.MenuFont, FontStyle.Bold)
+ : SystemFonts.MenuFont;
+
if (((MenuItem)sender).Text == "-")
e.ItemHeight = SEPARATOR_HEIGHT;
else
{
- e.ItemHeight = (SystemFonts.MenuFont.Height > ICON_SIZE) ? SystemFonts.MenuFont.Height : ICON_SIZE;
- e.ItemHeight += BORDER_VERTICAL;
+ e.ItemHeight = ((SystemFonts.MenuFont.Height > ICON_SIZE) ? SystemFonts.MenuFont.Height : ICON_SIZE)
+ + BORDER_VERTICAL;
+
+ e.ItemWidth = LEFT_MARGIN + ICON_SIZE + RIGHT_MARGIN
+
+ //item text width
+ + TextRenderer.MeasureText(((MenuItem)sender).Text, font, new Size(0, 0), TextFormatFlags.SingleLine).Width
+ + SHORTCUT_MARGIN
+
+ //shortcut text width
+ + TextRenderer.MeasureText(ShortcutToString(((MenuItem)sender).Shortcut), font, new Size(0, 0), TextFormatFlags.SingleLine).Width
+
+ //arrow width
+ + ((((MenuItem)sender).IsParent) ? ARROW_MARGIN : 0);
}
-
- e.ItemWidth = LEFT_MARGIN + ICON_SIZE + RIGHT_MARGIN
-
- //item text width
- //edit by wj32 - fix for default items on XP
- + ((((MenuItem)sender).DefaultItem) ? (
- TextRenderer.MeasureText(((MenuItem)sender).Text,
- new Font(SystemFonts.MenuFont, FontStyle.Bold), new Size(0, 0), TextFormatFlags.SingleLine).Width
- ) : (
- TextRenderer.MeasureText(((MenuItem)sender).Text, SystemFonts.MenuFont, new Size(0, 0), TextFormatFlags.SingleLine).Width
- ))
- + SHORTCUT_MARGIN
-
- //shortcut text width
- + TextRenderer.MeasureText(ShortcutToString(((MenuItem)sender).Shortcut), SystemFonts.MenuFont, new Size(0, 0), TextFormatFlags.SingleLine).Width
-
- //arrow width
- + ((((MenuItem)sender).IsParent) ? ARROW_MARGIN : 0);
}
void MenuItem_DrawItem(object sender, DrawItemEventArgs e)
{
- //MenuItem menuItem = (MenuItem)sender;
- //MenuHelper menuHelper = new MenuHelper(menuItem, e.Graphics, this);
+ e.Graphics.CompositingQuality = CompositingQuality.HighSpeed;
+ e.Graphics.InterpolationMode = InterpolationMode.Low;
+
bool menuSelected = (e.State & DrawItemState.Selected) == DrawItemState.Selected;
if (menuSelected)
e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
else
e.Graphics.FillRectangle(SystemBrushes.Menu, e.Bounds);
-
+
if (((MenuItem)sender).Text == "-")
{
//draw the separator
- int yCenter = e.Bounds.Top + (e.Bounds.Height / 2);
+ int yCenter = e.Bounds.Top + (e.Bounds.Height / 2) - 1;
- e.Graphics.DrawLine(SystemPens.ControlDark, e.Bounds.Left, yCenter, (e.Bounds.Left + e.Bounds.Width), yCenter);
+ e.Graphics.DrawLine(SystemPens.ControlDark, e.Bounds.Left + 1, yCenter, (e.Bounds.Left + e.Bounds.Width - 2), yCenter);
+ e.Graphics.DrawLine(SystemPens.ControlLightLight, e.Bounds.Left + 1, yCenter + 1, (e.Bounds.Left + e.Bounds.Width - 2), yCenter + 1);
}
else //regular menu items
{
@@ -188,12 +185,12 @@ namespace wyDay.Controls
}
- private string ShortcutToString(Shortcut shortcut)
+ private static string ShortcutToString(Shortcut shortcut)
{
if (shortcut != Shortcut.None)
{
Keys keys = (Keys)shortcut;
- return System.ComponentModel.TypeDescriptor.GetConverter(keys.GetType()).ConvertToString(keys);
+ return TypeDescriptor.GetConverter(keys.GetType()).ConvertToString(keys);
}
return null;
@@ -204,46 +201,55 @@ namespace wyDay.Controls
string shortcutText = ShortcutToString(((MenuItem)sender).Shortcut);
int yPos = e.Bounds.Top + (e.Bounds.Height - SystemFonts.MenuFont.Height) / 2;
- Size textSize;
- // fixed by wj32 for DefaultItems on XP
- textSize = (((MenuItem)sender).DefaultItem) ? (
- TextRenderer.MeasureText(((MenuItem)sender).Text,
- new Font(SystemFonts.MenuFont, FontStyle.Bold), new Size(0, 0), TextFormatFlags.SingleLine)) :
- TextRenderer.MeasureText(((MenuItem)sender).Text, SystemFonts.MenuFont, new Size(0, 0), TextFormatFlags.SingleLine);
+ Size textSize = TextRenderer.MeasureText(((MenuItem)sender).Text, e.Font, new Size(0, 0), TextFormatFlags.SingleLine);
+
+ Rectangle textRect = new Rectangle(e.Bounds.Left + LEFT_MARGIN + ICON_SIZE + RIGHT_MARGIN, yPos,
+ textSize.Width, textSize.Height);
+
+ if (!((MenuItem)sender).Enabled && !isSelected) // disabled and not selected
+ {
+ textRect.Offset(1, 1);
+
+ TextRenderer.DrawText(e.Graphics, ((MenuItem)sender).Text, e.Font,
+ textRect,
+ SystemColors.ControlLightLight,
+ TextFormatFlags.SingleLine | (isUsingKeyboardAccel ? 0 : TextFormatFlags.HidePrefix));
+
+ textRect.Offset(-1, -1);
+ }
//Draw the menu item text
- if (((MenuItem)sender).Enabled)
- {
- TextRenderer.DrawText(e.Graphics, ((MenuItem)sender).Text, SystemFonts.MenuFont,
- new Rectangle(e.Bounds.Left + LEFT_MARGIN + ICON_SIZE + RIGHT_MARGIN, yPos, textSize.Width, textSize.Height),
- isSelected ? SystemColors.HighlightText : SystemColors.MenuText,
- TextFormatFlags.SingleLine | (isUsingKeyboardAccel ? 0 : TextFormatFlags.HidePrefix));
- }
- else
- {
- ControlPaint.DrawStringDisabled(e.Graphics, ((MenuItem)sender).Text, SystemFonts.MenuFont, isSelected ? SystemColors.Highlight : SystemColors.Menu,
- new Rectangle(e.Bounds.Left + LEFT_MARGIN + ICON_SIZE + RIGHT_MARGIN, yPos, textSize.Width, textSize.Height),
- TextFormatFlags.SingleLine | (isUsingKeyboardAccel ? 0 : TextFormatFlags.HidePrefix));
- }
+ TextRenderer.DrawText(e.Graphics, ((MenuItem)sender).Text, e.Font,
+ textRect,
+ ((MenuItem)sender).Enabled ? (isSelected ? SystemColors.HighlightText : SystemColors.MenuText) : SystemColors.GrayText,
+ TextFormatFlags.SingleLine | (isUsingKeyboardAccel ? 0 : TextFormatFlags.HidePrefix));
+
+
//Draw the shortcut text
if (shortcutText != null)
{
- textSize = TextRenderer.MeasureText(shortcutText, SystemFonts.MenuFont, Size.Empty, TextFormatFlags.SingleLine);
+ textSize = TextRenderer.MeasureText(shortcutText, e.Font, Size.Empty, TextFormatFlags.SingleLine);
+ textRect = new Rectangle(e.Bounds.Width - textSize.Width - ARROW_MARGIN, yPos, textSize.Width,
+ textSize.Height);
- if (((MenuItem)sender).Enabled)
+ if (!((MenuItem)sender).Enabled && !isSelected) // disabled and not selected
{
- TextRenderer.DrawText(e.Graphics, shortcutText, SystemFonts.MenuFont,
- new Rectangle(e.Bounds.Width - textSize.Width - ARROW_MARGIN, yPos, textSize.Width, textSize.Height),
- isSelected ? SystemColors.HighlightText : SystemColors.MenuText,
- TextFormatFlags.SingleLine);
- }
- else
- {
- ControlPaint.DrawStringDisabled(e.Graphics, shortcutText, SystemFonts.MenuFont, isSelected ? SystemColors.Highlight : SystemColors.Menu,
- new Rectangle(e.Bounds.Width - textSize.Width - ARROW_MARGIN, yPos, textSize.Width, textSize.Height), TextFormatFlags.SingleLine);
+ textRect.Offset(1, 1);
+
+ TextRenderer.DrawText(e.Graphics, shortcutText, e.Font,
+ textRect,
+ SystemColors.ControlLightLight,
+ TextFormatFlags.SingleLine | (isUsingKeyboardAccel ? 0 : TextFormatFlags.HidePrefix));
+
+ textRect.Offset(-1, -1);
}
+
+ TextRenderer.DrawText(e.Graphics, shortcutText, e.Font,
+ textRect,
+ ((MenuItem)sender).Enabled ? (isSelected ? SystemColors.HighlightText : SystemColors.MenuText) : SystemColors.GrayText,
+ TextFormatFlags.SingleLine);
}
}
}
diff --git a/trunk/ProcessHacker/Components/VistaMenu/VistaMenu.cs b/trunk/ProcessHacker/Components/VistaMenu/VistaMenu.cs
index d2c8990f0..b58928a93 100644
--- a/trunk/ProcessHacker/Components/VistaMenu/VistaMenu.cs
+++ b/trunk/ProcessHacker/Components/VistaMenu/VistaMenu.cs
@@ -2,33 +2,38 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
-using System.ComponentModel.Design;
-using System.Diagnostics;
using System.Drawing;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
-//VistaMenu 1.1, created by Wyatt O'Day
-//Visit: http://wyday.com/blog/2008/vista-menu-with-icons-in-c-sharp/
+//VistaMenu v1.2, created by Wyatt O'Day
+//Visit: http://wyday.com/vistamenu/
namespace wyDay.Controls
{
- [ProvideProperty("Image", typeof(MenuItem))]
- public partial class VistaMenu : System.ComponentModel.Component, IExtenderProvider, ISupportInitialize
+ //Properties for the MenuItem
+ internal class Properties
{
- private IContainer components = null;
- private Hashtable properties = new Hashtable();
- private Hashtable menuParents = new Hashtable();
+ public Image Image;
+ public IntPtr renderBmpHbitmap = IntPtr.Zero;
+ }
- private bool formHasBeenIntialized = false;
- private bool isVistaOrLater = false;
+ //enum WindowsType { VistaOrLater, XP, PreXP }
+
+ [ProvideProperty("Image", typeof(MenuItem))]
+ public partial class VistaMenu : Component, IExtenderProvider, ISupportInitialize
+ {
+ private Container components;
+ private readonly Hashtable properties = new Hashtable();
+ private readonly Hashtable menuParents = new Hashtable();
+
+ private bool formHasBeenIntialized;
+ private bool isVistaOrLater;
#region Imports
- public const int MIIM_BITMAP = 0x00000080;
-
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool SetMenuItemInfo(HandleRef hMenu, int uItem, bool fByPosition, MENUITEMINFO_T_RW lpmii);
@@ -48,7 +53,7 @@ namespace wyDay.Controls
InitializeComponent();
}
- public VistaMenu(System.ComponentModel.IContainer container)
+ public VistaMenu(IContainer container)
: this()
{
container.Add(this);
@@ -60,7 +65,7 @@ namespace wyDay.Controls
///
private void InitializeComponent()
{
-
+ components = new Container();
}
///
@@ -88,10 +93,20 @@ namespace wyDay.Controls
bool IExtenderProvider.CanExtend(object o)
{
- if (o is MenuItem || o is Form)
+ if (o is MenuItem)
+ {
+ // reject the menuitem if it's a top level element on a MainMenu bar
+ if (((MenuItem)o).Parent != null)
+ return ((MenuItem)o).Parent.GetType() != typeof(MainMenu);
+
+ // parent is null - meaning it's a context menu
return true;
- else
- return false;
+ }
+
+ if (o is Form)
+ return true;
+
+ return false;
}
private Properties EnsurePropertiesExists(MenuItem key)
@@ -111,7 +126,7 @@ namespace wyDay.Controls
#region MenuItem.Image
-
+ [DefaultValue(null)]
[Description("The Image for the MenuItem")]
[Category("Appearance")]
public Image GetImage(MenuItem mnuItem)
@@ -119,12 +134,12 @@ namespace wyDay.Controls
return EnsurePropertiesExists(mnuItem).Image;
}
+ [DefaultValue(null)]
public void SetImage(MenuItem mnuItem, Image value)
{
Properties prop = EnsurePropertiesExists(mnuItem);
-
- prop.Image = value;
+ prop.Image = value;
if (!DesignMode && isVistaOrLater)
{
@@ -163,21 +178,6 @@ namespace wyDay.Controls
}
}
- private bool ShouldSerializeImage(MenuItem mnuItem)
- {
- if (GetImage(mnuItem) != null)
- return true;
- else
- return false;
- }
-
- private void ResetImage(MenuItem mnuItem)
- {
- SetImage(mnuItem, null);
- }
-
-
-
#endregion
@@ -186,7 +186,7 @@ namespace wyDay.Controls
{
}
- MENUINFO mnuInfo = new MENUINFO();
+ readonly MENUINFO mnuInfo = new MENUINFO();
void AddVistaMenuItem(MenuItem mnuItem)
{
@@ -197,17 +197,15 @@ namespace wyDay.Controls
if (mnuBitmapChildren == null)
{
if (mnuItem.Parent.GetType() == typeof(ContextMenu))
- ((ContextMenu)mnuItem.Parent).Popup += new EventHandler(MenuItem_Popup);
+ ((ContextMenu)mnuItem.Parent).Popup += MenuItem_Popup;
else
- ((MenuItem)mnuItem.Parent).Popup += new EventHandler(MenuItem_Popup);
+ ((MenuItem)mnuItem.Parent).Popup += MenuItem_Popup;
//intialize all the topmost menus to be of type "MNS_CHECKORBMP" (for Vista classic theme)
SetMenuInfo(new HandleRef(null, mnuItem.Parent.Handle), mnuInfo);
- mnuBitmapChildren = new List