Showing tag results for Code

Jan 11, 2013
Post comments count0
Post likes count0

Understanding errors in classical linking: The delay-load catch-22

Raymond Chen
Raymond Chen

Wrapping up our week of understanding the classical model for linking, we'll put together all the little pieces we've learned this week to puzzle out a linker problem: The delay-load catch-22. You do some code cleanup, then rebuild your project, and you get LNK4199: /DELAYLOAD:SHLWAPI ignored; no imports found from SHLWAPI What does this er...

CodeLinker
Jan 10, 2013
Post comments count0
Post likes count0

Understanding the classical model for linking: Sometimes you don’t want a symbol to come along for a ride

Raymond Chen
Raymond Chen

Continuing our study of the classical model for linking, let's take another look at the trick of taking symbols along for the ride. The technique of taking symbols along for the ride is quite handy if that's what you want, but sometimes you don't actually want it. For example, a symbol taken along for the ride may create conflicts or create unw...

CodeLinker
Jan 9, 2013
Post comments count0
Post likes count0

Understanding the classical model for linking: You can override an LIB with another LIB, and a LIB with an OBJ, but you can’t override an OBJ

Raymond Chen
Raymond Chen

If you study the classical model for linking, you'll see that OBJ files provided directly to the linker have a special property: They are added to the module even if nobody requests a symbol from them. OBJs bundled into a library are pulled into the module only if they are needed to resolve a needed symbol request. If nobody needs a symbol in the...

CodeLinker
Jan 8, 2013
Post comments count0
Post likes count0

Understanding the classical model for linking: Taking symbols along for the ride

Raymond Chen
Raymond Chen

Last time, we learned the basics of the classical model for linking. Today, we'll look at the historical background for that model, and how the model is exploited by libraries. In the classical model, compilers and assemblers consume source code and spit out an OBJ file. They do as much as they can, but eventually they get stuck because they do...

CodeLinker
Jan 7, 2013
Post comments count0
Post likes count1

Understanding the classical model for linking, groundwork: The algorithm

Raymond Chen
Raymond Chen

The classical model for linking goes like this: Each OBJ file contains two lists of symbols. Provided symbols: These are symbols the OBJ contains definitions for. Needed symbols: These are symbols the OBJ would like the definitions for. (The official terms for these are exported and imported, but I will use provided and needed to avo...

CodeLinker
Jan 4, 2013
Post comments count0
Post likes count0

What’s the guidance on when to use rundll32? Easy: Don’t use it

Raymond Chen
Raymond Chen

Occasionally, a customer will ask, "What is Rundll32.exe and when should I use it instead of just writing a standalone exe?" The guidance is very simple: Don't use rundll32. Just write your standalone exe. Rundll32 is a leftover from Windows 95, and it has been deprecated since at least Windows Vista because it violates a lot of modern en...

Code
Jan 3, 2013
Post comments count0
Post likes count0

Why does my program run really slow or even crash (or stop crashing, or crash differently) if running under a debugger?

Raymond Chen
Raymond Chen

More than once, a customer has noticed that running the exact same program under the debugger rather than standalone causes it to change behavior. And not just in the "oh, the timing of various operations changed to hit different race conditions" but in much more fundamental ways like "my program runs really slow" or "my program crashes in a totall...

Code
Dec 28, 2012
Post comments count0
Post likes count0

What do HeapLock and HeapUnlock do, and when do I need to call them?

Raymond Chen
Raymond Chen

You never need to call the and functions under normal operation. Assuming the heap is serialized (which is the default), all the standard heap functions like and will automatically serialize. In fact, the way they serialize is by calling the¹ and functions! Nearly all heap operations complete in a single call. If your heap is serial...

Code
Dec 27, 2012
Post comments count0
Post likes count0

What is so special about the instance handle 0x10000000?

Raymond Chen
Raymond Chen

A customer wanted to know what it means when the function returns the special value . Um, it means that the library was loaded at ? Okay, here's some more information: "We're trying to debug an application which loads DLLs and attempts to hook their registry accesses when they call . It looks like when the special handle is returned from , the r...

Code