
int binpatch( unsigned char *, unsigned char *,
	      unsigned int, unsigned int );

/* BINPATCH()
 *
 * USAGE:
 *
 * BINPATCH( do_fork, get_pid, my_get_pid );
 *
 * The example replaces all calls made by do_fork() to get_pid() with
 * calls to my_get_pid().
 * 
 */

#define BINPATCH( caller, old_callee, new_callee )          \
	( binpatch( (unsigned char *)(BP_START_ ## caller), \
	            (unsigned char *)(BP_END_ ## caller),   \
	            BP_START_ ## old_callee,                \
	            (unsigned int)(new_callee) ) )


/* BINUNPATCH()
 *
 * USAGE:
 *
 * BINUNPATCH( do_fork, my_get_pid, get_pid );
 *
 * The example reverses the effects of the previous example by
 * replacing all calls made by do_fork() to my_get_pid() with calls
 * to get_pid().
 * 
 */

#define BINUNPATCH( caller, new_callee, old_callee )        \
	( binpatch( (unsigned char *)(BP_START_ ## caller), \
	            (unsigned char *)(BP_END_ ## caller),   \
                    (unsigned int)(new_callee),             \
	            BP_START_ ## old_callee ) )          


/* ORIGINAL()
 *
 * USAGE:
 *
 * int ret_val;
 * int (*orig_get_pid)(unsigned long);
 *
 * orig_get_pid = (int (*)(unsigned long))(ORIGINAL(get_pid));
 *
 * ret_val = orig_get_pid( flags );
 *
 *
 * The example calls the kernel's original get_pid() function.
 *
 */

#define ORIGINAL( fxn ) ( BP_START_ ## fxn )


#endif
