aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Lu2016-10-18 22:24:17 -0700
committerYifan Lu2016-10-18 22:24:17 -0700
commit6fb756e388e12720576e94c28a0b6543622d4518 (patch)
tree422c46efb6ad3789f836915a1c04b20ccd4f374e
parentAdded exemem for Vita (diff)
downloadsubstitute-6fb756e388e12720576e94c28a0b6543622d4518.tar.gz
Added execmem foreign write for Vita
-rw-r--r--lib/vita/execmem.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/vita/execmem.c b/lib/vita/execmem.c
index 1b37269..08eb923 100644
--- a/lib/vita/execmem.c
+++ b/lib/vita/execmem.c
@@ -2,7 +2,9 @@
#include "dis.h"
#include "execmem.h"
#include stringify(TARGET_DIR/jump-patch.h)
+#include <psp2kern/kernel/cpu.h>
#include <psp2kern/kernel/sysmem.h>
+#include <psp2kern/kernel/threadmgr.h>
#include "../../../slab.h"
#include "../../../taihen_internal.h"
@@ -117,5 +119,18 @@ int execmem_foreign_write_with_pc_patch(struct execmem_foreign_write *writes,
size_t nwrites,
UNUSED execmem_pc_patch_callback callback,
UNUSED void *callback_ctx) {
- return 0;
+ for (int i = 0; i < nwrites; i++) {
+ struct slab_chain *slab = (struct slab_chain *)writes[i].opt;
+ SceUID pid = slab->pid;
+ if (pid == SHARED_PID) {
+ pid = sceKernelGetProcessId();
+ }
+ if (pid == KERNEL_PID) {
+ sceKernelCpuUnrestrictedMemcpy(writes[i].dst, writes[i].src, writes[i].len);
+ } else {
+ sceKernelRxMemcpyKernelToUserForPid(pid, (uintptr_t)writes[i].dst, writes[i].src, writes[i].len);
+ }
+ sceKernelCpuIcacheAndL2Flush(writes[i].dst, writes[i].len);
+ }
+ return SUBSTITUTE_OK;
}