I can only speak from writing interrupt service routines in assembly code back in school, but I remember running into problems from not storing values in certain registers and restoring them after I was done. Also, you have to make sure to call the proper handler from your own handler so as not to break the chain. For instance, if A() calls B(), but your method X() replaces A(), and DOESN'T call B(), well then the system is broken. I assume your code is just a hook and not meant to replace the existing code. To make things work as planned, I would imagine you want your method X() to call A() so that it can in turn call B() and keep the cycle going.
Dunno if any of that helped, but I'm trying to answer what few posts I may be vaguely helpful with