Beispiel #1
0
        public static List <MibTcpRowOwnerId> GetTcpConnections(IpVersion ipVersion, TcpTableClass tableClass)
        {
            int tableSize = 0;

            GetExtendedTcpTable(IntPtr.Zero, ref tableSize, true, ipVersion, tableClass);

            var tcpTablePtr    = Marshal.AllocHGlobal(tableSize);
            var tcpConnections = new List <MibTcpRowOwnerId>();

            try
            {
                if (GetExtendedTcpTable(tcpTablePtr, ref tableSize, true, ipVersion, tableClass) != 0)
                {
                    return(tcpConnections);
                }

                var table  = Marshal.PtrToStructure <MibTcpTableOwnerPid>(tcpTablePtr);
                var rowPtr = IntPtr.Add(tcpTablePtr, Marshal.SizeOf(table.TableCount));
                for (var i = 0; i < table.TableCount; i++)
                {
                    var tcpRow = Marshal.PtrToStructure <MibTcpRowOwnerId>(rowPtr);

                    tcpConnections.Add(tcpRow);

                    rowPtr = IntPtr.Add(rowPtr, Marshal.SizeOf(tcpRow));
                }
            }
            finally
            {
                Marshal.FreeHGlobal(tcpTablePtr);
            }

            return(tcpConnections);
        }
Beispiel #2
0
 public static extern uint GetExtendedTcpTable(
     IntPtr tcpTable,
     ref int outBufLen,
     bool sort,
     IpVersion ipVersion,
     TcpTableClass tableClass,
     uint reserved = 0);
Beispiel #3
0
 private static extern int GetExtendedTcpTable(
     byte[] pTcpTable,
     out int dwOutBufLen,
     bool sort,
     int ipVersion,
     TcpTableClass tblClass,
     int reserved);
Beispiel #4
0
 private static extern uint GetExtendedTcpTable(IntPtr pTcpTable, ref int dwOutBufLen, bool sort, int ipVersion, TcpTableClass tblClass, uint reserved = 0);
Beispiel #5
0
 private static extern uint GetExtendedTcpTable(IntPtr pTcpTable, ref int pdwSize, bool bOrder,
                                                int ulAf, TcpTableClass tableClass, uint reserved = 0);
 private static extern uint GetExtendedTcpTable(IntPtr pTcpTable, ref int dwOutBufLen, bool sort, int ipVersion,
     TcpTableClass tblClass, uint reserved = 0);
 internal static extern uint GetExtendedTcpTable(SafeLocalFree pTcpTable, ref uint dwOutBufLen, bool order, uint IPVersion, TcpTableClass tableClass, uint reserved);
 internal extern static uint GetExtendedTcpTable(SafeLocalFree pTcpTable, ref uint dwOutBufLen, bool order,
                                                 uint IPVersion, TcpTableClass tableClass, uint reserved);
 internal extern static uint GetExtendedTcpTable(SafeLocalAllocHandle pTcpTable, ref uint dwOutBufLen, bool order,
                                                 uint IPVersion, TcpTableClass tableClass, uint reserved);
 internal static unsafe partial uint GetExtendedTcpTable(IntPtr pTcpTable, uint *dwOutBufLen, [MarshalAs(UnmanagedType.Bool)] bool order,
                                                         uint IPVersion, TcpTableClass tableClass, uint reserved);
 internal static unsafe partial uint GetExtendedTcpTable(IntPtr pTcpTable, uint *dwOutBufLen, bool order,
                                                         uint IPVersion, TcpTableClass tableClass, uint reserved);
 public static extern int GetExtendedTcpTable(IntPtr pTcpTable, ref dword pdwSize, bool bOrder, AfInet ulAf, TcpTableClass tcpTableClass, dword reserved = 0);
Beispiel #13
0
 public static extern int GetExtendedTcpTable(byte[] tcpTable, out int size, bool order, uint ipVersion, TcpTableClass tableClass, uint reserved);