From 4cf492c8d33a11d61d70782ecd5f7854a0c013bd Mon Sep 17 00:00:00 2001 From: Valentin Radu Date: Sun, 10 Oct 2021 06:03:22 +0300 Subject: [PATCH] Added guard to stop trying to hook Start menu after some time if not found --- ExplorerPatcher/StartMenu.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ExplorerPatcher/StartMenu.c b/ExplorerPatcher/StartMenu.c index b6bb221..a8cad77 100644 --- a/ExplorerPatcher/StartMenu.c +++ b/ExplorerPatcher/StartMenu.c @@ -201,6 +201,7 @@ DWORD WINAPI HookStartMenu(HookStartMenuParams* params) while (TRUE) { + unsigned int retry = 0; HANDLE hProcess, hSnapshot; PROCESSENTRY32 pe32; while (TRUE) @@ -233,6 +234,7 @@ DWORD WINAPI HookStartMenu(HookStartMenuParams* params) { printf("Unable to open handle to StartMenuExperienceHost.exe.\n"); Sleep(params->dwTimeout); + continue; } TCHAR wszProcessPath[MAX_PATH]; DWORD dwLength = MAX_PATH; @@ -261,6 +263,8 @@ DWORD WINAPI HookStartMenu(HookStartMenuParams* params) } else { + retry++; + if (retry > 5) return 0; Sleep(params->dwTimeout); } }