473,545 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to access the NT Name Cache?

Hi all,

I would like to know how to access the NT/2000/XP/2003 Name cache; what I
mean by this is:

Open a Command Prompt and..,

C:\>
C:\>IPCONFIG /DISPLAYDNS

You will see a bunch of cached name records for pretty much all of the
websites / domains that have been resovled since you booted the computer. I
would realy like to know what API or function I could access this data with
so it could speed up my DNS lookups but I have been unable to find the API
function.

Please help

Regards,

Michael.

Jan 5 '07 #1
9 2553
OK.

So I opended the IPconfig.exe from C:\windows\syst em32\

I see an External sysbol link to a function called DnsGetCacheData Table()
Sounds like it could be the one!

Does any one no where to get the C/C++ header for this or an already VB
converted one.

Its not listed in the Win2k3 SDK

regards

Mike.

"Michael M." <no****@mike.co mwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Hi all,

I would like to know how to access the NT/2000/XP/2003 Name cache; what I
mean by this is:

Open a Command Prompt and..,

C:\>
C:\>IPCONFIG /DISPLAYDNS

You will see a bunch of cached name records for pretty much all of the
websites / domains that have been resovled since you booted the computer.
I would realy like to know what API or function I could access this data
with so it could speed up my DNS lookups but I have been unable to find
the API function.

Please help

Regards,

Michael.

Jan 5 '07 #2
Have you looked at your hosts file? This file can be used to do exactly
what you are asking about. If your program just opened this text file and
appended to it, you'd get what you want.
"Michael M." <no****@mike.co mwrote in message
news:%2******** *******@TK2MSFT NGP02.phx.gbl.. .
OK.

So I opended the IPconfig.exe from C:\windows\syst em32\

I see an External sysbol link to a function called DnsGetCacheData Table()
Sounds like it could be the one!

Does any one no where to get the C/C++ header for this or an already VB
converted one.

Its not listed in the Win2k3 SDK

regards

Mike.

"Michael M." <no****@mike.co mwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>Hi all,

I would like to know how to access the NT/2000/XP/2003 Name cache; what I
mean by this is:

Open a Command Prompt and..,

C:\>
C:\>IPCONFIG /DISPLAYDNS

You will see a bunch of cached name records for pretty much all of the
websites / domains that have been resovled since you booted the computer.
I would realy like to know what API or function I could access this data
with so it could speed up my DNS lookups but I have been unable to find
the API function.

Please help

Regards,

Michael.


Jan 6 '07 #3
Thanks Scott,

I am aware of the Hosts file, but this is static, only your localhost
127.0.0.1 record is there by default, it does not get automaticly updated.

This file is loaded into the name cache you can it's entrys IPconfig /
DisplayDns, but
IPconfig / FlushDns does not remove them (Why are these commands not
listed when you type IPconfig / ? they are not exactly secret ????)

Win XP does Names likes this I believe

Host File & LMhost file -loads into cache -check cache -check dns
server <-wait for lookup

on a NT / 2Kx domain might append default DNS suffix to the name and check
for that as well.

Anyway what I want is:

Lets say the scenario of a internet access / NAT windows server that has a
bunch of connections to webservers. All of thoose webservers has already
been translated to IP addresses, and stored in that name cache and
(depending on Time To Live) will be threre for some time.

It makes no sense for an application to launch a new thread and lookup
Google.com or Microsoft.com again when it has allready been done and stored.
I would like to read that data into an array or List every 60 seconds or so,
and search that before doing a lookup (I will be doing reverse lookup so
won't be able to rely on NT searching the cache for me)

I have found a C++ exmple code that has some clues on this, if can convert
it and get it to work I will naturaly post back here.

The other thing is writing to that file could leave stale records, I would
have to loop through and them update them or Cleint computers would lose
domain resovles on the LANs that the software runs on.

Thanks for your reply though, I have seen add / popup blocking software
write Dodgy Domains to that file!

Example
Adverts.SomeDod gyCompany.Com 127.0.0.1

or is it the other way round?

That will not resovle so is quite effective :0)

Regards

Mike.
"Scott M." <s-***@nospam.nosp amwrote in message
news:e5******** ******@TK2MSFTN GP06.phx.gbl...
Have you looked at your hosts file? This file can be used to do exactly
what you are asking about. If your program just opened this text file and
appended to it, you'd get what you want.
"Michael M." <no****@mike.co mwrote in message
news:%2******** *******@TK2MSFT NGP02.phx.gbl.. .
>OK.

So I opended the IPconfig.exe from C:\windows\syst em32\

I see an External sysbol link to a function called DnsGetCacheData Table()
Sounds like it could be the one!

Does any one no where to get the C/C++ header for this or an already VB
converted one.

Its not listed in the Win2k3 SDK

regards

Mike.

"Michael M." <no****@mike.co mwrote in message
news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
>>Hi all,

I would like to know how to access the NT/2000/XP/2003 Name cache; what
I mean by this is:

Open a Command Prompt and..,

C:\>
C:\>IPCONFI G /DISPLAYDNS

You will see a bunch of cached name records for pretty much all of the
websites / domains that have been resovled since you booted the
computer. I would realy like to know what API or function I could access
this data with so it could speed up my DNS lookups but I have been
unable to find the API function.

Please help

Regards,

Michael.



Jan 6 '07 #4
Hey Mike,

I wish I had more info. for you, but I can tell you that typing "ipconfig
/?" <---no space bettween / and ? does give you a list of all command line
switches.

good luck
"Michael M." <no****@mike.co mwrote in message
news:uZ******** ******@TK2MSFTN GP03.phx.gbl...
Thanks Scott,

I am aware of the Hosts file, but this is static, only your localhost
127.0.0.1 record is there by default, it does not get automaticly updated.

This file is loaded into the name cache you can it's entrys IPconfig /
DisplayDns, but
IPconfig / FlushDns does not remove them (Why are these commands not
listed when you type IPconfig / ? they are not exactly secret ????)

Win XP does Names likes this I believe

Host File & LMhost file -loads into cache -check cache -check dns
server <-wait for lookup

on a NT / 2Kx domain might append default DNS suffix to the name and check
for that as well.

Anyway what I want is:

Lets say the scenario of a internet access / NAT windows server that has a
bunch of connections to webservers. All of thoose webservers has already
been translated to IP addresses, and stored in that name cache and
(depending on Time To Live) will be threre for some time.

It makes no sense for an application to launch a new thread and lookup
Google.com or Microsoft.com again when it has allready been done and
stored. I would like to read that data into an array or List every 60
seconds or so, and search that before doing a lookup (I will be doing
reverse lookup so won't be able to rely on NT searching the cache for me)

I have found a C++ exmple code that has some clues on this, if can convert
it and get it to work I will naturaly post back here.

The other thing is writing to that file could leave stale records, I would
have to loop through and them update them or Cleint computers would lose
domain resovles on the LANs that the software runs on.

Thanks for your reply though, I have seen add / popup blocking software
write Dodgy Domains to that file!

Example
Adverts.SomeDod gyCompany.Com 127.0.0.1

or is it the other way round?

That will not resovle so is quite effective :0)

Regards

Mike.
"Scott M." <s-***@nospam.nosp amwrote in message
news:e5******** ******@TK2MSFTN GP06.phx.gbl...
>Have you looked at your hosts file? This file can be used to do exactly
what you are asking about. If your program just opened this text file
and appended to it, you'd get what you want.
"Michael M." <no****@mike.co mwrote in message
news:%2******* ********@TK2MSF TNGP02.phx.gbl. ..
>>OK.

So I opended the IPconfig.exe from C:\windows\syst em32\

I see an External sysbol link to a function called
DnsGetCacheDa taTable() Sounds like it could be the one!

Does any one no where to get the C/C++ header for this or an already VB
converted one.

Its not listed in the Win2k3 SDK

regards

Mike.

"Michael M." <no****@mike.co mwrote in message
news:%2****** **********@TK2M SFTNGP04.phx.gb l...
Hi all,

I would like to know how to access the NT/2000/XP/2003 Name cache; what
I mean by this is:

Open a Command Prompt and..,

C:\>
C:\>IPCONF IG /DISPLAYDNS

You will see a bunch of cached name records for pretty much all of the
websites / domains that have been resovled since you booted the
computer. I would realy like to know what API or function I could
access this data with so it could speed up my DNS lookups but I have
been unable to find the API function.

Please help

Regards,

Michael.





Jan 6 '07 #5
Very interesting question... there's so little out there!

All I've learned so far is that the DnsGetCacheData Table() function is in
dnsapi.dll, but you've probably already figured that one out. There appears
to be good info in the article titled: "Explore the Windows DNS cache" here:
http://www.codepieces.net/ , but I guess I'm not literate enough to
understand the example.

I was thinking I could just figure out where the cache is stored and access
it myself, but I've learned it's all in RAM, so no-go on that front.

Anyway, good luck!
--

Eric

"Michael M." <no****@mike.co mwrote in message
news:#c******** *****@TK2MSFTNG P02.phx.gbl...
OK.

So I opended the IPconfig.exe from C:\windows\syst em32\

I see an External sysbol link to a function called DnsGetCacheData Table()
Sounds like it could be the one!

Does any one no where to get the C/C++ header for this or an already VB
converted one.

Its not listed in the Win2k3 SDK

regards

Mike.

"Michael M." <no****@mike.co mwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>Hi all,

I would like to know how to access the NT/2000/XP/2003 Name cache; what I
mean by this is:

Open a Command Prompt and..,

C:\>
C:\>IPCONFIG /DISPLAYDNS

You will see a bunch of cached name records for pretty much all of the
websites / domains that have been resovled since you booted the computer.
I would realy like to know what API or function I could access this data
with so it could speed up my DNS lookups but I have been unable to find
the API function.

Please help

Regards,

Michael.

Jan 6 '07 #6

"Michael M." <no****@mike.co mwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
: Hi all,
:
: I would like to know how to access the NT/2000/XP/2003 Name cache;
what I
: mean by this is:
:
: Open a Command Prompt and..,
:
: C:\>
: C:\>IPCONFIG /DISPLAYDNS
:
: You will see a bunch of cached name records for pretty much all of
the
: websites / domains that have been resovled since you booted the
computer. I
: would realy like to know what API or function I could access this
data with
: so it could speed up my DNS lookups but I have been unable to find
the API
: function.
:
: Please help
:
: Regards,
:
: Michael.
This isn't what you're looking for specifically, and it's really an
ugly hack, but....

How about running the IPCONFIG command from a shell and piping the
output to a file? (IPCONFIG /DISPLAYDNS >
[SOME_FOLDER]\displaydns.dat )

From there, you could open the file, parse the contents then delete
it. That would do as an interim solution.

Ralf
--
--
----------------------------------------------------------
* ^~^ ^~^ *
* _ {~ ~} {~ ~} _ *
* /_``>*< >*<''_\ *
* (\--_)++) (++(_--/) *
----------------------------------------------------------
There are no advanced students in Aikido - there are only
competent beginners. There are no advanced techniques -
only the correct application of basic principles.
Jan 6 '07 #7
That's what I was suggesting, but instead of "some file", I suggested using
the hosts file, since it is consulted automatically.
"_AnonCowar d" <ab*@xyz.comwro te in message
news:45******** **************@ roadrunner.com. ..
>
"Michael M." <no****@mike.co mwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
: Hi all,
:
: I would like to know how to access the NT/2000/XP/2003 Name cache;
what I
: mean by this is:
:
: Open a Command Prompt and..,
:
: C:\>
: C:\>IPCONFIG /DISPLAYDNS
:
: You will see a bunch of cached name records for pretty much all of
the
: websites / domains that have been resovled since you booted the
computer. I
: would realy like to know what API or function I could access this
data with
: so it could speed up my DNS lookups but I have been unable to find
the API
: function.
:
: Please help
:
: Regards,
:
: Michael.
This isn't what you're looking for specifically, and it's really an
ugly hack, but....

How about running the IPCONFIG command from a shell and piping the
output to a file? (IPCONFIG /DISPLAYDNS >
[SOME_FOLDER]\displaydns.dat )

From there, you could open the file, parse the contents then delete
it. That would do as an interim solution.

Ralf
--
--
----------------------------------------------------------
* ^~^ ^~^ *
* _ {~ ~} {~ ~} _ *
* /_``>*< >*<''_\ *
* (\--_)++) (++(_--/) *
----------------------------------------------------------
There are no advanced students in Aikido - there are only
competent beginners. There are no advanced techniques -
only the correct application of basic principles.


Jan 6 '07 #8
Ok I have converted the C++ sample and I have it working now, but I have a
question

I am new to VB.net have been only programming on and off for the last two
months.

using the interop marshal class I need to retrieve a string from a pointer
the string is passed from the

DnsGetCacheData Table() so it is a C++ string, all I have is the start memory
address of a string; how do I determine the length of the string so I don't
hit the tried to read protected memory error?

Right now I am just reading 128 bytes from the start address of the string
pointer it seems to work about 95 out of 100 which is wierd.

Eric <er**@ejproduct ions.composted me this which had a link to C++ example
which I converted.

<<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<
Very interesting question... there's so little out there!

All I've learned so far is that the DnsGetCacheData Table() function is in
dnsapi.dll, but you've probably already figured that one out. There appears
to be good info in the article titled: "Explore the Windows DNS cache" here:
http://www.codepieces.net/ , but I guess I'm not literate enough to
understand the example.

I was thinking I could just figure out where the cache is stored and access
it myself, but I've learned it's all in RAM, so no-go on that front.

Anyway, good luck!
>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>

Ps if anyone is intrested I can post my VB.Net port of this function.

Regards,

Michael.

"Michael M." <no****@mike.co mwrote in message
news:%2******** *******@TK2MSFT NGP02.phx.gbl.. .
OK.

So I opended the IPconfig.exe from C:\windows\syst em32\

I see an External sysbol link to a function called DnsGetCacheData Table()
Sounds like it could be the one!

Does any one no where to get the C/C++ header for this or an already VB
converted one.

Its not listed in the Win2k3 SDK

regards

Mike.

"Michael M." <no****@mike.co mwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
>Hi all,

I would like to know how to access the NT/2000/XP/2003 Name cache; what I
mean by this is:

Open a Command Prompt and..,

C:\>
C:\>IPCONFIG /DISPLAYDNS

You will see a bunch of cached name records for pretty much all of the
websites / domains that have been resovled since you booted the computer.
I would realy like to know what API or function I could access this data
with so it could speed up my DNS lookups but I have been unable to find
the API function.

Please help

Regards,

Michael.


Jan 7 '07 #9
What an idiot.
I did not check the overload options of Marshal.PtrToSt ringAuto the second
option does not require a length guess it finds the first null char or
something then returns the left all chars to the left of that?

Michael.

"Michael M." <no****@mike.co mwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Ok I have converted the C++ sample and I have it working now, but I have a
question

I am new to VB.net have been only programming on and off for the last two
months.

using the interop marshal class I need to retrieve a string from a pointer
the string is passed from the

DnsGetCacheData Table() so it is a C++ string, all I have is the start
memory address of a string; how do I determine the length of the string so
I don't hit the tried to read protected memory error?

Right now I am just reading 128 bytes from the start address of the string
pointer it seems to work about 95 out of 100 which is wierd.

Eric <er**@ejproduct ions.composted me this which had a link to C++
example which I converted.

<<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<<<<<<<<< <<<<<<<
Very interesting question... there's so little out there!

All I've learned so far is that the DnsGetCacheData Table() function is in
dnsapi.dll, but you've probably already figured that one out. There
appears
to be good info in the article titled: "Explore the Windows DNS cache"
here:
http://www.codepieces.net/ , but I guess I'm not literate enough to
understand the example.

I was thinking I could just figure out where the cache is stored and
access
it myself, but I've learned it's all in RAM, so no-go on that front.

Anyway, good luck!
>>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>>>>> >>>>>>>>>>>


Ps if anyone is intrested I can post my VB.Net port of this function.

Regards,

Michael.

"Michael M." <no****@mike.co mwrote in message
news:%2******** *******@TK2MSFT NGP02.phx.gbl.. .
>OK.

So I opended the IPconfig.exe from C:\windows\syst em32\

I see an External sysbol link to a function called DnsGetCacheData Table()
Sounds like it could be the one!

Does any one no where to get the C/C++ header for this or an already VB
converted one.

Its not listed in the Win2k3 SDK

regards

Mike.

"Michael M." <no****@mike.co mwrote in message
news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
>>Hi all,

I would like to know how to access the NT/2000/XP/2003 Name cache; what
I mean by this is:

Open a Command Prompt and..,

C:\>
C:\>IPCONFI G /DISPLAYDNS

You will see a bunch of cached name records for pretty much all of the
websites / domains that have been resovled since you booted the
computer. I would realy like to know what API or function I could access
this data with so it could speed up my DNS lookups but I have been
unable to find the API function.

Please help

Regards,

Michael.



Jan 7 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1553
by: Angelos Karantzalis | last post by:
Hi guys, for a while now, we've been flirting with the idea of having a single component in our app that handles all the plumbing for our Db calls ( creating connections, Commands & Parametes etc. ) through an xml definition of each Db call. For instance, a call to a Stored Procedure would be described like this: <data-action...
0
3015
by: totierne | last post by:
comp.databases.ms-access, I want to know how to use Oracle views with session variables in Access. The parameterised views in access, are migrated to views with per session variables. The open questions: How to display a resultset
3
3481
by: Lyle Fairfield | last post by:
In a recent thread there has been discussion about Data Access Pages. It has been suggested that they are not permitted on many or most secure sites. Perhaps, that it is so, although I know of no site that has this prohibition, and I have uploaded DAPs to various sites and used them from those sites. I do not understand why any site...
1
1410
by: Christopher | last post by:
In one of our ASP.NET Pages, we are starting a new background thread that we do not need to go and get any status on or use after the page finishes. The thread merely does some background stuff on its own and finishes on its own, no feedback back to the user (by design). Within that thread however, some items need to be accessed and/or...
1
2695
by: William Sullivan | last post by:
I'm trying to nail down some issues with the cache in my application. Currently, I have an object that stands between my business logic and database logic called CacheLogic (cute, no?). Global.asax.cs creates it in Application_Start, initializes it and places it in the cache. During initialization, CacheLogic retrieves data from the DB logic...
3
7978
by: Shailesh Humbad | last post by:
I figured out what was causing the "Access is Denied" error when calling functions from referenced DLLs in my service. I've tried to be very detailed, so bear with me. It turns out that libraries I made myself were not having this problem, but it only happened with a zip library I downloaded and copied into my program's directory. When...
5
2664
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp The Joy of Interoperability Sometimes a revolution in programming forces you to abandon all that's come before. To take an extreme example, suppose you have been writing Visual Basic applications for years now. If you're like many developers,...
7
5341
by: bhavin30 | last post by:
Is there a way to obtain user information (using LOGON_USER server variables) when you have set up the security to Anonymous Access? I have tried setting the security to both Anonymous + Window Integrated, without any luck. I'm using IIS 6.0 on Windows Server 2003 Thanks in advance!
0
7420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
6003
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5349
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.