internal static ConnectionInfo[] GetConnections() { UIntPtr count = UIntPtr.Zero; IntPtr connections = Interop.NT_GetConnections(ref count); int connectionInfoSize = Marshal.SizeOf(typeof(NtConnectionInfo)); int arraySize = (int)count.ToUInt64(); ConnectionInfo[] connectionsArray = new ConnectionInfo[arraySize]; for (int i = 0; i < arraySize; i++) { IntPtr data = new IntPtr(connections.ToInt64() + connectionInfoSize * i); var con = (NtConnectionInfo)Marshal.PtrToStructure(data, typeof(NtConnectionInfo)); connectionsArray[i] = new ConnectionInfo(con.RemoteId.ToString(), ReadUTF8String(con.RemoteName), (int)con.RemotePort, (long)con.LastUpdate, (int)con.ProtocolVersion); } Interop.NT_DisposeConnectionInfoArray(connections, count); return(connectionsArray); }