aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Lu2016-10-05 22:27:32 -0700
committerYifan Lu2016-10-05 22:27:32 -0700
commitd2971bb2511a96061467cc2276fdeae6b2bbd5e0 (patch)
treee3a5082788e605c667d3fdaf96620156793602a5
parentAdded option to removed pthread dependency (diff)
downloadsubstitute-d2971bb2511a96061467cc2276fdeae6b2bbd5e0.tar.gz
Fixed missing trampoline_size_left decrement for making initial trampoline jump
Added comment about min exec page size requirement
-rw-r--r--lib/hook-functions.c4
-rw-r--r--lib/vita/execmem.c21
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/hook-functions.c b/lib/hook-functions.c
index 8363567..5f71229 100644
--- a/lib/hook-functions.c
+++ b/lib/hook-functions.c
@@ -195,6 +195,7 @@ int substitute_hook_functions(const struct substitute_function_hook *hooks,
initial_target = (uintptr_t) trampoline_ptr;
make_jump_patch(&trampoline_ptr, (uintptr_t) trampoline_ptr,
(uintptr_t) hook->replacement, arch);
+ trampoline_size_left -= patch_size;
} else {
initial_target = (uintptr_t) hook->replacement;
}
@@ -211,6 +212,9 @@ int substitute_hook_functions(const struct substitute_function_hook *hooks,
if ((ret = execmem_alloc_unsealed(0, &trampoline_ptr,
&trampoline_size_left)))
goto end;
+ /* NOTE: We assume that each page is large enough (min 0x1000)
+ * so we don't lose a reference by having one hook allocate two
+ * pages. */
hi->trampoline_page = trampoline_ptr;
}
diff --git a/lib/vita/execmem.c b/lib/vita/execmem.c
new file mode 100644
index 0000000..4667752
--- /dev/null
+++ b/lib/vita/execmem.c
@@ -0,0 +1,21 @@
+#include <psp2kern/kernel/sysmem.h>
+#include "execmem.h"
+#include "substitute.h"
+
+int execmem_alloc_unsealed(uintptr_t hint, void **page_p, size_t *size_p) {
+ return 0;
+}
+
+int execmem_seal(void *page) {
+ return SUBSTITUTE_OK;
+}
+
+void execmem_free(void *page) {
+}
+
+int execmem_foreign_write_with_pc_patch(struct execmem_foreign_write *writes,
+ size_t nwrites,
+ execmem_pc_patch_callback callback,
+ void *callback_ctx) {
+ return 0;
+}