Вход на сайт

Просмотр новости

Найдите то, что Вас интересует

If somebody tries to hot-patch an already-hot-patched function, how do they avoid conflicts?

Дата публикации: 05-10-2026 14:00:00

Hot-patching is for Windows, not for you.
The post If somebody tries to hot-patch an already-hot-patched function, how do they avoid conflicts? appeared first on The Old New Thing.


Основное содержимое страницы с новостью.

For the past few days, I did a quick survey of hot-patching mechanisms. But the hot-patch design accommodates only one hot-patcher. If somebody goes to hot-patch a function and finds that it’s already been hot-patched, what happens?

If somebody goes to hot-patch a function and finds that it’s already been hot-patched, then something has gone wrong.

The intended audience of hot-patching is Windows Update on systems that support hot-patching (as of this writing, Windows Server and more recently Windows 11 Enterprise, as far as I can tell). The idea is that when a Windows Update arrives, and the administrator has opted into hot-patching, and a file in the update is marked as “safe for hot-patching”,¹ then Windows Update will use the space reserved for hot-patching to replace the affected functions on the fly.

Since the only code authorized to use the hot-patch space is Windows Update, the system doesn’t have to deal with the case that the function has already been hot-patched by somebody else. There is no other code authorized to be somebody else!

But what if the function has been detoured or otherwise patched by somebody not authorized to do so?

My reading of the hot-patching code suggests that if the hot-patch code detects rogue patching, it declares the file to be not hot-patchable, and the system will have to reboot. (This tends to make customers unhappy.)

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.

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.

Related reading: Application compatibility layers are there for the customer, not for the program.

¹ Not all changes are safe for hot-patching, For example, if it changes a data structure’s layout or invariants, it isn’t hot-patchable because any instances of the data structure that were created before the hot-patch will not be in a legal state after the hot-patch.

Author

Raymond Chen

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

Схожие новости

#Наименование новостиТональностьИнформативностьДата публикации
1Windows on AArch64 also provides for hot-patching, but it’s much simpler than on x86012.7730-09-2026
2Windows on Itanium also provided for hot-patching, in an even simpler way010.201-10-2026
3Why is there no Windows hot-patching support for other architectures like 32-bit ARM and MIPS?09.0602-10-2026
4No, really, you need to pass all unhandled messages to DefWindowProc, part 205.8424-09-2026
5Debugging walkthrough: Access violation on nonsense instruction, episode 307.8925-09-2026
6As a general rule, calling product support while drunk is not recommended04.5629-09-2026
7Why does the compiler sometimes use ud2 and sometimes int 3 for code that shouldn’t execute?07.706-10-2026
8How can undefined opcodes ud0 and ud1 have parameters? How undefined were they?08.607-10-2026
9C++ reminder: Function-local static variables are initialized only once, even if it looks like they get initialized multiple times05.9228-09-2026
10Windows 11 fixes buggy DLL file that lead to crashes on new insider build014.9607-10-2026

Классификация: . Схожих патентов: 0. Схожих новостей: 10. Тональность: 0. Информативность: 12.97. Источник: blogs.msdn.microsoft.com.