diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2017-08-19 23:15:39 +0300 |
---|---|---|
committer | Kacper Michajłow <kasper93@gmail.com> | 2017-08-28 00:13:38 +0300 |
commit | affc0126a21c144aa995c84112844a10d1502b0e (patch) | |
tree | 8b0d9f96ed115972f09e676c49f25a1b7a2a2766 | |
parent | 2f346a55917f999729202c0da1cbc7dfa758e2e7 (diff) |
ExceptionHandler: Use proper pointer type.
-rw-r--r-- | src/mpc-hc/ExceptionHandler.cpp | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/src/mpc-hc/ExceptionHandler.cpp b/src/mpc-hc/ExceptionHandler.cpp index d221d4645..ac6f79baa 100644 --- a/src/mpc-hc/ExceptionHandler.cpp +++ b/src/mpc-hc/ExceptionHandler.cpp @@ -22,6 +22,7 @@ #include "ExceptionHandler.h"
#include <windows.h>
#include <psapi.h>
+#include <inttypes.h>
#ifndef _DEBUG
@@ -115,21 +116,16 @@ void HandleCommonException(LPEXCEPTION_POINTERS exceptionInfo) {
wchar_t message[MAX_PATH + 255];
wchar_t module[MAX_PATH];
- wchar_t* moduleName = nullptr;
- if (GetExceptionModule(exceptionInfo->ExceptionRecord->ExceptionAddress, module)) {
- moduleName = module;
- } else {
- moduleName = _T("[UNKNOWN]");
- }
+ const wchar_t* moduleName = GetExceptionModule(exceptionInfo->ExceptionRecord->ExceptionAddress, module) ? module : _T("[UNKNOWN]");
- uint64_t codeBase = (uint64_t)GetModuleHandle(NULL);
- uint64_t offset = (uint64_t)exceptionInfo->ExceptionRecord->ExceptionAddress - codeBase;
+ const uintptr_t codeBase = uintptr_t(GetModuleHandle(nullptr));
+ const uintptr_t offset = uintptr_t(exceptionInfo->ExceptionRecord->ExceptionAddress) - codeBase;
swprintf_s(message, _countof(message), _T(\
"An error has occurred. MPC-HC will close now.\n\n"\
"Exception:\n%s\n\n"\
"Crashing module:\n%s\n"\
- "Offset: 0x%I64X, Codebase: 0x%I64X\n\n"),
+ "Offset: 0x%" PRIXPTR ", Codebase: 0x%" PRIXPTR "\n\n"),
GetExceptionName(exceptionInfo->ExceptionRecord->ExceptionCode),
moduleName,
offset,
@@ -142,17 +138,12 @@ void HandleAccessViolation(LPEXCEPTION_POINTERS exceptionInfo) {
wchar_t message[MAX_PATH + 255];
wchar_t module[MAX_PATH];
- wchar_t* moduleName = NULL;
- if (GetExceptionModule(exceptionInfo->ExceptionRecord->ExceptionAddress, module)) {
- moduleName = module;
- } else {
- moduleName = _T("[UNKNOWN]");
- }
+ const wchar_t* moduleName = GetExceptionModule(exceptionInfo->ExceptionRecord->ExceptionAddress, module) ? module : _T("[UNKNOWN]");
- uint64_t codeBase = (uint64_t)GetModuleHandle(NULL);
- uint64_t offset = (uint64_t)exceptionInfo->ExceptionRecord->ExceptionAddress - codeBase;
+ const uintptr_t codeBase = uintptr_t(GetModuleHandle(nullptr));
+ const uintptr_t offset = uintptr_t(exceptionInfo->ExceptionRecord->ExceptionAddress) - codeBase;
- wchar_t* accessType = NULL;
+ const wchar_t* accessType;
switch (exceptionInfo->ExceptionRecord->ExceptionInformation[0]) {
case 0:
accessType = _T("read");
@@ -172,8 +163,8 @@ void HandleAccessViolation(LPEXCEPTION_POINTERS exceptionInfo) "An error has occurred. MPC-HC will close now.\n\n"\
"Exception:\n%s\n\n"\
"Crashing module:\n%s\n"\
- "Offset: 0x%I64X, Codebase: 0x%I64X\n"\
- "The thread %u tried to %s memory at address 0x%IX\n\n"),
+ "Offset: 0x%" PRIXPTR ", Codebase: 0x%" PRIXPTR "\n"\
+ "The thread %lu tried to %s memory at address 0x%" PRIXPTR "\n\n"),
GetExceptionName(exceptionInfo->ExceptionRecord->ExceptionCode),
moduleName,
offset,
|