Showing archive results for 2014

Apr 14, 2014
Post comments count0
Post likes count1

Enumerating subsets with binomial coefficients

Raymond Chen

Inspired by the Little Program which enumerates set partitions, I decided to do the binomial coefficients this week. In other words, today's Little Program generates all subsets of size k from a set of size n. As before, the key is to interpret a recurrence combinatorially. In general, when a recurrence is of the form A + B, it means that at th...

Code
Apr 11, 2014
Post comments count0
Post likes count2

Windows is not a Microsoft Visual C/C++ Run-Time delivery channel

Raymond Chen

There's a DLL in the system directory called , and from its name, you might think that it is the Microsoft Visual C/C++ Run-Time library. That is a perfectly reasonable guess. But it would also be wrong. The Microsoft Visual C/C++ Run-Time libraries go by names like or or or , and the debugging versions have a in there, too. And like MFC,...

Code
Apr 10, 2014
Post comments count0
Post likes count1

Why does PrintWindow hate CS_PARENTDC? redux

Raymond Chen

Why does hate ? Because everybody hates ! Commenter kero claims that it's "easy to fix" the problem with and . You just remove the style temporarily, then do the normal , then restore the style. The question is then why simply doesn't do this. The question assumes that the described workaround actually works. It may work in limited situati...

Code
Apr 8, 2014
Post comments count0
Post likes count2

Why is Rundll32 called Rundll32 and not just Rundll?

Raymond Chen

There is an oft-abused program named . Why does its name end in ? Why not just call it ? (I will for the moment ignore the rude behavior of calling people stupid under the guise of asking a question.) Because there needed to be a way to distinguish the 16-bit version from the 32-bit version. Windows 95 had both (the 16-bit version) and (...

History
Apr 7, 2014
Post comments count0
Post likes count1

Using WM_SETREDRAW to speed up adding a lot of elements to a control

Raymond Chen

Today's Little Program shows one way you can implement a better version of . Our first version doesn't use at all. Start with the scratch program and make the following changes: Most of this program was stolen from my scroll bar series. The interesting new bits are that you can add one new item by hitting 1, or you can add ten thousand item...

Code
Apr 4, 2014
Post comments count0
Post likes count1

It's bad enough for a guest to demolish the host's house; demolishing an unrelated person's house is taking it to a whole new level

Raymond Chen

"How do I destroy a window that belongs to another process?" The function will not destroy windows that belong to another thread, much less another process. The best you can do is post a message to the window to ask it nicely. The function response to the message by destroying the window, but the window is free to add a custom handler for th...

Code
Apr 3, 2014
Post comments count0
Post likes count1

Why does the access violation error message put the operation in quotation marks? Is is some sort of euphemism?

Raymond Chen

When an application crashes with an access violation, the error message says something like The instruction at "XX" referenced memory at "YY". The memory could not be "read". Why is the operation in quotation marks? Is this some sort of euphemism? The odd phrasing is a consequence of globalization. The operation name is a verb in the infinitive...

Other
Apr 2, 2014
Post comments count0
Post likes count1

It rather involved being on the other side of this airtight hatchway: Invalid parameters from one security level crashing code at the same security level (again)

Raymond Chen

A few years after I posted this story, the security team received something very similar. If have found that if you call the XYZ function (whose last parameter is supposed to be a pointer to a ) and instead of passing a value pointer to a , you pass , then you can trigger an access violation in the XYZ function. The XYZ function does not check ...

Other
Apr 1, 2014
Post comments count0
Post likes count1

Buggy milk cartons, beeping computers, and other silliness

Raymond Chen

Some time ago, there was a performance-related bug that went something like this: mm/dd/yy Created by bob The attached file contains a dataset that takes a very long time to process. The engineer who fixed the problem decided to take the cryptic approach: mm/dd/yy Resolved as fixed by alice It got better. It was a common practice during hig...

Other