| 149 | } |
| 150 | |
| 151 | void writeMemoryErrorDetails(FILE* outputFile, PEXCEPTION_POINTERS ex, const char* description) |
| 152 | { |
| 153 | fputs(description, outputFile); |
| 154 | fprintf(outputFile, " (instruction: 0x%p) ", ex->ExceptionRecord->ExceptionAddress); |
| 155 | // Using %p for ULONG_PTR later on, so it must have size identical to size of pointer |
| 156 | // This is not the universally portable solution but good enough for Win32/64 |
| 157 | C_ASSERT(sizeof(void*) == sizeof(ex->ExceptionRecord->ExceptionInformation[1])); |
| 158 | switch (ex->ExceptionRecord->ExceptionInformation[0]) { |
| 159 | case 0: |
| 160 | fprintf(outputFile, "reading from 0x%p", |
| 161 | reinterpret_cast<void*>(ex->ExceptionRecord->ExceptionInformation[1])); |
| 162 | break; |
| 163 | case 1: |
| 164 | fprintf(outputFile, "writing to 0x%p", |
| 165 | reinterpret_cast<void*>(ex->ExceptionRecord->ExceptionInformation[1])); |
| 166 | break; |
| 167 | case 8: |
| 168 | fprintf(outputFile, "data execution prevention at 0x%p", |
| 169 | reinterpret_cast<void*>(ex->ExceptionRecord->ExceptionInformation[1])); |
| 170 | break; |
| 171 | default: |
| 172 | break; |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | /* |
| 177 | * Any evaluation of the exception needs to be done here! |