From 13de7f08af1fa37c6f0aeb8bd58d8971aab8d069 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Sat, 24 Nov 2018 21:09:17 +0100 Subject: [PATCH] [TCPIP] Implement enumerating UDP connections with owner PID --- drivers/network/tcpip/include/info.h | 3 ++- drivers/network/tcpip/tcpip/info.c | 7 ++++++- drivers/network/tcpip/tcpip/ninfo.c | 9 ++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/network/tcpip/include/info.h b/drivers/network/tcpip/include/info.h index c0998db479b..358a8b0a5a1 100644 --- a/drivers/network/tcpip/include/info.h +++ b/drivers/network/tcpip/include/info.h @@ -121,7 +121,8 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable( PADDRESS_FILE AddrFile, TDI_STATUS InfoTdiQueryGetConnectionUdpTable( PADDRESS_FILE AddrFile, PNDIS_BUFFER Buffer, - PUINT BufferSize); + PUINT BufferSize, + BOOLEAN Extended); TDI_STATUS InfoTdiSetRoute(PIP_INTERFACE IF, PVOID Buffer, diff --git a/drivers/network/tcpip/tcpip/info.c b/drivers/network/tcpip/tcpip/info.c index e29d415a7a5..b64e8619ed1 100644 --- a/drivers/network/tcpip/tcpip/info.c +++ b/drivers/network/tcpip/tcpip/info.c @@ -271,6 +271,11 @@ TDI_STATUS InfoTdiQueryInformationEx( return InfoTdiQueryGetConnectionTcpTable(EntityListContext, Buffer, BufferSize, TRUE); else return TDI_INVALID_PARAMETER; + else if (ID->toi_entity.tei_entity == CL_TL_ENTITY) + if ((EntityListContext = GetContext(ID->toi_entity))) + return InfoTdiQueryGetConnectionUdpTable(EntityListContext, Buffer, BufferSize, TRUE); + else + return TDI_INVALID_PARAMETER; else return TDI_INVALID_PARAMETER; @@ -297,7 +302,7 @@ TDI_STATUS InfoTdiQueryInformationEx( return TDI_INVALID_PARAMETER; else if (ID->toi_entity.tei_entity == CL_TL_ENTITY) if ((EntityListContext = GetContext(ID->toi_entity))) - return InfoTdiQueryGetConnectionUdpTable(EntityListContext, Buffer, BufferSize); + return InfoTdiQueryGetConnectionUdpTable(EntityListContext, Buffer, BufferSize, FALSE); else return TDI_INVALID_PARAMETER; else diff --git a/drivers/network/tcpip/tcpip/ninfo.c b/drivers/network/tcpip/tcpip/ninfo.c index 63d1d124c42..06eddd4bafa 100644 --- a/drivers/network/tcpip/tcpip/ninfo.c +++ b/drivers/network/tcpip/tcpip/ninfo.c @@ -249,17 +249,20 @@ TDI_STATUS InfoTdiQueryGetConnectionTcpTable(PADDRESS_FILE AddrFile, TDI_STATUS InfoTdiQueryGetConnectionUdpTable(PADDRESS_FILE AddrFile, PNDIS_BUFFER Buffer, - PUINT BufferSize) + PUINT BufferSize, + BOOLEAN Extended) { - MIB_UDPROW UdpRow; + MIB_UDPROW_OWNER_PID UdpRow; TDI_STATUS Status = TDI_INVALID_REQUEST; TI_DbgPrint(DEBUG_INFO, ("Called.\n")); UdpRow.dwLocalAddr = AddrFile->Address.Address.IPv4Address; UdpRow.dwLocalPort = AddrFile->Port; + UdpRow.dwOwningPid = (DWORD)AddrFile->ProcessId; - Status = InfoCopyOut( (PCHAR)&UdpRow, sizeof(UdpRow), + Status = InfoCopyOut( (PCHAR)&UdpRow, + (Extended ? sizeof(MIB_UDPROW_OWNER_PID) : sizeof(MIB_UDPROW)), Buffer, BufferSize ); TI_DbgPrint(DEBUG_INFO, ("Returning %08x\n", Status));