Skip to content

Commit d3ee123

Browse files
committed
Fix single instance regression when application minimized
1 parent aacc84e commit d3ee123

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

ProcessHacker/appsup.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* application support functions
44
*
55
* Copyright (C) 2010-2016 wj32
6+
* Copyright (C) 2017 dmex
67
*
78
* This file is part of Process Hacker.
89
*
@@ -723,6 +724,7 @@ typedef struct _GET_PROCESS_MAIN_WINDOW_CONTEXT
723724
HWND ImmersiveWindow;
724725
HANDLE ProcessId;
725726
BOOLEAN IsImmersive;
727+
BOOLEAN SkipInvisible;
726728
} GET_PROCESS_MAIN_WINDOW_CONTEXT, *PGET_PROCESS_MAIN_WINDOW_CONTEXT;
727729

728730
BOOL CALLBACK PhpGetProcessMainWindowEnumWindowsProc(
@@ -735,7 +737,7 @@ BOOL CALLBACK PhpGetProcessMainWindowEnumWindowsProc(
735737
HWND parentWindow;
736738
WINDOWINFO windowInfo;
737739

738-
if (!IsWindowVisible(hwnd))
740+
if (context->SkipInvisible && !IsWindowVisible(hwnd))
739741
return TRUE;
740742

741743
GetWindowThreadProcessId(hwnd, &processId);
@@ -769,12 +771,22 @@ HWND PhGetProcessMainWindow(
769771
_In_ HANDLE ProcessId,
770772
_In_opt_ HANDLE ProcessHandle
771773
)
774+
{
775+
return PhGetProcessMainWindowEx(ProcessId, ProcessHandle, TRUE);
776+
}
777+
778+
HWND PhGetProcessMainWindowEx(
779+
_In_ HANDLE ProcessId,
780+
_In_opt_ HANDLE ProcessHandle,
781+
_In_ BOOLEAN SkipInvisible
782+
)
772783
{
773784
GET_PROCESS_MAIN_WINDOW_CONTEXT context;
774785
HANDLE processHandle = NULL;
775786

776787
memset(&context, 0, sizeof(GET_PROCESS_MAIN_WINDOW_CONTEXT));
777788
context.ProcessId = ProcessId;
789+
context.SkipInvisible = SkipInvisible;
778790

779791
if (ProcessHandle)
780792
processHandle = ProcessHandle;

ProcessHacker/include/appsup.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ HWND PhGetProcessMainWindow(
109109
_In_opt_ HANDLE ProcessHandle
110110
);
111111

112+
HWND PhGetProcessMainWindowEx(
113+
_In_ HANDLE ProcessId,
114+
_In_opt_ HANDLE ProcessHandle,
115+
_In_ BOOLEAN SkipInvisible
116+
);
117+
112118
PPH_STRING PhGetServiceRelevantFileName(
113119
_In_ PPH_STRINGREF ServiceName,
114120
_In_ SC_HANDLE ServiceHandle

ProcessHacker/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ static BOOLEAN NTAPI PhpPreviousInstancesCallback(
445445
{
446446
HWND hwnd;
447447

448-
hwnd = PhGetProcessMainWindow((HANDLE)processId64, NULL);
448+
hwnd = PhGetProcessMainWindowEx((HANDLE)processId64, NULL, FALSE);
449449

450450
if (hwnd)
451451
{

0 commit comments

Comments
 (0)