https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6fb6c7b50b7f7b65737b3…
commit 6fb6c7b50b7f7b65737b373553ca0d400d924f36
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sat Nov 24 21:12:44 2018 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Sat Nov 24 21:41:10 2018 +0100
[IPHLPAPI] Implement getOwnerUdoTable(), to get UDP connections with owner PID
---
dll/win32/iphlpapi/ipstats_reactos.c | 61 ++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git a/dll/win32/iphlpapi/ipstats_reactos.c b/dll/win32/iphlpapi/ipstats_reactos.c
index d117a5f4ce..8c1c842c9c 100644
--- a/dll/win32/iphlpapi/ipstats_reactos.c
+++ b/dll/win32/iphlpapi/ipstats_reactos.c
@@ -700,6 +700,67 @@ PMIB_UDPTABLE getUdpTable(void)
return IpUdpTable;
}
+PMIB_UDPTABLE_OWNER_PID getOwnerUdpTable(void)
+{
+ DWORD numEntities, returnSize;
+ TDIEntityID *entitySet;
+ HANDLE tcpFile;
+ int i, totalNumber, TmpIdx, CurrIdx = 0;
+ NTSTATUS status;
+ PMIB_UDPTABLE_OWNER_PID IpOwnerUdpTable = NULL;
+ PMIB_UDPROW_OWNER_PID AdapterOwnerUdpTable = NULL;
+
+ TRACE("called.\n");
+
+ totalNumber = getNumUdpEntries();
+
+ status = openTcpFile( &tcpFile, FILE_READ_DATA );
+ if( !NT_SUCCESS(status) ) {
+ ERR("openTcpFile returned 0x%08lx\n", status);
+ return 0;
+ }
+
+ IpOwnerUdpTable = HeapAlloc
+ ( GetProcessHeap(), 0,
+ sizeof(DWORD) + (sizeof(MIB_UDPROW_OWNER_PID) * totalNumber) );
+ if (!IpOwnerUdpTable) {
+ closeTcpFile(tcpFile);
+ return NULL;
+ }
+
+ status = tdiGetEntityIDSet( tcpFile, &entitySet, &numEntities );
+
+ for( i = 0; i < numEntities; i++ ) {
+ if( entitySet[i].tei_entity == CL_TL_ENTITY &&
+ hasArp( tcpFile, &entitySet[i] ) ) {
+
+ status = tdiGetSetOfThings( tcpFile,
+ INFO_CLASS_PROTOCOL,
+ INFO_TYPE_PROVIDER,
+ IP_MIB_ADDRTABLE_ENTRY_ID,
+ CL_TL_ENTITY,
+ entitySet[i].tei_instance,
+ 0,
+ sizeof(MIB_UDPROW_OWNER_PID),
+ (PVOID *)&AdapterOwnerUdpTable,
+ &returnSize );
+
+ if( status == STATUS_SUCCESS ) {
+ for( TmpIdx = 0; TmpIdx < returnSize; TmpIdx++, CurrIdx++ )
+ IpOwnerUdpTable->table[CurrIdx] = AdapterOwnerUdpTable[TmpIdx];
+ tdiFreeThingSet( AdapterOwnerUdpTable );
+ }
+ }
+ }
+
+ closeTcpFile( tcpFile );
+
+ tdiFreeThingSet( entitySet );
+ IpOwnerUdpTable->dwNumEntries = CurrIdx;
+
+ return IpOwnerUdpTable;
+}
+
DWORD getNumTcpEntries(void)
{
DWORD numEntities;