diff options
Diffstat (limited to 'src/dutil/proc2utl.cpp')
| -rw-r--r-- | src/dutil/proc2utl.cpp | 21 |
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 | } |
