The Old New Thing

How to view the stack of a user-mode thread when its kernel stack has been paged out

Suppose you have a machine that has crashed, and your investigation shows that the reason is that there is a critical section that everybody is waiting for. While waiting for that critical section, work piles up, and eventually the machine keels over. Suppose further that this crash is given to you in the form of a kernel debugger. In case ...

When does GetTickCount consider the system to have started?

The Get­Tick­Count and Get­Tick­Count­64 functions return "the number of milliseconds that have elapsed since the system was started." (The 32-bit version wraps around after around 50 days.) But when exactly is the system considered to have started? Is it when power is applied to the computer? When the BIOS completes POST? ...
Comments are closed.0 0
Code

How can I wait until all startup applications have finished launching?

A customer wanted to know how to detect that all startup applications have finished launching. They wanted to wait until everything settled down before proceeding with some task. What if two programs did this? Suppose two programs both wanted to detect that all startup applications have finished launching. Each one would sit there waiting ...
Comments are closed.0 0
Code

A little cheat in my Tiger Beat photo homage

One thing nobody has called out in my tribute to the Bill Gates Tiger Beat photo, either because it was too subtle or too obvious, is that the photo is actually a mirror image. The arrangement of furniture in the room was not correct: The big table was on the wrong side of the room. It was also too heavy to move around, so we cheated. We ...

Kicking around a function that formats stuff

Today's "Little Program" is really a "Little Puzzle" that got out of hand. This started out as a practical question: This code fragment screams out for some sort of simplification. (I've changed the names of the classes.) Clearly, the pattern is Everything here is pretty straightforward, except for the string.Format part. Can we write...
Comments are closed.0 0
Code

Why does an attempt to create a SysLink control in my plug-in sometimes fail?

A customer had written a plug-in for some application, and they found that their plug-in was unable to create a SysLink control via the Create­Window­ExW function. The same code in a standalone application works fine, but when the code is placed in their plug-in, the code fails. Debugging showed that the call to Init­Common­...
Comments are closed.0 0
Code

How do I get a handle to the primary monitor?

There are various ways of getting a monitor. You can get the monitor from a point, from a rectangle, or from a window. But how do you get the primary monitor? The primary monitor is defined to be the one which has (0, 0) as its origin. Therefore, one solution is The desktop window by convention is deemed to reside primarily on the ...
Comments are closed.0 0
Code

Passing the incorrect object type for a handle, how bad is it?

A customer asked a somewhat strange question: "We are calling Set­Event but passing the handle to a waitable timer. Application Verifier reports, "Incorrect object type for handle." But the code works well. We want to know the risks of passing the wrong object type to Set­Event. Is the recommendation only to pass handles of type "Event...
Comments are closed.0 0
Code

Microspeak: Line of sight

I first encountered this term in a meeting I attended. Q: We would like to be able to reverse the polarity of the neutron flow without requiring a reboot. A: Yes, that is something we've been thinking about, but we don't have line of sight to having that feature before the end of the month. From context, having line of sight to a result...

Feedback usabilla icon