The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
When you transfer control across stack frames, all the frames in between need to be in on the joke
Chris Hill suggests discussing the use of structured exception handling as it relates to the window manager, and specifically the implications for applications which raise exceptions from a callback. If you plan on raising an exception and handling it in a function higher up the stack, all the stack frames in between need to be be in on your little scheme, because they need to be able to unwind. (And I don't mean "unwind" in the "have a beer and watch some football" sense of "unwind".) If you wrote all the code in between the point the exception is raised and the point it is handled, then you're in good sha...
The case of the asynchronous copy and delete
A customer reported some strange behavior in the and functions. They were able to reduce the problem to a simple test program, which went like this (pseudocode): When they ran the program, they found that sometimes the copy failed on the first try with error 5 () but if they waited a second and tried again, it succeeded. Similarly, sometimes the delete failed on the first try, but succeeded on the second try if you waited a bit. What's going on here? It looks like the is returning before the file copy is complete, causing the to fail because the copy is still in progress. Conversely, it looks like ...
You can't rule out a total breakdown of normal functioning, because a total breakdown of normal functioning could manifest itself as anything
A customer was attempting to study a problem that their analysis traced back to the function returning . Is it a valid conclusion that there is no heap corruption? While heap corruption may not be the avenue of investigation you'd first pursue, you can't rule it out. In the presence of a total breakdown of normal functioning, anything can happen, including appearing to be some other type of failure entirely. For example, the heap corruption might have corrupted the bookkeeping data in such a way as to make the heap behave as if it were a fixed-sized heap, say by corrupting the location where the heap manage...
How did the X-Mouse setting come to be?
Commenter HiTechHiTouch wants to know whether the "X-Mouse" feature went through the "every request starts at −100 points filter", and if so, how did it manage to gain 99 points? The X-Mouse feature is ancient and long predates the "−100 points" rule. It was added back in the days when a developer could add a random rogue feature because he liked it. But I'm getting ahead of myself. Rewind back to 1995. Windows 95 had just shipped, and some of the graphics people had shifted their focus to DirectX. The DirectX team maintained a very close relationship with the video game software community, ...
Why don't the shortcuts I put in the CSIDL_COMMON_FAVORITES folder show up in the Favorites menu?
A customer created some shortcuts in the folder, expecting them to appear in the Favorites menu for all users. Instead, they appeared in the Favorites menu for no users. Why isn't working? The value was added at the same time as the other values, and its name strongly suggests that its relationship to is the same as the relationship between and , or between and , or between and . That suggestion is a false one. In fact, is not hooked up to anything. It's another of those vestigial values that got created with the intent of actually doing something but that thing never actually happened. I don't think...
Buzzword-filled subject line easily misinterpreted by unsuspecting manager
A colleague of mine submitted some paperwork regarding the end-date of his college intern. The automated response combined HR buzzwords in an unfortunate way: Subject: Intern Termination Report was executed Just to be sure, my colleague stopped by his intern's office. He's still there. And still alive. For now.
Adventures in undefined behavior: The premature downcast
A customer encountered the following problem: The function converts the cookie back to a object, and then checks if the object is a object by calling . If so, then it does some more stuff to figure out what type of paint to buy. (Note to nitpickers: The actual scenario was not like this, but I presented it this way to illustrate the point. If you say "You should've used RTTI" or "You should've had a BuyPaint method on the Shape class", then you're missing the point.) The programmers figured they'd save some typing by casting the result of to a right away, because after all, since is a virtual method...
I'm not calling a virtual function from my constructor or destructor, but I'm still getting a __purecall error
Some time ago, I described what is for: It's to detect the cases where you call a virtual method with no implementation (a so-called pure virtual method). This can happen during object constructor or destruction, since those are times when you can validly have a partially-implemented object. Well, there's another case this can happen: If the object has already been destructed. If you call a method on an object that has already been destructed, the behavior is undefined. In practice, what happens is that the method runs on whatever leftover values are in memory where the object used to be. Depending on how luc...
Psychic debugging: Why Chinese characters don't work
Here's a walkthrough of an actual case of psychic debugging. I'm using the internal XYZ table-generating tool, but it appears to be useless in my case. Does this tool work? Right now, I'm just resorting to the manual method of generating my data table (Chinese and English). Hooray for vague questions! "It appears to be useless." But there were enough tiny clues in the question that made it possible to make a psychic guess. First of all, the parenthetical "Chinese and English" suggests that there are Chinese characters in the data being passed to the XYZ table-generating tool. Second of all, one might make a...