Showing tag results for Code

Nov 6, 2009
Post comments count0
Post likes count1

Signs that the symbols in your stack trace are wrong

Raymond Chen

One of the things programmers send to each other when they are trying to collaborate on a debugging problem is stack traces. Usually something along the lines of "My program does X, then Y, then Z, and then it crashes. Here is a stack trace. Can you tell me what's wrong?" It helps if you at least glance at the stack trace before you send it, bec...

Code
Oct 23, 2009
Post comments count0
Post likes count1

If you have to cast, you can't afford it

Raymond Chen

A customer reported a crash inside a function we'll call : The title of today's entry gives the answer away. (The title is also an exaggeration, but it's a pun on the saying If you have to ask, you can't afford it.) The last parameter to the function is declared as a : A pointer to a generic pointer. Note that it is not itself a generic poi...

Code
Oct 16, 2009
Post comments count0
Post likes count1

Important window message numbers to memorize

Raymond Chen

You probably know them already, but if you're new to Win32, here are some key window messages. I would normally suggest that you commit them to memory, but if you do enough debugging, you'll end up memorizing them anyway because you see them all the time. I include in the list even though it is a low-traffic message because you do see it a lot w...

Code
Oct 15, 2009
Post comments count0
Post likes count1

Don't use global state to manage a local problem, practical exam

Raymond Chen

There was much speculation as to how the "Ignore other applications that use Dynamic Data Exchange" setting got set. Well, one possibility is that somebody used global state to manage a local problem. "Why on earth does this setting exist?" I don't know, but there appear to be scripts which rely on it. The setting is exposed to scripts, and pe...

CodeTips/Support
Oct 9, 2009
Post comments count0
Post likes count1

LoadString can load strings with embedded nulls, but your wrapper function might not

Raymond Chen

Whenever somebody reports that the function or the member of the structure is not working, my psychic powers tell me that they failed to manage the double-null-terminated strings. Since string resources take the form of a counted string, they can contain embedded null characters, since the null character is not being used as the string term...

Code
Oct 8, 2009
Post comments count0
Post likes count1

What is the format of a double-null-terminated string with no strings?

Raymond Chen

One of the data formats peculiar to Windows is the double-null-terminated string. If you have a bunch of strings and you want to build one of these elusive double-null-terminated strings out of it, it's no big deal. But what about the edge cases? What if you want to build a double-null-terminated string with no strings? Let's step back and lo...

Code
Oct 7, 2009
Post comments count0
Post likes count1

The ways people mess up IUnknown::QueryInterface, episode 3

Raymond Chen

Today we'll combine information you already know, some of which I covered in The ways people mess up IUnknown::QueryInterface with additional clues from The layout of a COM object. There's still not enough information for you to solve the problem entirely on your own, but maybe you can demonstrate your nascent psychic debugging powers and solve ...

Code
Oct 1, 2009
Post comments count0
Post likes count1

In the search for the subtle source of the problem, you sometimes overlook the obvious one

Raymond Chen

A customer was encountering a problem with lots of duplicate GUIDs. How is that possible? The whole point of the GUID generation algorithm is to work hard to avoid duplication. Was one of the fundamental assumptions of the algorithm broken? Maybe there was a duplicate MAC? Was the clock regressing? One of my colleagues pointed out that in the sea...

Code
Sep 30, 2009
Post comments count0
Post likes count1

Why do messages posted by PostThreadMessage disappear?

Raymond Chen

The only thread message you can meaningfully post to a thread displaying UI is , and even then, it's only because you want to wake up the message loop for some reason. A common problem I see is people who use to talk to a thread that is displaying UI and then wonder why the message never arrives. Oh, the message arrived all right. It arrived and...

Code
Sep 25, 2009
Post comments count0
Post likes count1

The ways people mess up IUnknown::QueryInterface, episode 2

Raymond Chen

Sadly, I get to add another entry to The ways people mess up : Blindly responding to everything. Some people are just too eager to please. No matter what the interface is, they say, "Sure, we do that!" Furthermore, no matter what you ask for, they always return the same interface. Even if it's not what you asked for. Exercise: Some pe...

Code