Cool solution, but I'd assume/hope Windows currently has sufficient memory protections to not allow applications to rewrite their own memory - especially if the function was already in a DLL to begin with and not JIT-generated code?
https://learn.microsoft.com/en-us/windows/win32/api/processt...
But that's a rare edge case.