Skip to content

Commit af3d39c

Browse files
committed
[Setup] Fix minimum OS version
1 parent 43ef233 commit af3d39c

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

tools/CustomSetupTool/CustomSetupTool/CustomSetupTool.vcxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<AdditionalLibraryDirectories>$(SolutionDir)..\..\phlib\bin\$(Configuration)$(PlatformArchitecture);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
6969
<SubSystem>Windows</SubSystem>
7070
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
71+
<MinimumRequiredVersion>6.01</MinimumRequiredVersion>
7172
</Link>
7273
<ResourceCompile>
7374
<PreprocessorDefinitions>_UNICODE;UNICODE;%(PreprocessorDefinitions);$(ExternalCompilerOptions)</PreprocessorDefinitions>
@@ -97,7 +98,7 @@
9798
<AdditionalDependencies>uxtheme.lib;winhttp.lib;phlib.lib;ntdll.lib;%(AdditionalDependencies)</AdditionalDependencies>
9899
<AdditionalLibraryDirectories>$(SolutionDir)..\..\phlib\bin\$(Configuration)$(PlatformArchitecture);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
99100
<SubSystem>Windows</SubSystem>
100-
<MinimumRequiredVersion>5.01</MinimumRequiredVersion>
101+
<MinimumRequiredVersion>6.01</MinimumRequiredVersion>
101102
<SetChecksum>true</SetChecksum>
102103
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
103104
</Link>

tools/CustomSetupTool/CustomSetupTool/appsup.c

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -470,38 +470,45 @@ PPH_STRING GetProcessHackerInstallPath(VOID)
470470
return installPath;
471471
}
472472

473-
BOOLEAN ShutdownProcessHacker(VOID)
473+
static BOOLEAN NTAPI PhpPreviousInstancesCallback(
474+
_In_ PPH_STRINGREF Name,
475+
_In_ PPH_STRINGREF TypeName,
476+
_In_opt_ PVOID Context
477+
)
474478
{
475-
HWND windowHandle;
476-
HANDLE processHandle;
477-
ULONG processID = 0;
478-
479-
while (windowHandle = FindWindow(L"ProcessHacker", NULL))
479+
ULONG64 processId64;
480+
PH_STRINGREF firstPart;
481+
PH_STRINGREF secondPart;
482+
483+
if (
484+
PhStartsWithStringRef2(Name, L"PhMutant_", TRUE) &&
485+
PhSplitStringRefAtChar(Name, L'_', &firstPart, &secondPart) &&
486+
PhStringToInteger64(&secondPart, 10, &processId64)
487+
)
480488
{
481-
GetWindowThreadProcessId(windowHandle, &processID);
489+
HANDLE processHandle;
482490

483491
if (NT_SUCCESS(PhOpenProcess(
484492
&processHandle,
485493
SYNCHRONIZE | PROCESS_TERMINATE,
486-
ULongToHandle(processID)
494+
ULongToHandle((ULONG)processId64)
487495
)))
488496
{
489-
PostMessage(windowHandle, WM_QUIT, 0, 0);
490-
491-
// Wait for process exit.
492-
if (WaitForSingleObject(processHandle, 10 * 1000) != WAIT_OBJECT_0)
493-
{
494-
// Timed out, kill the process.
495-
NtTerminateProcess(processHandle, 1);
496-
}
497-
497+
NtTerminateProcess(processHandle, 1);
498498
NtClose(processHandle);
499499
}
500500
}
501501

502502
return TRUE;
503503
}
504504

505+
BOOLEAN ShutdownProcessHacker(VOID)
506+
{
507+
PhEnumDirectoryObjects(PhGetNamespaceHandle(), PhpPreviousInstancesCallback, NULL);
508+
509+
return TRUE;
510+
}
511+
505512
BOOLEAN CreateDirectoryPath(_In_ PWSTR DirPath)
506513
{
507514
BOOLEAN success = FALSE;

0 commit comments

Comments
 (0)