http://valinet6l6tq6d5yohaa6gdsf2ho4qcqcxyj2nahp5kd4z7nsa6ycdqd.onion/2021/11/18/Functional-Windows-10-flyouts-on-Windows-11.html
There are plenty of libraries to aid with this, like funchook or Microsoft Detours . I have done it manually as well in the past, the big problem is that in order to automate this, you need a disassembler at runtime: recall that x86 is CISC (instructions length varies).