diff options
Diffstat (limited to 'src/dutil/dutil.cpp')
-rw-r--r-- | src/dutil/dutil.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/dutil/dutil.cpp b/src/dutil/dutil.cpp index 99ce1bc6..c500191a 100644 --- a/src/dutil/dutil.cpp +++ b/src/dutil/dutil.cpp | |||
@@ -2,6 +2,21 @@ | |||
2 | 2 | ||
3 | #include "precomp.h" | 3 | #include "precomp.h" |
4 | 4 | ||
5 | |||
6 | // Exit macros | ||
7 | #define DExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_DUTIL, x, s, __VA_ARGS__) | ||
8 | #define DExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_DUTIL, x, s, __VA_ARGS__) | ||
9 | #define DExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_DUTIL, x, s, __VA_ARGS__) | ||
10 | #define DExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_DUTIL, x, s, __VA_ARGS__) | ||
11 | #define DExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_DUTIL, x, s, __VA_ARGS__) | ||
12 | #define DExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_DUTIL, x, s, __VA_ARGS__) | ||
13 | #define DExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_DUTIL, p, x, e, s, __VA_ARGS__) | ||
14 | #define DExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_DUTIL, p, x, s, __VA_ARGS__) | ||
15 | #define DExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_DUTIL, p, x, e, s, __VA_ARGS__) | ||
16 | #define DExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_DUTIL, p, x, s, __VA_ARGS__) | ||
17 | #define DExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_DUTIL, e, x, s, __VA_ARGS__) | ||
18 | #define DExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_DUTIL, g, x, s, __VA_ARGS__) | ||
19 | |||
5 | // No need for OACR to warn us about using non-unicode APIs in this file. | 20 | // No need for OACR to warn us about using non-unicode APIs in this file. |
6 | #pragma prefast(disable:25068) | 21 | #pragma prefast(disable:25068) |
7 | 22 | ||
@@ -84,7 +99,7 @@ extern "C" void DAPI Dutil_AssertMsg( | |||
84 | 99 | ||
85 | char szMsg[DUTIL_STRING_BUFFER]; | 100 | char szMsg[DUTIL_STRING_BUFFER]; |
86 | hr = ::StringCchCopyA(szMsg, countof(szMsg), szMessage); | 101 | hr = ::StringCchCopyA(szMsg, countof(szMsg), szMessage); |
87 | ExitOnFailure(hr, "failed to copy message while building assert message"); | 102 | DExitOnFailure(hr, "failed to copy message while building assert message"); |
88 | 103 | ||
89 | if (Dutil_pfnDisplayAssert) | 104 | if (Dutil_pfnDisplayAssert) |
90 | { | 105 | { |
@@ -123,7 +138,7 @@ extern "C" void DAPI Dutil_AssertMsg( | |||
123 | if (ERROR_SUCCESS != er) | 138 | if (ERROR_SUCCESS != er) |
124 | { | 139 | { |
125 | hr = ::StringCchCatA(szMsg, countof(szMsg), "\nAbort=Debug, Retry=Skip, Ignore=Skip all"); | 140 | hr = ::StringCchCatA(szMsg, countof(szMsg), "\nAbort=Debug, Retry=Skip, Ignore=Skip all"); |
126 | ExitOnFailure(hr, "failed to concat string while building assert message"); | 141 | DExitOnFailure(hr, "failed to concat string while building assert message"); |
127 | 142 | ||
128 | id = ::MessageBoxA(0, szMsg, "Debug Assert Message", | 143 | id = ::MessageBoxA(0, szMsg, "Debug Assert Message", |
129 | MB_SERVICE_NOTIFICATION | MB_TOPMOST | | 144 | MB_SERVICE_NOTIFICATION | MB_TOPMOST | |
@@ -480,24 +495,24 @@ extern "C" HRESULT DAPI LoadSystemLibraryWithPath( | |||
480 | WCHAR wzPath[MAX_PATH] = { }; | 495 | WCHAR wzPath[MAX_PATH] = { }; |
481 | 496 | ||
482 | cch = ::GetSystemDirectoryW(wzPath, MAX_PATH); | 497 | cch = ::GetSystemDirectoryW(wzPath, MAX_PATH); |
483 | ExitOnNullWithLastError(cch, hr, "Failed to get the Windows system directory."); | 498 | DExitOnNullWithLastError(cch, hr, "Failed to get the Windows system directory."); |
484 | 499 | ||
485 | if (L'\\' != wzPath[cch - 1]) | 500 | if (L'\\' != wzPath[cch - 1]) |
486 | { | 501 | { |
487 | hr = ::StringCchCatNW(wzPath, MAX_PATH, L"\\", 1); | 502 | hr = ::StringCchCatNW(wzPath, MAX_PATH, L"\\", 1); |
488 | ExitOnRootFailure(hr, "Failed to terminate the string with a backslash."); | 503 | DExitOnRootFailure(hr, "Failed to terminate the string with a backslash."); |
489 | } | 504 | } |
490 | 505 | ||
491 | hr = ::StringCchCatW(wzPath, MAX_PATH, wzModuleName); | 506 | hr = ::StringCchCatW(wzPath, MAX_PATH, wzModuleName); |
492 | ExitOnRootFailure(hr, "Failed to create the fully-qualified path to %ls.", wzModuleName); | 507 | DExitOnRootFailure(hr, "Failed to create the fully-qualified path to %ls.", wzModuleName); |
493 | 508 | ||
494 | *phModule = ::LoadLibraryW(wzPath); | 509 | *phModule = ::LoadLibraryW(wzPath); |
495 | ExitOnNullWithLastError(*phModule, hr, "Failed to load the library %ls.", wzModuleName); | 510 | DExitOnNullWithLastError(*phModule, hr, "Failed to load the library %ls.", wzModuleName); |
496 | 511 | ||
497 | if (psczPath) | 512 | if (psczPath) |
498 | { | 513 | { |
499 | hr = StrAllocString(psczPath, wzPath, MAX_PATH); | 514 | hr = StrAllocString(psczPath, wzPath, MAX_PATH); |
500 | ExitOnFailure(hr, "Failed to copy the path to library."); | 515 | DExitOnFailure(hr, "Failed to copy the path to library."); |
501 | } | 516 | } |
502 | 517 | ||
503 | LExit: | 518 | LExit: |