How to get number of Rules and details of rule using WFP API ( like the old INetFwPolicy2 COM based APIs )

Sinha Prokash 46 Reputation points
2022-02-18T18:18:09.65+00:00

Using - INetFwPolicy2 , INetFwRules, INetFwRule , and associated COM based ( old style firewall API ) I can see all the rules like ---


Name: Windows Collaboration Computer Name Registration Service (SSDP-Out)
Description: Outbound rule for the Windows Collaboration Computer Name Registration Service to allow use of the Simple Service Discovery Protocol. [UDP 1900]
Application Name: C:\WINDOWS\system32\svchost.exe
Service Name: Ssdpsrv
IP Protocol: UDP
Local Ports: *
Remote Ports: 1900
LocalAddresses: *
RemoteAddresses: LocalSubnet
Profile: Domain
Profile: Private
Profile: Public
Direction: Out
Action: Allow
Interface Types: All

On my machine the number of rules is 531, and each one is a rule.

How can I get a similar output using WFP API ??

Using WFP API, enumerate over all the Filters, I get 337 such Filters ( Basically number of Rules using old FW API, and number of Filters does not match using WFP ).

result = FwpmFilterCreateEnumHandle0(
engine,
NULL, // &enumTempl( result is 1783,
&enumHandle
);
EXIT_ON_ERROR(FwpmFilterCreateEnumHandle0);

result = FwpmFilterEnum0(
    engine,
    enumHandle,
    INFINITE,
    filters,
    numFilters
);
EXIT_ON_ERROR(FwpmFilterEnum0);

So is there a way to get the old style information using WFP API ?? If not, then can I use the old type COM based API for some specific routines of my module ?

Thanks,
Prokash

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,619 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.