aboutsummaryrefslogtreecommitdiff
path: root/lib/substitute.h
diff options
context:
space:
mode:
authorYifan Lu2016-10-09 13:28:28 -0700
committerYifan Lu2016-10-09 13:29:59 -0700
commit1a804fae87a6d952f6c62c6d9151cbf6b77c2dc9 (patch)
tree9bce4076addc4d5ac502730e3da448dca8d9ee0d /lib/substitute.h
parentSlab allocation mirroring for Vita (diff)
downloadsubstitute-1a804fae87a6d952f6c62c6d9151cbf6b77c2dc9.tar.gz
Added basic hook removal support
Diffstat (limited to 'lib/substitute.h')
-rw-r--r--lib/substitute.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/substitute.h b/lib/substitute.h
index 4e4f7f9..224fd04 100644
--- a/lib/substitute.h
+++ b/lib/substitute.h
@@ -104,6 +104,16 @@ struct substitute_function_hook {
void *opt;
};
+struct substitute_function_hook_record {
+ /* Function that was originally hooked. */
+ void *function;
+ /** Should at least be MAX_JUMP_PATCH_SIZE for your platform */
+ size_t buffer_size;
+ /** Store the original code. Must be large enough to hold MAX_JUMP_PATCH_SIZE
+ * for whatever platform your are targeting! */
+ char saved_buffer[];
+};
+
/* substitute_hook_functions options */
#ifndef NO_PTHREADS
enum {
@@ -149,16 +159,26 @@ enum {
* @hooks see struct substitute_function_hook
* @nhooks number of hooks
* @recordp if non-NULL, on success receives a pointer that can be used to
- * cleanly undo the hooks; currently unimplemented, so pass NULL
+ * cleanly undo the hooks
* @options options - see above
* @return SUBSTITUTE_OK, or any of most of the SUBSTITUTE_ERR_*
*/
-struct substitute_function_hook_record;
int substitute_hook_functions(const struct substitute_function_hook *hooks,
size_t nhooks,
struct substitute_function_hook_record **recordp,
int options);
+/**
+ * @brief Frees hooks and restores original code.
+ *
+ * @param records from `substitute_hook_functions`
+ * @param[in] nhooks Number of hooks to free
+ *
+ * @return SUBSTITUTE_OK, or any of most of the SUBSTITUTE_ERR_*
+ */
+int substitute_free_hooks(struct substitute_function_hook_record *records,
+ size_t nhooks);
+
#ifndef NO_DYNAMIC_LINKER_STUFF /* declare dynamic linker-related stuff? */
#ifdef __APPLE__