Skip to content

Commit

Permalink
Setup: Reverted the method for ending explorer.exe and its subprocesses
Browse files Browse the repository at this point in the history
  • Loading branch information
Amrsatrio committed Feb 22, 2024
1 parent cb3f967 commit fdc357b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 43 deletions.
36 changes: 0 additions & 36 deletions ExplorerPatcher/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 0 additions & 2 deletions ExplorerPatcher/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 20 additions & 5 deletions ep_setup/ep_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -759,6 +772,8 @@ int WINAPI wWinMain(
}
}

Sleep(1000);

// --------------------------------------------------------------------------------

// C:\Program Files\ExplorerPatcher
Expand Down

0 comments on commit fdc357b

Please sign in to comment.