The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
How do I convert an error code to text when FORMAT_MESSAGE_FROM_SYSTEM doesn’t work?
For the same reason that not all error codes are defined in , not all error strings are defined in the system message table. If you've ever played with the message compiler, you'd quickly have recognized the file as the header file associated with a message resource. In other words, there's a file that gets processed by the message compiler, and out pops the message resource (which becomes the system message table) and the header file. As we saw a few years ago, not all error messages live in , which means that not all error messages live in the system message table. Each component that provides error code...
What possible use are those extra bits in kernel handles? Part 3: New object types
Last time, we saw how those extra bits can be used to multiplex HANDLE with other values. That was a specific case of a more general scenario: Expanding the handle namespace to include things that aren't handles. (You can also view today's example as a generalization of the sentinel value problem, where we need to generate an arbitrary number of sentinel values dynamically. Actually, multiplexing HANDLE with HRESULT is also just another special case: We expanded the handle namespace to include error codes too.) As I noted in the base article, the people who are most interested in this sort of thing are peopl...
The stroke-count-based sort isn’t random, although it looks that way if you only see it in translation
During the NBC coverage of the opening ceremony of the Beijing Olympics, the announcers more than once said that the teams will not be entering in the normal order, but rather in a random order based on the number of strokes in the team's name as translated into Chinese. This is an odd use of the word random. You might say that at the Athens Olympics, the teams did not enter in the normal order, but rather in a random order based on the collation of the characters in the team's name as translated into Greek. Teams enter the stadium in the collation order customary for the host nation, with the exception that...
What possible use are those extra bits in kernel handles? Part 2: Overcoming limited expressiveness
Last time, we saw how those extra bits can be used to develop safe sentinel values. That is a special case of a more general problem: How do you pack 33 bits of information into a 32-bit value? Whereas last time, we weren't forced into the use of a sentinel value because we could develop a (cumbersome) helper class and switch people over to the helper class (or to pass two parameters to every function that used to take one), there are places where you are forced to try to squeeze 33 bits of information into a 32-bit value, and the helper class simply isn't going to work. (I'm going to assume 32-bit Wi...
What does each country claim for its own?, greatest hits
A little while back, I invited readers to describe what students are taught (or end up believing) are the greatest contributions of their country. Many people strayed from the "what students are taught" part of the exercise, but I didn't mind too much as long as you were funny. Here are some of my favorites: Representing Greece is Pi, who writes, In Greece I was also taught that Greeks invented democracy. Other than that Greeks are supposed to have laid the groundwork for the development of philosophy, mathematics, physics, biology and pretty much every other greek named thing as a science (except for ...
What possible use are those extra bits in kernel handles? Part 1: Sentinels
Kernel handles are always a multiple of four; the bottom two bits are available for applications to use. But why would an application need those bits anyway? The short answer is extending the handle namespace. The long answer will take a few days to play out. (This series was written in response to Igor Levicki being unable to imagine "how this can save anything (in terms of performance)". Then again, who said that it had anything to do with performance? Actually, I'm surprised that my dear readers weren't familiar with the techniques described in this series. Perhaps I shouldn't have written this series and...
DHS: The Television Series – the next chapter
Okay, so first there was the story about the planned DHS television series. And then there was the follow-up reporting that the whole thing was an investment scam and there was no such show after all. Following through on the story, it looks like the ringleader behind the scam has been sentenced to one year in prison and an accomplice to five years probation and $250 a month in restitution. The TV Squad article says retribution, which would be strange if true. But it's not. (Read the announcements of the accomplice's indictment and guilty plea.) At $250 a month, it's going to take a long time to repay the c...
Microspeak: Pencils down
I'm particularly fascinated by Microspeak terms which nobody actually knows the meaning of. You can defend jargon by saying that it's a shorthand way of talking in order to improve communication, but if nobody actually knows what it means, the in order to improve communication part is completely turned on its head. The Microspeak that allegedly allows people to communicate better ends up making them communicate worse. A colleague of mine introduced me to this new type of Microspeak. Our conversation takes place in an impromptu hallway meeting between the development manager and a few members of the team. Tea...
Wedding + two-year-old flower girl = wildcard
I was in San Francisco this weekend for a wedding. The flower girl was the bride's two-year-old niece, and when you add a two-year-old to the wedding party, you never know what's going to happen, because two-year-olds don't understand the world the same way adults do. During the unity candle ceremony, the two-year-old pushed her way to the table, joining the bride and groom, in order to get a front-row seat for the ritual. And then when the unity candle was lit, she tried to blow it out. Because when you're two years old, the only time you see people make a big deal about lighting a candle is when it's ato...