fixed Allow only one instance to work even if PH is running elevated

git-svn-id: svn://svn.code.sf.net/p/processhacker/code@792 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
wj32
2009-03-01 03:48:08 +00:00
parent 63ae8290f5
commit 72ea054dc1
5 changed files with 29 additions and 7 deletions
+10
View File
@@ -2338,6 +2338,16 @@ namespace ProcessHacker
}
catch
{ }
// If it's Vista and we're elevated, we should allow certain window message to allow
// Allow only one instance to work.
if (Program.WindowsVersion == "Vista" &&
Program.ElevationType == Win32.TOKEN_ELEVATION_TYPE.TokenElevationTypeFull)
{
Win32.ChangeWindowMessageFilter(Win32.WindowMessage.ShowWindow, Win32.UipiFilterFlag.Add);
Win32.ChangeWindowMessageFilter(Win32.WindowMessage.SysCommand, Win32.UipiFilterFlag.Add);
Win32.ChangeWindowMessageFilter((Win32.WindowMessage)0x9991, Win32.UipiFilterFlag.Add);
}
}
private void HackerWindow_Load(object sender, EventArgs e)
+1 -1
View File
@@ -15,7 +15,7 @@
<ApplicationIcon>ProcessHacker.ico</ApplicationIcon>
<StartupObject>ProcessHacker.Program</StartupObject>
<ApplicationManifest>app.manifest</ApplicationManifest>
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
+2 -2
View File
@@ -264,8 +264,8 @@ namespace ProcessHacker
if (Win32.SendMessage(hWnd, (Win32.WindowMessage)0x9991, IntPtr.Zero, IntPtr.Zero).ToInt32() ==
0x1119)
{
Win32.ShowWindow(hWnd, Win32.ShowWindowType.Restore);
Win32.ShowWindow(hWnd, Win32.ShowWindowType.Show);
Win32.SendMessage(hWnd, Win32.WindowMessage.SysCommand, new IntPtr(0xf120), IntPtr.Zero);
Win32.SendMessage(hWnd, Win32.WindowMessage.ShowWindow, IntPtr.Zero, IntPtr.Zero);
Win32.SetForegroundWindow(hWnd);
found = true;
return false;
+6
View File
@@ -989,6 +989,12 @@ namespace ProcessHacker
TokenImpersonation
}
public enum UipiFilterFlag : int
{
Add = 1,
Remove = 2
}
public enum UDP_TABLE_CLASS : int
{
UDP_TABLE_BASIC,
+10 -4
View File
@@ -1,4 +1,4 @@
/*
/*
* Process Hacker -
* windows API functions
*
@@ -875,6 +875,15 @@ namespace ProcessHacker
#region Windows
[DllImport("user32.dll")]
public static extern bool ChangeWindowMessageFilter(WindowMessage message, UipiFilterFlag flag);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr windowHandle, WindowMessage msg, IntPtr w, IntPtr l);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr PostMessage(IntPtr windowHandle, WindowMessage msg, IntPtr w, IntPtr l);
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
@@ -996,9 +1005,6 @@ namespace ProcessHacker
public static extern bool AdjustWindowRect(ref System.Drawing.Rectangle rect, WindowStyles style,
[MarshalAs(UnmanagedType.Bool)]bool menu);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr windowHandle, WindowMessage msg, IntPtr w, IntPtr l);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr RegisterClass(ref WindowClass wndClass);