public static UInt32 AddIPAddress(IPAddress ipAddress, IPAddress ipAddressMask, int adaptorIndex) { // Note :: This Function has not been tested yet ! IntPtr ptrNTEContext; IntPtr ptrNTEInstance; #pragma warning disable 612,618 uint result = Win32Funcs.AddIPAddress((uint)ipAddress.Address, (uint)ipAddressMask.Address, #pragma warning restore 612,618 adaptorIndex, out ptrNTEContext, out ptrNTEInstance); return(result); }
public UdpRow(Win32Funcs.UdpRow udpRow) { try { _processId = udpRow.owningPid; int localPort = (udpRow.localPort1 << 8) + (udpRow.localPort2) + (udpRow.localPort3 << 24) + (udpRow.localPort4 << 16); long localAddress = udpRow.localAddr; _localEndPoint = new IPEndPoint(localAddress, localPort); } catch { } }
public TcpRow(Win32Funcs.TcpRow tcpRow) { _state = tcpRow.state; _processId = tcpRow.owningPid; int localPort = (tcpRow.localPort1 << 8) + (tcpRow.localPort2) + (tcpRow.localPort3 << 24) + (tcpRow.localPort4 << 16); long localAddress = tcpRow.localAddr; _localEndPoint = new IPEndPoint(localAddress, localPort); int remotePort = (tcpRow.remotePort1 << 8) + (tcpRow.remotePort2) + (tcpRow.remotePort3 << 24) + (tcpRow.remotePort4 << 16); long remoteAddress = tcpRow.remoteAddr; _remoteEndPoint = new IPEndPoint(remoteAddress, remotePort); }
public IPNetRow(Win32Funcs.IpNetRow ipNetRow) { // Todo : I Know what i have to do here! :D ;) _orginalData = ipNetRow; _adaptorIndex = ipNetRow.adaptorIndex; var macaddress = new byte[8] { ipNetRow.adaptorPhysicalMacAddress0, ipNetRow.adaptorPhysicalMacAddress1, ipNetRow.adaptorPhysicalMacAddress2, ipNetRow.adaptorPhysicalMacAddress3, ipNetRow.adaptorPhysicalMacAddress4, ipNetRow.adaptorPhysicalMacAddress5, ipNetRow.adaptorPhysicalMacAddress6, ipNetRow.adaptorPhysicalMacAddress7 }; _entryMacAddress = new PhysicalAddress(macaddress); _entryIPAddress = new IPAddress(BitConverter.GetBytes(ipNetRow.adaptorAddr)); _typeOfArp = (Win32Funcs.ArpEntryType)ipNetRow.typeOfARPEntry; }
public static UdpTable GetExtendedUdpTable(bool sorted, Win32Funcs.UdpTableType tabletype) { var udpRows = new List <UdpRow>(); IntPtr udpTable = IntPtr.Zero; int udpTableLength = 0; if ( Win32Funcs.GetExtendedUdpTable(udpTable, ref udpTableLength, sorted, Win32Funcs.AfInet, tabletype, 0) != 0) { try { udpTable = Marshal.AllocHGlobal(udpTableLength); if ( Win32Funcs.GetExtendedUdpTable(udpTable, ref udpTableLength, true, Win32Funcs.AfInet, tabletype, 0) == 0) { var table = (Win32Funcs.UdpTable)Marshal.PtrToStructure(udpTable, typeof(Win32Funcs.UdpTable)); var rowPtr = (IntPtr)((long)udpTable + Marshal.SizeOf(table.Length)); for (int i = 0; i < table.Length; ++i) { udpRows.Add( new UdpRow( (Win32Funcs.UdpRow)Marshal.PtrToStructure(rowPtr, typeof(Win32Funcs.UdpRow)))); rowPtr = (IntPtr)((long)rowPtr + Marshal.SizeOf(typeof(Win32Funcs.TcpRow))); } } } finally { if (udpTable != IntPtr.Zero) { Marshal.FreeHGlobal(udpTable); } } } return(new UdpTable(udpRows)); }
public static UdpTable GetExtendedUdpTable(bool sorted, Win32Funcs.UdpTableType tabletype) { var udpRows = new List<UdpRow>(); IntPtr udpTable = IntPtr.Zero; int udpTableLength = 0; if ( Win32Funcs.GetExtendedUdpTable(udpTable, ref udpTableLength, sorted, Win32Funcs.AfInet, tabletype, 0) != 0) { try { udpTable = Marshal.AllocHGlobal(udpTableLength); if ( Win32Funcs.GetExtendedUdpTable(udpTable, ref udpTableLength, true, Win32Funcs.AfInet, tabletype, 0) == 0) { var table = (Win32Funcs.UdpTable) Marshal.PtrToStructure(udpTable, typeof (Win32Funcs.UdpTable)); var rowPtr = (IntPtr) ((long) udpTable + Marshal.SizeOf(table.Length)); for (int i = 0; i < table.Length; ++i) { udpRows.Add( new UdpRow( (Win32Funcs.UdpRow) Marshal.PtrToStructure(rowPtr, typeof (Win32Funcs.UdpRow)))); rowPtr = (IntPtr) ((long) rowPtr + Marshal.SizeOf(typeof (Win32Funcs.TcpRow))); } } } finally { if (udpTable != IntPtr.Zero) { Marshal.FreeHGlobal(udpTable); } } } return new UdpTable(udpRows); }
public static IPNetTable GetIpNetTable(bool sorted) { var ipNetRows = new List <IPNetRow>(); IntPtr ipNetTable = IntPtr.Zero; int ipNetTableLength = 0; if (Win32Funcs.GetIpNetTable(ipNetTable, ref ipNetTableLength, sorted) != 0) { try { ipNetTable = Marshal.AllocCoTaskMem(ipNetTableLength); if (Win32Funcs.GetIpNetTable(ipNetTable, ref ipNetTableLength, sorted) == 0) { var table = (Win32Funcs.IpNetTable)Marshal.PtrToStructure(ipNetTable, typeof(Win32Funcs.IpNetTable)); var rowPtr = (IntPtr)((long)ipNetTable + Marshal.SizeOf(table.Length)); for (int i = 0; i < table.Length; i++) { ipNetRows.Add( new IPNetRow( (Win32Funcs.IpNetRow)Marshal.PtrToStructure(rowPtr, typeof(Win32Funcs.IpNetRow)))); rowPtr = (IntPtr)((long)rowPtr + Marshal.SizeOf(typeof(Win32Funcs.IpNetRow))); } } } finally { if (ipNetTable != IntPtr.Zero) { Marshal.FreeHGlobal(ipNetTable); } } } return(new IPNetTable(ipNetRows)); }