aboutsummaryrefslogtreecommitdiff
path: root/src/dutil/proc2utl.cpp
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2021-03-02 14:19:14 -0600
committerSean Hall <r.sean.hall@gmail.com>2021-03-02 15:40:02 -0600
commit10ebf674da5df9224e4eddd3545518434c5b455b (patch)
treeea1f4063edd46e9942eab94dd7adb2f75c6c589e /src/dutil/proc2utl.cpp
parent3bbf1347b900ec115a12faf8f46965c9b7649696 (diff)
downloadwix-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/proc2utl.cpp')
-rw-r--r--src/dutil/proc2utl.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/dutil/proc2utl.cpp b/src/dutil/proc2utl.cpp
index 8a2fd09b..a59d2ffc 100644
--- a/src/dutil/proc2utl.cpp
+++ b/src/dutil/proc2utl.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/******************************************************************** 20/********************************************************************
6 ProcFindAllIdsFromExeName() - returns an array of process ids that are running specified executable. 21 ProcFindAllIdsFromExeName() - returns an array of process ids that are running specified executable.
7 22
@@ -21,7 +36,7 @@ extern "C" HRESULT DAPI ProcFindAllIdsFromExeName(
21 hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 36 hSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
22 if (INVALID_HANDLE_VALUE == hSnap) 37 if (INVALID_HANDLE_VALUE == hSnap)
23 { 38 {
24 ExitWithLastError(hr, "Failed to create snapshot of processes on system"); 39 ProcExitWithLastError(hr, "Failed to create snapshot of processes on system");
25 } 40 }
26 41
27 fContinue = ::Process32FirstW(hSnap, &peData); 42 fContinue = ::Process32FirstW(hSnap, &peData);
@@ -33,13 +48,13 @@ extern "C" HRESULT DAPI ProcFindAllIdsFromExeName(
33 if (!*ppdwProcessIds) 48 if (!*ppdwProcessIds)
34 { 49 {
35 *ppdwProcessIds = static_cast<DWORD*>(MemAlloc(sizeof(DWORD), TRUE)); 50 *ppdwProcessIds = static_cast<DWORD*>(MemAlloc(sizeof(DWORD), TRUE));
36 ExitOnNull(ppdwProcessIds, hr, E_OUTOFMEMORY, "Failed to allocate array for returned process IDs."); 51 ProcExitOnNull(ppdwProcessIds, hr, E_OUTOFMEMORY, "Failed to allocate array for returned process IDs.");
37 } 52 }
38 else 53 else
39 { 54 {
40 DWORD* pdwReAllocReturnedPids = NULL; 55 DWORD* pdwReAllocReturnedPids = NULL;
41 pdwReAllocReturnedPids = static_cast<DWORD*>(MemReAlloc(*ppdwProcessIds, sizeof(DWORD) * ((*pcProcessIds) + 1), TRUE)); 56 pdwReAllocReturnedPids = static_cast<DWORD*>(MemReAlloc(*ppdwProcessIds, sizeof(DWORD) * ((*pcProcessIds) + 1), TRUE));
42 ExitOnNull(pdwReAllocReturnedPids, hr, E_OUTOFMEMORY, "Failed to re-allocate array for returned process IDs."); 57 ProcExitOnNull(pdwReAllocReturnedPids, hr, E_OUTOFMEMORY, "Failed to re-allocate array for returned process IDs.");
43 58
44 *ppdwProcessIds = pdwReAllocReturnedPids; 59 *ppdwProcessIds = pdwReAllocReturnedPids;
45 } 60 }