Hardcore Windows programming: any Kernel experts out there?

I’ve been trying to get this sample to work in Windows XP: http://www.codeguru.com/Cpp/W-P/files/fileinformation/article.php/c4453/

After much wailing and gnashing of teeth, I get it to compile under the latest version of the DDK that I got from MSDN.

The problem is, when I run it, the following line from FOIDoc.cpp:

if (ot_fobj == psh->bObjectType)

Never returns ‘true’. It’s as if none of the objects being enumerated is of type “File”. I suspect this is something to do with the differences in headers or something between Win 2k (for which the sample was written) and Win XP.

Any ideas anyone?

Well, I can’t actually step through it as I don’t want to go through the teeth-gnashing involved in getting it to work with the DDK, but I looked at the code and downloaded the executable, and it doesn’t work for me, either. I suspect you’re hunch is right, especially since the CodeGuru article states it’s for NT/2000 ONLY.

It’s been a while since I worked with this level of internals, but when I did, I remember that every new version of Windows typically sent us spinning to update all the undocumented changes to the undocumented features.

Have you tried running it on XP Pro? I only have XP home. Maybe Pro will work better.

On a completely different note, boy it was fun to look at real live C++ code again. I’ve been working so much in C# and various Web technologies lately that the raw power of C++ is strangely compelling.

[darth vader voice]
“Come to the dark side, Athena. Feel the power of non-smart pointers and raw function calls.”
[/darth vader voice]

I tried it on XP Pro only - didn’t work for me either.

You’d think Microsoft would want to make it easy for people to write drivers, to promote the OS even more than it already is!

Funny you should remark about C++. 99% of my days are spent in C#, and I had the opposite impression - boy, am I glad I don’t have to go through all THAT every time I want to accomplish something. I was a C++ guy for years and years, but I don’t miss it.

MS has never been great about documenting the nether regions of the kernel. When I worked on projects that required this level of coding, we worked practically hand-in-hand with Microsoft. It helps to work for a large company with a lot of clout in these situations.

Don’t get me wrong on C++ - I really like the ease of C# as well. I’d just forgotton how very raw C++ is. It seems like most jobs are going towards Java/C#/Web crap/etc, which is more fun in the long run anyway. In fact, I’m expecting an offer tomorrow for a C#/ASP.NET job - way fun!