diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2021-03-02 14:19:14 -0600 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2021-03-02 15:40:02 -0600 |
| commit | 10ebf674da5df9224e4eddd3545518434c5b455b (patch) | |
| tree | ea1f4063edd46e9942eab94dd7adb2f75c6c589e /src/dutil/apputil.cpp | |
| parent | 3bbf1347b900ec115a12faf8f46965c9b7649696 (diff) | |
| download | wix-10ebf674da5df9224e4eddd3545518434c5b455b.tar.gz wix-10ebf674da5df9224e4eddd3545518434c5b455b.tar.bz2 wix-10ebf674da5df9224e4eddd3545518434c5b455b.zip | |
Update rest of dutil to use their own source with the Exit* macros.
Fix some CA warnings.
Diffstat (limited to 'src/dutil/apputil.cpp')
| -rw-r--r-- | src/dutil/apputil.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/dutil/apputil.cpp b/src/dutil/apputil.cpp index 8562a47a..589a09dd 100644 --- a/src/dutil/apputil.cpp +++ b/src/dutil/apputil.cpp | |||
| @@ -2,6 +2,20 @@ | |||
| 2 | 2 | ||
| 3 | #include "precomp.h" | 3 | #include "precomp.h" |
| 4 | 4 | ||
| 5 | // Exit macros | ||
| 6 | #define AppExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_APPUTIL, x, s, __VA_ARGS__) | ||
| 7 | #define AppExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_APPUTIL, x, s, __VA_ARGS__) | ||
| 8 | #define AppExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_APPUTIL, x, s, __VA_ARGS__) | ||
| 9 | #define AppExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_APPUTIL, x, s, __VA_ARGS__) | ||
| 10 | #define AppExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_APPUTIL, x, s, __VA_ARGS__) | ||
| 11 | #define AppExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_APPUTIL, x, s, __VA_ARGS__) | ||
| 12 | #define AppExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_APPUTIL, p, x, e, s, __VA_ARGS__) | ||
| 13 | #define AppExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_APPUTIL, p, x, s, __VA_ARGS__) | ||
| 14 | #define AppExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_APPUTIL, p, x, e, s, __VA_ARGS__) | ||
| 15 | #define AppExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_APPUTIL, p, x, s, __VA_ARGS__) | ||
| 16 | #define AppExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_APPUTIL, e, x, s, __VA_ARGS__) | ||
| 17 | #define AppExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_APPUTIL, g, x, s, __VA_ARGS__) | ||
| 18 | |||
| 5 | const DWORD PRIVATE_LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800; | 19 | const DWORD PRIVATE_LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800; |
| 6 | typedef BOOL(WINAPI *LPFN_SETDEFAULTDLLDIRECTORIES)(DWORD); | 20 | typedef BOOL(WINAPI *LPFN_SETDEFAULTDLLDIRECTORIES)(DWORD); |
| 7 | typedef BOOL(WINAPI *LPFN_SETDLLDIRECTORYW)(LPCWSTR); | 21 | typedef BOOL(WINAPI *LPFN_SETDLLDIRECTORYW)(LPCWSTR); |
| @@ -33,6 +47,7 @@ extern "C" void DAPI AppInitialize( | |||
| 33 | 47 | ||
| 34 | // Best effort call to initialize default DLL directories to system only. | 48 | // Best effort call to initialize default DLL directories to system only. |
| 35 | HMODULE hKernel32 = ::GetModuleHandleW(L"kernel32"); | 49 | HMODULE hKernel32 = ::GetModuleHandleW(L"kernel32"); |
| 50 | Assert(hKernel32); | ||
| 36 | LPFN_SETDEFAULTDLLDIRECTORIES pfnSetDefaultDllDirectories = (LPFN_SETDEFAULTDLLDIRECTORIES)::GetProcAddress(hKernel32, "SetDefaultDllDirectories"); | 51 | LPFN_SETDEFAULTDLLDIRECTORIES pfnSetDefaultDllDirectories = (LPFN_SETDEFAULTDLLDIRECTORIES)::GetProcAddress(hKernel32, "SetDefaultDllDirectories"); |
| 37 | if (pfnSetDefaultDllDirectories) | 52 | if (pfnSetDefaultDllDirectories) |
| 38 | { | 53 | { |
| @@ -90,13 +105,13 @@ extern "C" DAPI_(HRESULT) AppParseCommandLine( | |||
| 90 | // which fails pretty miserably if your first argument is something like | 105 | // which fails pretty miserably if your first argument is something like |
| 91 | // FOO="C:\Program Files\My Company". So give it something harmless to play with. | 106 | // FOO="C:\Program Files\My Company". So give it something harmless to play with. |
| 92 | hr = StrAllocConcat(&sczCommandLine, L"ignored ", 0); | 107 | hr = StrAllocConcat(&sczCommandLine, L"ignored ", 0); |
| 93 | ExitOnFailure(hr, "Failed to initialize command line."); | 108 | AppExitOnFailure(hr, "Failed to initialize command line."); |
| 94 | 109 | ||
| 95 | hr = StrAllocConcat(&sczCommandLine, wzCommandLine, 0); | 110 | hr = StrAllocConcat(&sczCommandLine, wzCommandLine, 0); |
| 96 | ExitOnFailure(hr, "Failed to copy command line."); | 111 | AppExitOnFailure(hr, "Failed to copy command line."); |
| 97 | 112 | ||
| 98 | argv = ::CommandLineToArgvW(sczCommandLine, &argc); | 113 | argv = ::CommandLineToArgvW(sczCommandLine, &argc); |
| 99 | ExitOnNullWithLastError(argv, hr, "Failed to parse command line."); | 114 | AppExitOnNullWithLastError(argv, hr, "Failed to parse command line."); |
| 100 | 115 | ||
| 101 | // Skip "ignored" argument/hack. | 116 | // Skip "ignored" argument/hack. |
| 102 | *pArgv = argv + 1; | 117 | *pArgv = argv + 1; |
