void hotfixer(void *caller, void *callee, void *new_func) { /* * Get the true address of the callee */ callee -= 8; // XXX: Validate this! // Should be equal to pop eax+call /* * Check various call instructions */ if(*((void **) ((char *) caller) - 4) == callee) { /* * Patch new function into place */ *((void **) ((char *) caller) - 4) = new_func; } }