Skip to content

Instantly share code, notes, and snippets.

@jjxtra
Created July 21, 2020 13:49
Show Gist options
  • Save jjxtra/e00eda540d68ccf8a421d20ee68bc289 to your computer and use it in GitHub Desktop.
Save jjxtra/e00eda540d68ccf8a421d20ee68bc289 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Wfp
{
/// PInvoke wrappers for Windows Filtering Platform
public class WfpNativeInterop
{
public enum FWP_DIRECTION_
{
/// FWP_DIRECTION_OUTBOUND -> 0
FWP_DIRECTION_OUTBOUND = 0,
/// FWP_DIRECTION_INBOUND -> 1
FWP_DIRECTION_INBOUND = 1,
/// FWP_DIRECTION_MAX -> 2
FWP_DIRECTION_MAX = 2,
}
public enum FWP_IP_VERSION_
{
/// FWP_IP_VERSION_V4 -> 0
FWP_IP_VERSION_V4 = 0,
/// FWP_IP_VERSION_V6 -> 1
FWP_IP_VERSION_V6 = 1,
/// FWP_IP_VERSION_NONE -> 2
FWP_IP_VERSION_NONE = 2,
/// FWP_IP_VERSION_MAX -> 3
FWP_IP_VERSION_MAX = 3,
}
public enum FWP_NE_FAMILY_
{
/// FWP_AF_INET -> FWP_IP_VERSION_V4
FWP_AF_INET = FWP_IP_VERSION_.FWP_IP_VERSION_V4,
/// FWP_AF_INET6 -> FWP_IP_VERSION_V6
FWP_AF_INET6 = FWP_IP_VERSION_.FWP_IP_VERSION_V6,
/// FWP_AF_ETHER -> FWP_IP_VERSION_NONE
FWP_AF_ETHER = FWP_IP_VERSION_.FWP_IP_VERSION_NONE,
/// FWP_AF_NONE -> 3
FWP_AF_NONE = 3,
}
public enum FWP_ETHER_ENCAP_METHOD_
{
/// FWP_ETHER_ENCAP_METHOD_ETHER_V2 -> 0
FWP_ETHER_ENCAP_METHOD_ETHER_V2 = 0,
/// FWP_ETHER_ENCAP_METHOD_SNAP -> 1
FWP_ETHER_ENCAP_METHOD_SNAP = 1,
/// FWP_ETHER_ENCAP_METHOD_SNAP_W_OUI_ZERO -> 3
FWP_ETHER_ENCAP_METHOD_SNAP_W_OUI_ZERO = 3,
}
public enum FWP_DATA_TYPE_
{
/// FWP_EMPTY -> 0
FWP_EMPTY = 0,
/// FWP_UINT8 -> 1
FWP_UINT8 = 1,
/// FWP_UINT16 -> 2
FWP_UINT16 = 2,
/// FWP_UINT32 -> 3
FWP_UINT32 = 3,
/// FWP_UINT64 -> 4
FWP_UINT64 = 4,
/// FWP_INT8 -> 5
FWP_INT8 = 5,
/// FWP_INT16 -> 6
FWP_INT16 = 6,
/// FWP_INT32 -> 7
FWP_INT32 = 7,
/// FWP_INT64 -> 8
FWP_INT64 = 8,
/// FWP_FLOAT -> 9
FWP_FLOAT = 9,
/// FWP_DOUBLE -> 10
FWP_DOUBLE = 10,
/// FWP_BYTE_ARRAY16_TYPE -> 11
FWP_BYTE_ARRAY16_TYPE = 11,
/// FWP_BYTE_BLOB_TYPE -> 12
FWP_BYTE_BLOB_TYPE = 12,
/// FWP_SID -> 13
FWP_SID = 13,
/// FWP_SECURITY_DESCRIPTOR_TYPE -> 14
FWP_SECURITY_DESCRIPTOR_TYPE = 14,
/// FWP_TOKEN_INFORMATION_TYPE -> 15
FWP_TOKEN_INFORMATION_TYPE = 15,
/// FWP_TOKEN_ACCESS_INFORMATION_TYPE -> 16
FWP_TOKEN_ACCESS_INFORMATION_TYPE = 16,
/// FWP_UNICODE_STRING_TYPE -> 17
FWP_UNICODE_STRING_TYPE = 17,
/// FWP_BYTE_ARRAY6_TYPE -> 18
FWP_BYTE_ARRAY6_TYPE = 18,
/// FWP_SINGLE_DATA_TYPE_MAX -> 0xff
FWP_SINGLE_DATA_TYPE_MAX = 255,
/// FWP_V4_ADDR_MASK -> 0x100
FWP_V4_ADDR_MASK = 256,
/// FWP_V6_ADDR_MASK -> 0x101
FWP_V6_ADDR_MASK = 257,
/// FWP_RANGE_TYPE -> 0x102
FWP_RANGE_TYPE = 258,
/// FWP_DATA_TYPE_MAX -> 0x103
FWP_DATA_TYPE_MAX = 259,
}
public enum FWP_MATCH_TYPE_
{
/// FWP_MATCH_EQUAL -> 0
FWP_MATCH_EQUAL = 0,
/// FWP_MATCH_GREATER -> 1
FWP_MATCH_GREATER = 1,
/// FWP_MATCH_LESS -> 2
FWP_MATCH_LESS = 2,
/// FWP_MATCH_GREATER_OR_EQUAL -> 3
FWP_MATCH_GREATER_OR_EQUAL = 3,
/// FWP_MATCH_LESS_OR_EQUAL -> 4
FWP_MATCH_LESS_OR_EQUAL = 4,
/// FWP_MATCH_RANGE -> 5
FWP_MATCH_RANGE = 5,
/// FWP_MATCH_FLAGS_ALL_SET -> 6
FWP_MATCH_FLAGS_ALL_SET = 6,
/// FWP_MATCH_FLAGS_ANY_SET -> 7
FWP_MATCH_FLAGS_ANY_SET = 7,
/// FWP_MATCH_FLAGS_NONE_SET -> 8
FWP_MATCH_FLAGS_NONE_SET = 8,
/// FWP_MATCH_EQUAL_CASE_INSENSITIVE -> 9
FWP_MATCH_EQUAL_CASE_INSENSITIVE = 9,
/// FWP_MATCH_NOT_EQUAL -> 10
FWP_MATCH_NOT_EQUAL = 10,
/// FWP_MATCH_TYPE_MAX -> 11
FWP_MATCH_TYPE_MAX = 11,
}
public enum FWP_VSWITCH_NETWORK_TYPE_
{
/// FWP_VSWITCH_NETWORK_TYPE_UNKNOWN -> 0
FWP_VSWITCH_NETWORK_TYPE_UNKNOWN = 0,
/// FWP_VSWITCH_NETWORK_TYPE_PRIVATE -> 1
FWP_VSWITCH_NETWORK_TYPE_PRIVATE = 1,
/// FWP_VSWITCH_NETWORK_TYPE_INTERNAL -> 2
FWP_VSWITCH_NETWORK_TYPE_INTERNAL = 2,
/// FWP_VSWITCH_NETWORK_TYPE_EXTERNAL -> 3
FWP_VSWITCH_NETWORK_TYPE_EXTERNAL = 3,
}
public enum FWP_CLASSIFY_OPTION_TYPE_
{
/// FWP_CLASSIFY_OPTION_MULTICAST_STATE -> 0
FWP_CLASSIFY_OPTION_MULTICAST_STATE = 0,
/// FWP_CLASSIFY_OPTION_LOOSE_SOURCE_MAPPING -> 1
FWP_CLASSIFY_OPTION_LOOSE_SOURCE_MAPPING = 1,
/// FWP_CLASSIFY_OPTION_UNICAST_LIFETIME -> 2
FWP_CLASSIFY_OPTION_UNICAST_LIFETIME = 2,
/// FWP_CLASSIFY_OPTION_MCAST_BCAST_LIFETIME -> 3
FWP_CLASSIFY_OPTION_MCAST_BCAST_LIFETIME = 3,
/// FWP_CLASSIFY_OPTION_SECURE_SOCKET_SECURITY_FLAGS -> 4
FWP_CLASSIFY_OPTION_SECURE_SOCKET_SECURITY_FLAGS = 4,
/// FWP_CLASSIFY_OPTION_SECURE_SOCKET_AUTHIP_MM_POLICY_KEY -> 5
FWP_CLASSIFY_OPTION_SECURE_SOCKET_AUTHIP_MM_POLICY_KEY = 5,
/// FWP_CLASSIFY_OPTION_SECURE_SOCKET_AUTHIP_QM_POLICY_KEY -> 6
FWP_CLASSIFY_OPTION_SECURE_SOCKET_AUTHIP_QM_POLICY_KEY = 6,
/// FWP_CLASSIFY_OPTION_LOCAL_ONLY_MAPPING -> 7
FWP_CLASSIFY_OPTION_LOCAL_ONLY_MAPPING = 7,
/// FWP_CLASSIFY_OPTION_MAX -> 8
FWP_CLASSIFY_OPTION_MAX = 8,
}
public enum FWP_FILTER_ENUM_TYPE_
{
/// FWP_FILTER_ENUM_FULLY_CONTAINED -> 0
FWP_FILTER_ENUM_FULLY_CONTAINED = 0,
/// FWP_FILTER_ENUM_OVERLAPPING -> 1
FWP_FILTER_ENUM_OVERLAPPING = 1,
/// FWP_FILTER_ENUM_TYPE_MAX -> 2
FWP_FILTER_ENUM_TYPE_MAX = 2,
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct FWPM_DISPLAY_DATA0_
{
/// wchar_t*
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string name;
/// wchar_t*
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)]
public string description;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct FWP_BYTE_BLOB_
{
/// UINT32->int
public int size;
/// UINT8*
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPStr)]
public string data;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Ansi)]
public struct FWP_BYTE_ARRAY6_
{
/// UINT8[6]
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 6)]
public string byteArray6;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Ansi)]
public struct FWP_BYTE_ARRAY16_
{
/// UINT8[16]
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 16)]
public string byteArray16;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct FWP_TOKEN_INFORMATION
{
/// ULONG->int
public int sidCount;
/// PSID_AND_ATTRIBUTES->_SID_AND_ATTRIBUTES*
public System.IntPtr sids;
/// ULONG->int
public int restrictedSidCount;
/// PSID_AND_ATTRIBUTES->_SID_AND_ATTRIBUTES*
public System.IntPtr restrictedSids;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct FWP_V4_ADDR_AND_MASK_
{
/// UINT32->int
public int addr;
/// UINT32->int
public int mask;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential, CharSet = System.Runtime.InteropServices.CharSet.Ansi)]
public struct FWP_V6_ADDR_AND_MASK_
{
/// UINT8[0]
[System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst = 0)]
public string addr;
/// UINT8->char
public byte prefixLength;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Explicit)]
public struct Anonymous_750df4da_d850_4fa1_a0b8_aefa57daeefd
{
/// UINT8->char
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public byte uint8;
/// UINT16->short
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public short uint16;
/// UINT32->int
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public int uint32;
/// UINT64*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr uint64;
/// INT8->char
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public byte int8;
/// INT16->short
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public short int16;
/// INT32->int
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public int int32;
/// INT64*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr int64;
/// float
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public float float32;
/// double*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr double64;
/// FWP_BYTE_ARRAY16*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr byteArray16;
/// FWP_BYTE_BLOB*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr byteBlob;
/// SID*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr sid;
/// FWP_BYTE_BLOB*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr sd;
/// FWP_TOKEN_INFORMATION*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr tokenInformation;
/// FWP_BYTE_BLOB*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr tokenAccessInformation;
/// LPWSTR->WCHAR*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr unicodeString;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct FWP_VALUE0_
{
/// FWP_DATA_TYPE->FWP_DATA_TYPE_
public FWP_DATA_TYPE_ type;
/// Anonymous_750df4da_d850_4fa1_a0b8_aefa57daeefd
public Anonymous_750df4da_d850_4fa1_a0b8_aefa57daeefd Union1;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct FWP_RANGE0_
{
/// FWP_VALUE0->FWP_VALUE0_
public FWP_VALUE0_ valueLow;
/// FWP_VALUE0->FWP_VALUE0_
public FWP_VALUE0_ valueHigh;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Explicit)]
public struct Anonymous_bf22c1aa_535d_4df6_af7c_2f1c9e645897
{
/// GUID->_GUID
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public Guid filterType;
/// GUID->_GUID
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public Guid calloutKey;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct FWPM_ACTION0_
{
/// FWP_ACTION_TYPE->UINT32->int
public int type;
/// Anonymous_bf22c1aa_535d_4df6_af7c_2f1c9e645897
public Anonymous_bf22c1aa_535d_4df6_af7c_2f1c9e645897 Union1;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Explicit)]
public struct Anonymous_99707a60_90d9_473c_951b_97fea591b664
{
/// UINT8->char
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public byte uint8;
/// UINT16->short
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public short uint16;
/// UINT32->int
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public int uint32;
/// UINT64*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr uint64;
/// INT8->char
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public byte int8;
/// INT16->short
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public short int16;
/// INT32->int
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public int int32;
/// INT64*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr int64;
/// float
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public float float32;
/// double*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr double64;
/// FWP_BYTE_ARRAY16*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr byteArray16;
/// FWP_BYTE_BLOB*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr byteBlob;
/// SID*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr sid;
/// FWP_BYTE_BLOB*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr sd;
/// FWP_BYTE_BLOB*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr tokenInformation;
/// FWP_BYTE_BLOB*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr tokenAccessInformation;
/// LPWSTR->WCHAR*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr unicodeString;
/// FWP_BYTE_ARRAY6*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr byteArray6;
/// FWP_V4_ADDR_AND_MASK*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr v4AddrMask;
/// FWP_V6_ADDR_AND_MASK*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr v6AddrMask;
/// FWP_RANGE0*
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public System.IntPtr rangeValue;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct FWP_CONDITION_VALUE0_
{
/// FWP_DATA_TYPE->FWP_DATA_TYPE_
public FWP_DATA_TYPE_ type;
/// Anonymous_99707a60_90d9_473c_951b_97fea591b664
public Anonymous_99707a60_90d9_473c_951b_97fea591b664 Union1;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct FWPM_FILTER_CONDITION0_
{
/// GUID->_GUID
public Guid fieldKey;
/// FWP_MATCH_TYPE->FWP_MATCH_TYPE_
public FWP_MATCH_TYPE_ matchType;
/// FWP_CONDITION_VALUE0->FWP_CONDITION_VALUE0_
public FWP_CONDITION_VALUE0_ conditionValue;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Explicit)]
public struct Anonymous_cb34be57_1743_4fbd_bd83_ab14b1cf7ace
{
/// UINT64->__int64
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public long rawContext;
/// GUID->_GUID
[System.Runtime.InteropServices.FieldOffsetAttribute(0)]
public Guid providerContextKey;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct FWPM_FILTER0_
{
/// GUID->_GUID
public Guid filterKey;
/// FWPM_DISPLAY_DATA0->FWPM_DISPLAY_DATA0_
public FWPM_DISPLAY_DATA0_ displayData;
/// UINT32->int
public int flags;
/// GUID*
public Guid* providerKey;
/// FWP_BYTE_BLOB->FWP_BYTE_BLOB_
public FWP_BYTE_BLOB_ providerData;
/// GUID->_GUID
public Guid layerKey;
/// GUID->_GUID
public Guid subLayerKey;
/// FWP_VALUE0->FWP_VALUE0_
public FWP_VALUE0_ weight;
/// UINT32->int
public int numFilterConditions;
/// FWPM_FILTER_CONDITION0*
public FWPM_FILTER_CONDITION0_* filterCondition;
/// FWPM_ACTION0->FWPM_ACTION0_
public FWPM_ACTION0_ action;
/// Anonymous_cb34be57_1743_4fbd_bd83_ab14b1cf7ace
public Anonymous_cb34be57_1743_4fbd_bd83_ab14b1cf7ace Union1;
/// GUID*
public Guid* reserved;
/// UINT64->__int64
public long filterId;
/// FWP_VALUE0->FWP_VALUE0_
public FWP_VALUE0_ effectiveWeight;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct FWPM_SUBLAYER0_
{
/// GUID->_GUID
public Guid subLayerKey;
/// FWPM_DISPLAY_DATA0->FWPM_DISPLAY_DATA0_
public FWPM_DISPLAY_DATA0_ displayData;
/// UINT32->int
public int flags;
/// GUID*
public Guid* providerKey;
/// FWP_BYTE_BLOB->FWP_BYTE_BLOB_
public FWP_BYTE_BLOB_ providerData;
/// UINT16->short
public short weight;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct SECURITY_DESCRIPTOR_
{
/// BYTE->char
public byte Revision;
/// BYTE->char
public byte Sbz1;
/// SECURITY_DESCRIPTOR_CONTROL->WORD->short
public short Control;
/// PSID->PVOID->void*
public System.IntPtr Owner;
/// PSID->PVOID->void*
public System.IntPtr Group;
/// PACL->ACL*
public System.IntPtr Sacl;
/// PACL->ACL*
public System.IntPtr Dacl;
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public struct FWPM_CALLOUT0_
{
public Guid calloutKey;
public FWPM_DISPLAY_DATA0_ displayData;
public uint flags;
public Guid* providerKey; // _GUID
public FWP_BYTE_BLOB_ providerData;
public Guid applicableLayer;
public uint calloutId;
}
// authnservice = 10 or uint.MaxValue, pass null for the other inputs
[System.Runtime.InteropServices.DllImportAttribute("FWPUClnt.dll", EntryPoint = "FwpmEngineOpen0")]
public static extern uint FwpmEngineOpen0([System.Runtime.InteropServices.InAttribute()] [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.LPWStr)] string serverName, uint authnService, [System.Runtime.InteropServices.InAttribute()] System.IntPtr authIdentity, [System.Runtime.InteropServices.InAttribute()] System.IntPtr session, ref System.IntPtr engineHandle);
[System.Runtime.InteropServices.DllImportAttribute("FWPUClnt.dll", EntryPoint = "FwpmEngineClose0")]
public static extern uint FwpmEngineClose0(IntPtr handle);
// flags = 1 means read only transaction, flags of 0 is read/write transaction
[System.Runtime.InteropServices.DllImportAttribute("FWPUClnt.dll", EntryPoint = "FwpmTransactionBegin0")]
public static extern uint FwpmTransactionBegin0(IntPtr engineHandle, uint flags);
[System.Runtime.InteropServices.DllImportAttribute("FWPUClnt.dll", EntryPoint = "FwpmTransactionCommit0")]
public static extern uint FwpmTransactionCommit0(IntPtr engineHandle);
[System.Runtime.InteropServices.DllImportAttribute("FWPUClnt.dll", EntryPoint = "FwpmFilterAdd0")]
public static extern uint FwpmFilterAdd0(IntPtr engineHandle, ref FWPM_FILTER0_ filter, ref SECURITY_DESCRIPTOR_ sd, ref IntPtr id);
[System.Runtime.InteropServices.DllImportAttribute("FWPUClnt.dll", EntryPoint = "FwpmFilterDeleteById0")]
public static extern uint FwpmFilterDeleteById0(IntPtr engineHandle, IntPtr id);
[System.Runtime.InteropServices.DllImportAttribute("FWPUClnt.dll", EntryPoint = "FwpmFilterDeleteByKey0")]
public static extern uint FwpmFilterDeleteByKey0(IntPtr engineHandle, ref Guid key);
[System.Runtime.InteropServices.DllImportAttribute("FWPUClnt.dll", EntryPoint = "FwpmSubLayerAdd0")]
public static extern uint FwpmSubLayerAdd0([System.Runtime.InteropServices.InAttribute()] System.IntPtr engineHandle, [System.Runtime.InteropServices.InAttribute()] ref FWPM_SUBLAYER0_ subLayer, [System.Runtime.InteropServices.InAttribute()] System.IntPtr sd);
[System.Runtime.InteropServices.DllImportAttribute("FWPUClnt.dll", EntryPoint = "FwpmSubLayerDeleteByKey0")]
public static extern uint FwpmSubLayerDeleteByKey0(IntPtr engineHandle, ref Guid key);
[System.Runtime.InteropServices.DllImportAttribute("FWPUClnt.dll", EntryPoint = "FwpmCalloutAdd0")]
public static extern uint FwpmCalloutAdd0(IntPtr engineHandle, ref FWPM_CALLOUT0_ callout, ref SECURITY_DESCRIPTOR_ sd, ref IntPtr id);
[System.Runtime.InteropServices.DllImportAttribute("FWPUClnt.dll", EntryPoint = "FwpmCalloutDeleteById0")]
public static extern uint FwpmCalloutDeleteById0(IntPtr engineHandle, uint id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment