Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Problem with EGTB.EXE

Author: Dann Corbit

Date: 14:20:24 08/06/99

Go up one level in this thread


Change this function in the EGTB code as follows:
static BYTE *PbMapFileForRead
  (
    char *szName,
    HANDLE * phFile,
    HANDLE * phFileMapping
)
{
  HANDLE hFile;
  HANDLE hFileMapping;
  LPVOID lpFileBase;

  hFile = CreateFile (szName, GENERIC_READ, FILE_SHARE_READ,
                      NULL, OPEN_EXISTING,
                      FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
  if (INVALID_HANDLE_VALUE == hFile)
    {
      printf ("*** Couldn't open file %s with CreateFile()\n", szName);
      exit (1);
    }
  hFileMapping = CreateFileMapping (hFile, NULL, PAGE_READONLY, 0, 0, NULL);
  if (0 == hFileMapping)
    {
      CloseHandle (hFile);
      printf ("*** Couldn't open file %s mapping with CreateFileMapping()\n",
szName);
      exit (1);
    }
  lpFileBase = MapViewOfFile (hFileMapping, FILE_MAP_READ, 0, 0, 0);
  if (0 == lpFileBase)
    {
      CloseHandle (hFileMapping);
      CloseHandle (hFile);
      printf ("*** Couldn't map view of file %s with MapViewOfFile()\n",
szName);
// NEW STUFF BELOW **********************************
      LPVOID lpMsgBuf;
      FormatMessage(
         FORMAT_MESSAGE_ALLOCATE_BUFFER |
         FORMAT_MESSAGE_FROM_SYSTEM |
         FORMAT_MESSAGE_IGNORE_INSERTS,
         NULL,
         GetLastError(),
         MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
         (LPTSTR) &lpMsgBuf,
         0,
         NULL
      );
      printf("%s\n", (LPCTSTR)lpMsgBuf);
      // Free the buffer.
      LocalFree( lpMsgBuf );
// END NEW STUFF *************************************
      exit (1);
    }
  if (NULL != phFile)
    *phFile = hFile;
  if (NULL != phFileMapping)
    *phFileMapping = hFileMapping;
  return (BYTE *) lpFileBase;
}

And it will diagnose the problem for you.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.