示例#1
0
        protected static int IPSecEnumNFAData(IntPtr hStore, Guid PolicyIdentifer, out IPSEC_NFA_DATA ipsecNfaData, out int numNfaObjects)
        {
            ipsecNfaData  = new();
            numNfaObjects = -1;

            IntPtr pppIpsecNFAdata = Marshal.AllocHGlobal(IntPtr.Size);
            IntPtr pNumNFAObjects  = Marshal.AllocHGlobal(Marshal.SizeOf(new int()));

            int hr = IPSecEnumNFAData(hStore, PolicyIdentifer, pppIpsecNFAdata, pNumNFAObjects);

            if (hr != 0)
            {
                return(hr);
            }

            IntPtr ppIpsecNFAdata = Marshal.ReadIntPtr(pppIpsecNFAdata);
            IntPtr pIpsecNFAdata  = Marshal.ReadIntPtr(ppIpsecNFAdata);

            ipsecNfaData  = (IPSEC_NFA_DATA)Marshal.PtrToStructure(pIpsecNFAdata, typeof(IPSEC_NFA_DATA));
            numNfaObjects = Marshal.ReadInt32(pNumNFAObjects);

            Marshal.FreeHGlobal(pppIpsecNFAdata);
            Marshal.FreeHGlobal(pNumNFAObjects);

            return(hr);
        }
示例#2
0
        protected static int IPSecCreateNFAData(IntPtr hStore, Guid PolicyIdentifer, IPSEC_NFA_DATA ipsecNFAData)
        {
            IntPtr pIpsecNFAData = Marshal.AllocHGlobal(Marshal.SizeOf(new IPSEC_NFA_DATA()) + 0x50);

            Marshal.StructureToPtr(ipsecNFAData, pIpsecNFAData, false);
            int hr = IPSecCreateNFAData(hStore, PolicyIdentifer, pIpsecNFAData);

            Marshal.FreeHGlobal(pIpsecNFAData);
            return(hr);
        }
示例#3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="policyGuid"></param>
 /// <param name="ipsecNfaData"></param>
 /// <param name="numNfaObjects"></param>
 /// <returns></returns>
 private int GetPolicyNFAData(Guid policyGuid, out IPSEC_NFA_DATA ipsecNfaData, out int numNfaObjects) => IPSecEnumNFAData(hStore, policyGuid, out ipsecNfaData, out numNfaObjects);
示例#4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="policyIdentifier"></param>
 /// <param name="ipsecNFAData"></param>
 /// <returns></returns>
 private int CreateRule(Guid policyIdentifier, IPSEC_NFA_DATA ipsecNFAData) => IPSecCreateNFAData(hStore, policyIdentifier, ipsecNFAData);