]> granicus.if.org Git - nethack/commitdiff
more win32 recover
authornethack.allison <nethack.allison>
Mon, 19 Aug 2002 01:12:23 +0000 (01:12 +0000)
committernethack.allison <nethack.allison>
Mon, 19 Aug 2002 01:12:23 +0000 (01:12 +0000)
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

index 49638007d9d1e15d1d127c31db136d501533cc68..fc6c173dc3c82a255dd2843ea975f53559ff219d 100644 (file)
@@ -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));