Reputation: 53
I found port numbers and process ID through GetTcpTable(), PID only identifies process, but I want services within process such as svchost.exe is actully using the port.... sysinternals "procexp" tool shows TCP/IP ports along with services using those ports, under 'TCP/IP' tab... I would like to know what win32 api should use to implement such feature? Or how to implement by other ways?
Upvotes: 2
Views: 806
Reputation: 53
Firstly query the port information from one of the table such as TCP or UDP with TCP_TABLE_OWNER_MODULE_ALL flag, you will get table with information. Now send each row in the table to GetOwnerModuleFromTcpEntry()
which is of IpHlper API. Now you will get ModuleName which is either process name or service name that is running on given port.
Now from this moduleName you can retrive other information about service or process.
Upvotes: 1