aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/apputil.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/dutil/apputil.cpp21
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
5const DWORD PRIVATE_LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800; 19const DWORD PRIVATE_LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x00000800;
6typedef BOOL(WINAPI *LPFN_SETDEFAULTDLLDIRECTORIES)(DWORD); 20typedef BOOL(WINAPI *LPFN_SETDEFAULTDLLDIRECTORIES)(DWORD);
7typedef BOOL(WINAPI *LPFN_SETDLLDIRECTORYW)(LPCWSTR); 21typedef 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;