From fdc357b23fd2b8d612863f18e553543ad3b2c92c Mon Sep 17 00:00:00 2001 From: Amrsatrio Date: Thu, 22 Feb 2024 16:39:53 +0700 Subject: [PATCH] Setup: Reverted the method for ending explorer.exe and its subprocesses --- ExplorerPatcher/utility.c | 36 ------------------------------------ ExplorerPatcher/utility.h | 2 -- ep_setup/ep_setup.c | 25 ++++++++++++++++++++----- 3 files changed, 20 insertions(+), 43 deletions(-) diff --git a/ExplorerPatcher/utility.c b/ExplorerPatcher/utility.c index 0cdee8f..16ed1f6 100644 --- a/ExplorerPatcher/utility.c +++ b/ExplorerPatcher/utility.c @@ -1536,42 +1536,6 @@ BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOve return TRUE; } -DWORD GetProcessIdByExeName(LPCWSTR wszProcessName) -{ - HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (hSnap != INVALID_HANDLE_VALUE) - { - PROCESSENTRY32W pe; - pe.dwSize = sizeof(pe); - BOOL bRet = Process32FirstW(hSnap, &pe); - while (bRet) - { - if (!_wcsicmp(pe.szExeFile, wszProcessName)) - { - CloseHandle(hSnap); - return pe.th32ProcessID; - } - bRet = Process32NextW(hSnap, &pe); - } - CloseHandle(hSnap); - } - return 0; -} - -void KillProcess(LPCWSTR wszProcessName) -{ - DWORD dwProcessId = GetProcessIdByExeName(wszProcessName); - if (!dwProcessId) - return; - - HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwProcessId); - if (hProcess) - { - TerminateProcess(hProcess, 1); - CloseHandle(hProcess); - } -} - #ifdef _WIN64 inline BOOL MaskCompare(PVOID pBuffer, LPCSTR lpPattern, LPCSTR lpMask) { diff --git a/ExplorerPatcher/utility.h b/ExplorerPatcher/utility.h index a7e275d..5cbbc6e 100644 --- a/ExplorerPatcher/utility.h +++ b/ExplorerPatcher/utility.h @@ -670,8 +670,6 @@ typedef struct _MonitorOverrideData } MonitorOverrideData; BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOverrideData* mod); -DWORD GetProcessIdByExeName(LPCWSTR wszProcessName); -void KillProcess(LPCWSTR wszProcessName); #ifdef _WIN64 PVOID FindPattern(PVOID pBase, SIZE_T dwSize, LPCSTR lpPattern, LPCSTR lpMask); diff --git a/ep_setup/ep_setup.c b/ep_setup/ep_setup.c index 21c6b66..66eabfb 100644 --- a/ep_setup/ep_setup.c +++ b/ep_setup/ep_setup.c @@ -651,11 +651,24 @@ int WINAPI wWinMain( } } Sleep(100); - KillProcess(L"explorer.exe"); - KillProcess(L"StartMenuExperienceHost.exe"); - KillProcess(L"SearchHost.exe"); - KillProcess(L"SearchApp.exe"); - KillProcess(L"ShellExperienceHost.exe"); + GetSystemDirectoryW(wszPath, MAX_PATH); + wcscat_s(wszPath, MAX_PATH, L"\\taskkill.exe"); + SHELLEXECUTEINFOW sei; + ZeroMemory(&sei, sizeof(SHELLEXECUTEINFOW)); + sei.cbSize = sizeof(sei); + sei.fMask = SEE_MASK_NOCLOSEPROCESS; + sei.hwnd = NULL; + sei.hInstApp = NULL; + sei.lpVerb = NULL; + sei.lpFile = wszPath; + sei.lpParameters = L"/f /im explorer.exe"; + sei.hwnd = NULL; + sei.nShow = SW_SHOWMINIMIZED; + if (ShellExecuteExW(&sei) && sei.hProcess) + { + WaitForSingleObject(sei.hProcess, INFINITE); + CloseHandle(sei.hProcess); + } Sleep(500); @@ -759,6 +772,8 @@ int WINAPI wWinMain( } } + Sleep(1000); + // -------------------------------------------------------------------------------- // C:\Program Files\ExplorerPatcher