The Old New Thing

Everyone should have a house pianist

Last year, a request was sent out to a social mailing list that went something like this: Hi, everybody. My girlfriend is coming to visit for a week, and she's a pianist. Does anybody have a piano they would be willing to let her practice on while she's here? I offered the piano in my living room and gave him the key to my house. I came ...

The default verb is not necessarily "open"

If you hunt around the Internet you'll find lots of people† who hard-code the string as the second parameter to the function, indicating that they want to open the document specified as the third parameter. While that's a nice thing to want to do, it might not be the right thing. When the user double-clicks a document, the shell ...

Stupid debugger tricks: Calling functions and methods

Back in the old days, if you wanted to call a function from inside the debugger, you had to do it by hand: Save the registers, push the parameters onto the stack (or into registers if the function uses or ) push the address of the function, move the instruction pointer to the start of the function you want to call, then hit "g" to resume ...

Using the "gu" debugger command to find the infinite loop

Somebody says, "Your program is consuming 100% CPU" and hands you a debug session. Usually, this happens because one thread has gotten stuck in an infinite loop. And if you're lucky it's the type of infinite loop that's easy to diagnose because it's just one function that isn't returning. (The more complicated types are where a function does ...

Identifying an object whose underlying DLL has been unloaded

Okay, so I gave it away in the title, but follow along anyway. Your program chugs along and then suddenly it crashes like this: Instantly you recognize the following: This is a virtual method call. (Call indirect through register plus offset.) — Very high confidence. The vtable is in . (That is the base register of ...

How much time does it take for a pedestrian to cross the street?

It sounds like the set-up to an old joke, but it's not. It's just one of the random bits of trivia that I wondered about. For intersections with both high pedestrian and high vehicle volumes, I was able to find the Federal Highway Administration recommendation, which is to give pedestrians a head start to allow them to cross one lane of ...

What is the underlying object behind a COM interface pointer?

When you're debugging, you might have a pointer to a COM interface and want to know what the underlying object is. Now, sometimes this trick won't work because the interface pointer actually points to a stub or proxy, but in the case where no marshalling is involved, it works great. (This technique also works for many C++ compilers for any ...