MCPcopy Create free account
hub / github.com/bwapi/bwapi / BWAPIExceptionFilter

Function BWAPIExceptionFilter

bwapi/BWAPI/Source/ExceptionFilter.cpp:85–314  ·  view source on GitHub ↗

The primary exception filter

Source from the content-addressed store, hash-verified

83
84// The primary exception filter
85LONG 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;

Callers

nothing calls this directly

Calls 15

DDrawDestroyFunction · 0.85
GetCurrentProductVersionFunction · 0.85
GetExceptionNameFunction · 0.85
getModuleNameFromFunction · 0.85
c_strMethod · 0.80
getLastErrorMethod · 0.80
DefFilterProcMethod · 0.80
getRevisionMethod · 0.45
getClientVersionMethod · 0.45
isDebugMethod · 0.45
isMultiplayerMethod · 0.45
isBattleNetMethod · 0.45

Tested by

no test coverage detected