mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
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:
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -989,6 +989,12 @@ namespace ProcessHacker
|
||||
TokenImpersonation
|
||||
}
|
||||
|
||||
public enum UipiFilterFlag : int
|
||||
{
|
||||
Add = 1,
|
||||
Remove = 2
|
||||
}
|
||||
|
||||
public enum UDP_TABLE_CLASS : int
|
||||
{
|
||||
UDP_TABLE_BASIC,
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user