This thread about runtime modification touches on how to do it and why things are the way they are.
It was pretty trivial to get working, though I wasn’t concerned about hot-swapping when I followed this recently, so I got to bypass most of the issues.