Let's say that we have function A and function B, as shown below :
#include <stdio.h>
#include <stdlib.h>
void a( )
{
printf("Hello from function a!\n");
return;
}
void b( )
{
printf("Hello from function b!\n");
return;
}
int main( )
{
printf( "a = %p, b = %p\n", a, b );
a( );
b( );
return 0;
}
Which in this case gives the output of :
a = 00401334, b = 00401349
Hello from function a!
Hello from function b!
Is there a way to programatically( using C and the winapi ) switch those 2 function calls from an external program to have the call to a( ) print out b's message and b( ) print out a's message with a hook of some type? If so, how would I write such a program, assuming my program is running long enough to switch the functions, and the functions aren't inlined.