From 9968e1ffabd4691e5103c0e08eb66c009cdfe26e Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Mon, 19 Aug 2002 01:12:23 +0000 Subject: [PATCH] more win32 recover It turns out that the processentry32 structure contents are slightly different on 2000/XP than they are on 95/98/Me according to the docs. szExeFile Pointer to a null-terminated string that specifies the name of the executable file for the process. Windows 2000/XP: The file name does not include the path. Windows 95/98/Me: The file name includes the path. Ensure that we check for the target values at the end of the string. --- util/recover.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/recover.c b/util/recover.c index 49638007d..fc6c173dc 100644 --- a/util/recover.c +++ b/util/recover.c @@ -418,8 +418,10 @@ int pid; if (Process32First(hProcessSnap, &pe32)) { do { if (pe32.th32ProcessID == (unsigned)pid && pe32.szExeFile && - (!strcmpi(pe32.szExeFile, "nethack.exe") || - !strcmpi(pe32.szExeFile, "nethackw.exe"))) + ((strlen(pe32.szExeFile) >= 12 && + !strcmpi(&pe32.szExeFile[strlen(pe32.szExeFile) - 12], "nethackw.exe")) || + (strlen(pe32.szExeFile) >= 11 && + !strcmpi(&pe32.szExeFile[strlen(pe32.szExeFile) - 11], "nethack.exe")))) bRet = TRUE; } while (Process32Next(hProcessSnap, &pe32));