Some years ago parts of the Windows 2000 source code have been leaked to the web. All I can tell you that it is a zip file around 200 MB in size. Where can you find it? Well I leave that one for you figure out. Enough said that after a while of looking, I got my hands on it.
The leak caused one of the biggest stirs on the Internet in recent years, as everyone could have a peak at what Microsoft holds dear the most, and guards to their best extent. It’s a mystery where the file came from, or how it got passed the walls of Microsoft. Either way, it’s still out there. And since 2000 is long retired, and with XP going to bed soon too, I don’t think the file poses much of a threat to the company today since most of the code is probably now changed, updated or entirely replaced.
What’s in the package? Good parts of the Windows shell, accessories, controls, networking… a lot really.
By looking at the code, sometimes you can find very interesting pieces of comments.
private/windows/shell/acessory/notepad/notepad.c
// bugbug
// for some reason, this procedure tries to maintain
// a valid ‘fp’ even though I believe it does not need
// to be.
// bugbug
“bugbug”’s seem to be around in a lot of lines, also in:
private/shell/shell32/bitbuck.c
// !! HACKHACK !! - This code was basically taken right out of NT4 so that we can
// compare against the old NT4 recycle bin ACL. The new helper function
// GetShellSecurityDescriptor puts the ACE’s in a different order
// than this function, and so we memcmp the ACL against botht this
// one and the new win2k one.
Also developers try to explain what is going on because they fear most will be confused about what is done in the following lines. But no bugbug this time. Just something that could screw up.
private/shell/shell32/dllload.c
// ——— COMCTL32.DLL —————-
//
// Wha? Delay-load comctl32? Yup, because some setup apps
// include comctl32.dll in their temporary setup directory,
// so we end up loading that comctl32 instead of the system
// comctl32, and ImageList_SetFlags is an API that didn’t exist
// in old versions of Comctl32, so shell32 would fail to load,
// and the setup app would barf. Fortunately, setup apps don’t
// use shell32 for much beyond CShellLink and SHChangeNotify,
// so the mixup of a new shell32 and a downlevel comctl32 won’t
// screw them too badly.
//
Sometimes, so it seems, their own work appears strange. Or stranger than they thought.
private/shell/shell32/execute.cpp
// Win31 is stranger than I could imagine, if you pass ShellExecute
// an invalid directory, it will change the current drive.
Trashed atoms around in certain hacks. Not sure what it does, but this is what it says.
private/shell/comctl32/commctrl.c
// HACK: we are intentionally incrementing the refcount on this atom
// WE DO NOT WANT IT TO GO BACK DOWN so we will not delete it in process
// detach (see comments for g_aCC32Subclass in subclass.c for more info)
// on Win95 doe this as early as possible to avoid getting
// a trashed atom.
The same file also confirms that some bugs are not theoretical.
// This is not purely theoretical - NT4/FE hit this bug.
Bogus code also around. Interesting.
private/shell/browseui/isfband.cpp
// BUGBUG: the below is bogus - no need to throw away and recreate.
Windows 97? o_O
private/shell/cplwiz/access/schemes.cpp
// New scheme data for Windows 97
And morons are around too. And they are Microsoft’s own…
private/genx/shell/inc/prsht.w
// we are such morons. Wiz97 underwent a redesign between IE4 and IE5
private/shell/ext/ftp/ftpdrop.cpp
// We have to do this only because Exchange is a moron.
And these are only a few examples of what people have put into the code which is available in the zip package. However to be fair, all in all the quality of the code that can be seen is genuinely excellent. There’s a lot of serious documentation in there for a lot of variables and functions, and it is described what happens with which lines. I am surprised at this I have to say. From what I can see, the code isn’t as bad as I thought it’d be. It could be better, of course. And there is better. To be fair, a lot of people have worked on this, and it shows. Most of the functions do fit on a single screen, so that’s impressive to my mind.
Just wanted to share these findings with you.