Fix. Msi, firewall outbound profile (#7704)

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2024-04-12 18:44:18 +08:00 committed by GitHub
parent 8231d07706
commit 24ea55b010
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -272,26 +272,9 @@ HRESULT AddFirewallRuleWithEdgeTraversal(
goto Cleanup;
}
if (in) {
CurrentProfilesBitMask = NET_FW_PROFILE2_ALL;
}
else {
// Retrieve Current Profiles bitmask
hr = pNetFwPolicy2->get_CurrentProfileTypes(&CurrentProfilesBitMask);
if (FAILED(hr))
{
printf("get_CurrentProfileTypes failed: 0x%08lx\n", hr);
goto Cleanup;
}
// When possible we avoid adding firewall rules to the Public profile.
// If Public is currently active and it is not the only active profile, we remove it from the bitmask
if ((CurrentProfilesBitMask & NET_FW_PROFILE2_PUBLIC) &&
(CurrentProfilesBitMask != NET_FW_PROFILE2_PUBLIC))
{
CurrentProfilesBitMask ^= NET_FW_PROFILE2_PUBLIC;
}
}
// If you want the rule to avoid public, you can refer to
// https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ics/c-adding-an-outbound-rule
CurrentProfilesBitMask = NET_FW_PROFILE2_ALL;
hr = pNetFwRule->put_Direction(in ? NET_FW_RULE_DIR_IN : NET_FW_RULE_DIR_OUT);
if (FAILED(hr))