The Old New Thing

Why doesn’t HeapValidate detect corruption in the managed heap?

A customer had a program that was corrupting the managed heap by p/invoking incorrectly. The problem didn't show up until the next garbage collection pass, at which point the CLR got all freaked-out-like. "According to Knowledge Base article 286470, the tool is supposed to catch heap corruption, but it doesn't catch squat." Depending on ...

Poisoning your own DNS for fun and profit

When you type a phrase into the Windows Vista Start menu's search box and click Search the Internet, then the Start menu hands the query off to your default Internet search provider. Or at least that's what the Illuminati would have you believe. A customer reported that when they typed a phrase into the Search box and clicked Search the ...

Finding a printer, and then creating a shortcut to that printer

Today's "Little Program" does two things: It looks for a printer in the Printers folder, and then once it finds it, it creates a shortcut to that printer. As is common with "Little Programs", I don't bother with error checking. I'll leave you to do that. Second part first, since it is handy on its own: Creating a shortcut to an arbitrary ...

When you have a SAFEARRAY, you need to know what it is a SAFEARRAY *of*

A customer had a problem with SAFEARRAY, or more specifically, with CComSafeArray. CComSafeArray<VARIANT> sa; GetAwesomeArray(&sa); LONG lb = sa.GetLowerBound(); LONG ub = sa.GetUpperBound(); for (LONG i = lb; i <= ub; i++) { CComVariant item = sa.GetAt(i); ... use the item ... } The GetAt method returns a VARIANT&, ...