How Do i find the listed functions of DNSAPI

  • Thread starter Thread starter lloyd
  • Start date Start date
L

lloyd

Hi ALL,

I am trying to find out all the function names inside of DNSAPI.DLL.
I tried to view this in OLEVIEW but to no avail, also from the object
browser.
This did not help either.

If any one has any info please help me out, also if you tell me what
exactly does this DLL do, we have a query that is being used in c#,
with an unsafe method of coding.
They are using a function called LowLevelQuery to query the DNS
server.

Is this a function inside of DNSAPI??


Thanks,
Lloyd
 
You would be better of posting on one of the programming lists.

My guess is that DNSAPI.dll is NOT an OLE module and you
would be better off with one of the traditional BinDump (sp?)
or similar tools.
 
I am trying to find out all the function names inside
of DNSAPI.DLL. I tried to view this in OLEVIEW but
to no avail, also from the object browser.
<snip>

Try having a look here ;-)

http://msdn.microsoft.com/library/en-us/dns/dns/dns_functions.asp

for the API documentation and here

http://www.codeguru.com/Cpp/I-N/internet/dns/article.php/c6173/

for a working example (COM object using the DNS APIs)

Regards

--

* ObiWan

Microsoft MVP: Windows Server - Networking
http://mvp.support.microsoft.com
http://italy.mvps.org
 
Hi ObiWan,

Thanks for your reply.

We have implemented the DNSAPI to perform a lookup on the DNS servers
to return us the A,MX,PTR,TXT records if any. This implementation is
in C# and we are referencing the Windows System DLL into our
application using DLLIMPORT function .

What we are noticing is the intermittant and weird behaviour of the
system, sometimes it does not return any DNS record. Most of the times
it does.
We are struggling to solve this issue,

I hope you can throw some light into this dark tunnel
 
What we are noticing is the intermittant and
weird behaviour of the system, sometimes it
does not return any DNS record. Most of the
times it does.
We are struggling to solve this issue,

Could you explain the problem with some more
details and/or give an example of the problem
you're facing ??

Also, are you releasing the resource records
(buffers) returned from the DnsAPI after parsing
them ... or are you keeping them "hung" ?

And since I'm at it ... did you try disabling the
"dnsclient" (cache) service to see if this has
some effect on the above behaviour ?

That said, I think this thread may as well belong
to the C# newsgroup .. although, talking about
DNS it may belong here too

Regards

--

* ObiWan

Microsoft MVP: Windows Server - Networking
http://mvp.support.microsoft.com
http://italy.mvps.org
 
In
ObiWan said:
Could you explain the problem with some more
details and/or give an example of the problem
you're facing ??

Also, are you releasing the resource records
(buffers) returned from the DnsAPI after parsing
them ... or are you keeping them "hung" ?

And since I'm at it ... did you try disabling the
"dnsclient" (cache) service to see if this has
some effect on the above behaviour ?

That said, I think this thread may as well belong
to the C# newsgroup .. although, talking about
DNS it may belong here too

Regards

I think William Stacey can comment on this if he sees this thread. He
developed his NetDIG utility (nice utility, free at www.mvptools.com), using
VB.net. I believe he succesffully set it up this way. I'll ping him to get
him involved, if he hasn't seen this yet.

--
Regards,
Ace

Please direct all replies ONLY to the Microsoft public newsgroups
so all can benefit.

This posting is provided "AS-IS" with no warranties or guarantees
and confers no rights.

Ace Fekay, MCSE 2003 & 2000, MCSA 2003 & 2000, MCSE+I, MCT, MVP
Microsoft Windows MVP - Windows Server - Directory Services

Security Is Like An Onion, It Has Layers
HAM AND EGGS: A day's work for a chicken;
A lifetime commitment for a pig.
 
Hi ObiWan,

The problem is like this. We are building a SPF record from the
queried Domain DNS.

For example, we type in IBM.Com and it returns the listed
a,mx,ptr,include records and TXT records if any. we then process this
information.

What we noticed is that sometimes for the Domain like IBM.COM it
returns the a,mx,ptr,txt records and sometimes it does not return any
records.
Resulting in our process to fail

We are releasing all the memory allocated to the DNSAPI via system
free resources.

There might be a local DNS server on the Web server that hosts this
application, if so my questions are two fold

1) What does the DNS local server do? If it has cached the Records and
is serving us the records from its store, when and how can it be
serving us wrong Record?

2) How to byPass the local DNS server in code?
3) How to clear the cache on the server, it will have to be done
programmatically as it is a web interface and is open to all users to
query their domain.

Thanks in advance.
 
For example, we type in IBM.Com and it
returns the listed a,mx,ptr,include records
and TXT records if any. we then process
this information.

ok, but ... do you mean you're performing three (or more)
separate queries (one for A, another for MX and so on..)
or are you running ONE query which sometimes returns
a wealth of intos and some others returns ... "nothing" ??

I've seen that happen at times, the solution was using
separate queries, the cause .. well, afaict ... if the data
you request isn't cached then you'll have the full data
set, otherwise ... ;-)
We are releasing all the memory allocated to the
DNSAPI via system free resources.

What I mean is .. are you calling DnsRecordListFree()
after parsing the returned DNS record list as needed ?
1) What does the DNS local server do? If it has cached the
Records and is serving us the records from its store, when
and how can it be serving us wrong Record?

The DNSAPI can either use the system configured DNS
addresses (TCP properties) or you can specify one or
more DNS servers to be queried, notice that in the first
case the answers will be cached by the DNSclient service
while in the second case this caching won't take place
2) How to byPass the local DNS server in code?

You don't need to do that as long as the local DNS server
is also configured into TCP properties, otherwise, as I wrote
above you can specify the DNS server(s) addresses using
the DnsQuery() "aipServers" parameter - for more details
please refer to the following pages

MSDN reference

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dns/dns/dns_functions.asp

Sample Code (may be of help)

http://www.codeguru.com/Cpp/I-N/internet/dns/article.php/c6173/

3) How to clear the cache on the server, it will have to be done
programmatically as it is a web interface and is open to all
users to query their domain.

I can's see why you want to clean the cache, such a thing will
have a negative impact on the DNS performance, so.. better
writing your code to avoid problems with cached records
Thanks in advance.

You're welcome and ... if Ace will succeed in calling William
"here" he may as well have more tips/infos for you :-)


--

* ObiWan

Microsoft MVP: Windows Server - Networking
http://mvp.support.microsoft.com
http://italy.mvps.org
 
I think William Stacey can comment on this if he sees this thread. He
developed his NetDIG utility (nice utility, free at www.mvptools.com),
using VB.net. I believe he succesffully set it up this way. I'll ping him
to get him involved, if he hasn't seen this yet.

Thanks Ace :-)

PS/OT:

If you've two spare seconds
please jump into the "italian
caffetteria" NG we'll be
happy to welcome you ;-)


--

* ObiWan

Microsoft MVP: Windows Server - Networking
http://mvp.support.microsoft.com
http://italy.mvps.org
 
Yes we are passing seperate queries for "A", once processed we pass
query for MX and so on. ALl this is done with in one context.

the following is a sample snippet of our code
=========================================================
public static IPAddress[] GetARecords(string szDomain, Context
context)
{
try {
DnsRecordSetA records = (DnsRecordSetA)LowLevelQuery(szDomain,
TYPE_A,context);
return records.Addresses;
}
catch(DNSResultNXDomainException)
{
return new IPAddress[0];
}
}
public static string[] GetMXDomainNames(string szDomain, Context
context)
{
try {
DnsRecordSetMX records =
(DnsRecordSetMX)LowLevelQuery(szDomain, TYPE_MX, context);
return records.Hosts;
}
catch(DNSResultNXDomainException)
{
return new string[0];
}
}
===================================================
=======================================================

To clear the DNS record list we are using the following system DLL to
unallocate
[DllImport("kernel32.dll")] public static extern unsafe void*
LocalFree(void* pv);

i have seen the links you had sent me, i dont see or i havent come
across any one who has faced this problem.

I have a weird feeling that the Local Dns server which is serving
cached pages is messing up

or it could be that there are some Header errors for the DNS response,
but then why would it give an error some times and not always for a
particular domain??


Regards,
 
catch(DNSResultNXDomainException)
{
return new IPAddress[0];
}
To clear the DNS record list we are
using the following system DLL to
unallocate [DllImport("kernel32.dll")]
public static extern unsafe void*
LocalFree(void* pv);

Hmm ... you're directly returning an value
from the "DnsList" which you get after the
query *and* you aren't using the function
DnsRecordListFree() to allow the DnsLib
to deallocate/clean its internal data; imho
you should try copying the returned values
to a local area, calling the Dns...Free() as
above and returning the copy you created
this _may_ fix the issue which I suspect is
caused by some trashing inside the DnsLib
due to missing cleanup
 
I think William Stacey can comment on this if he sees this thread. He
developed his NetDIG utility (nice utility, free at www.mvptools.com), using
VB.net. I believe he succesffully set it up this way. I'll ping him to get
him involved, if he hasn't seen this yet.

VB? What is that? :-) It was done in C#. Cheers!
 
I replied to email but will post here. Can't really help with dnsapi.dll as
I wrote my own resolver in c# so I did not run into this issue (but probably
1000 others while developing.) With some pushing I could probably dress it
up into a general library with docs (have been meaning to do that.) hth
 
I replied to email but will post here.

Hi William .. so Ace called you at end :-)
Can't really help with dnsapi.dll as
I wrote my own resolver in c#

Yes, saw it, nice piece of code :-)
so I did not run into this issue

ok, but the strange thing is that I used the
DnsAPI calls many times and I never had
such a problem; if you read the latest posts
on this thread you'll see that the code the OP
uses seems to "miss" some calls the the
DnsRecordListFree() API, this in turn trashes
the DnsLib resources at the point that the
calls fail due to a low-resource condition

or .. better said, that's my suspect :-)

--

* ObiWan

Microsoft MVP: Windows Server - Networking
http://mvp.support.microsoft.com
http://italy.mvps.org
 
In
ObiWan said:
Thanks Ace :-)

PS/OT:

If you've two spare seconds
please jump into the "italian
caffetteria" NG we'll be
happy to welcome you ;-)

Is that a usenet group?

Ace
 
In
Kevin D. Goodknecht Sr. said:
Hey, Ace it's a MVP private group
microsoft.private.mvp.italian.caffetteria

Duh, ok! LOL. I was looking thru usenet and couldn't find it!
:-)

Thanks!
 
Back
Top