diff options
Diffstat (limited to 'src/ext/Msmq/ca/mqexec.cpp')
| -rw-r--r-- | src/ext/Msmq/ca/mqexec.cpp | 192 |
1 files changed, 192 insertions, 0 deletions
diff --git a/src/ext/Msmq/ca/mqexec.cpp b/src/ext/Msmq/ca/mqexec.cpp new file mode 100644 index 00000000..ff7e9b14 --- /dev/null +++ b/src/ext/Msmq/ca/mqexec.cpp | |||
| @@ -0,0 +1,192 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | #include "precomp.h" | ||
| 4 | |||
| 5 | |||
| 6 | /******************************************************************** | ||
| 7 | MessageQueuingExecuteInstall - CUSTOM ACTION ENTRY POINT | ||
| 8 | |||
| 9 | Input: deferred CustomActionData - MessageQueuingExecuteInstall | ||
| 10 | ********************************************************************/ | ||
| 11 | extern "C" UINT __stdcall MessageQueuingExecuteInstall(MSIHANDLE hInstall) | ||
| 12 | { | ||
| 13 | HRESULT hr = S_OK; | ||
| 14 | UINT er = ERROR_SUCCESS; | ||
| 15 | |||
| 16 | LPWSTR pwzCustomActionData = NULL; | ||
| 17 | LPWSTR pwzData = NULL; | ||
| 18 | |||
| 19 | // initialize | ||
| 20 | hr = WcaInitialize(hInstall, "MessageQueuingExecuteInstall"); | ||
| 21 | ExitOnFailure(hr, "Failed to initialize MessageQueuingExecuteInstall"); | ||
| 22 | |||
| 23 | hr = MqiExecInitialize(); | ||
| 24 | ExitOnFailure(hr, "Failed to initialize"); | ||
| 25 | |||
| 26 | // get custom action data | ||
| 27 | hr = WcaGetProperty(L"CustomActionData", &pwzCustomActionData); | ||
| 28 | ExitOnFailure(hr, "Failed to get CustomActionData"); | ||
| 29 | pwzData = pwzCustomActionData; | ||
| 30 | |||
| 31 | // create message queues | ||
| 32 | hr = MqiCreateMessageQueues(&pwzData); | ||
| 33 | ExitOnFailure(hr, "Failed to create message queues"); | ||
| 34 | if (S_FALSE == hr) ExitFunction(); | ||
| 35 | |||
| 36 | // add message queue permissions | ||
| 37 | hr = MqiAddMessageQueuePermissions(&pwzData); | ||
| 38 | ExitOnFailure(hr, "Failed to add message queue permissions"); | ||
| 39 | if (S_FALSE == hr) ExitFunction(); | ||
| 40 | |||
| 41 | hr = S_OK; | ||
| 42 | |||
| 43 | LExit: | ||
| 44 | // clean up | ||
| 45 | ReleaseStr(pwzCustomActionData); | ||
| 46 | |||
| 47 | // uninitialize | ||
| 48 | MqiExecUninitialize(); | ||
| 49 | |||
| 50 | er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; | ||
| 51 | return WcaFinalize(er); | ||
| 52 | } | ||
| 53 | |||
| 54 | /******************************************************************** | ||
| 55 | MessageQueuingRollbackInstall - CUSTOM ACTION ENTRY POINT | ||
| 56 | |||
| 57 | Input: deferred CustomActionData - MessageQueuingRollbackInstall | ||
| 58 | ********************************************************************/ | ||
| 59 | extern "C" UINT __stdcall MessageQueuingRollbackInstall(MSIHANDLE hInstall) | ||
| 60 | { | ||
| 61 | HRESULT hr = S_OK; | ||
| 62 | UINT er = ERROR_SUCCESS; | ||
| 63 | |||
| 64 | LPWSTR pwzCustomActionData = NULL; | ||
| 65 | LPWSTR pwzData = NULL; | ||
| 66 | |||
| 67 | // initialize | ||
| 68 | hr = WcaInitialize(hInstall, "MessageQueuingRollbackInstall"); | ||
| 69 | ExitOnFailure(hr, "Failed to initialize MessageQueuingRollbackInstall"); | ||
| 70 | |||
| 71 | hr = MqiExecInitialize(); | ||
| 72 | ExitOnFailure(hr, "Failed to initialize"); | ||
| 73 | |||
| 74 | // get custom action data | ||
| 75 | hr = WcaGetProperty(L"CustomActionData", &pwzCustomActionData); | ||
| 76 | ExitOnFailure(hr, "Failed to get CustomActionData"); | ||
| 77 | pwzData = pwzCustomActionData; | ||
| 78 | |||
| 79 | // add message queue permissions | ||
| 80 | hr = MqiRollbackAddMessageQueuePermissions(&pwzData); | ||
| 81 | ExitOnFailure(hr, "Failed to rollback add message queue permissions"); | ||
| 82 | |||
| 83 | // create message queues | ||
| 84 | hr = MqiRollbackCreateMessageQueues(&pwzData); | ||
| 85 | ExitOnFailure(hr, "Failed to rollback create message queues"); | ||
| 86 | |||
| 87 | hr = S_OK; | ||
| 88 | |||
| 89 | LExit: | ||
| 90 | // clean up | ||
| 91 | ReleaseStr(pwzCustomActionData); | ||
| 92 | |||
| 93 | // uninitialize | ||
| 94 | MqiExecUninitialize(); | ||
| 95 | |||
| 96 | er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; | ||
| 97 | return WcaFinalize(er); | ||
| 98 | } | ||
| 99 | |||
| 100 | /******************************************************************** | ||
| 101 | MessageQueuingExecuteUninstall - CUSTOM ACTION ENTRY POINT | ||
| 102 | |||
| 103 | Input: deferred CustomActionData - MessageQueuingExecuteUninstall | ||
| 104 | ********************************************************************/ | ||
| 105 | extern "C" UINT __stdcall MessageQueuingExecuteUninstall(MSIHANDLE hInstall) | ||
| 106 | { | ||
| 107 | HRESULT hr = S_OK; | ||
| 108 | UINT er = ERROR_SUCCESS; | ||
| 109 | |||
| 110 | LPWSTR pwzCustomActionData = NULL; | ||
| 111 | LPWSTR pwzData = NULL; | ||
| 112 | |||
| 113 | // initialize | ||
| 114 | hr = WcaInitialize(hInstall, "MessageQueuingExecuteUninstall"); | ||
| 115 | ExitOnFailure(hr, "Failed to initialize MessageQueuingExecuteUninstall"); | ||
| 116 | |||
| 117 | hr = MqiExecInitialize(); | ||
| 118 | ExitOnFailure(hr, "Failed to initialize"); | ||
| 119 | |||
| 120 | // get custom action data | ||
| 121 | hr = WcaGetProperty(L"CustomActionData", &pwzCustomActionData); | ||
| 122 | ExitOnFailure(hr, "Failed to get CustomActionData"); | ||
| 123 | pwzData = pwzCustomActionData; | ||
| 124 | |||
| 125 | // remove message queue permissions | ||
| 126 | hr = MqiRemoveMessageQueuePermissions(&pwzData); | ||
| 127 | ExitOnFailure(hr, "Failed to remove message queue permissions"); | ||
| 128 | if (S_FALSE == hr) ExitFunction(); | ||
| 129 | |||
| 130 | // delete message queues | ||
| 131 | hr = MqiDeleteMessageQueues(&pwzData); | ||
| 132 | ExitOnFailure(hr, "Failed to delete message queues"); | ||
| 133 | if (S_FALSE == hr) ExitFunction(); | ||
| 134 | |||
| 135 | hr = S_OK; | ||
| 136 | |||
| 137 | LExit: | ||
| 138 | // clean up | ||
| 139 | ReleaseStr(pwzCustomActionData); | ||
| 140 | |||
| 141 | // uninitialize | ||
| 142 | MqiExecUninitialize(); | ||
| 143 | |||
| 144 | er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; | ||
| 145 | return WcaFinalize(er); | ||
| 146 | } | ||
| 147 | |||
| 148 | /******************************************************************** | ||
| 149 | MessageQueuingRollbackUninstall - CUSTOM ACTION ENTRY POINT | ||
| 150 | |||
| 151 | Input: deferred CustomActionData - MessageQueuingRollbackUninstall | ||
| 152 | ********************************************************************/ | ||
| 153 | extern "C" UINT __stdcall MessageQueuingRollbackUninstall(MSIHANDLE hInstall) | ||
| 154 | { | ||
| 155 | HRESULT hr = S_OK; | ||
| 156 | UINT er = ERROR_SUCCESS; | ||
| 157 | |||
| 158 | LPWSTR pwzCustomActionData = NULL; | ||
| 159 | LPWSTR pwzData = NULL; | ||
| 160 | |||
| 161 | // initialize | ||
| 162 | hr = WcaInitialize(hInstall, "MessageQueuingRollbackUninstall"); | ||
| 163 | ExitOnFailure(hr, "Failed to initialize MessageQueuingRollbackUninstall"); | ||
| 164 | |||
| 165 | hr = MqiExecInitialize(); | ||
| 166 | ExitOnFailure(hr, "Failed to initialize"); | ||
| 167 | |||
| 168 | // get custom action data | ||
| 169 | hr = WcaGetProperty(L"CustomActionData", &pwzCustomActionData); | ||
| 170 | ExitOnFailure(hr, "Failed to get CustomActionData"); | ||
| 171 | pwzData = pwzCustomActionData; | ||
| 172 | |||
| 173 | // delete message queues | ||
| 174 | hr = MqiRollbackDeleteMessageQueues(&pwzData); | ||
| 175 | ExitOnFailure(hr, "Failed to delete message queues"); | ||
| 176 | |||
| 177 | // remove message queue permissions | ||
| 178 | hr = MqiRollbackRemoveMessageQueuePermissions(&pwzData); | ||
| 179 | ExitOnFailure(hr, "Failed to remove message queue permissions"); | ||
| 180 | |||
| 181 | hr = S_OK; | ||
| 182 | |||
| 183 | LExit: | ||
| 184 | // clean up | ||
| 185 | ReleaseStr(pwzCustomActionData); | ||
| 186 | |||
| 187 | // uninitialize | ||
| 188 | MqiExecUninitialize(); | ||
| 189 | |||
| 190 | er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; | ||
| 191 | return WcaFinalize(er); | ||
| 192 | } | ||
