The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

It rather involved being on the other side of this airtight hatchway: Invalid parameters from one security level crashing code at the same security level
Dec 8, 2010
Post comments count 0
Post likes count 0

It rather involved being on the other side of this airtight hatchway: Invalid parameters from one security level crashing code at the same security level

Raymond Chen
Raymond Chen

In the category of dubious security vulnerability, I submit the following (paraphrased) report: I have discovered that if you call the function (whose first parameter is supposed to be a pointer to a IUnknown), and instead of passing a valid COM object pointer, you pass a pointer to a random hunk of data, you can trigger an access violation in the function which is exploitable by putting specially-crafted data in that memory blob. An attacker can exploit the function for remote execution and compromise the system, provided an application uses the function and passes a pointer to untrusted data as the firs...

Creative naming in pursuit of subverting the no-fun zone
Dec 7, 2010
Post comments count 0
Post likes count 0

Creative naming in pursuit of subverting the no-fun zone

Raymond Chen
Raymond Chen

For a time, the Information Technology department at Microsoft cracked down on what it believed to be frivolous mailing lists. All mailing lists inside the company had to have a valid business purpose. The nascent wireless networking team found a way to circumvent this rule: They created a mailing list for discussion of non-business topics but officially said that it was for discussing Wireless Networking Interference.

TrackMouseEvent tracks mouse events in your window, but only if the events belong to your window
Dec 6, 2010
Post comments count 0
Post likes count 0

TrackMouseEvent tracks mouse events in your window, but only if the events belong to your window

Raymond Chen
Raymond Chen

Greg Williams wonders why fails to detect mouse hover events when responding to Do­Drag­Drop callbacks. "My suspicion is that monopolizes the window so that a message is never posted, so it won't end up being useful." That's basically it, for the appropriate sense of the word "monopolize." The monitors mouse events that take place in your window and notifies your window when events of interest occur. But this requires that the events actually take place in your window! The function calls so that it can carry out the task of following the mouse anywhere on the screen. Recall that mouse events nor...

ZOMG! This program is using 100% CPU!1! Think of the puppies!!11!!1!1!eleven
Dec 3, 2010
Post comments count 0
Post likes count 0

ZOMG! This program is using 100% CPU!1! Think of the puppies!!11!!1!1!eleven

Raymond Chen
Raymond Chen

Calm down.

The alignment declaration specifier is in bytes, not bits
Dec 2, 2010
Post comments count 0
Post likes count 0

The alignment declaration specifier is in bytes, not bits

Raymond Chen
Raymond Chen

Explicit object alignment is not something most people worry about when writing code, which means that when you decide to worry about it, you may be a bit rusty on how the declarations work. (After all, if it's something you worried about all the time, then you wouldn't have trouble remembering how to do it!) I was looking at some customer code, and there was a class who had a data member with an explicit alignment declaration. I pointed out that the comment didn't match the code. The comment says that the variable needs to be DWORD-aligned (which in Windows-speak means aligned on a 32-bit boundary), but th...

I will be speaking at TechEd China 2010 today
Dec 1, 2010
Post comments count 0
Post likes count 0

I will be speaking at TechEd China 2010 today

Raymond Chen
Raymond Chen

As I've mentioned a few times by now, the way to get me to show up at your event is to invite me. The easiest (i.e. cheapest) way is to hold your event in the Seattle area so that my travel expenses are effectively zero; I just use my bus pass. The folks at TechEd China 2010, on the other hand, had to fly me all the way out to Beijing, which is where I've been this week. Preparing these talks is a lot of work, because each one is different. It's not like I have a "stock presentation" that I give over and over. So even if you invite me, I may decline because I simply don't have the time to write up a new present...

How do I delete bytes from the beginning of a file?
Dec 1, 2010
Post comments count 0
Post likes count 0

How do I delete bytes from the beginning of a file?

Raymond Chen
Raymond Chen

It's easy to append bytes to the end of a file: Just open it for writing, seek to the end, and start writing. It's also easy to delete bytes from the end of a file: Seek to the point where you want the file to be truncated and call . But how do you delete bytes from the beginning of a file? You can't, but you sort of can, even though you can't. The underlying abstract model for storage of file contents is in the form of a chunk of bytes, each indexed by the file offset. The reason appending bytes and truncating bytes is so easy is that doing so doesn't alter the file offsets of any other bytes in the file. I...

Microspeak: Take-away
Nov 30, 2010
Post comments count 0
Post likes count 0

Microspeak: Take-away

Raymond Chen
Raymond Chen

At Microsoft, the take-away is the essential message of a presentation or the conclusion that you are expected to draw from a situation. It is something you are expected to remember when the whole thing is over, a piece of information you take away with you as you leave the room. XYZ demo take away (title of a document) The preferred intensifier is key, and you probably see it attached to the phrase take-away more often than not. This example comes from a presentation on the results of a user study: Results: XYZ Tough to Use In fact, every single slide in this presentation had a bullet point at the botto...

What were Get/SetMessageExtraInfo ever used for?
Nov 29, 2010
Post comments count 0
Post likes count 0

What were Get/SetMessageExtraInfo ever used for?

Raymond Chen
Raymond Chen

KJK::Hyperion asks, "Could you shed some light on Get/SetMessageExtraInfo? It's almost like nobody on earth used them, ever, and I can't get some sample code." Yup, that's about right. Nobody on earth (to within experimental error) ever used them. These functions were introduced on July 20, 1990 (I'm looking at the change history right now) at the request of what was then called the Hand-Writing Windows group, which shipped the first version of Windows for Pen Computing in 1992. The idea was that each input event from the custom pen hardware would have this extra information associated with it, and the software...