The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

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

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

Jul 20, 2006
Post comments count 0
Post likes count 0

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

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

Jul 19, 2006
Post comments count 0
Post likes count 0

The traffic gods are punishing me for bicycling

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

Jul 19, 2006
Post comments count 0
Post likes count 0

Exported functions that are really forwarders

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

Jul 18, 2006
Post comments count 0
Post likes count 1

How are DLL functions exported in 32-bit Windows?

Raymond Chen

The designers of 32-bit Windows didn't have to worry quite so much about squeezing everything into 256KB of memory. Since modules in Win32 are based on demand-paging, all you have to do is map the entire image into memory and then run around accessing the parts you need. There is no distinction between resident and non-resident names; the names of exported functions are just stored in the image, with a pointer (well, a relative virtual address) to the name stored in the export table. Unlike the 16-bit ordinal export table, the 32-bit ordinal export table is not sparse. If your DLL exports two functions, one as ...

Jul 17, 2006
Post comments count 0
Post likes count 0

The day the peloton lost its way

Raymond Chen

It's the one time a year that more than fifty people in the United States actually give a hoot about bicycle racing. Yes, it's the Tour de France. (Follow the racers live via GPS!) But this story isn't about the Tour. It's about Stage 4 of the 2005 ENECO Tour. You can follow along with the live report. Everything was going pretty much like a typical racing stage, until time code 13:55. Veikkanen is now gone from the back of the lead group, but the peloton appears to have taken a wrong turn!! The peloton is just stopped in the road. nobody knows what happened, riders are getting off their bikes. Zabe...

Jul 17, 2006
Post comments count 0
Post likes count 1

How were DLL functions imported in 16-bit Windows?

Raymond Chen

A threaded linked list.

Jul 14, 2006
Post comments count 0
Post likes count 1

How were DLL functions exported in 16-bit Windows?

Raymond Chen

The whole point of dynamic link libraries (DLLs) is that the linkage is dynamic. Whereas statically-linked libraries are built into the final product, a module that uses a dynamically-linked library merely says, "I would like function X from Y.DLL, please." This technique has advantages and disadvantages. One advantage is more efficient use of storage, since there is only one copy of Y.DLL in memory rather than a separate copy bound into each module. Another advantage is that an update to Y.DLL can be made without having to re-compile all the programs that used it. On the other hand, the ability to swap in functi...

Jul 13, 2006
Post comments count 0
Post likes count 0

Glass houses are great places to throw stones

Raymond Chen

Whenever I write an article explaining that programs should avoid doing X, I can confidently rely on a comment saying, "Well, Microsoft Product Q does this!" as if to say, "Gotcha, you hypocrite!" But they're saying "gotcha" to the wrong person. Because, and I'm sure it's a shock to many people to read this, I did not personally write every line of software Microsoft ever produced. (And even if I did write it, I may have written it as a younger developer, before I learned about said rule. Because, and I'm sure this is also a shock to many people, I was once a beginner, too.) If you find a Micros...