Showing archive results for 2012

Feb 17, 2012
Post comments count0
Post likes count1

How do I find out which process has a file open?

Raymond Chen

Classically, there was no way to find out which process has a file open. A file object has a reference count, and when the reference count drops to zero, the file is closed. But there's nobody keeping track of which processes own how many references. (And that's ignoring the case that the reference is not coming from a process in the first place; ...

Code
Feb 16, 2012
Post comments count0
Post likes count1

Why does the DrawIcon function draw at the default icon size?

Raymond Chen

Miral wondered why the function draws at the default icon size instead of respecting the actual icon size. After all, if you loaded a nonstandard-sized icon via , then presumably you want to use that nonstandard size. The question is one of those types of questions that fails to understand history, like asking why NASA didn't send the space shut...

History
Feb 15, 2012
Post comments count0
Post likes count1

When does an icon handler shell extension get unloaded?

Raymond Chen

A customer had a question about the function. They used the function to obtain the icon for a file, and they discovered that when they asked for the icon of a particular type of file, the shell extension for the associated application was loaded. But unfortunately the third party shell extension is not getting unloaded, maybe because of a bug. Ca...

Code
Feb 14, 2012
Post comments count0
Post likes count0

The awesome Valentine's Day gift disguised as an uncreative one

Raymond Chen

A few years ago, one of my colleagues wanted to surprise his wife with a new laptop for Valentine's Day. (As a bonus, he set the wallpaper to one of their wedding pictures.) Now, he could just give her a neatly wrapped laptop, but he wanted this one to be a super-surprise. First, he bought a large box of chocolates. He then carefully opened the bo...

Non-Computer
Feb 10, 2012
Post comments count0
Post likes count2

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 v...

Code
Feb 9, 2012
Post comments count0
Post likes count1

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...

Code
Feb 8, 2012
Post comments count0
Post likes count1

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 w...

Code
Feb 7, 2012
Post comments count0
Post likes count1

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 ...

OtherMicrospeak