Showing tag results for Code

Feb 22, 2012
Post comments count0
Post likes count1

Instead of creating something and then trying to hide it, simply don't create it in the first place

Raymond Chen

A customer had a question, which was sort of I bet somebody got a really nice bonus for that feature in reverse. A customer is asking if there is a way to programmatically control the icons in the notification area. Specifically, they want the setting for their notification icon to be "Only show notifications" rather than "Show icon and notifi...

Code
Feb 20, 2012
Post comments count0
Post likes count1

What's the difference between Text Document, Text Document – MS-DOS Format, and Unicode Text Document?

Raymond Chen

Alasdair King asks why Wordpad has three formats, Text Document, Text Document - MS-DOS Format, and Unicode Text Document. "Isn't at least one redundant?" Recall that in Windows, three code pages have special status. Three text file formats. Three encodings. Hm... I wonder... As you might have guessed by now, the three text file formats c...

Code
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 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 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 3, 2012
Post comments count0
Post likes count1

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

Code
Jan 27, 2012
Post comments count0
Post likes count1

Does mapping the same shared memory two times in a process lead to double the address space usage?

Raymond Chen

A customer designed a system which uses shared memory. Specifically, for each database file, they create a corresponding shared memory block of, say, 200MB. Multiple clients which connect to the same database file use the same shared memory block. Naturally, if two processes each access the same database file, each process will map the shared memor...

Code
Jan 25, 2012
Post comments count0
Post likes count1

How do I disable the fault-tolerant heap?

Raymond Chen

A while back, I linked to a talk by Silviu Calinoiu on the fault-tolerant heap. But what if you don't want the fault-tolerant heap? For example, during program development, you probably want to disable the fault-tolerant heap for your program: If the program is crashing, then it should crash so you can debug it! Method 1 is to disable the ...

Code