The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Dec 5, 2012
Post comments count 0
Post likes count 1

Why do I get notified for changes to HKEY_CLASSES_ROOT when nobody is writing to HKEY_CLASSES_ROOT?

Raymond Chen

A customer had a question about the function. We are using it to monitor the tree as follows: If I understand the documentation correctly, this registers for notifications when subkeys are added, deleted, or when values are changed. However, it seems that my event becomes signaled at many other times, for example, when I switch folders in an Explorer window. I fired up Process Monitor and confirmed that nobody (not even Explorer) is writing to . Why are we getting spurious notifications? Have we misunderstood what this function does? Everything is working as expected; it's just that your expectation...

Dec 4, 2012
Post comments count 0
Post likes count 1

The QuickCD PowerToy, a brief look back

Raymond Chen

One of the original Windows 95 PowerToys was a tool called QuickCD. Though that wasn't its original name. The original name of the QuickCD PowerToy was FlexiCD. You'd think that it was short for "Flexible CD Player", but you'd be wrong. FlexiCD was actually named after its author, whose name is Felix, but who uses the "Flexi" anagram as a whimsical nickname. We still called him Felix, but he would occasionally use the Flexi nickname to sign off an email message, or use it whenever he had to create a userid for a Web site (if Web sites which required user registration existed in 1994). You can still see rem...

Dec 3, 2012
Post comments count 0
Post likes count 1

Have you found any TheDailyWTF-worthy code during the development of Windows 95?

Raymond Chen

Mott555 is interested in some sloppy/ugly code or strange workarounds or code comments during the development of Windows 95, like "anything TheDailyWTF-worthy." I discovered that opening a particular program churned the hard drive a lot when you opened it. I decided to hook up the debugger to see what the problem was. What I discovered was code that went roughly like this, in pseudo-code: The code enumerated every file in the system directory, Windows directory, Program Files directory, and possibly also the kitchen sink and their uncle's kitchen sink. It tries to load each one as a library, and sees ...

Nov 30, 2012
Post comments count 0
Post likes count 1

The debugger lied to you because the CPU was still juggling data in the air

Raymond Chen

A colleague was studying a very strange failure, which I've simplified for expository purpose. The component in question has the following basic shape, ignoring error checking: There are two parts of the object. One part that is essential to the object's task, and another part that is needed only when updating. The parts related to updating are expensive, so the object sets them up only when an update is active. You indicate that an update is active by calling , and you indicate that you are finished updating by calling . There are a few race conditions here, and one of them manifested itself in a cras...

Nov 29, 2012
Post comments count 0
Post likes count 1

Various ways of performing an operation asynchronously after a delay

Raymond Chen

Okay, if you have a UI thread that pumps messages, then the easiest way to perform an operation after a delay is to set a timer. But let's say you don't have a UI thread that you can count on. One method is to burn a thread: Less expensive is to borrow a thread from the thread pool: But both of these methods hold a thread hostage for the duration of the delay. Better would be to consume a thread only when the action is in progress. For that, you can use a thread pool timer: The timer queue timer technique is complicated by the fact that we want the timer to self-cancel, so it needs to know its handle,...

Nov 28, 2012
Post comments count 0
Post likes count 1

Why are there both FIND and FINDSTR programs, with unrelated feature sets?

Raymond Chen

Jonathan wonders why we have both and , and furthermore, why the two programs have unrelated features. The program supports UTF-16, which doesn't; on the other hand, the program supports regular expressions, which does not. The reason why their feature sets are unrelated is that the two programs are unrelated. The program came first. As I noted in the article, the program dates back to 1982. When it was ported to Windows NT, Unicode support was added. But nobody bothered to add any features to it. It was intended to be a straight port of the old MS-DOS program. Meanwhile, one of my colleagues ove...

Nov 27, 2012
Post comments count 0
Post likes count 1

Security vulnerability reports as a way to establish your l33t kr3|)z

Raymond Chen

There is an entire subculture of l33t l4x0rs who occasionally pop into our world, and as such have to adapt their communication style to match their audience. Sometimes the adaptation is incomplete. You may have trouble finding the exploit buried in that perl script, because the perl script consists almost entirely of graffiti and posturing and chest-thumping. (You may also have noticed a bug.) Here is the script with all the fluff removed: This could've been conveyed in a simple sentence: "Create a one-byte file consisting of a single null byte." But if you did that, then you wouldn't get your chance t...

Nov 26, 2012
Post comments count 0
Post likes count 1

Puzzling triple rainbow clearly identifies location of pot of gold

Raymond Chen

I noted to some friends that the weather forecast for Seattle two weekends ago called for rain on Friday, rain on Saturday, and rain on Sunday. But at least on Monday, the forecast was not for rain. It was for heavy rain. One of the consequences of Seattle's annual Rain Festival (runs from January 1 to December 31) is that we get plenty of potential for rainbows. A friend of mine was lucky enough to capture a photo of a puzzling triple rainbow this past weekend. The primary and secondary rainbows we all know about, but what's that vertical rainbow shooting straight up into the sky? (And observe that the landi...

Nov 26, 2012
Post comments count 0
Post likes count 1

How does the window manager decide where to place a newly-created window?

Raymond Chen

Amit wonders how Windows chooses where to place a newly-opened window on a multiple-monitor system and gives as an example an application whose monitor choice appears inconsistent. The easy part is if the application specifies where it wants the window to be. In that case, the window is placed at the requested location. How the application chooses those coordinates is up to the application. On the other hand, if the application passes , this means that the application is saying, "I have no opinion where the window should go. Please pick a place for me." If this is the first top-level window created by the app...