The Old New Thing
Practical development throughout the evolution of Windows.
Latest posts
Exploiting the inattentive, episode 2: The unlabeled line
In Episode 1 we learned that "Snide" brand powdered laundry detergent comes with a scoop that holds 5/8 cup detergent, even though the directions call for only 3/8 cup. The intent here is to get people to use more detergent than necessary, thereby increasing sales. A box of detergent which should be sufficient for 30 loads ends up running out after only 18. Consider it "technically legal" mislabeling. I returned to Snide brand powdered laundry detergent this week and discovered that they have taken this little trick to a new level. The markings on the side of the scoop read like this: ...
Why does SetWindowsHookEx take an HINSTANCE parameter?
An anonymous commenter asked why the function takes an parameter if the first thing it's going to do is convert the instance handle into a file name. Because that's not how it worked in 16-bit Windows. In 16-bit Windows there was no such thing as hook injection. All 16-bit Windows applications ran in the same address space, so there was no need to inject anything anywhere. Consequently, there was no need to convert the instance handle into a file name in order to inject it. Instead, the instance handle was used to increment the reference count on the module so that the hook procedure wouldn't get unloaded w...
Space scientist James Van Allen (1914–2006)
Discoverer of the Van Allen radiation belts and one of the TIME magazine men of the year for 1960 James Van Allen died yesterday. (What a coincidence. What are the odds that the person to discover the Van Allen radiation belts would also be named Van Allen?) I never met the man, but I met his granddaughter. She has an amazing facility with languages and became fluent in Japanese after spending a year as an exchange student. Her Japanese was so good that at one point, a girl came up to her and asked, "How do you get your skin so pale?", mistaking her for a native who had undergone some sort of bleaching process ...
One way people abused hooks in 16-bit Windows
We saw last time how windows hooks were implemented in 16-bit Windows. Even though the was an opaque data type that should have been treated like a handle, many programs "knew enough to be dangerous" and took advantage of the fact that the was just a pointer to the previous hook procedure. The most common way of abusing this knowledge was by unhooking from the windows hook chain the wrong way. Instead of calling the function to unhook a windows hook, they called again! Specifically, they removed their hook by simply reinstalling the previous hook at the head of the chain: This code worked in spite of i...
How were window hooks implemented in 16-bit Windows?
The mechanism for keeping track of window hooks was very different in 16-bit Windows. The functions involved were , and . The first two functions still exist today, but the third one has been replaced with a macro: Disclaimer: All code below is "reconstructed from memory". The spirit of the code is intact, but the precise details may be off. To install a windows hook in 16-bit Windows, you started by calling : The return value from must be saved in a global variable, which we gave the somewhat provocative name . The hook procedure itself went something like this: And then when you were finished, you...
A look inside WinInet's index.dat file and changes in IE7 and Vista
My frequent bicycling buddy Ari Pernick wrote a couple of articles over on the Windows Network Development blog on the topic of the file, which appears to have gotten a bit of attention lately. This past weekend, I joined Ari and another friend in a ride along the Upper Loop of the annual Tour De Peaks bicycle ride. I'd never done this ride before; I tend to do the same routes over and over. This doesn't bother me like it does other people. We had originally planned to do both the Upper and Lower loops (50km each for a total of 100km), and Ari chatted with one of the ride organizers about the characteristic...
Candidate for most obscure keyboard shortcut: Shift+F8
One of the most obscure keyboard shortcuts has got to be Shift+F8, which is used for listbox discontiguous extended selection. Man, what a mouthful. KB article Q301583 doesn't help matters by listing this keyboard shortcut under "Dialog box keyboard shortcuts" even though it isn't a dialog box keyboard shortcut. It's a listbox keyboard shortcut. If the listbox supports extended selections (via ), then you can use the Shift+F8 shortcut to create discontiguous multiple selections from the keyboard. (Via the mouse, you can just Ctrl+Click to create a discontiguous multiple selection.) Type Shift+F8 once to enter e...
Even more about C# anonymous methods, from the source
If you want to know still more about C# anonymous methods, you can check out the web site of Grant Richins who has an entire category devoted to anonymous methods, and he should know, since he actually implemented them. Now that CLR week is over, I'm curious what you all thought of it. Would you like to see another CLR week at some point? Should I stick to Win32? (Or doesn't it matter because I'm an arrogant Microsoft apologist either way?)
The day Tully's ran out of coffee
Today, Tully's coffee shops begin offering free Wi-Fi (in shops where Wi-Fi is available). Tully's isn't as widespread as Starbucks, but it's the best of the major chain coffee shops in the Seattle area, according to a highly unscientific poll of my friends. Seeing Tully's name back in the news reminded me of an incident that occurred to one of my colleagues, who went into the local Tully's one evening and asked for a cup of drip coffee. The Tully's employee went to the pot, then turned around and said, "Actually, we don't have any coffee." My colleague did get a profuse apology from the district manager, who ...