Skip to content
TopicTracker
From devblogs.microsoft.com/oldnewthingView original
TranslationTranslation

A compatibility note on the abuse of Windows window class extra bytes

The article discusses how some programs misuse Windows window class extra bytes to secretly store data, and provides a compatibility note on this practice.

Background

- Raymond Chen is a veteran Microsoft developer who writes "The Old New Thing" blog, a long-running inside look at Windows design decisions, quirks, and backwards-compatibility challenges. - "Window class extra bytes" (CBWNDEXTRA) is a small, fixed block of memory that Windows allocates per window instance, intended for data that a well-behaved app associates with that window (e.g., storing a pointer or flag). - Some software developers have "abused" this feature by writing unrelated metadata into those bytes — beyond their declared purpose — relying on undocumented behavior that happened to work on older Windows versions. - This post discusses a specific compatibility case: newer Windows builds had to preserve that accidental behavior because existing apps crashed without it, illustrating the immense burden of legacy support that Windows carries.

Related stories

  • A developer found that a DLL was no longer in memory even though it hadn't been formally unloaded, tracing the issue to Windows' DLL load ordering. When a DLL is loaded at a base address that conflicts with another DLL loaded earlier, the system may relocate it and then later discard the relocated version without clear notification, confusing developers expecting explicit unload.