diff --git a/doc/fixes34.1 b/doc/fixes34.1 index 8a38da350..6b1a22d5b 100644 --- a/doc/fixes34.1 +++ b/doc/fixes34.1 @@ -207,7 +207,6 @@ zero entries in DUNGEON, MONSTERS, et al, of config file are now treated as preserving the default rather than being ignored enlightenment: don't misreport polymorphed lycanthrope as "in beast form" remove TIMED_DELAY from the features checked for version compatibility -rolling boulder hitting monster stuck in pit should stop even when mon survives Platform- and/or Interface-Specific Fixes @@ -216,6 +215,8 @@ wince: added Windows CE port from Alex Kompel win32: win32 build no longer defines MICRO win32: allow error save files to be generated win32: strip illegal file name characters from plname and replace with '_' +win32: don't let recover build a save file out of level files belonging + to an active NetHack.exe or NetHackw.exe process win32gui: make error() work; it was essentially non-operative in 3.4.0 win32gui: fix alignment of columns in menu windows win32gui: Window menu File|Save worked during #quit disclosure processing @@ -227,6 +228,7 @@ win32gui: A caret bug was fixed win32gui: fix bug that caused two lines too many to be drawn on each paint win32gui: last line no longer highlighted win32gui: reduce the number of popups and support for !popup +win32gui: support for not having popup windows win32tty: honour the use_inverse option and default to ATR_BOLD if disabled win32tty: respond only to mouse clicks not mouse movement win32tty: allow ^C to abort the game at the "Who are you?" prompt diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index e5d5f826b..2da4d4280 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -342,7 +342,11 @@ char *argv[]; if (fd < 0) { raw_print("Cannot create lock file"); } else { +#ifdef WIN32 + hackpid = GetCurrentProcessId(); +#else hackpid = 1; +#endif write(fd, (genericptr_t) &hackpid, sizeof(hackpid)); close(fd); } diff --git a/util/recover.c b/util/recover.c index 1c47fc5bc..072c493ca 100644 --- a/util/recover.c +++ b/util/recover.c @@ -20,6 +20,10 @@ extern int FDECL(vms_creat, (const char *,unsigned)); extern int FDECL(vms_open, (const char *,int,unsigned)); #endif /* VMS */ +#if defined(WIN32) && !defined(WIN_CE) +static boolean is_NetHack_process(pid); +#endif + int FDECL(restore_savefile, (char *)); void FDECL(set_levelfile_name, (int)); int FDECL(open_levelfile, (int)); @@ -230,6 +234,15 @@ char *basename; Close(gfd); return(-1); } +#if defined(WIN32) && !defined(WIN_CE) + if (is_NetHack_process(hpid)) { + Fprintf(stderr, "%s\n%s%s%s\n", + "Those level files belong to an active NetHack process and cannot be recovered.", + "recovery for \"", basename, "\" aborting."); + Close(gfd); + return(-1); + } +#endif if (read(gfd, (genericptr_t) &savelev, sizeof(savelev)) != sizeof(savelev)) { Fprintf(stderr, @@ -385,4 +398,37 @@ void nhce_message(FILE* f, const char* str, ...) } #endif +#if defined(WIN32) && !defined(WIN_CE) +#include + +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 && + (!strcmpi(pe32.szExeFile, "nethack.exe") || + !strcmpi(pe32.szExeFile, "nethackw.exe"))) + bRet = TRUE; + } + while (Process32Next(hProcessSnap, &pe32)); + } + else + bRet = FALSE; + CloseHandle(hProcessSnap); + return bRet; +} +#endif + /*recover.c*/