Windows hot-patching is a one-lane road, and rogue patchers cause a pileup

If somebody tries to hot-patch an already-hot-patched function

Raymond Chen explains that Windows hot-patching is designed for Windows Update alone, so if a function is already hot-patched by someone else, the system treats it as rogue patching and declares the file not hot-patchable, forcing a reboot. A race condition can leave a binary half-patched with no reliable rollback, like parking in a fire zone.

An application that uses the hot-patching space is parking in a fire zone. Everything seems to be fine until the fire truck shows up, and then somebody's house burns to the ground because the fire truck can't get there.
  1. drdexebtjl

    Interesting framing that hooking functions is considered “rogue” by Microsoft, or something you’re “not authorized” to do, when Microsoft themselves makes the detours library and never framed it like this before.

    Also, missing from this explanation: hooks are usually applied per process, from user space. The code pages in a dynamic library are CoW’d from the shared page when you write to them to apply a patch.

    Does the Windows Update work similarly, or does it somehow modify the original, shared page, affecting all processes? Does a hook in a single process disable hot patching on the entire system?

  2. jonhohle

    At a previous job I wrote a docker build for patching individual Java class files on top of a monolithic docker image. This was not runtime patching, but allowed a single layer that was only a few kilobytes to be deployed quickly in emergency situations.

    Interestingly, it had similar constraints and checked them at build time: it could not be a public ABI change and only one patch at a time.

  3. high_na_euv

    >There is a race condition: The prescan may show that all the functions are safe to patch, but then somebody might patch a function after the prescan completes. In that case, the patcher will get halfway through and then discover the rogue-patched function, and now it’s kind of stuck. It can’t continue forward, and it can’t reliably roll back (because the rollback is probably also going to fail because the patch got overpatched). You’re stuck with a binary in memory that is half-patched, and who knows what’ll happen now.

    Ehh :) scenarios like this are the best

  4. fsfod

    Windows parallel DLL loading also defensively disables itself for a process if it finds some NT DLL functions have been hooked https://stackoverflow.com/questions/42789199/why-there-are-t...

  5. dataflow

    If your hotpatching library is competent, then it does everything atomically. Either by suspending all threads first and temporarily resuming them while they're executing any affected instructions, or by just using atomics when possible.

    In which case there is no race condition.

More from this day

2026-10-07