The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Feb 10, 2012
Post comments count 0
Post likes count 2

Fancy use of exception handling in FormatMessage leads to repeated "discovery" of security flaw

Raymond Chen

Every so often, somebody "discovers" an alleged security vulnerability in the function. You can try it yourself: If you run this program under the debugger and you tell it to break on all exceptions, then you will find that it breaks on an access violation trying to write to an invalid address. Did you just find a buffer overflow security vulnerability? The function was part of the original Win32 interface, back in the days when you had lots of address space (two whole gigabytes) but not a lot of RAM (12 megabytes, or 16 if you were running Server). The implementation of reflects this historical reali...

Feb 9, 2012
Post comments count 0
Post likes count 1

What is the effect of memory-mapped file access on GetLastError()?

Raymond Chen

A customer was using memory-mapped files and was looking for information as to whether access to the memory-mapped data modifies the value returned by . A member of the kernel team replied, "No, memory-mapped I/O does not ever change the value returned by ." That answer is simultaneously correct and wrong, a case of looking at the world through kernel-colored glasses. While it's true that the kernel does not ever change the value returned by , it's also the case that you might change it. If you set up an exception handler, then your exception handler might perform operations that affect the last-error cod...

Feb 8, 2012
Post comments count 0
Post likes count 1

The path-searching algorithm is not a backtracking algorithm

Raymond Chen

Suppose your PATH environment variable looks like this: Suppose that you call intending to load the library at . If the network server is down, the call will fail. Why doesn't it just skip the bad directory in the PATH and continue searching? Suppose the function skipped the bad network directory and kept searching. Suppose that the code which called was really after the file . By taking the server down, you have tricked the function into loading instead. (And maybe that was your DLL planting attack: If you can convince the system to reject all the versions on the by some means, you can then get to ...

Feb 7, 2012
Post comments count 0
Post likes count 1

Microspeak: fit

Raymond Chen

In Microspeak, fit is a predicate noun which is never used on its own but always comes with a modifying adjective. For something to be a good fit is for something to be appropriate or suitable for a particular situation. The opposite of a good fit is not a bad fit, because that's pejorative. Rather, something that is not a good fit is referred to as a poor fit. The purpose of a previewer plug-in is to allow users to view the media without opening it. An image editing tool would not be a good fit for the previewing feature. (Alternatively, "would be a poor fit for the previewing feature.") To be a good fit with...

Feb 6, 2012
Post comments count 0
Post likes count 1

The story of the mysterious WINA20.386 file

Raymond Chen

Global or local.

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

The compatibility constraints of error codes, episode 2

Raymond Chen

A customer reported an incompatibility in Windows 7: If A: is a floppy drive and they call and there is no disk in the drive, the call fails with the error . Previous versions of Windows failed with the error . Both error codes are reasonable responses to the situation. "The module couldn't be found because the drive is not ready." Programs should treat a failed as a failed library load and shouldn't be sensitive to the precise reason for the error. (They can display a more specific error to the user based on the error code, but overall program logic shouldn't depend on the error code.) Fortunately, the...

Feb 2, 2012
Post comments count 0
Post likes count 1

When you are looking for more information, it helps to say what you need the information for

Raymond Chen

It's often the case that when a question from a customer gets filtered through a customer liaison, some context gets lost. (I'm giving the customer the benefit of the doubt here and assuming that it's the customer liaison that removed the context rather than the customer who never provided it.) Consider the following request: We would like to know more information about the method the shell uses to resolve shortcuts. This is kind of a vague question. It's like asking "I'd like to know more about the anti-lock braking system in my car." There are any number of pieces of information that could be provided abou...

Feb 1, 2012
Post comments count 0
Post likes count 1

Things I've written that have amused other people, Episode 9

Raymond Chen

A customer liaison reported that their customer wants to be able to access their machine without needing a password. They just want to be able to and be able to access the files right away. I guess because passwords are confusing, easy to forget, and just get in the way. Anyway, the customer discovered that they could do so on Windows XP by going to the folder they want to share, going to the Sharing tab, then clicking on the If you understand the security risks but want to share files without running the wizard link, and then on the Enable File Sharing dialog, clicking Just enable file sharing. What th...

Jan 31, 2012
Post comments count 0
Post likes count 1

The Freudian typo that will not die: Enchanced video quality

Raymond Chen

While wasting time doing valuable background research on my computer, I received the following suggestion: For enchanced video quality, click here. It's good to know that the typo that I first encountered in 1993 is still alive and kicking. (And even though it's not important to the story, people will demand some sort of follow-up, so here it is: I submitted feedback to the vendor, who said that it was a known issue fixed in the next update.)