c++ - Difference between GetExtendedUdpTable and netstat result -
i used code opened udp ports , application use every port.
dword (winapi *pgetextendedudptable)( pvoid pudptable, pdword pdwsize, bool border, ulong ulaf, udp_table_class tableclass, ulong reserved ); mib_udptable_owner_pid *pudpinfo; mib_udprow_owner_pid *owner; dword size; dword dwresult; hmodule hlib = loadlibrary((lpcwstr)"iphlpapi.dll"); pgetextendedudptable = (dword (winapi *)(pvoid,pdword,bool,ulong,udp_table_class,ulong)) getprocaddress(hlib, "getextendedtcptable"); if ( !pgetextendedudptable ) { //printf("could not load iphlpapi.dll. application windows xp sp2 , up.\n"); return "could not load iphlpapi.dll. application windows xp sp2 , up.\n"; } dwresult = pgetextendedudptable(null, &size, false, af_inet, (udp_table_class)5, 0); pudpinfo = (mib_udptable_owner_pid*)malloc(size); dwresult = pgetextendedudptable(pudpinfo, &size, false, af_inet, (udp_table_class)5, 0); // if (dwresult != no_error) { printf("couldn't our ip table"); return "couldn't our ip table"; } (dword dwloop = 0; dwloop < pudpinfo->dwnumentries; dwloop++) { owner = &pudpinfo->table[dwloop]; applicationname = getnamebypid(owner->dwowningpid); openedport = convertint(ntohs(owner->dwlocalport)); localadress = convertint(ntohs(owner->dwlocaladdr)); }
but, haven't same result netstat -ano.in code, have port 0 more 10 times in netstat command port 0 doesn't exist.
you have udp everywhere function you're querying tcp 1 (getextendedtcptable
).
Comments
Post a Comment