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/proc3utl.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/proc3utl.cpp')
-rw-r--r-- | src/dutil/proc3utl.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/dutil/proc3utl.cpp b/src/dutil/proc3utl.cpp index 038f002b..6d3cbc67 100644 --- a/src/dutil/proc3utl.cpp +++ b/src/dutil/proc3utl.cpp | |||
@@ -2,6 +2,21 @@ | |||
2 | 2 | ||
3 | #include "precomp.h" | 3 | #include "precomp.h" |
4 | 4 | ||
5 | |||
6 | // Exit macros | ||
7 | #define ProcExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_PROCUTIL, x, s, __VA_ARGS__) | ||
8 | #define ProcExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_PROCUTIL, x, s, __VA_ARGS__) | ||
9 | #define ProcExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_PROCUTIL, x, s, __VA_ARGS__) | ||
10 | #define ProcExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_PROCUTIL, x, s, __VA_ARGS__) | ||
11 | #define ProcExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_PROCUTIL, x, s, __VA_ARGS__) | ||
12 | #define ProcExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_PROCUTIL, x, s, __VA_ARGS__) | ||
13 | #define ProcExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_PROCUTIL, p, x, e, s, __VA_ARGS__) | ||
14 | #define ProcExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_PROCUTIL, p, x, s, __VA_ARGS__) | ||
15 | #define ProcExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_PROCUTIL, p, x, e, s, __VA_ARGS__) | ||
16 | #define ProcExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_PROCUTIL, p, x, s, __VA_ARGS__) | ||
17 | #define ProcExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_PROCUTIL, e, x, s, __VA_ARGS__) | ||
18 | #define ProcExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_PROCUTIL, g, x, s, __VA_ARGS__) | ||
19 | |||
5 | static HRESULT GetActiveSessionUserToken( | 20 | static HRESULT GetActiveSessionUserToken( |
6 | __out HANDLE *phToken | 21 | __out HANDLE *phToken |
7 | ); | 22 | ); |
@@ -25,20 +40,20 @@ extern "C" HRESULT DAPI ProcExecuteAsInteractiveUser( | |||
25 | PROCESS_INFORMATION pi = { }; | 40 | PROCESS_INFORMATION pi = { }; |
26 | 41 | ||
27 | hr = GetActiveSessionUserToken(&hToken); | 42 | hr = GetActiveSessionUserToken(&hToken); |
28 | ExitOnFailure(hr, "Failed to get active session user token."); | 43 | ProcExitOnFailure(hr, "Failed to get active session user token."); |
29 | 44 | ||
30 | if (!::CreateEnvironmentBlock(&pEnvironment, hToken, FALSE)) | 45 | if (!::CreateEnvironmentBlock(&pEnvironment, hToken, FALSE)) |
31 | { | 46 | { |
32 | ExitWithLastError(hr, "Failed to create environment block for UI process."); | 47 | ProcExitWithLastError(hr, "Failed to create environment block for UI process."); |
33 | } | 48 | } |
34 | 49 | ||
35 | hr = StrAllocFormatted(&sczFullCommandLine, L"\"%ls\" %ls", wzExecutablePath, wzCommandLine); | 50 | hr = StrAllocFormatted(&sczFullCommandLine, L"\"%ls\" %ls", wzExecutablePath, wzCommandLine); |
36 | ExitOnFailure(hr, "Failed to allocate full command-line."); | 51 | ProcExitOnFailure(hr, "Failed to allocate full command-line."); |
37 | 52 | ||
38 | si.cb = sizeof(si); | 53 | si.cb = sizeof(si); |
39 | if (!::CreateProcessAsUserW(hToken, wzExecutablePath, sczFullCommandLine, NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT, pEnvironment, NULL, &si, &pi)) | 54 | if (!::CreateProcessAsUserW(hToken, wzExecutablePath, sczFullCommandLine, NULL, NULL, FALSE, CREATE_UNICODE_ENVIRONMENT, pEnvironment, NULL, &si, &pi)) |
40 | { | 55 | { |
41 | ExitWithLastError(hr, "Failed to create UI process: %ls", sczFullCommandLine); | 56 | ProcExitWithLastError(hr, "Failed to create UI process: %ls", sczFullCommandLine); |
42 | } | 57 | } |
43 | 58 | ||
44 | *phProcess = pi.hProcess; | 59 | *phProcess = pi.hProcess; |
@@ -74,7 +89,7 @@ static HRESULT GetActiveSessionUserToken( | |||
74 | // Loop through the sessions looking for the active one. | 89 | // Loop through the sessions looking for the active one. |
75 | if (!::WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, &pSessionInfo, &cSessions)) | 90 | if (!::WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, &pSessionInfo, &cSessions)) |
76 | { | 91 | { |
77 | ExitWithLastError(hr, "Failed to enumerate sessions."); | 92 | ProcExitWithLastError(hr, "Failed to enumerate sessions."); |
78 | } | 93 | } |
79 | 94 | ||
80 | for (DWORD i = 0; i < cSessions; ++i) | 95 | for (DWORD i = 0; i < cSessions; ++i) |
@@ -96,7 +111,7 @@ static HRESULT GetActiveSessionUserToken( | |||
96 | // Get the user token from the active session. | 111 | // Get the user token from the active session. |
97 | if (!::WTSQueryUserToken(dwSessionId, &hToken)) | 112 | if (!::WTSQueryUserToken(dwSessionId, &hToken)) |
98 | { | 113 | { |
99 | ExitWithLastError(hr, "Failed to get active session user token."); | 114 | ProcExitWithLastError(hr, "Failed to get active session user token."); |
100 | } | 115 | } |
101 | 116 | ||
102 | *phToken = hToken; | 117 | *phToken = hToken; |