Gotchas when using linker sections to arrange data, part 1
We saw last time that you can use linker sections to arrange the order in which data appears in the module. We ended with a diagram like this: mydata$a firstInitializer main.obj mydata$g DoThisSooner3...
View ArticleGotchas when using linker sections to arrange data, part 2
We saw last time that you need to accommodate potential padding between fragments within a section when walking through an array of pointers. Fortunately, it's a simple matter of skipping over null...
View ArticleThe case of the System process that consumed a lot of CPU
A report came in through Feedback Hub that the System process was consuming high CPU. I was able to explain to the customer how to include a performance trace so the problem could be diagnosed. In...
View ArticleSaying good-bye to the original Microsoft Redmond campus
The end is near for the original Microsoft Redmond campus. The nine buildings that formed the original campus are slated for demolition to make way for a new campus redesign. The buildings are making...
View ArticleWhat’s the point of passing a never-signaled event to MsgWaitForMultipleObjects?
In the Quake source code, there is this variable tevent whose usage is rather strange. 49 static HANDLE tevent; It is initialized at program startup to a newly-created unsignaled event. 660 tevent...
View ArticleHow do I revert a control back to its default theme?
A customer disabled visual styles for their control so that they could do custom rendering, but when the system switches to high contrast mode, they want to abandon their customizations and revert to...
View ArticleSongs with every other beat removed, how to make your own!
YouTube channel EveryOtherBeat takes popular songs and removes every other beat. So does the Tumblr EverySecondBeat. Here's how you can create your own: Go to The Infinite Jukebox. The original...
View ArticleClosing the race window between creating a suspended process and putting it...
A customer had a test harness that spawns a very large number of processes. To make sure everything gets cleaned up if the test harness closes unexpectedly, they start the process suspended, then...
View ArticleThe Moncler 1 Pierpaolo Piccioli, your high fashion for the elegant parties...
Behold, the latest in high fashion. The Moncler 1 Pierpaolo Piccioli down-quilted long buffer dress. It could be yours for only $2700. Add the cape for only $3565. I like how the white one is in the...
View ArticleHow do I suppress the “Did you mean to switch apps?” warning message from my...
A customer had an application that used a UWP XAML WebView control. There are some points at which the user can click an element in the hosted HTML which triggers the main app to navigate to another...
View ArticleFor a brief period, the kernel tried to deal with gamma rays corrupting the...
At one point, the following code was added to the part of the kernel that brings the system out of a low-power state: ; ; Invalidate the processor cache so that any stray gamma ; rays (I'm serious)...
View ArticleTrying to allocate the same virtual address in multiple processes
A customer wanted to know if it is possible to allocate shared memory at the same virtual address in multiple processes. The short answer is that you can try to map a shared memory block at a specific...
View ArticleHow can I make a dialog box right-to-left at runtime?
A customer had a program that decided at runtime what language to use for its user interface. The customer was having trouble getting the program's dialog boxes to show up with right-to-left layout...
View ArticleThe default number of threads in an I/O completion port is the number of...
The CreateIoCompletionPort function lets you specify how many concurrent threads can be processing work from the completion port. But if you pass a value of 0 for NumberOfConcurrentThreads, "the...
View ArticleIf activation of your gift card lasts more than four hours, consult a...
I received a gift card. The instructions which accompany the gift card include the following: To activate, sign the back of the card. In some cases, activation may take up to four hours. What, you...
View ArticleWhat’s up with Code Analysis rule CA2202: Do not dispose objects multiple times?
You thought you'd be able to make it through the entire year without suffering through a CLR Week. And you almost made it. But here it is. Ha ha. There's no theme for this week; it's just a collection...
View ArticleNifty trick: Combining constructor with collection initializer
C# provides a number of ways of initializing collections. If a collection has a single-parameter Add method, you can add items into the collection as part of initialization: var list = new...
View ArticleWhat happens if I mutate a string in a p/invoke?
When it comes time to p/invoke to a Win32 function that writes to a string buffer, everybody uses a StringBuilder class to receive the string. But could we just use a string? I mean, we can still...
View ArticleTaking advantage of the ordering guarantees of the LINQ GroupBy method
A customer wanted to group a set of data by one field, and within each group, sort the data by another field, and then sort the groups by that second field. For example, given the following data set:...
View ArticleWhy does Clipboard.SetData put extra junk in the clipboard data? And how can...
One of the ways of putting data on the clipboard is with the System.Windows.Forms.Clipboard object. There are methods for putting text on the clipboard in one of a few the standard text formats. And...
View Article