The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

The efficiency of ordinal-based imports while still being name-based
Jul 28, 2006
Post comments count 0
Post likes count 0

The efficiency of ordinal-based imports while still being name-based

Raymond Chen
Raymond Chen

Reader Tom brought up the interesting point that ordinal-based imports are slightly faster than name-based, though not by much. But if even that tiny fraction of a percentage bothers you, you can still get the benefits of ordinal-based imports while still being name-based. People are more familiar with the first half of the "rebase and bind" duo than the second. But it's binding that speeds up import table resolution. When a DLL is "bound" to another DLL, information about the target DLL is cached in the original DLL. Specifically, the timestamp of the target (so that the loader can detect whether the cache is ...

Handy tip: If you're going to break into vehicles, the police vehicle service center is probably a bad place
Jul 27, 2006
Post comments count 0
Post likes count 0

Handy tip: If you're going to break into vehicles, the police vehicle service center is probably a bad place

Raymond Chen
Raymond Chen

And you probably shouldn't fall asleep in the van you break into.

Index to the series on DLL imports and exports
Jul 27, 2006
Post comments count 0
Post likes count 0

Index to the series on DLL imports and exports

Raymond Chen
Raymond Chen

For reference.

Names in the import library are decorated for a reason
Jul 27, 2006
Post comments count 0
Post likes count 0

Names in the import library are decorated for a reason

Raymond Chen
Raymond Chen

When I wrote that the symbolic name for the imported function table entry for a function is called , the statement was "true enough" for the discussion at hand, but the reality is messier, and the reason for the messy reality is function name decoration. When a naive compiler generates a reference to a function, the reference is decorated in a manner consistent with its architecture, language, and calling convention. (Some time ago, I discussed some of the decorations you'll see on x86 systems.) For example, a naive call to the function results in the compiler generating code equivalent to (on an x86 system;...

Real Madrid (i.e., proper football) comes to Seattle
Jul 26, 2006
Post comments count 0
Post likes count 0

Real Madrid (i.e., proper football) comes to Seattle

Raymond Chen
Raymond Chen

Hot off the presses. Real Madrid (with David Beckham, Ronaldo, and other stars) will play an exhibition match against D. C. United in Seah^H^H^H^HQuest Field on Wednesday, August 9th. I wonder if it'll be anything like the last soccer match I saw. At least let's hope they're ready to play instead of having tired themselves out playing video games. Tickets go on sale today.

What happens when you get dllimport wrong?
Jul 26, 2006
Post comments count 0
Post likes count 0

What happens when you get dllimport wrong?

Raymond Chen
Raymond Chen

Now that we've learned what the declaration specifier does, what if you get it wrong? If you forget to declare a function as , then you're basically making the compiler act like a naive compiler that doesn't understand . When the linker goes to resolve the external reference for the function, it will use the stub from the import library, and everything will work as before. You do miss out on the optimization that enables, but the code will still run. You're just running in naive mode. (There are still some header files in the Platform SDK that neglect to use the declaration specifier. As a result, anybody wh...

If you know German, the world is, well, slightly more confusing
Jul 25, 2006
Post comments count 0
Post likes count 0

If you know German, the world is, well, slightly more confusing

Raymond Chen
Raymond Chen

While it may be true that if you know Swedish, the world is funnier, I have to admit that my knowledge of German only served to create momentary confusion. When I saw the headline that the head of BetonSports was arrested, I thought to myself, "Who the heck would have a web site devoted to sports in concrete?" That's because the German word Beton means "concrete" (the construction material) in English, and the German word Sport means the same as in English. It took me a few moments to realize that the company's name is "Bet on Sports".

Issues related to forcing a stub to be created for an imported function
Jul 25, 2006
Post comments count 0
Post likes count 0

Issues related to forcing a stub to be created for an imported function

Raymond Chen
Raymond Chen

I noted last time that you can concoct situations that force the creation of a stub for an imported function. For example, if you declare a global function pointer variable: then the C compiler is forced to generate the stub and assign the address of the stub to the variable. That's the best it can do, since the loader will patch up only the imported function address table; it won't patch up anything else in the data segment. The C++ compiler, on the other hand, can take advantage of some C++ magic and secretly generate a "pseudo global constructor" (I just made up that term so don't go around using it li...

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