Each program that sends packets more then likely has a predefined structure, so you could read first few bytes of packet and get most likely program.
Also if you check the port that could be more helpful as there uassly unique.
Another would be check destination ip. Have a list you check against(somthing like this).
PortUsed,DestIp:NameOfProgram
Read in whole file when app starts. Use , as delimiter and read in vars to check against and : to read in name of app. There is nice containers you could use to link vars to name. Or just recursively search each line till match found or EOF.
I don't know how this function alone will get you the EXE file which send/receive data on the network.
There is an undocumented way by using AllocateAndGetTcpExTableFromStack() and AllocateAndGetUdpExTableFromStack() from IpHelperApi whose prototypes are: