win32: hold .0 file open exclusively
-prevents problems with internal recover if second copy of game is started up with the same player name.
This commit is contained in:
@@ -233,53 +233,6 @@ void win32_abort()
|
||||
#endif
|
||||
abort();
|
||||
}
|
||||
|
||||
#if !defined(WIN_CE)
|
||||
#include <tlhelp32.h>
|
||||
boolean
|
||||
is_NetHack_process(pid)
|
||||
int pid;
|
||||
{
|
||||
HANDLE hProcessSnap = NULL;
|
||||
PROCESSENTRY32 pe32 = {0};
|
||||
boolean bRet = FALSE;
|
||||
HINSTANCE hinstLib;
|
||||
genericptr_t ProcTest;
|
||||
BOOL fFreeResult;
|
||||
|
||||
hinstLib = LoadLibrary("KERNEL32");
|
||||
if (hinstLib != NULL) {
|
||||
ProcTest = (genericptr_t) GetProcAddress(hinstLib, "Process32Next");
|
||||
if (!ProcTest) {
|
||||
fFreeResult = FreeLibrary(hinstLib);
|
||||
return FALSE;
|
||||
}
|
||||
fFreeResult = FreeLibrary(hinstLib);
|
||||
}
|
||||
|
||||
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*/
|
||||
|
||||
Reference in New Issue
Block a user