The evolution of window and class extra bytes in Windows
The blog post discusses how window and class extra bytes in Windows evolved, with their intended usage encoded in the naming prefix.
Background
- Raymond Chen is a veteran Microsoft developer who blogs at "The Old New Thing" about Windows history and internals. His posts often assume deep knowledge of Win32 programming.
- "Window extra bytes" and "class extra bytes" refer to small chunks of memory that old-school Windows programmers could reserve when registering a window class (a template for creating windows). These bytes let you store per-window or per-class custom data without creating your own data structures — a trick from the 16-bit era when memory was tight and C++ wasn't yet the norm.
- The "prefix" mentioned is the naming convention used for these byte offsets (e.g., `cbWindowExtra` vs. `cbClassExtra`), which signals whether the extra bytes belong to each individual window instance (window extra) or are shared across all windows of that class (class extra).
- This matters because it's a piece of Windows archaeology: understanding how developers worked around the lack of proper per-window data storage before `SetWindowLongPtr` / `GWLP_USERDATA` and modern C++ object-oriented approaches became standard.