Browse Source

Setup: Reverted the method for ending explorer.exe and its subprocesses

pull/2940/merge
Amrsatrio 2 years ago
parent
commit
fdc357b23f
  1. 36
      ExplorerPatcher/utility.c
  2. 2
      ExplorerPatcher/utility.h
  3. 25
      ep_setup/ep_setup.c

36
ExplorerPatcher/utility.c

@ -1536,42 +1536,6 @@ BOOL ExtractMonitorByIndex(HMONITOR hMonitor, HDC hDC, LPRECT lpRect, MonitorOve @@ -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)
{

2
ExplorerPatcher/utility.h

@ -670,8 +670,6 @@ typedef struct _MonitorOverrideData @@ -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);

25
ep_setup/ep_setup.c

@ -651,11 +651,24 @@ int WINAPI wWinMain( @@ -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( @@ -759,6 +772,8 @@ int WINAPI wWinMain(
}
}
Sleep(1000);
// --------------------------------------------------------------------------------
// C:\Program Files\ExplorerPatcher

Loading…
Cancel
Save