From 6fb756e388e12720576e94c28a0b6543622d4518 Mon Sep 17 00:00:00 2001 From: Yifan Lu Date: Tue, 18 Oct 2016 22:24:17 -0700 Subject: Added execmem foreign write for Vita --- lib/vita/execmem.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 #include +#include #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; } -- cgit v1.2.3