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/polcutil.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/polcutil.cpp')
| -rw-r--r-- | src/dutil/polcutil.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/dutil/polcutil.cpp b/src/dutil/polcutil.cpp index 1cc29e61..1fdfa18c 100644 --- a/src/dutil/polcutil.cpp +++ b/src/dutil/polcutil.cpp | |||
| @@ -2,6 +2,21 @@ | |||
| 2 | 2 | ||
| 3 | #include "precomp.h" | 3 | #include "precomp.h" |
| 4 | 4 | ||
| 5 | |||
| 6 | // Exit macros | ||
| 7 | #define PolcExitOnLastError(x, s, ...) ExitOnLastErrorSource(DUTIL_SOURCE_POLCUTIL, x, s, __VA_ARGS__) | ||
| 8 | #define PolcExitOnLastErrorDebugTrace(x, s, ...) ExitOnLastErrorDebugTraceSource(DUTIL_SOURCE_POLCUTIL, x, s, __VA_ARGS__) | ||
| 9 | #define PolcExitWithLastError(x, s, ...) ExitWithLastErrorSource(DUTIL_SOURCE_POLCUTIL, x, s, __VA_ARGS__) | ||
| 10 | #define PolcExitOnFailure(x, s, ...) ExitOnFailureSource(DUTIL_SOURCE_POLCUTIL, x, s, __VA_ARGS__) | ||
| 11 | #define PolcExitOnRootFailure(x, s, ...) ExitOnRootFailureSource(DUTIL_SOURCE_POLCUTIL, x, s, __VA_ARGS__) | ||
| 12 | #define PolcExitOnFailureDebugTrace(x, s, ...) ExitOnFailureDebugTraceSource(DUTIL_SOURCE_POLCUTIL, x, s, __VA_ARGS__) | ||
| 13 | #define PolcExitOnNull(p, x, e, s, ...) ExitOnNullSource(DUTIL_SOURCE_POLCUTIL, p, x, e, s, __VA_ARGS__) | ||
| 14 | #define PolcExitOnNullWithLastError(p, x, s, ...) ExitOnNullWithLastErrorSource(DUTIL_SOURCE_POLCUTIL, p, x, s, __VA_ARGS__) | ||
| 15 | #define PolcExitOnNullDebugTrace(p, x, e, s, ...) ExitOnNullDebugTraceSource(DUTIL_SOURCE_POLCUTIL, p, x, e, s, __VA_ARGS__) | ||
| 16 | #define PolcExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_POLCUTIL, p, x, s, __VA_ARGS__) | ||
| 17 | #define PolcExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_POLCUTIL, e, x, s, __VA_ARGS__) | ||
| 18 | #define PolcExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_POLCUTIL, g, x, s, __VA_ARGS__) | ||
| 19 | |||
| 5 | const LPCWSTR REGISTRY_POLICIES_KEY = L"SOFTWARE\\Policies\\"; | 20 | const LPCWSTR REGISTRY_POLICIES_KEY = L"SOFTWARE\\Policies\\"; |
| 6 | 21 | ||
| 7 | static HRESULT OpenPolicyKey( | 22 | static HRESULT OpenPolicyKey( |
| @@ -25,14 +40,14 @@ extern "C" HRESULT DAPI PolcReadNumber( | |||
| 25 | { | 40 | { |
| 26 | ExitFunction1(hr = S_FALSE); | 41 | ExitFunction1(hr = S_FALSE); |
| 27 | } | 42 | } |
| 28 | ExitOnFailure(hr, "Failed to open policy key: %ls", wzPolicyPath); | 43 | PolcExitOnFailure(hr, "Failed to open policy key: %ls", wzPolicyPath); |
| 29 | 44 | ||
| 30 | hr = RegReadNumber(hk, wzPolicyName, pdw); | 45 | hr = RegReadNumber(hk, wzPolicyName, pdw); |
| 31 | if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) | 46 | if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) |
| 32 | { | 47 | { |
| 33 | ExitFunction1(hr = S_FALSE); | 48 | ExitFunction1(hr = S_FALSE); |
| 34 | } | 49 | } |
| 35 | ExitOnFailure(hr, "Failed to open policy key: %ls, name: %ls", wzPolicyPath, wzPolicyName); | 50 | PolcExitOnFailure(hr, "Failed to open policy key: %ls, name: %ls", wzPolicyPath, wzPolicyName); |
| 36 | 51 | ||
| 37 | LExit: | 52 | LExit: |
| 38 | ReleaseRegKey(hk); | 53 | ReleaseRegKey(hk); |
| @@ -60,14 +75,14 @@ extern "C" HRESULT DAPI PolcReadString( | |||
| 60 | { | 75 | { |
| 61 | ExitFunction1(hr = S_FALSE); | 76 | ExitFunction1(hr = S_FALSE); |
| 62 | } | 77 | } |
| 63 | ExitOnFailure(hr, "Failed to open policy key: %ls", wzPolicyPath); | 78 | PolcExitOnFailure(hr, "Failed to open policy key: %ls", wzPolicyPath); |
| 64 | 79 | ||
| 65 | hr = RegReadString(hk, wzPolicyName, pscz); | 80 | hr = RegReadString(hk, wzPolicyName, pscz); |
| 66 | if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) | 81 | if (E_FILENOTFOUND == hr || E_PATHNOTFOUND == hr) |
| 67 | { | 82 | { |
| 68 | ExitFunction1(hr = S_FALSE); | 83 | ExitFunction1(hr = S_FALSE); |
| 69 | } | 84 | } |
| 70 | ExitOnFailure(hr, "Failed to open policy key: %ls, name: %ls", wzPolicyPath, wzPolicyName); | 85 | PolcExitOnFailure(hr, "Failed to open policy key: %ls, name: %ls", wzPolicyPath, wzPolicyName); |
| 71 | 86 | ||
| 72 | LExit: | 87 | LExit: |
| 73 | ReleaseRegKey(hk); | 88 | ReleaseRegKey(hk); |
| @@ -99,10 +114,10 @@ static HRESULT OpenPolicyKey( | |||
| 99 | LPWSTR sczPath = NULL; | 114 | LPWSTR sczPath = NULL; |
| 100 | 115 | ||
| 101 | hr = PathConcat(REGISTRY_POLICIES_KEY, wzPolicyPath, &sczPath); | 116 | hr = PathConcat(REGISTRY_POLICIES_KEY, wzPolicyPath, &sczPath); |
| 102 | ExitOnFailure(hr, "Failed to combine logging path with root path."); | 117 | PolcExitOnFailure(hr, "Failed to combine logging path with root path."); |
| 103 | 118 | ||
| 104 | hr = RegOpen(HKEY_LOCAL_MACHINE, sczPath, KEY_READ, phk); | 119 | hr = RegOpen(HKEY_LOCAL_MACHINE, sczPath, KEY_READ, phk); |
| 105 | ExitOnFailure(hr, "Failed to open policy registry key."); | 120 | PolcExitOnFailure(hr, "Failed to open policy registry key."); |
| 106 | 121 | ||
| 107 | LExit: | 122 | LExit: |
| 108 | ReleaseStr(sczPath); | 123 | ReleaseStr(sczPath); |
