Showing archive results for 2014

Aug 22, 2014
Post comments count0
Post likes count1

Dispelling the myths, rumors, and innuendo surrounding the QueryPerformanceCounter function

Raymond Chen

The function has been the subject of much rumor and innuendo. In response to all the confusion, the kernel folks put together a page which tries to settle the controversy once and for all. It discusses the history of QPC over the ages, the problems it had on earlier versions of Windows or older firmware (which is probably where a lot of the myth...

Code
Aug 22, 2014
Post comments count0
Post likes count1

Why does the OpenThread function behave differently when the target thread belongs to another process?

Raymond Chen

A customer discovered strange behavior in the function and wondered whether it was expected. We use the function to obtain a thread handle with , passing in a valid thread ID. We later pass this handle to to get the thread exit code. We have found that the function succeeds if the thread in question belongs to another process, provided the thre...

Code
Aug 21, 2014
Post comments count0
Post likes count1

Some reasons not to do anything scary in your DllMain, part 3

Raymond Chen

In the same week, the shell team was asked to investigate two failures. The first one was a deadlock in Explorer. The participating threads look like this: The shell extension caused this problem because it ignored the rule against calling shell and COM functions from the entry point, as specifically called out in the documentation as example...

Code
Aug 20, 2014
Post comments count0
Post likes count1

If you're looking for the code that displays a particular dialog box, the most directly way to find it is to look for the dialog box

Raymond Chen

Suppose you are working in a large or unfamiliar code base and you want to know where the code is that displays a particular dialog box or message box or something. Probably the most direct way of figuring this out is to look for the strings. Say there is a message box that asks for user confirmation. "Are you sure you want to frobulate the flux c...

Other
Aug 19, 2014
Post comments count0
Post likes count1

My friend and his buddy invented the online shopping cart back in 1994

Raymond Chen

Back in 1994 or so, my friend helped out his buddy who worked as the IT department for a local Seattle company known as Sub Pop Records. Here's what their Web site looked like back then. Oh, and in case you were wondering, when I said that his buddy worked as the IT department, I mean that the IT department consisted of one guy, namely him. And t...

History
Aug 18, 2014
Post comments count0
Post likes count1

News flash: Big houses cost more to maintain

Raymond Chen

In 2005, we learned that big houses cost more to heat. In 2006, we learned that big houses cost more to cool. But then the research into big houses seems to have stalled. No worries. The research journal The Wall Street Journal recently released a paper concluding that big houses cost more to maintain.

Non-ComputerNews flash
Aug 18, 2014
Post comments count0
Post likes count1

Deleting elements from an JavaScript array and closing up the gaps

Raymond Chen

Today's Little Program is an exercise that solves the following problem: Given a JavaScript array and an unsorted array (possibly containing duplicates), calculate the result of deleting all of the elements from the original array as specified by the indices. For example, suppose and . The indices specify that elements 2 (charles), 4 (eve...

Code
Aug 15, 2014
Post comments count0
Post likes count1

The scope of the C# checked/unchecked keyword is static, not dynamic

Raymond Chen

C# has operators and to control the behavior of the language in the face of integer overflow. There are also and statements which apply the behavior to blocks of statements rather than single expressions. Why, then, doesn't this code below raise an overflow exception? (Mini-exercise: Why couldn't I have just written ?) The answer is th...

Code
Aug 14, 2014
Post comments count0
Post likes count1

Customers not getting the widgets they paid for if they click too fast -or- In C#, the += operator is not merely not guaranteed to be atomic, it is guaranteed not to be atomic

Raymond Chen

In the C# language, operation/assignment such as are explicitly not atomic. But you already knew this, at least for properties. Recall that properties are syntactic sugar for method calls. A property declaration is internally converted to the equivalent of Accessing a property is similarly transformed. Note that the only operations you c...

Code
Aug 13, 2014
Post comments count0
Post likes count0

Keep your eye on the code page: C# edition (the mysterious third code page)

Raymond Chen

A customer was having trouble manipulating the console from a C# program: We found that C# can read only ASCII data from the console. If we try to read non-ASCII data, we get garbage. Observe that this program is unable to read the Å and ö characters. They come back as garbage. Although there are three code pages that have spec...

Code