How real-mode Windows loaded code from the disk, and how you could use that...
Real-mode Windows was originally designed to run on a PC with 192KB of RAM and two 360KB floppy drives. We saw some time ago that code was loaded dynamically off the disk on demand. The same principle...
View ArticleExplorer is a single-instance application, but you can find other ways to get...
Explorer is a single-instance application, which means that if you try to elevate it, or if you try to run the 32-bit version on a 64-bit system, you don't actually get an elevated Explorer or a...
View ArticleA brief discussion on how best to respond to the end-session messages
A customer discovered that their application's shutdown code sometimes deadlocked. To address the problem, they moved the bulk of their shutdown code to the WM_ENDSESSION message handler. The...
View ArticleThe gradual erosion of the SEM_NOOPENFILEERRORBOX error mode
The SEM_NOOPENFILEERRORBOX flag has a long history. It goes back to 16-bit Windows and the way modules were loaded from floppy disks. If the loader could not find the file it needed, it prompted...
View ArticleFor sale: One TARDIS, working (lights), you must pick up from Vancouver
Ever wanted a full-size TARDIS that works? Well, at least the the lights work. For sale: TARDIS - FULL SIZE - $2500 (191 Alexander Street, Vancouver, BC, Canada) condition: excellent size /...
View ArticleA survey of the various ways of creating GDI bitmaps with predefined data
Suppose you have a buffer full of pixels and you want to create a GDI bitmap that contains those pixels. We'll start with the CreateBitmap function. This creates a device-dependent bitmap with the...
View ArticleHow do I create a shortcut in the Send To menu that runs a program with a...
To add an item to your Send To menu, create a shortcut in the Send To folder. The easy way to do this is to open an Explorer window and type shell:sendto in the address bar. This will take you...
View ArticleMicrospeak: snap
Today's Microspeak is the word snap, which means "To take a snapshot of the source code," usually for the purpose of producing a build. The build lab snaps at 6pm, so make sure your changes are in by...
View ArticleHow do I programmatically obtain the user’s selected accent color in Windows 10?
If you want to obtain the user's accent color, you can ask the UISettings object for the current color value of UIColorType.Accent. How you get this information depends on what kind of program you're...
View ArticleWhat can I do if I want to throw a C++ exception from my InitOnce callback?
Suppose you want to use the InitOnceExecuteOnce function to perform one-time initialization, but your initialization function might throw a C++ exception. We know that this is not allowed because...
View ArticleIf I have a thread waiting on an event, and I call SetEvent immediately...
A customer had developed a producer-consumer scenario and used a manual-reset event to coordinate the threads. "If there are n threads waiting on an event, is it guaranteed that all n threads will be...
View ArticleWhen I enable page heap, why is my one-byte buffer overrun not detected...
Page Heap is a mode of the heap manager¹ that can be enabled by the Debugging Tools for Windows. When enabled, each memory allocation is placed at the end of a dedicated page, and the page that...
View ArticleThe Windows 8 close gestures, a retrospective
In Windows 8, you can close an app by moving the mouse to the top of the screen until the title bar appears, and then click the X button. But how do you do it if you are on a touch-only device? The...
View ArticleHow do I get the current directory for a non-current drive?
As we learned some time ago, each drive has its own current directory for backward-compatibility with DOS 1.0 (which predates the concept of directories). This is simulated internally by magic...
View ArticleCan memcpy go into an infinite loop? Why is it being blamed for a busy hang?
A customer reported that their program locks up once or twice each day. They took a full dump of the file while it was hung and asked windbg to analyze it. Here's a redacted version of what it said:...
View ArticleHow can I atomically leave a critical section and delete it?
A customer had a thread which has entered a critical section. It has finished whatever it needs to do, and now it wants to leave the critical section and delete it. But wait, there's a race condition...
View ArticleWhy does my __FILE__ macro produce an invalid address, which mysteriously...
A customer couldn't understand what the debugger was showing them. They had a function that used the __FILE__ macro, but the address of the resulting string was reported by the debugger as invalid: //...
View ArticleThat time a customer reported an error in the map used by Flight Simulator
Microsoft Flight Simulator prided itself on its accuracy and realism. One of the things it has to get right are maps, because knowing where you are is kind of important when you're flying a plane....
View ArticleUnder what conditions could a commit of reserved memory fail?
A customer's program reserves a large chunk of address space (VirtualAlloc with MEM_RESERVE) and commits memory into it as necessary (VirtualAlloc with MEM_COMMIT). They received crash reports that...
View ArticleOn generating sentinel pointer values in Windows
Suppose you have a need for sentinel pointer values. Let's say that your function operates on pointers to Widget objects, but you need a few special values that convey special meaning, like "There is...
View Article