Ejemplo n.º 1
0
    // Token: 0x0600008C RID: 140 RVA: 0x00009F1C File Offset: 0x0000811C
    public static TCPGet.MIB_TCPROW_OWNER_PID[] GetAllTCPConnections()
    {
        TCPGet.MIB_TCPROW_OWNER_PID[] result = null;
        IntPtr pTCPTable;
        int    cb;

        TCPGet.GetExtendedTcpTable(pTCPTable, ref cb, false, 2, 5, 0);
        IntPtr intPtr = Marshal.AllocHGlobal(cb);

        if (TCPGet.GetExtendedTcpTable(intPtr, ref cb, false, 2, 5, 0) == 0)
        {
            object obj = Marshal.PtrToStructure(intPtr, typeof(TCPGet.MIB_TCPTABLE_OWNER_PID));
            TCPGet.MIB_TCPTABLE_OWNER_PID mib_TCPTABLE_OWNER_PID2;
            TCPGet.MIB_TCPTABLE_OWNER_PID mib_TCPTABLE_OWNER_PID = (obj != null) ? ((TCPGet.MIB_TCPTABLE_OWNER_PID)obj) : mib_TCPTABLE_OWNER_PID2;
            TCPGet.MIB_TCPROW_OWNER_PID[] array = new TCPGet.MIB_TCPROW_OWNER_PID[mib_TCPTABLE_OWNER_PID.NumberOfEntries - 1 + 1];
            int num  = 0;
            int num2 = mib_TCPTABLE_OWNER_PID.NumberOfEntries - 1;
            for (int i = num; i <= num2; i++)
            {
                IntPtr ptr = new IntPtr(intPtr.ToInt32() + Marshal.SizeOf <int>(mib_TCPTABLE_OWNER_PID.NumberOfEntries) + Marshal.SizeOf(typeof(TCPGet.MIB_TCPROW_OWNER_PID)) * i);
                TCPGet.MIB_TCPROW_OWNER_PID[] array2 = array;
                int    num3 = i;
                object obj2 = Marshal.PtrToStructure(ptr, typeof(TCPGet.MIB_TCPROW_OWNER_PID));
                TCPGet.MIB_TCPROW_OWNER_PID mib_TCPROW_OWNER_PID;
                array2[num3] = ((obj2 != null) ? ((TCPGet.MIB_TCPROW_OWNER_PID)obj2) : mib_TCPROW_OWNER_PID);
            }
            result = array;
        }
        Marshal.FreeHGlobal(intPtr);
        return(result);
    }
Ejemplo n.º 2
0
    // Token: 0x0600008B RID: 139 RVA: 0x00009E2C File Offset: 0x0000802C
    public static object TCPString()
    {
        string text = string.Empty;

        foreach (TCPGet.MIB_TCPROW_OWNER_PID row in TCPGet.GetAllTCPConnections())
        {
            TCPGet.TcpConnection tcpConnection = TCPGet.MIB_ROW_To_TCP(row);
            text = string.Concat(new string[]
            {
                text,
                tcpConnection.Proc,
                ",",
                tcpConnection.localAddress,
                ",",
                Conversions.ToString(tcpConnection.LocalPort),
                ",",
                tcpConnection.RemoteAddress,
                ",",
                Conversions.ToString(tcpConnection.remotePort),
                ",",
                tcpConnection.State.ToString(),
                "|"
            });
        }
        return(text);
    }