QUOTE(nurbles @ 28.04.2010 16:40)

I wrote several of the programs that are being flagged with PDM.DNS Query. The actual DNS access code came from Microsoft's samples of WinSock applications, yet, as I understand it, my code is apparently "using a DNS API in a non-stardard way." Hopefully, someone can provide an example of the "standard" way, since it is not the documented way.
I know I can exclude these programs, but I'd like to know what I could be doing that is non-standard. Can anyone help, preferably by providing an acceptable C function (using standard Win32 APIs, not C++, .NET or any other managed crap) to determine the various IP addresses of both the local computer and remote computers?
If acceptable code is not an option, then at least provide a list of "non-standard" uses of the Win32 DNS APIs, preferably with explanations of the risks involved with them. Or at least a link to an article on this topic.
Thanks?
KAV seems to display this alert on DNS cache requests. Both WinSock functions (getaddrinfo and gethostbyname) do trigger this alert.
The workaround is to use DnsQuery function with DNS_QUERY_BYPASS_CACHE option.
The following example lacks IPv6 support but it would work for simple resolve requests. This exact code was not tested and may contain errors, but it may help you.
CODE
#include <winsock2.h>
#include <ws2tcpip.h>
#include <dnsapi.h>
#pragma comment(lib,"dnsapi.lib")
#pragma comment(lib,"Ws32_2.lib")
int connect(const char* host, const char* port) {
struct DNS_RECORD *resolved, *server;
int res, retval = -1;
struct sockaddr_in addr;
short nPort = atoi(port);
addr.sin_family = AF_INET;
addr.sin_port = nPort;
res = DnsQuery_UTF8(host,DNS_TYPE_A,DNS_QUERY_BYPASS_CACHE, NULL, &resolved, NULL);
if (res)
return -1;
/* Try all found addresses in the order returned.
* If error is not set in the end we have connected successfully.*/
for (server = resolved; server ;server = server->pNext) {
if (server->wType != DNS_TYPE_A)
continue;
sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sockfd == INVALID_SOCKET)
continue;
addr.sin_addr.S_addr = server->Data.A.IpAddress;
if (connect(sockfd,&addr,sizeof(addr)) == SOCKET_ERROR) {
closesocket(sockfd);
retval = -1;
sockfd = INVALID_SOCKET;
continue;
}
retval = 0;
break;
}
DnsRecordListFree(resolved);
return retval;
}