| 99 | |
| 100 | #ifdef _WIN32 |
| 101 | static LONG CALLBACK |
| 102 | VectoredHandler(PEXCEPTION_POINTERS pExceptionInfo) |
| 103 | { |
| 104 | PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord; |
| 105 | DWORD ExceptionCode = pExceptionRecord->ExceptionCode; |
| 106 | |
| 107 | if (ExceptionCode == EXCEPTION_ACCESS_VIOLATION && |
| 108 | pExceptionRecord->NumberParameters >= 2 && |
| 109 | pExceptionRecord->ExceptionInformation[0] == 1) { // writing |
| 110 | |
| 111 | const uintptr_t addr = static_cast<uintptr_t>(pExceptionRecord->ExceptionInformation[1]); |
| 112 | const size_t page = addr / sPageSize; |
| 113 | |
| 114 | std::unique_lock<std::mutex> lock(mutex); |
| 115 | |
| 116 | const auto it = sPages.find(page); |
| 117 | if (it != sPages.end()) { |
| 118 | GLMemoryShadow *shadow = it->second; |
| 119 | shadow->onAddressWrite(addr, page); |
| 120 | return EXCEPTION_CONTINUE_EXECUTION; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | return EXCEPTION_CONTINUE_SEARCH; |
| 125 | } |
| 126 | |
| 127 | #else |
| 128 |
nothing calls this directly
no test coverage detected