//////////////////////////////////////////////////////////////////////////////// // // Port <-> Process (Netstat -noa) // // File : RFPortXP.cpp // Comment : Only For XP // // Create at : 2002.5.31 // Create by : Refdom // Email : refdom@263.net // Home Page : www.opengram.com // // If you modify the code, or add more functions, please email me a copy. // //////////////////////////////////////////////////////////////////////////////// #include <stdio.h> #include <windows.h> #include <iprtrmib.h> #include <tlhelp32.h> #include <iphlpapi.h> #pragma comment(lib, "ws2_32.lib") // Maximum string lengths for ASCII ip address and port names // #define HOSTNAMELEN 256 #define PORTNAMELEN 256 #define ADDRESSLEN HOSTNAMELEN+PORTNAMELEN // // Our option flags // #define FLAG_ALL_ENDPOINTS 1 #define FLAG_SHOW_NUMBERS 2 // // Undocumented extended information structures available // only on XP and higher // typedef struct tagMIB_TCPEXROW{ DWORD dwState; // state of the connection DWORD dwLocalAddr; // address on local computer DWORD dwLocalPort; // port number on local computer DWORD dwRemoteAddr; // address on remote computer DWORD dwRemotePort; // port number on remote computer DWORD dwProcessId; } MIB_TCPEXROW, *PMIB_TCPEXROW;
typedef struct tagMIB_UDPEXROW{ DWORD dwLocalAddr; // address on local computer DWORD dwLocalPort; // port number on local computer DWORD dwProcessId; } MIB_UDPEXROW, *PMIB_UDPEXROW;