The guide to trading candy

Important information to know this evening.


If there is no 16-bit emulation layer in 64-bit Windows, how come certain 16-bit installers are allowed to run?

Troy Martin is puzzled by the remark in this knowledge base article that says No 16-bit code can run, except for recognized InstallShield and Acme installers (these are hard-coded in Wow64 to allow them to work). I agree that the sentence is rather confusingly written. It says “No 16-bit code can run, except for this…


Distinguishing between asking for help with a product and asking for help with a product’s installation

Internally at Microsoft, we have a programmer’s tool which I will call Program Q. On the peer-to-peer mailing list for Program Q, somebody asked the following question: What’s the best way to look at all tables created in the past week? I want to repeat this command across multiple table repositories. Somebody chimed in with the answer….


Help me optimize this code which enumerates all possible GUIDs

Hi, I’m looking for help optimizing this code. It creates a file containing every possible GUID. class Program { public static void Main(string[] args) { using (var w = new System.IO.StreamWriter(“all_guids.txt”)) { for (long l1 = 0; l1 <= 0xFFFFFFFFL; l1++) for (long l2 = 0; l2 <= 0xFFFFFFFFL; l2++) for (long l3 = 0;…


The financial acumen of sea turtles

I dreamed that I was attending some sort of “how to be awesome” seminar where the presenter said, among other things, that a sea turtle, when left to thrive undisturbed, amasses $1 million in personal wealth within one year.


Using GetLogicalProcessorInformationEx to see the relationship between logical and physical processors

Today’s Little Program uses the Get­Logical­Processor­Information­Ex function to print the mapping of logical processors to physical processors, as well as the mapping of logical processors to packages. (A dual-core processor is a single package with two cores. If those cores are themselves dual-hyperthreaded, then you have four logical processors total.) #define STRICT #include <windows.h> #include…


My, those threads start up really fast nowadays

Here’s a little puzzle inspired by an actual bug: // global variable DWORD g_WorkerThreadId; bool IsRunningOnWorkerThread() { return GetCurrentThreadId() == g_WorkerThreadId; } bool LaunchWorkerThread() { HANDLE hThread = CreateThread(nullptr, 0, WorkerThread, nullptr, 0, &g_WorkerThreadId); if (hThread != nullptr) { CloseHandle(hThread); return true; } return false; } DWORD CALLBACK WorkerThread(void *Proc) { // Can this assertion…


When should I use the FIND_FIRST_EX_LARGE_FETCH flag to FindFirstFileEx?

Windows 7 introduces a new flag to the Find­First­File­Ex function called FIND_FIRST_EX_LARGE_FETCH. The documentation says that it “uses a larger buffer for directory queries, which can increase performance of the find operation.” This is classic MSDN-style normative documentation: It provides “just the facts”. Far be it for MSDN to tell you how to write your application;…


It rather involved being on the other side of this airtight hatchway: Planting DLLs into directories on the PATH for applications whose current directory is always System32

A bunch of security vulnerability reports came in from the same person, all of the form, “Program X is vulnerable to DLL planting if you create a DLL with the name Y in a directory on the PATH,” with varying values of X and Y. In all the cases, Program X runs as SYSTEM with…


The hierarchy of user education, as interpreted by a vice president

One of my colleagues told me a story from his days on the Windows team. He had to give a presentation to his vice president on his feature, and he prepared his presentation and demo obsessively to make sure it went smoothly. At the meeting, there were three presentations on the schedule, all of them…