The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

Raise la lanterne rouge
Jul 24, 2006
Post comments count 0
Post likes count 0

Raise la lanterne rouge

Raymond Chen
Raymond Chen

Sure, everybody knows that Floyd Landis won this year's Tour de France. But what about the guy who came in last? While the race leader wears the maillot jaune (yellow jersey), the person at the bottom of the pack is saddled with the lanterne rouge (red lantern), after the lamp that hangs on the back of a train. This year's "winner" is Wim Vansevenant, who at least appears to be a good sport about it. Lanterne rouge is not a position you go for. It comes for you. (It also amuses me that there's even a Tour de France Lanterne Rouge blog which keeps track of who is "pulling up the rear" throughout the race.) N...

How a less naive compiler calls an imported function
Jul 24, 2006
Post comments count 0
Post likes count 0

How a less naive compiler calls an imported function

Raymond Chen
Raymond Chen

If a function is declared with the declaration specifier, this instructs the Visual Studio C/C++ compiler that the function in question is an imported function rather than a normal function with external linkage. With this additional information, the compiler generates slightly different code when it needs to reference an imported function, since the compiler is aware of the special way imported functions are implemented. First, there is no need for the stub function any more, because the compiler can generate the special instruction inline. Furthermore, the compiler knows that the address of an imported fun...

Floyd Landis stuns everybody on stage 17; Raymond less impressive
Jul 21, 2006
Post comments count 0
Post likes count 0

Floyd Landis stuns everybody on stage 17; Raymond less impressive

Raymond Chen
Raymond Chen

Wow. I delayed my departure for work Thursday morning until the results were in. And then I was inspired by Floyd's fantastic performance to kick it up a notch on one of the hills on my route, only to find about two thirds of the way up that there's a reason I don't normally go up the hill that fast... (On an unrelated note, a mini-van tried to run me off the road while I was heading up that hill. They pulled up next to me and then started a right turn. Fortunately I was able to escape to the right.) Okay, well, attacking that hill wasn't such a great idea now, was it. I decided to continue with an alternate r...

I didn't realize that it was International Group B Strep Awareness Month
Jul 21, 2006
Post comments count 0
Post likes count 0

I didn't realize that it was International Group B Strep Awareness Month

Raymond Chen
Raymond Chen

I guess they're not doing a particularly good job of creating awareness because it wasn't until I consulted the 2006 National Health Observances calendar that the month of July is International Group B Strep Awareness Month. For some reason, July and August are pretty light on the health observances calendar. Maybe because people are on summer vacation. Who decides whether a particular health observance merits a day, a week, or a month? You'd think they'd save the months for the really big issues, seeing as there are only twelve of them. And for some reason, ultraviolet radiation gets two months. May is Ultrav...

Calling an imported function, the naive way
Jul 21, 2006
Post comments count 0
Post likes count 0

Calling an imported function, the naive way

Raymond Chen
Raymond Chen

An import library resolves symbols for imported functions, but it isn't consulted until the link phase. Let's consider a naive implementation where the compiler is blissfully unaware of the existence of imported functions. In the 16-bit world, this caused no difficulty at all. The compiler generated a far call instruction and left an external record in the object file indicating that the address of the function should be filled in by the linker. At that time, the linker realizes that the external symbol corresponds to an imported function, so it takes all the call targets, threads them together, and creates an ...

Buy me some peanuts and a set of double-pointed 2's
Jul 20, 2006
Post comments count 0
Post likes count 0

Buy me some peanuts and a set of double-pointed 2's

Raymond Chen
Raymond Chen

It's the second annual Stitch 'n Pitch at Safeco Field. Stitch n' Pitch events for other cities can be found on the Stitch n' Pitch web site. (Channeling Lynne Truss: Ahem, people, the spelling of the middle word is 'n' with an apostrophe fore and aft.) [10am: Fixed sepleling.] Seattle Times readers Dave Butner and Mike Wilson took issue with the event (though Mr. Wilson's outrage bordered on satirical). To me, baseball is like soccer: It's a game whose primary draw is not the actual scoring but rather the anticipation that a run might be scored. It's in the tension that builds as scoring opportunities devel...

Rethinking the way DLL exports are resolved for 32-bit Windows
Jul 20, 2006
Post comments count 0
Post likes count 0

Rethinking the way DLL exports are resolved for 32-bit Windows

Raymond Chen
Raymond Chen

Over the past few days we've learned how 16-bit Windows exported and imported functions from DLLs and that the way functions are exported from 32-bit DLLs matches the 16-bit method reasonably well. But the 16-bit way functions are imported simply doesn't work in the 32-bit world. Recall that in 16-bit Windows, the fixups for an imported function are threaded through the code segment. This works great in 16-bit Windows since there was a single address space: Code segments were shared globally, and once a segment was loaded, each process could use it. But 32-bit Windows uses separate address spaces. If the fixu...

The traffic gods are punishing me for bicycling
Jul 19, 2006
Post comments count 0
Post likes count 0

The traffic gods are punishing me for bicycling

Raymond Chen
Raymond Chen

It happened again. The last time I participated in a bicycle ride that started in Seattle, I got stuck in highway traffic both going out and coming back. The 520 bridge was closed for inspection so everybody was taking the I-90 bridge instead. But traffic at the western terminal of I-90 was backed up because the Alaska Way Viaduct was closed for some sort of fundraiser walk-a-thon. And then, after the ride was over, I got stuck in traffic on the return trip as well because the Mariners baseball game had just let out, and that on top of all the traffic created by the 520 bridge being closed. This weekend, head...

Exported functions that are really forwarders
Jul 19, 2006
Post comments count 0
Post likes count 0

Exported functions that are really forwarders

Raymond Chen
Raymond Chen

Last time, we saw how the way Win32 exports functions is pretty much the same as the way 16-bit Windows exports functions, but with a change in emphasis from ordinal-based exports to name-based exports. This change in emphasis is not expressed anywhere in the file format; both 16-bit and 32-bit DLLs can export either by name or by ordinal (or by both), but the designers of Win32 were biased in spirit in favor of name-only exports. But there is a new type of exported function in Win32, known as a forwarder. A forwarder looks just like a regular exported function, except that the entry in the ordinal export tab...