Method hooking
Method hooking is a technique where a method is swapped at runtime with a newly created method. The original swapped out method can still be invoked, but this is not required. This way, the same method call is done by the application; however, another function is executed.
Graphical representation of the approach
Graphical representation of the approach#
public int a() { int x = b(); ... }
public int b() { ... return c; }
public int a() { int x = c; ... }
Denotes the flow of a normal program
In the function body (a) function (b) is called. The variable (c) is defined in the function body (b) and returned to the calling function. The return value of the function call is assigned to variable (x).