aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchris_bednarski <Chris.Bednarski@minfos.com.au>2023-08-26 17:31:08 +1000
committerBob Arnson <github@bobs.org>2023-09-12 18:11:21 -0400
commit409d3b63bff29df0859a217ba2843b85d65d2efe (patch)
tree0d39b596681a501d8003db72785bcb1a87f134d4
parente7656ce03e5412b3f12aec7ddd879b3ef771a065 (diff)
downloadwix-409d3b63bff29df0859a217ba2843b85d65d2efe.tar.gz
wix-409d3b63bff29df0859a217ba2843b85d65d2efe.tar.bz2
wix-409d3b63bff29df0859a217ba2843b85d65d2efe.zip
add FIREWALL_EXCEPTION_ATTRIBUTES struct
-rw-r--r--src/ext/Firewall/ca/firewall.cpp198
1 files changed, 89 insertions, 109 deletions
diff --git a/src/ext/Firewall/ca/firewall.cpp b/src/ext/Firewall/ca/firewall.cpp
index 491b10fa..2a1ef825 100644
--- a/src/ext/Firewall/ca/firewall.cpp
+++ b/src/ext/Firewall/ca/firewall.cpp
@@ -8,6 +8,20 @@ enum eFirewallExceptionQuery { feqName = 1, feqRemoteAddresses, feqPort, feqProt
8enum eFirewallExceptionTarget { fetPort = 1, fetApplication, fetUnknown }; 8enum eFirewallExceptionTarget { fetPort = 1, fetApplication, fetUnknown };
9enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 }; 9enum eFirewallExceptionAttributes { feaIgnoreFailures = 1 };
10 10
11struct FIREWALL_EXCEPTION_ATTRIBUTES
12{
13 LPWSTR pwzName;
14
15 LPWSTR pwzRemoteAddresses;
16 LPWSTR pwzPort;
17 int iProtocol;
18 LPWSTR pwzProgram;
19 int iAttributes;
20 int iProfile;
21 LPWSTR pwzDescription;
22 int iDirection;
23};
24
11/****************************************************************** 25/******************************************************************
12 SchedFirewallExceptions - immediate custom action worker to 26 SchedFirewallExceptions - immediate custom action worker to
13 register and remove firewall exceptions. 27 register and remove firewall exceptions.
@@ -26,17 +40,9 @@ static UINT SchedFirewallExceptions(
26 PMSIHANDLE hRec = NULL; 40 PMSIHANDLE hRec = NULL;
27 41
28 LPWSTR pwzCustomActionData = NULL; 42 LPWSTR pwzCustomActionData = NULL;
29 LPWSTR pwzName = NULL;
30 LPWSTR pwzRemoteAddresses = NULL;
31 LPWSTR pwzPort = NULL;
32 int iProtocol = 0;
33 int iAttributes = 0;
34 int iProfile = 0;
35 LPWSTR pwzProgram = NULL;
36 LPWSTR pwzComponent = NULL; 43 LPWSTR pwzComponent = NULL;
37 LPWSTR pwzFormattedFile = NULL; 44
38 LPWSTR pwzDescription = NULL; 45 FIREWALL_EXCEPTION_ATTRIBUTES attrs = { 0 };
39 int iDirection = MSI_NULL_INTEGER;
40 46
41 // initialize 47 // initialize
42 hr = WcaInitialize(hInstall, "SchedFirewallExceptions"); 48 hr = WcaInitialize(hInstall, "SchedFirewallExceptions");
@@ -55,34 +61,34 @@ static UINT SchedFirewallExceptions(
55 61
56 while (S_OK == (hr = WcaFetchRecord(hView, &hRec))) 62 while (S_OK == (hr = WcaFetchRecord(hView, &hRec)))
57 { 63 {
58 hr = WcaGetRecordFormattedString(hRec, feqName, &pwzName); 64 hr = WcaGetRecordFormattedString(hRec, feqName, &attrs.pwzName);
59 ExitOnFailure(hr, "Failed to get firewall exception name."); 65 ExitOnFailure(hr, "Failed to get firewall exception name.");
60 66
61 hr = WcaGetRecordFormattedString(hRec, feqRemoteAddresses, &pwzRemoteAddresses); 67 hr = WcaGetRecordFormattedString(hRec, feqRemoteAddresses, &attrs.pwzRemoteAddresses);
62 ExitOnFailure(hr, "Failed to get firewall exception remote addresses."); 68 ExitOnFailure(hr, "Failed to get firewall exception remote addresses.");
63 69
64 hr = WcaGetRecordFormattedString(hRec, feqPort, &pwzPort); 70 hr = WcaGetRecordFormattedString(hRec, feqPort, &attrs.pwzPort);
65 ExitOnFailure(hr, "Failed to get firewall exception port."); 71 ExitOnFailure(hr, "Failed to get firewall exception port.");
66 72
67 hr = WcaGetRecordInteger(hRec, feqProtocol, &iProtocol); 73 hr = WcaGetRecordInteger(hRec, feqProtocol, &attrs.iProtocol);
68 ExitOnFailure(hr, "Failed to get firewall exception protocol."); 74 ExitOnFailure(hr, "Failed to get firewall exception protocol.");
69 75
70 hr = WcaGetRecordFormattedString(hRec, feqProgram, &pwzProgram); 76 hr = WcaGetRecordFormattedString(hRec, feqProgram, &attrs.pwzProgram);
71 ExitOnFailure(hr, "Failed to get firewall exception program."); 77 ExitOnFailure(hr, "Failed to get firewall exception program.");
72 78
73 hr = WcaGetRecordInteger(hRec, feqAttributes, &iAttributes); 79 hr = WcaGetRecordInteger(hRec, feqAttributes, &attrs.iAttributes);
74 ExitOnFailure(hr, "Failed to get firewall exception attributes."); 80 ExitOnFailure(hr, "Failed to get firewall exception attributes.");
75 81
76 hr = WcaGetRecordInteger(hRec, feqProfile, &iProfile); 82 hr = WcaGetRecordInteger(hRec, feqProfile, &attrs.iProfile);
77 ExitOnFailure(hr, "Failed to get firewall exception profile."); 83 ExitOnFailure(hr, "Failed to get firewall exception profile.");
78 84
79 hr = WcaGetRecordString(hRec, feqComponent, &pwzComponent); 85 hr = WcaGetRecordString(hRec, feqComponent, &pwzComponent);
80 ExitOnFailure(hr, "Failed to get firewall exception component."); 86 ExitOnFailure(hr, "Failed to get firewall exception component.");
81 87
82 hr = WcaGetRecordFormattedString(hRec, feqDescription, &pwzDescription); 88 hr = WcaGetRecordFormattedString(hRec, feqDescription, &attrs.pwzDescription);
83 ExitOnFailure(hr, "Failed to get firewall exception description."); 89 ExitOnFailure(hr, "Failed to get firewall exception description.");
84 90
85 hr = WcaGetRecordInteger(hRec, feqDirection, &iDirection); 91 hr = WcaGetRecordInteger(hRec, feqDirection, &attrs.iDirection);
86 ExitOnFailure(hr, "Failed to get firewall exception direction."); 92 ExitOnFailure(hr, "Failed to get firewall exception direction.");
87 93
88 // figure out what we're doing for this exception, treating reinstall the same as install 94 // figure out what we're doing for this exception, treating reinstall the same as install
@@ -98,25 +104,25 @@ static UINT SchedFirewallExceptions(
98 hr = WcaWriteIntegerToCaData(todoComponent, &pwzCustomActionData); 104 hr = WcaWriteIntegerToCaData(todoComponent, &pwzCustomActionData);
99 ExitOnFailure(hr, "failed to write exception action to custom action data"); 105 ExitOnFailure(hr, "failed to write exception action to custom action data");
100 106
101 hr = WcaWriteStringToCaData(pwzName, &pwzCustomActionData); 107 hr = WcaWriteStringToCaData(attrs.pwzName, &pwzCustomActionData);
102 ExitOnFailure(hr, "failed to write exception name to custom action data"); 108 ExitOnFailure(hr, "failed to write exception name to custom action data");
103 109
104 hr = WcaWriteIntegerToCaData(iProfile, &pwzCustomActionData); 110 hr = WcaWriteIntegerToCaData(attrs.iProfile, &pwzCustomActionData);
105 ExitOnFailure(hr, "failed to write exception profile to custom action data"); 111 ExitOnFailure(hr, "failed to write exception profile to custom action data");
106 112
107 hr = WcaWriteStringToCaData(pwzRemoteAddresses, &pwzCustomActionData); 113 hr = WcaWriteStringToCaData(attrs.pwzRemoteAddresses, &pwzCustomActionData);
108 ExitOnFailure(hr, "failed to write exception remote addresses to custom action data"); 114 ExitOnFailure(hr, "failed to write exception remote addresses to custom action data");
109 115
110 hr = WcaWriteIntegerToCaData(iAttributes, &pwzCustomActionData); 116 hr = WcaWriteIntegerToCaData(attrs.iAttributes, &pwzCustomActionData);
111 ExitOnFailure(hr, "failed to write exception attributes to custom action data"); 117 ExitOnFailure(hr, "failed to write exception attributes to custom action data");
112 118
113 if (*pwzProgram) 119 if (*attrs.pwzProgram)
114 { 120 {
115 // If program is defined, we have an application exception. 121 // If program is defined, we have an application exception.
116 hr = WcaWriteIntegerToCaData(fetApplication, &pwzCustomActionData); 122 hr = WcaWriteIntegerToCaData(fetApplication, &pwzCustomActionData);
117 ExitOnFailure(hr, "failed to write exception target (application) to custom action data"); 123 ExitOnFailure(hr, "failed to write exception target (application) to custom action data");
118 124
119 hr = WcaWriteStringToCaData(pwzProgram, &pwzCustomActionData); 125 hr = WcaWriteStringToCaData(attrs.pwzProgram, &pwzCustomActionData);
120 ExitOnFailure(hr, "failed to write application path to custom action data"); 126 ExitOnFailure(hr, "failed to write application path to custom action data");
121 } 127 }
122 else 128 else
@@ -126,16 +132,16 @@ static UINT SchedFirewallExceptions(
126 ExitOnFailure(hr, "failed to write exception target (port) to custom action data"); 132 ExitOnFailure(hr, "failed to write exception target (port) to custom action data");
127 } 133 }
128 134
129 hr = WcaWriteStringToCaData(pwzPort, &pwzCustomActionData); 135 hr = WcaWriteStringToCaData(attrs.pwzPort, &pwzCustomActionData);
130 ExitOnFailure(hr, "failed to write application path to custom action data"); 136 ExitOnFailure(hr, "failed to write application path to custom action data");
131 137
132 hr = WcaWriteIntegerToCaData(iProtocol, &pwzCustomActionData); 138 hr = WcaWriteIntegerToCaData(attrs.iProtocol, &pwzCustomActionData);
133 ExitOnFailure(hr, "failed to write exception protocol to custom action data"); 139 ExitOnFailure(hr, "failed to write exception protocol to custom action data");
134 140
135 hr = WcaWriteStringToCaData(pwzDescription, &pwzCustomActionData); 141 hr = WcaWriteStringToCaData(attrs.pwzDescription, &pwzCustomActionData);
136 ExitOnFailure(hr, "failed to write firewall rule description to custom action data"); 142 ExitOnFailure(hr, "failed to write firewall rule description to custom action data");
137 143
138 hr = WcaWriteIntegerToCaData(iDirection, &pwzCustomActionData); 144 hr = WcaWriteIntegerToCaData(attrs.iDirection, &pwzCustomActionData);
139 ExitOnFailure(hr, "failed to write firewall rule direction to custom action data"); 145 ExitOnFailure(hr, "failed to write firewall rule direction to custom action data");
140 } 146 }
141 147
@@ -172,14 +178,13 @@ static UINT SchedFirewallExceptions(
172 } 178 }
173 179
174LExit: 180LExit:
175 ReleaseStr(pwzCustomActionData); 181 ReleaseStr(attrs.pwzName);
176 ReleaseStr(pwzName); 182 ReleaseStr(attrs.pwzRemoteAddresses);
177 ReleaseStr(pwzRemoteAddresses); 183 ReleaseStr(attrs.pwzPort);
178 ReleaseStr(pwzPort); 184 ReleaseStr(attrs.pwzProgram);
179 ReleaseStr(pwzProgram); 185 ReleaseStr(attrs.pwzDescription);
180 ReleaseStr(pwzComponent); 186 ReleaseStr(pwzComponent);
181 ReleaseStr(pwzDescription); 187 ReleaseStr(pwzCustomActionData);
182 ReleaseStr(pwzFormattedFile);
183 188
184 return WcaFinalize(er = FAILED(hr) ? ERROR_INSTALL_FAILURE : er); 189 return WcaFinalize(er = FAILED(hr) ? ERROR_INSTALL_FAILURE : er);
185} 190}
@@ -272,12 +277,7 @@ LExit:
272********************************************************************/ 277********************************************************************/
273static HRESULT CreateFwRuleObject( 278static HRESULT CreateFwRuleObject(
274 __in BSTR bstrName, 279 __in BSTR bstrName,
275 __in int iProfile, 280 __in FIREWALL_EXCEPTION_ATTRIBUTES const& attrs,
276 __in_opt LPCWSTR wzRemoteAddresses,
277 __in LPCWSTR wzPort,
278 __in int iProtocol,
279 __in LPCWSTR wzDescription,
280 __in int iDirection,
281 __out INetFwRule** ppNetFwRule 281 __out INetFwRule** ppNetFwRule
282 ) 282 )
283{ 283{
@@ -289,11 +289,11 @@ static HRESULT CreateFwRuleObject(
289 *ppNetFwRule = NULL; 289 *ppNetFwRule = NULL;
290 290
291 // convert to BSTRs to make COM happy 291 // convert to BSTRs to make COM happy
292 bstrRemoteAddresses = ::SysAllocString(wzRemoteAddresses); 292 bstrRemoteAddresses = ::SysAllocString(attrs.pwzRemoteAddresses);
293 ExitOnNull(bstrRemoteAddresses, hr, E_OUTOFMEMORY, "failed SysAllocString for remote addresses"); 293 ExitOnNull(bstrRemoteAddresses, hr, E_OUTOFMEMORY, "failed SysAllocString for remote addresses");
294 bstrPort = ::SysAllocString(wzPort); 294 bstrPort = ::SysAllocString(attrs.pwzPort);
295 ExitOnNull(bstrPort, hr, E_OUTOFMEMORY, "failed SysAllocString for port"); 295 ExitOnNull(bstrPort, hr, E_OUTOFMEMORY, "failed SysAllocString for port");
296 bstrDescription = ::SysAllocString(wzDescription); 296 bstrDescription = ::SysAllocString(attrs.pwzDescription);
297 ExitOnNull(bstrDescription, hr, E_OUTOFMEMORY, "failed SysAllocString for description"); 297 ExitOnNull(bstrDescription, hr, E_OUTOFMEMORY, "failed SysAllocString for description");
298 298
299 hr = ::CoCreateInstance(__uuidof(NetFwRule), NULL, CLSCTX_ALL, __uuidof(INetFwRule), (void**)&pNetFwRule); 299 hr = ::CoCreateInstance(__uuidof(NetFwRule), NULL, CLSCTX_ALL, __uuidof(INetFwRule), (void**)&pNetFwRule);
@@ -302,12 +302,12 @@ static HRESULT CreateFwRuleObject(
302 hr = pNetFwRule->put_Name(bstrName); 302 hr = pNetFwRule->put_Name(bstrName);
303 ExitOnFailure(hr, "failed to set exception name"); 303 ExitOnFailure(hr, "failed to set exception name");
304 304
305 hr = pNetFwRule->put_Profiles(static_cast<NET_FW_PROFILE_TYPE2>(iProfile)); 305 hr = pNetFwRule->put_Profiles(static_cast<NET_FW_PROFILE_TYPE2>(attrs.iProfile));
306 ExitOnFailure(hr, "failed to set exception profile"); 306 ExitOnFailure(hr, "failed to set exception profile");
307 307
308 if (MSI_NULL_INTEGER != iProtocol) 308 if (MSI_NULL_INTEGER != attrs.iProtocol)
309 { 309 {
310 hr = pNetFwRule->put_Protocol(static_cast<NET_FW_IP_PROTOCOL>(iProtocol)); 310 hr = pNetFwRule->put_Protocol(static_cast<NET_FW_IP_PROTOCOL>(attrs.iProtocol));
311 ExitOnFailure(hr, "failed to set exception protocol"); 311 ExitOnFailure(hr, "failed to set exception protocol");
312 } 312 }
313 313
@@ -329,9 +329,9 @@ static HRESULT CreateFwRuleObject(
329 ExitOnFailure(hr, "failed to set exception description '%ls'", bstrDescription); 329 ExitOnFailure(hr, "failed to set exception description '%ls'", bstrDescription);
330 } 330 }
331 331
332 if (MSI_NULL_INTEGER != iDirection) 332 if (MSI_NULL_INTEGER != attrs.iDirection)
333 { 333 {
334 hr = pNetFwRule->put_Direction(static_cast<NET_FW_RULE_DIRECTION> (iDirection)); 334 hr = pNetFwRule->put_Direction(static_cast<NET_FW_RULE_DIRECTION> (attrs.iDirection));
335 ExitOnFailure(hr, "failed to set exception direction"); 335 ExitOnFailure(hr, "failed to set exception direction");
336 } 336 }
337 337
@@ -352,15 +352,8 @@ LExit:
352 352
353********************************************************************/ 353********************************************************************/
354static HRESULT AddApplicationException( 354static HRESULT AddApplicationException(
355 __in LPCWSTR wzFile, 355 __in FIREWALL_EXCEPTION_ATTRIBUTES const& attrs,
356 __in LPCWSTR wzName, 356 __in BOOL fIgnoreFailures
357 __in int iProfile,
358 __in_opt LPCWSTR wzRemoteAddresses,
359 __in BOOL fIgnoreFailures,
360 __in LPCWSTR wzPort,
361 __in int iProtocol,
362 __in LPCWSTR wzDescription,
363 __in int iDirection
364 ) 357 )
365{ 358{
366 HRESULT hr = S_OK; 359 HRESULT hr = S_OK;
@@ -370,9 +363,9 @@ static HRESULT AddApplicationException(
370 INetFwRule* pNetFwRule = NULL; 363 INetFwRule* pNetFwRule = NULL;
371 364
372 // convert to BSTRs to make COM happy 365 // convert to BSTRs to make COM happy
373 bstrFile = ::SysAllocString(wzFile); 366 bstrFile = ::SysAllocString(attrs.pwzProgram);
374 ExitOnNull(bstrFile, hr, E_OUTOFMEMORY, "failed SysAllocString for path"); 367 ExitOnNull(bstrFile, hr, E_OUTOFMEMORY, "failed SysAllocString for path");
375 bstrName = ::SysAllocString(wzName); 368 bstrName = ::SysAllocString(attrs.pwzName);
376 ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); 369 ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name");
377 370
378 // get the collection of firewall rules 371 // get the collection of firewall rules
@@ -387,7 +380,7 @@ static HRESULT AddApplicationException(
387 hr = pNetFwRules->Item(bstrName, &pNetFwRule); 380 hr = pNetFwRules->Item(bstrName, &pNetFwRule);
388 if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) 381 if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr)
389 { 382 {
390 hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, iDirection, &pNetFwRule); 383 hr = CreateFwRuleObject(bstrName, attrs, &pNetFwRule);
391 ExitOnFailure(hr, "failed to create FwRule object"); 384 ExitOnFailure(hr, "failed to create FwRule object");
392 385
393 // set edge traversal to true 386 // set edge traversal to true
@@ -429,15 +422,9 @@ LExit:
429 422
430********************************************************************/ 423********************************************************************/
431static HRESULT AddPortException( 424static HRESULT AddPortException(
432 __in LPCWSTR wzName, 425 __in FIREWALL_EXCEPTION_ATTRIBUTES const& attrs,
433 __in int iProfile, 426 __in BOOL fIgnoreFailures
434 __in_opt LPCWSTR wzRemoteAddresses, 427 )
435 __in BOOL fIgnoreFailures,
436 __in LPCWSTR wzPort,
437 __in int iProtocol,
438 __in LPCWSTR wzDescription,
439 __in int iDirection
440)
441{ 428{
442 HRESULT hr = S_OK; 429 HRESULT hr = S_OK;
443 BSTR bstrName = NULL; 430 BSTR bstrName = NULL;
@@ -445,7 +432,7 @@ static HRESULT AddPortException(
445 INetFwRule* pNetFwRule = NULL; 432 INetFwRule* pNetFwRule = NULL;
446 433
447 // convert to BSTRs to make COM happy 434 // convert to BSTRs to make COM happy
448 bstrName = ::SysAllocString(wzName); 435 bstrName = ::SysAllocString(attrs.pwzName);
449 ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name"); 436 ExitOnNull(bstrName, hr, E_OUTOFMEMORY, "failed SysAllocString for name");
450 437
451 // get the collection of firewall rules 438 // get the collection of firewall rules
@@ -460,7 +447,7 @@ static HRESULT AddPortException(
460 hr = pNetFwRules->Item(bstrName, &pNetFwRule); 447 hr = pNetFwRules->Item(bstrName, &pNetFwRule);
461 if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr) 448 if (HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) == hr)
462 { 449 {
463 hr = CreateFwRuleObject(bstrName, iProfile, wzRemoteAddresses, wzPort, iProtocol, wzDescription, iDirection, &pNetFwRule); 450 hr = CreateFwRuleObject(bstrName, attrs, &pNetFwRule);
464 ExitOnFailure(hr, "failed to create FwRule object"); 451 ExitOnFailure(hr, "failed to create FwRule object");
465 452
466 // enable it 453 // enable it
@@ -535,16 +522,9 @@ extern "C" UINT __stdcall ExecFirewallExceptions(
535 LPWSTR pwz = NULL; 522 LPWSTR pwz = NULL;
536 LPWSTR pwzCustomActionData = NULL; 523 LPWSTR pwzCustomActionData = NULL;
537 int iTodo = WCA_TODO_UNKNOWN; 524 int iTodo = WCA_TODO_UNKNOWN;
538 LPWSTR pwzName = NULL;
539 LPWSTR pwzRemoteAddresses = NULL;
540 int iAttributes = 0;
541 int iTarget = fetUnknown; 525 int iTarget = fetUnknown;
542 LPWSTR pwzFile = NULL; 526
543 LPWSTR pwzPort = NULL; 527 FIREWALL_EXCEPTION_ATTRIBUTES attrs = { 0 };
544 LPWSTR pwzDescription = NULL;
545 int iProtocol = 0;
546 int iProfile = 0;
547 int iDirection = 0;
548 528
549 // initialize 529 // initialize
550 hr = WcaInitialize(hInstall, "ExecFirewallExceptions"); 530 hr = WcaInitialize(hInstall, "ExecFirewallExceptions");
@@ -576,35 +556,35 @@ extern "C" UINT __stdcall ExecFirewallExceptions(
576 } 556 }
577 } 557 }
578 558
579 hr = WcaReadStringFromCaData(&pwz, &pwzName); 559 hr = WcaReadStringFromCaData(&pwz, &attrs.pwzName);
580 ExitOnFailure(hr, "failed to read name from custom action data"); 560 ExitOnFailure(hr, "failed to read name from custom action data");
581 561
582 hr = WcaReadIntegerFromCaData(&pwz, &iProfile); 562 hr = WcaReadIntegerFromCaData(&pwz, &attrs.iProfile);
583 ExitOnFailure(hr, "failed to read profile from custom action data"); 563 ExitOnFailure(hr, "failed to read profile from custom action data");
584 564
585 hr = WcaReadStringFromCaData(&pwz, &pwzRemoteAddresses); 565 hr = WcaReadStringFromCaData(&pwz, &attrs.pwzRemoteAddresses);
586 ExitOnFailure(hr, "failed to read remote addresses from custom action data"); 566 ExitOnFailure(hr, "failed to read remote addresses from custom action data");
587 567
588 hr = WcaReadIntegerFromCaData(&pwz, &iAttributes); 568 hr = WcaReadIntegerFromCaData(&pwz, &attrs.iAttributes);
589 ExitOnFailure(hr, "failed to read attributes from custom action data"); 569 ExitOnFailure(hr, "failed to read attributes from custom action data");
590 BOOL fIgnoreFailures = feaIgnoreFailures == (iAttributes & feaIgnoreFailures); 570 BOOL fIgnoreFailures = feaIgnoreFailures == (attrs.iAttributes & feaIgnoreFailures);
591 571
592 hr = WcaReadIntegerFromCaData(&pwz, &iTarget); 572 hr = WcaReadIntegerFromCaData(&pwz, &iTarget);
593 ExitOnFailure(hr, "failed to read target from custom action data"); 573 ExitOnFailure(hr, "failed to read target from custom action data");
594 574
595 if (iTarget == fetApplication) 575 if (iTarget == fetApplication)
596 { 576 {
597 hr = WcaReadStringFromCaData(&pwz, &pwzFile); 577 hr = WcaReadStringFromCaData(&pwz, &attrs.pwzProgram);
598 ExitOnFailure(hr, "failed to read file path from custom action data"); 578 ExitOnFailure(hr, "failed to read file path from custom action data");
599 } 579 }
600 580
601 hr = WcaReadStringFromCaData(&pwz, &pwzPort); 581 hr = WcaReadStringFromCaData(&pwz, &attrs.pwzPort);
602 ExitOnFailure(hr, "failed to read port from custom action data"); 582 ExitOnFailure(hr, "failed to read port from custom action data");
603 hr = WcaReadIntegerFromCaData(&pwz, &iProtocol); 583 hr = WcaReadIntegerFromCaData(&pwz, &attrs.iProtocol);
604 ExitOnFailure(hr, "failed to read protocol from custom action data"); 584 ExitOnFailure(hr, "failed to read protocol from custom action data");
605 hr = WcaReadStringFromCaData(&pwz, &pwzDescription); 585 hr = WcaReadStringFromCaData(&pwz, &attrs.pwzDescription);
606 ExitOnFailure(hr, "failed to read protocol from custom action data"); 586 ExitOnFailure(hr, "failed to read protocol from custom action data");
607 hr = WcaReadIntegerFromCaData(&pwz, &iDirection); 587 hr = WcaReadIntegerFromCaData(&pwz, &attrs.iDirection);
608 ExitOnFailure(hr, "failed to read direction from custom action data"); 588 ExitOnFailure(hr, "failed to read direction from custom action data");
609 589
610 switch (iTarget) 590 switch (iTarget)
@@ -614,15 +594,15 @@ extern "C" UINT __stdcall ExecFirewallExceptions(
614 { 594 {
615 case WCA_TODO_INSTALL: 595 case WCA_TODO_INSTALL:
616 case WCA_TODO_REINSTALL: 596 case WCA_TODO_REINSTALL:
617 WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls on port %ls, protocol %d", pwzName, pwzPort, iProtocol); 597 WcaLog(LOGMSG_STANDARD, "Installing firewall exception %ls on port %ls, protocol %d", attrs.pwzName, attrs.pwzPort, attrs.iProtocol);
618 hr = AddPortException(pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription, iDirection); 598 hr = AddPortException(attrs, fIgnoreFailures);
619 ExitOnFailure(hr, "failed to add/update port exception for name '%ls' on port %ls, protocol %d", pwzName, pwzPort, iProtocol); 599 ExitOnFailure(hr, "failed to add/update port exception for name '%ls' on port %ls, protocol %d", attrs.pwzName, attrs.pwzPort, attrs.iProtocol);
620 break; 600 break;
621 601
622 case WCA_TODO_UNINSTALL: 602 case WCA_TODO_UNINSTALL:
623 WcaLog(LOGMSG_STANDARD, "Uninstalling firewall exception2 %ls on port %ls, protocol %d", pwzName, pwzPort, iProtocol); 603 WcaLog(LOGMSG_STANDARD, "Uninstalling firewall exception %ls on port %ls, protocol %d", attrs.pwzName, attrs.pwzPort, attrs.iProtocol);
624 hr = RemoveException(pwzName, fIgnoreFailures); 604 hr = RemoveException(attrs.pwzName, fIgnoreFailures);
625 ExitOnFailure(hr, "failed to remove port exception for name '%ls' on port %ls, protocol %d", pwzName, pwzPort, iProtocol); 605 ExitOnFailure(hr, "failed to remove port exception for name '%ls' on port %ls, protocol %d", attrs.pwzName, attrs.pwzPort, attrs.iProtocol);
626 break; 606 break;
627 } 607 }
628 break; 608 break;
@@ -632,15 +612,15 @@ extern "C" UINT __stdcall ExecFirewallExceptions(
632 { 612 {
633 case WCA_TODO_INSTALL: 613 case WCA_TODO_INSTALL:
634 case WCA_TODO_REINSTALL: 614 case WCA_TODO_REINSTALL:
635 WcaLog(LOGMSG_STANDARD, "Installing firewall exception2 %ls (%ls)", pwzName, pwzFile); 615 WcaLog(LOGMSG_STANDARD, "Installing firewall exception %ls (%ls)", attrs.pwzName, attrs.pwzProgram);
636 hr = AddApplicationException(pwzFile, pwzName, iProfile, pwzRemoteAddresses, fIgnoreFailures, pwzPort, iProtocol, pwzDescription, iDirection); 616 hr = AddApplicationException(attrs, fIgnoreFailures);
637 ExitOnFailure(hr, "failed to add/update application exception for name '%ls', file '%ls'", pwzName, pwzFile); 617 ExitOnFailure(hr, "failed to add/update application exception for name '%ls', file '%ls'", attrs.pwzName, attrs.pwzProgram);
638 break; 618 break;
639 619
640 case WCA_TODO_UNINSTALL: 620 case WCA_TODO_UNINSTALL:
641 WcaLog(LOGMSG_STANDARD, "Uninstalling firewall exception2 %ls (%ls)", pwzName, pwzFile); 621 WcaLog(LOGMSG_STANDARD, "Uninstalling firewall exception %ls (%ls)", attrs.pwzName, attrs.pwzProgram);
642 hr = RemoveException(pwzName, fIgnoreFailures); 622 hr = RemoveException(attrs.pwzName, fIgnoreFailures);
643 ExitOnFailure(hr, "failed to remove application exception for name '%ls', file '%ls'", pwzName, pwzFile); 623 ExitOnFailure(hr, "failed to remove application exception for name '%ls', file '%ls'", attrs.pwzName, attrs.pwzProgram);
644 break; 624 break;
645 } 625 }
646 break; 626 break;
@@ -649,11 +629,11 @@ extern "C" UINT __stdcall ExecFirewallExceptions(
649 629
650LExit: 630LExit:
651 ReleaseStr(pwzCustomActionData); 631 ReleaseStr(pwzCustomActionData);
652 ReleaseStr(pwzName); 632 ReleaseStr(attrs.pwzName);
653 ReleaseStr(pwzRemoteAddresses); 633 ReleaseStr(attrs.pwzRemoteAddresses);
654 ReleaseStr(pwzFile); 634 ReleaseStr(attrs.pwzProgram);
655 ReleaseStr(pwzPort); 635 ReleaseStr(attrs.pwzPort);
656 ReleaseStr(pwzDescription); 636 ReleaseStr(attrs.pwzDescription);
657 ::CoUninitialize(); 637 ::CoUninitialize();
658 638
659 return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS); 639 return WcaFinalize(FAILED(hr) ? ERROR_INSTALL_FAILURE : ERROR_SUCCESS);