The primary exception filter
| 83 | |
| 84 | // The primary exception filter |
| 85 | LONG WINAPI BWAPIExceptionFilter(EXCEPTION_POINTERS *ep) |
| 86 | { |
| 87 | // Destroy fullscreen mode and show the cursor (something the original doesn't do!) |
| 88 | DDrawDestroy(); |
| 89 | ShowCursor(TRUE); |
| 90 | |
| 91 | // Create the log file path |
| 92 | char szLogFilename[MAX_PATH]; |
| 93 | time_t myTime = time(nullptr); |
| 94 | strftime(szLogFilename, sizeof(szLogFilename), "Errors\\%Y %b %d.txt", localtime(&myTime)); |
| 95 | |
| 96 | // Create the file |
| 97 | FILE *hFile = fopen( (installPath() + szLogFilename).c_str(), "a+"); |
| 98 | if ( hFile ) |
| 99 | { |
| 100 | fprintf(hFile, "\n//////////////////////////////////////////////////\n"); |
| 101 | |
| 102 | // Print the time |
| 103 | fprintf(hFile, "TIME: %s\n", ctime(&myTime)); |
| 104 | |
| 105 | // Print version data |
| 106 | WORD w1,w2,w3,w4; |
| 107 | GetCurrentProductVersion(w1, w2, w3, w4); |
| 108 | fprintf(hFile, "VERSION: %hu.%hu.%hu.%hu\n", w1, w2, w3, w4); |
| 109 | |
| 110 | // BWAPI/Broodwar specific |
| 111 | fprintf(hFile, "BWAPI:\n"); |
| 112 | fprintf(hFile, " REVISION: %d\n", BWAPI::BroodwarImpl.getRevision()); |
| 113 | fprintf(hFile, " CLIENT VERSION: %d\n", BWAPI::BroodwarImpl.getClientVersion()); |
| 114 | fprintf(hFile, " BUILD: %s\n", BWAPI::BroodwarImpl.isDebug() ? "DEBUG" : "RELEASE"); |
| 115 | fprintf(hFile, " ERROR: %s\n", BWAPI::BroodwarImpl.getLastError().c_str()); |
| 116 | fprintf(hFile, " LOCATION: %s %s\n", BWAPI::BroodwarImpl.isMultiplayer() ? (BWAPI::BroodwarImpl.isBattleNet() ? "Battle.net" : "Multiplayer") : "Single Player", BWAPI::BroodwarImpl.isReplay() ? "Replay" : ""); |
| 117 | |
| 118 | if ( BWAPI::BroodwarImpl.isInGame() ) |
| 119 | { |
| 120 | fprintf(hFile, "MAP: %s\n %s\n", BWAPI::BroodwarImpl.mapName().c_str(), BWAPI::BroodwarImpl.mapFileName().c_str()); |
| 121 | NULLCHECK(BWAPI::BroodwarImpl.self()); |
| 122 | NULLCHECK(BWAPI::BroodwarImpl.enemy()); |
| 123 | NULLCHECK(BWAPI::BroodwarImpl.neutral()); |
| 124 | if ( BWAPI::BroodwarImpl.hAIModule && !BWAPI::BroodwarImpl.client ) |
| 125 | fprintf(hFile, "\"Broodwar\" pointer was not initialized for AI module.\n"); |
| 126 | if ( BWAPI::BroodwarImpl.hTournamentModule && !BWAPI::BroodwarImpl.tournamentAI ) |
| 127 | fprintf(hFile, "\"Broodwar\" pointer was not initialized for Tournament module.\n"); |
| 128 | } |
| 129 | |
| 130 | // Print the exception info |
| 131 | DWORD dwExceptionCode = ep->ExceptionRecord->ExceptionCode; |
| 132 | fprintf(hFile, "\nEXCEPTION: 0x%08lX %s\n", dwExceptionCode, GetExceptionName(dwExceptionCode)); |
| 133 | |
| 134 | // Store exception address |
| 135 | PVOID pExceptionAddr = ep->ExceptionRecord->ExceptionAddress; |
| 136 | |
| 137 | // Print offending module info |
| 138 | fprintf(hFile, "FAULT: 0x%p %s\n", pExceptionAddr, getModuleNameFrom(pExceptionAddr).c_str()); |
| 139 | |
| 140 | // Print register information |
| 141 | fprintf(hFile, "REGISTERS:\n"); |
| 142 | DWORD dwCntxtFlags = ep->ContextRecord->ContextFlags; |
nothing calls this directly
no test coverage detected