The Mystery of the Passive USB-to-PS/2 Mouse Adapter

2025-03-28
The Mystery of the Passive USB-to-PS/2 Mouse Adapter

Early USB mice often included a green adapter to convert the USB Type-A plug to PS/2. This wasn't a smart adapter; it was purely mechanical, with no circuitry. The mouse itself did the conversion, detecting the signal type (USB or PS/2) and adjusting accordingly. It's analogous to a simple power adapter – the intelligence resides in the device, not the adapter. So, if you find one of these, remember it's just a physical connector; the actual conversion happens within the dual-bus mouse.

Read more
Hardware Mouse Adapter

Debugging a Race Condition: The RtlRunOnceExecuteOnce Trap

2025-03-23
Debugging a Race Condition: The RtlRunOnceExecuteOnce Trap

A colleague encountered a tricky concurrency issue during a weekly debug session: a critical section failed to prevent two threads from entering the same code block, leading to a `TraceLoggingRegister` double-registration failure. Deep debugging revealed the root cause: the initialization function `InitializeCriticalSectionOnce` for `RtlRunOnceExecuteOnce` incorrectly returned `STATUS_SUCCESS` (0). This led `RtlRunOnceExecuteOnce` to believe initialization failed, causing it to re-initialize the critical section on every call, triggering the race condition. The solution was to change the return value to `TRUE`, or more elegantly, replace `CRITICAL_SECTION` with `SRWLOCK`. This case highlights how subtle return value errors can lead to severe consequences and underscores the importance of choosing the appropriate synchronization primitive.

Read more
Development

TypeScript Native Compiler: 10x Performance Boost

2025-03-11
TypeScript Native Compiler: 10x Performance Boost

The TypeScript team announced a native port of the TypeScript compiler and tools to dramatically improve performance. This native implementation is projected to drastically speed up editor startup, reduce most build times by 10x, and substantially reduce memory usage. Initial testing shows compilation speed improvements of more than 10x for several large projects (e.g., VS Code, Playwright). Future native TypeScript (planned as TypeScript 7) will support more advanced refactorings, deeper code analysis, and lay the foundation for next-gen AI development tools. TypeScript 6 (JS-based) will continue to be maintained to ensure a smooth transition.

Read more

Subtle C++/WinRT Invoke Issue and its Fix

2025-03-09
Subtle C++/WinRT Invoke Issue and its Fix

A C++/WinRT pull request fixed an ambiguity in `winrt::impl::promise_base::set_completed`'s call to `invoke`, caused by Argument-dependent Lookup (ADL). The upgrade to C++20 coroutines expanded the ADL search space, unexpectedly finding `std::invoke` instead of the intended `winrt::impl::invoke`. The article details the ADL mechanism and provides a patch for older C++/WinRT versions: declaring a better-matching `invoke` function in the `winrt::Windows::Foundation` namespace to guide the compiler. This patch also includes a static assertion to ensure it's automatically removed after upgrading C++/WinRT.

Read more
Development

The 'Other' Trap in Enums: Version Compatibility and Open Enums

2025-03-02
The 'Other' Trap in Enums: Version Compatibility and Open Enums

This article discusses the pitfalls of using an 'Other' value (e.g., WidgetFlavor::Other) in C++ enums. Adding new enum values presents a challenge: how to handle them and maintain compatibility with older code versions. The author suggests avoiding 'Other' altogether and declaring the enum as open-ended, letting programs handle unrecognized values independently. This elegantly solves version compatibility issues, preventing confusion when adding new enum values and ensuring smooth transitions between old and new code.

Read more
Development Version Compatibility

Major Improvements to MSVC Address Sanitizer (ASan)

2025-02-25
Major Improvements to MSVC Address Sanitizer (ASan)

Microsoft has significantly improved the quality of MSVC Address Sanitizer (ASan). They've successfully upstreamed major parts of ASan to LLVM, enabling faster integration of improvements from the LLVM community. Furthermore, they've integrated ASan into the MSVC codebase, including the compiler, linker, and tools, allowing for memory safety issue detection in continuous integration. Visual Studio 2022 version 17.13 includes numerous fixes, reducing false positives, improving error reporting, and handling multi-process scenarios.

Read more
Development

Windows 95 Setup: The Surprisingly Complex Story of a Tiny OS

2025-02-17
Windows 95 Setup: The Surprisingly Complex Story of a Tiny OS

This article reveals the hidden complexity of the Windows 95 setup program. To create a seemingly simple installer, the team had to build a miniature operating system from scratch within MS-DOS, including graphics libraries, a window manager, multilingual support, and even compatibility with Windows 3.1. They ultimately realized it was far more efficient to use the existing Windows 3.1 runtime, avoiding massive development efforts. The story highlights the importance of code reuse in software engineering and exposes the surprisingly complex nature of the Windows 95 setup program.

Read more
Development

The 'It's Now Safe to Turn Off Your Computer' Screen: A Windows 95 Nostalgia Trip

2025-02-16
The 'It's Now Safe to Turn Off Your Computer' Screen: A Windows 95 Nostalgia Trip

Remember the 'It's now safe to turn off your computer' message in Windows 95? This story recounts a humorous anecdote on an airplane where a fellow passenger repeatedly restarted their laptop after seeing the 'Windows has been shut down' screen, not realizing they needed to manually power off the machine. This highlights the lack of power management in older computers and explains why Windows 95 included the message: a gentle reassurance that it was safe to press the power button.

Read more
Tech

USB Spec Meeting Anecdote: The Premium of Translucent Blue

2025-02-10
USB Spec Meeting Anecdote: The Premium of Translucent Blue

At a USB specification meeting, a company showcased their USB floppy drives, surprisingly offering separate versions for PCs and Macs. Committee members were puzzled, as the specification ensured the same drive worked on both systems. The representative explained that the drives were electronically identical; the only difference was the Mac version came in translucent blue plastic and cost more. This reflected the then-popular translucent plastic trend of iMacs and highlighted how some manufacturers leveraged design differences for price premiums.

Read more
Hardware floppy drive

Missile Software's 'Null Garbage Collector': Memory Leaks? Not a Problem!

2025-02-07
Missile Software's 'Null Garbage Collector': Memory Leaks?  Not a Problem!

A developer recounts a clever application of a 'null garbage collector' in missile software. Because of the limited flight time and ample hardware memory, memory leaks in the program weren't a concern. Engineers calculated the potential memory leakage during flight and added double that amount of memory to ensure the program wouldn't crash before mission completion. This approach cleverly leveraged the program's runtime constraints, effectively solving the memory leak issue—a kind of 'ultimate garbage collection'.

Read more

Go 1.24 Cryptography Overhaul: Achieving FIPS 140-3 Compliance

2025-02-06

Go 1.24 significantly refactored its cryptography packages to achieve FIPS 140-3 compliance. This is a major step forward, featuring a pure Go (and Go assembly) implementation of a FIPS 140-3 validated cryptographic module, eliminating reliance on cgo or syscalls. Microsoft Go 1.24 also updated, adding macOS preview support and enhanced Azure Linux support, but maintains its use of system libraries for cryptography, diverging from the official Go approach. New environment variables like GODEBUG=fips140=on and GOFIPS140=latest control FIPS mode; the runtime automatically enables it on FIPS-compliant systems (Azure Linux, Windows).

Read more
Development

A Hidden Teapot and Design Flaw in Windows' 3D Pipes Screensaver

2024-12-28
A Hidden Teapot and Design Flaw in Windows' 3D Pipes Screensaver

The beloved Windows 3D Pipes screensaver, known for its mesmerizing pipe animations, hides a little-known secret: a rarely appearing teapot. This teapot is a tribute to the Utah teapot, a standard reference object in computer graphics, but its incredibly low appearance rate led to user complaints about low productivity. The article also reveals that in older Windows versions, the screensaver caused high CPU usage on servers due to software rendering, recommending a black screen saver for servers instead.

Read more

C++ Compiler Errors: Nonsensical Errors from a Function Declaration

2024-12-12
C++ Compiler Errors: Nonsensical Errors from a Function Declaration

A developer adding XAML support to a C++ application encountered a series of compiler errors simply by including the winrt/Windows.UI.Xaml.h header file. The errors stemmed from what appeared to be a normal function declaration: `template struct consume_Windows_UI_Xaml_IExceptionRoutedEventArgs { [[nodiscard]] auto ErrorMessage() const; };` The root cause was a pre-existing macro named ErrorMessage in the developer's project, conflicting with the function name. This macro created an ErrorMessageString object and returned a pointer to an error message string. The macro's lack of boundaries caused the compiler to misinterpret the function declaration as a macro invocation, resulting in errors like "not enough arguments." The solution involved disabling the macro using #pragma undef before including the header or removing the macro entirely and replacing it with an inline function.

Read more