I don’t know of any way to do it in kernelmode. That’s ok, since there are easy and obvious ways to do it in usermode. Usermode is where all the “complicated” stuff should happen anyway. Kernelmode is not meant to be a completely general development platform.
I know it’s tantalizing, since it seems like Microsoft has hidden the API that (according to incomplete reverse-engineering) might instantly solve your immediate problem. But “there is no alternative (in kernelmode)” isn’t enough justification to add a ton of extra risk to your product. Not to mention the extra time it will cost me and my team as we discover your product through bugcheck reports, root-cause the issue, follow up with your QA team to get this fixed, and publish a hardblock for your app in the next version of Windows.
The tone of this email is not meant to be nasty; I’m sorry if it reads harshly. I’m really only trying to help both of us and our mutual customers. I have taken as feedback that this information might need to be exposed in kernelmode – in planning future versions of Windows, we will balance this feedback against our desire to have most code move to usermode, as well as against our other priorities. I have also passed your earlier mail “To TDI Filter or not” to the WFP and WSK teams, who are taking it into consideration as well. We really do want you to be able to ship great products on Windows.
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Friday, October 30, 2009 5:02 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] netstat in kernel mode
Jeffrey,
As I mentioned in my reply to David, I would love a documented way of obtaining a table with all bound ports and connections in *KERNEL* mode, but everything I found so far refers only to *USER* mode. Please prove me wrong. It would save me and my company a lot of time.
There are several reasons for needing this functionality:
- When my driver starts, it needs to be able to perform essentially what “nestat -anop tcp” does so that it initializes its “knowledge” about the world: what ports are currently bound and what connections are active. Arguably I can do this in user-space (and I have in the past), but the problem is that the driver will need that information periodically, so that:
- it can detect when an extant port/connection are terminated
- it can deal with #2
I personally think that performing the query in user space and sending the information back to the driver every few seconds is a bad idea.
- The driver adds a number of WFP callouts and needs a way to determine when a server port gets unbound. To the best of my knowledge there is no WFP notification for unbound ports prior to Windows 7. Since the driver allocates state per server bound port, I need a way to clean up that state. I addition, our product must report the fact that a port has been unbound within 15 seconds or so from the port actually being unbound.
Please let me know if there are viable alternatives to what I am doing that would meet my requirements.
Thanks a lot,
Best,
–aydan
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer