SELF_RECOVER for win32

- define SELF_RECOVER for win32
- add code to perform a recover operation from
  within NetHack itself when SELF_RECOVER is defined
This commit is contained in:
nethack.allison
2002-08-21 03:30:19 +00:00
parent 591b832a84
commit 3515dcf1f1
5 changed files with 253 additions and 24 deletions

View File

@@ -234,6 +234,39 @@ void win32_abort()
abort();
}
#if !defined(WIN_CE)
#include <tlhelp32.h>
boolean
is_NetHack_process(pid)
int pid;
{
HANDLE hProcessSnap = NULL;
PROCESSENTRY32 pe32 = {0};
boolean bRet = FALSE;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcessSnap == INVALID_HANDLE_VALUE)
return FALSE;
/* Set size of the processentry32 structure before using it. */
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hProcessSnap, &pe32)) {
do {
if (pe32.th32ProcessID == (unsigned)pid && pe32.szExeFile &&
((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));
}
else
bRet = FALSE;
CloseHandle(hProcessSnap);
return bRet;
}
#endif /* WIN_CE*/
#endif /* WIN32 */
/*winnt.c*/