win32 recover
Prevent recover from building a savefile out of a currently active NetHack process.
This commit is contained in:
@@ -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
|
as preserving the default rather than being ignored
|
||||||
enlightenment: don't misreport polymorphed lycanthrope as "in beast form"
|
enlightenment: don't misreport polymorphed lycanthrope as "in beast form"
|
||||||
remove TIMED_DELAY from the features checked for version compatibility
|
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
|
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: win32 build no longer defines MICRO
|
||||||
win32: allow error save files to be generated
|
win32: allow error save files to be generated
|
||||||
win32: strip illegal file name characters from plname and replace with '_'
|
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: make error() work; it was essentially non-operative in 3.4.0
|
||||||
win32gui: fix alignment of columns in menu windows
|
win32gui: fix alignment of columns in menu windows
|
||||||
win32gui: Window menu File|Save worked during #quit disclosure processing
|
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: fix bug that caused two lines too many to be drawn on each paint
|
||||||
win32gui: last line no longer highlighted
|
win32gui: last line no longer highlighted
|
||||||
win32gui: reduce the number of popups and support for !popup
|
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: honour the use_inverse option and default to ATR_BOLD if disabled
|
||||||
win32tty: respond only to mouse clicks not mouse movement
|
win32tty: respond only to mouse clicks not mouse movement
|
||||||
win32tty: allow ^C to abort the game at the "Who are you?" prompt
|
win32tty: allow ^C to abort the game at the "Who are you?" prompt
|
||||||
|
|||||||
@@ -342,7 +342,11 @@ char *argv[];
|
|||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
raw_print("Cannot create lock file");
|
raw_print("Cannot create lock file");
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef WIN32
|
||||||
|
hackpid = GetCurrentProcessId();
|
||||||
|
#else
|
||||||
hackpid = 1;
|
hackpid = 1;
|
||||||
|
#endif
|
||||||
write(fd, (genericptr_t) &hackpid, sizeof(hackpid));
|
write(fd, (genericptr_t) &hackpid, sizeof(hackpid));
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,10 @@ extern int FDECL(vms_creat, (const char *,unsigned));
|
|||||||
extern int FDECL(vms_open, (const char *,int,unsigned));
|
extern int FDECL(vms_open, (const char *,int,unsigned));
|
||||||
#endif /* VMS */
|
#endif /* VMS */
|
||||||
|
|
||||||
|
#if defined(WIN32) && !defined(WIN_CE)
|
||||||
|
static boolean is_NetHack_process(pid);
|
||||||
|
#endif
|
||||||
|
|
||||||
int FDECL(restore_savefile, (char *));
|
int FDECL(restore_savefile, (char *));
|
||||||
void FDECL(set_levelfile_name, (int));
|
void FDECL(set_levelfile_name, (int));
|
||||||
int FDECL(open_levelfile, (int));
|
int FDECL(open_levelfile, (int));
|
||||||
@@ -230,6 +234,15 @@ char *basename;
|
|||||||
Close(gfd);
|
Close(gfd);
|
||||||
return(-1);
|
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))
|
if (read(gfd, (genericptr_t) &savelev, sizeof(savelev))
|
||||||
!= sizeof(savelev)) {
|
!= sizeof(savelev)) {
|
||||||
Fprintf(stderr,
|
Fprintf(stderr,
|
||||||
@@ -385,4 +398,37 @@ void nhce_message(FILE* f, const char* str, ...)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN32) && !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 &&
|
||||||
|
(!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*/
|
/*recover.c*/
|
||||||
|
|||||||
Reference in New Issue
Block a user