← Back to context

Comment by jasomill

5 hours ago

The Microsoft Detours[1] library does this for arbitrary Windows API calls. I've used it production to fix simple bugs in third-party software no longer supported by vendors.

For example, I have a program that opens Adobe Acrobat Reader as an out-of-process COM server, but tends to leave phantom Acrobat processes hanging around after it quits. To fix this, I wrap CreateProcess in a function that adds any Acrobat processes created to a job object[2] set up to make Windows automatically kill them when the application closes.

[1] https://github.com/microsoft/detours

[2] https://learn.microsoft.com/en-us/windows/win32/procthread/j...