diff options
Diffstat (limited to 'src/ca/mqexec.cpp')
| -rw-r--r-- | src/ca/mqexec.cpp | 214 |
1 files changed, 214 insertions, 0 deletions
diff --git a/src/ca/mqexec.cpp b/src/ca/mqexec.cpp new file mode 100644 index 00000000..bac54f31 --- /dev/null +++ b/src/ca/mqexec.cpp | |||
| @@ -0,0 +1,214 @@ | |||
| 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 | DllMain - standard entry point for all WiX CustomActions | ||
| 7 | |||
| 8 | ********************************************************************/ | ||
| 9 | extern "C" BOOL WINAPI DllMain( | ||
| 10 | IN HINSTANCE hInst, | ||
| 11 | IN ULONG ulReason, | ||
| 12 | IN LPVOID) | ||
| 13 | { | ||
| 14 | switch(ulReason) | ||
| 15 | { | ||
| 16 | case DLL_PROCESS_ATTACH: | ||
| 17 | WcaGlobalInitialize(hInst); | ||
| 18 | break; | ||
| 19 | |||
| 20 | case DLL_PROCESS_DETACH: | ||
| 21 | WcaGlobalFinalize(); | ||
| 22 | break; | ||
| 23 | } | ||
| 24 | |||
| 25 | return TRUE; | ||
| 26 | } | ||
| 27 | |||
| 28 | /******************************************************************** | ||
| 29 | MessageQueuingExecuteInstall - CUSTOM ACTION ENTRY POINT | ||
| 30 | |||
| 31 | Input: deferred CustomActionData - MessageQueuingExecuteInstall | ||
| 32 | ********************************************************************/ | ||
| 33 | extern "C" UINT __stdcall MessageQueuingExecuteInstall(MSIHANDLE hInstall) | ||
| 34 | { | ||
| 35 | HRESULT hr = S_OK; | ||
| 36 | UINT er = ERROR_SUCCESS; | ||
| 37 | |||
| 38 | LPWSTR pwzCustomActionData = NULL; | ||
| 39 | LPWSTR pwzData = NULL; | ||
| 40 | |||
| 41 | // initialize | ||
| 42 | hr = WcaInitialize(hInstall, "MessageQueuingExecuteInstall"); | ||
| 43 | ExitOnFailure(hr, "Failed to initialize MessageQueuingExecuteInstall"); | ||
| 44 | |||
| 45 | hr = MqiInitialize(); | ||
| 46 | ExitOnFailure(hr, "Failed to initialize"); | ||
| 47 | |||
| 48 | // get custom action data | ||
| 49 | hr = WcaGetProperty(L"CustomActionData", &pwzCustomActionData); | ||
| 50 | ExitOnFailure(hr, "Failed to get CustomActionData"); | ||
| 51 | pwzData = pwzCustomActionData; | ||
| 52 | |||
| 53 | // create message queues | ||
| 54 | hr = MqiCreateMessageQueues(&pwzData); | ||
| 55 | ExitOnFailure(hr, "Failed to create message queues"); | ||
| 56 | if (S_FALSE == hr) ExitFunction(); | ||
| 57 | |||
| 58 | // add message queue permissions | ||
| 59 | hr = MqiAddMessageQueuePermissions(&pwzData); | ||
| 60 | ExitOnFailure(hr, "Failed to add message queue permissions"); | ||
| 61 | if (S_FALSE == hr) ExitFunction(); | ||
| 62 | |||
| 63 | hr = S_OK; | ||
| 64 | |||
| 65 | LExit: | ||
| 66 | // clean up | ||
| 67 | ReleaseStr(pwzCustomActionData); | ||
| 68 | |||
| 69 | // uninitialize | ||
| 70 | MqiUninitialize(); | ||
| 71 | |||
| 72 | er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; | ||
| 73 | return WcaFinalize(er); | ||
| 74 | } | ||
| 75 | |||
| 76 | /******************************************************************** | ||
| 77 | MessageQueuingRollbackInstall - CUSTOM ACTION ENTRY POINT | ||
| 78 | |||
| 79 | Input: deferred CustomActionData - MessageQueuingRollbackInstall | ||
| 80 | ********************************************************************/ | ||
| 81 | extern "C" UINT __stdcall MessageQueuingRollbackInstall(MSIHANDLE hInstall) | ||
| 82 | { | ||
| 83 | HRESULT hr = S_OK; | ||
| 84 | UINT er = ERROR_SUCCESS; | ||
| 85 | |||
| 86 | LPWSTR pwzCustomActionData = NULL; | ||
| 87 | LPWSTR pwzData = NULL; | ||
| 88 | |||
| 89 | // initialize | ||
| 90 | hr = WcaInitialize(hInstall, "MessageQueuingRollbackInstall"); | ||
| 91 | ExitOnFailure(hr, "Failed to initialize MessageQueuingRollbackInstall"); | ||
| 92 | |||
| 93 | hr = MqiInitialize(); | ||
| 94 | ExitOnFailure(hr, "Failed to initialize"); | ||
| 95 | |||
| 96 | // get custom action data | ||
| 97 | hr = WcaGetProperty(L"CustomActionData", &pwzCustomActionData); | ||
| 98 | ExitOnFailure(hr, "Failed to get CustomActionData"); | ||
| 99 | pwzData = pwzCustomActionData; | ||
| 100 | |||
| 101 | // add message queue permissions | ||
| 102 | hr = MqiRollbackAddMessageQueuePermissions(&pwzData); | ||
| 103 | ExitOnFailure(hr, "Failed to rollback add message queue permissions"); | ||
| 104 | |||
| 105 | // create message queues | ||
| 106 | hr = MqiRollbackCreateMessageQueues(&pwzData); | ||
| 107 | ExitOnFailure(hr, "Failed to rollback create message queues"); | ||
| 108 | |||
| 109 | hr = S_OK; | ||
| 110 | |||
| 111 | LExit: | ||
| 112 | // clean up | ||
| 113 | ReleaseStr(pwzCustomActionData); | ||
| 114 | |||
| 115 | // uninitialize | ||
| 116 | MqiUninitialize(); | ||
| 117 | |||
| 118 | er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; | ||
| 119 | return WcaFinalize(er); | ||
| 120 | } | ||
| 121 | |||
| 122 | /******************************************************************** | ||
| 123 | MessageQueuingExecuteUninstall - CUSTOM ACTION ENTRY POINT | ||
| 124 | |||
| 125 | Input: deferred CustomActionData - MessageQueuingExecuteUninstall | ||
| 126 | ********************************************************************/ | ||
| 127 | extern "C" UINT __stdcall MessageQueuingExecuteUninstall(MSIHANDLE hInstall) | ||
| 128 | { | ||
| 129 | HRESULT hr = S_OK; | ||
| 130 | UINT er = ERROR_SUCCESS; | ||
| 131 | |||
| 132 | LPWSTR pwzCustomActionData = NULL; | ||
| 133 | LPWSTR pwzData = NULL; | ||
| 134 | |||
| 135 | // initialize | ||
| 136 | hr = WcaInitialize(hInstall, "MessageQueuingExecuteUninstall"); | ||
| 137 | ExitOnFailure(hr, "Failed to initialize MessageQueuingExecuteUninstall"); | ||
| 138 | |||
| 139 | hr = MqiInitialize(); | ||
| 140 | ExitOnFailure(hr, "Failed to initialize"); | ||
| 141 | |||
| 142 | // get custom action data | ||
| 143 | hr = WcaGetProperty(L"CustomActionData", &pwzCustomActionData); | ||
| 144 | ExitOnFailure(hr, "Failed to get CustomActionData"); | ||
| 145 | pwzData = pwzCustomActionData; | ||
| 146 | |||
| 147 | // remove message queue permissions | ||
| 148 | hr = MqiRemoveMessageQueuePermissions(&pwzData); | ||
| 149 | ExitOnFailure(hr, "Failed to remove message queue permissions"); | ||
| 150 | if (S_FALSE == hr) ExitFunction(); | ||
| 151 | |||
| 152 | // delete message queues | ||
| 153 | hr = MqiDeleteMessageQueues(&pwzData); | ||
| 154 | ExitOnFailure(hr, "Failed to delete message queues"); | ||
| 155 | if (S_FALSE == hr) ExitFunction(); | ||
| 156 | |||
| 157 | hr = S_OK; | ||
| 158 | |||
| 159 | LExit: | ||
| 160 | // clean up | ||
| 161 | ReleaseStr(pwzCustomActionData); | ||
| 162 | |||
| 163 | // uninitialize | ||
| 164 | MqiUninitialize(); | ||
| 165 | |||
| 166 | er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; | ||
| 167 | return WcaFinalize(er); | ||
| 168 | } | ||
| 169 | |||
| 170 | /******************************************************************** | ||
| 171 | MessageQueuingRollbackUninstall - CUSTOM ACTION ENTRY POINT | ||
| 172 | |||
| 173 | Input: deferred CustomActionData - MessageQueuingRollbackUninstall | ||
| 174 | ********************************************************************/ | ||
| 175 | extern "C" UINT __stdcall MessageQueuingRollbackUninstall(MSIHANDLE hInstall) | ||
| 176 | { | ||
| 177 | HRESULT hr = S_OK; | ||
| 178 | UINT er = ERROR_SUCCESS; | ||
| 179 | |||
| 180 | LPWSTR pwzCustomActionData = NULL; | ||
| 181 | LPWSTR pwzData = NULL; | ||
| 182 | |||
| 183 | // initialize | ||
| 184 | hr = WcaInitialize(hInstall, "MessageQueuingRollbackUninstall"); | ||
| 185 | ExitOnFailure(hr, "Failed to initialize MessageQueuingRollbackUninstall"); | ||
| 186 | |||
| 187 | hr = MqiInitialize(); | ||
| 188 | ExitOnFailure(hr, "Failed to initialize"); | ||
| 189 | |||
| 190 | // get custom action data | ||
| 191 | hr = WcaGetProperty(L"CustomActionData", &pwzCustomActionData); | ||
| 192 | ExitOnFailure(hr, "Failed to get CustomActionData"); | ||
| 193 | pwzData = pwzCustomActionData; | ||
| 194 | |||
| 195 | // delete message queues | ||
| 196 | hr = MqiRollbackDeleteMessageQueues(&pwzData); | ||
| 197 | ExitOnFailure(hr, "Failed to delete message queues"); | ||
| 198 | |||
| 199 | // remove message queue permissions | ||
| 200 | hr = MqiRollbackRemoveMessageQueuePermissions(&pwzData); | ||
| 201 | ExitOnFailure(hr, "Failed to remove message queue permissions"); | ||
| 202 | |||
| 203 | hr = S_OK; | ||
| 204 | |||
| 205 | LExit: | ||
| 206 | // clean up | ||
| 207 | ReleaseStr(pwzCustomActionData); | ||
| 208 | |||
| 209 | // uninitialize | ||
| 210 | MqiUninitialize(); | ||
| 211 | |||
| 212 | er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; | ||
| 213 | return WcaFinalize(er); | ||
| 214 | } | ||
