diff options
-rw-r--r-- | psxscl.local.patch | 13 | ||||
-rw-r--r-- | psxscl.local@lucio-vm.local.patch | 202 |
2 files changed, 0 insertions, 215 deletions
diff --git a/psxscl.local.patch b/psxscl.local.patch index 1b3b9c02..f41d39c0 100644 --- a/psxscl.local.patch +++ b/psxscl.local.patch @@ -122,16 +122,3 @@ index 2bd615c..705e646 100644 if ((status = __iovtbl[path_info->fdtypeat].close(path_info->hat))) return status; -diff --git a/src/process/_execve.c b/src/process/_execve.c -index a623d2a..80dd4a9 100644 ---- a/src/process/_execve.c -+++ b/src/process/_execve.c -@@ -232,7 +232,7 @@ intptr_t __sys_execve(const unsigned char * path, const char ** argv, const char - NT_SECTION_QUERY|NT_SECTION_MAP_EXECUTE, - &oa,&ssize, - NT_PAGE_EXECUTE, -- NT_SEC_IMAGE, -+ NT_SEC_RESERVE, - image->info.hfile))) - return __execve_return(tlca,0,target,-ENOEXEC); - diff --git a/psxscl.local@lucio-vm.local.patch b/psxscl.local@lucio-vm.local.patch deleted file mode 100644 index 1ef8615c..00000000 --- a/psxscl.local@lucio-vm.local.patch +++ /dev/null @@ -1,202 +0,0 @@ -diff --git a/src/init/psx_init_cwd.c b/src/init/psx_init_cwd.c -index 924b1b8..02846ba 100644 ---- a/src/init/psx_init_cwd.c -+++ b/src/init/psx_init_cwd.c -@@ -17,7 +17,7 @@ - #ifndef __PSX_DEFAULT_ROOT_DIRECTORY - #define __PSX_DEFAULT_ROOT_DIRECTORY { \ - '\\','?','?','\\', \ -- 'C',':','\\','m','i','d','i','p','i','x'} -+ 'Z',':','\\'} - #endif - - int32_t __psx_init_cwd(void) -diff --git a/project/common.mk b/project/common.mk -index 4390578..fa6df57 100644 ---- a/project/common.mk -+++ b/project/common.mk -@@ -102,6 +102,7 @@ COMMON_SRCS = \ - src/kernel/_systime.c \ - src/kernel/_uname.c \ - src/mman/_mmap.c \ -+ src/mman/_mprotect.c \ - src/mman/_mremap.c \ - src/mman/_munmap.c \ - src/mount/_mount.c \ -diff --git a/src/init/psx_dev_wip.c b/src/init/psx_dev_wip.c -index fe319bc..3915590 100644 ---- a/src/init/psx_dev_wip.c -+++ b/src/init/psx_dev_wip.c -@@ -89,6 +89,7 @@ static void __populate_syscall_vtbl(void) - - /* mman */ - set_syscall_pointer(mmap); -+ set_syscall_pointer(mprotect); - set_syscall_pointer(mremap); - set_syscall_pointer(munmap); - -@@ -263,6 +264,7 @@ static void __populate_strace_vtbl(void) - - /* mman */ - set_strace_pointer(mmap); -+ set_strace_pointer(mprotect); - set_strace_pointer(mremap); - set_strace_pointer(munmap); - -diff --git a/src/internal/psx.h b/src/internal/psx.h -index 1791bda..21efa46 100644 ---- a/src/internal/psx.h -+++ b/src/internal/psx.h -@@ -97,6 +97,7 @@ typedef intptr_t __sys_routine(uname)(struct __utsname *); - - /* mman */ - typedef void * __sys_routine(mmap)(void * addr, size_t length, int prot, int flags, int,off_t offset); -+typedef intptr_t __sys_routine(mprotect)(void * addr, size_t length, int prot); - typedef void * __sys_routine(mremap)(void * mapaddr, size_t mapsize, size_t newsize, int flags); - typedef intptr_t __sys_routine(munmap)(void * addr, size_t length); - -@@ -270,6 +271,7 @@ __sys_interface(uname); - - /* mman */ - __sys_interface(mmap); -+__sys_interface(mprotect); - __sys_interface(mremap); - __sys_interface(munmap); - -diff --git a/src/internal/psx_strace.c b/src/internal/psx_strace.c -index 6d39093..45e7ecd 100644 ---- a/src/internal/psx_strace.c -+++ b/src/internal/psx_strace.c -@@ -859,6 +859,22 @@ void * __strace_mmap(void * addr,size_t length,int prot,int flags,int fd,off_t o - - } - -+intptr_t __strace_mprotect(void * addr,size_t length,int prot) -+{ -+ struct __strace_params params = { -+ __STRACE_MPROTECT,3, -+ {__STRACE_SINTEGER,0}, -+ {{__STRACE_POINTER,(intptr_t)addr}, -+ {__STRACE_SINTEGER,length}, -+ {__STRACE_SINTEGER,prot}}}; -+ -+ if (!addr) params.params[0].type = __STRACE_SINTEGER; -+ params.ret.value = (intptr_t)__sys_mprotect(addr,length,prot); -+ __strace(¶ms); -+ return (void *)params.ret.value; -+ -+} -+ - void * __strace_mremap(void * mapaddr, size_t mapsize, size_t newsize, int flags) - { - struct __strace_params params = { -diff --git a/src/internal/psx_strace.h b/src/internal/psx_strace.h -index 67eecce..293cfdf 100644 ---- a/src/internal/psx_strace.h -+++ b/src/internal/psx_strace.h -@@ -60,6 +60,7 @@ enum __strace_sysids { - __STRACE_SYSINFO, - __STRACE_UNAME, - __STRACE_MMAP, -+ __STRACE_MPROTECT, - __STRACE_MREMAP, - __STRACE_MUNMAP, - __STRACE_MOUNT, -@@ -197,6 +198,7 @@ enum __strace_sysids { - "sysinfo", \ - "uname", \ - "mmap", \ -+ "mprotect", \ - "mremap", \ - "munmap", \ - "mount", \ -@@ -346,6 +348,7 @@ __strace_interface(uname); - - /* mman */ - __strace_interface(mmap); -+__strace_interface(mprotect); - __strace_interface(mremap); - __strace_interface(munmap); - -diff --git a/src/mman/_mmap.c b/src/mman/_mmap.c -index 13762e3..27ea942 100644 ---- a/src/mman/_mmap.c -+++ b/src/mman/_mmap.c -@@ -95,7 +95,9 @@ void * __sys_mmap( - return (void *)__psx_sig_epilog(m.tlca,-EINVAL,EPSXONLY); - - /* protection */ -- if (__psx_convert_flags_to_native( -+ if (!prot) -+ m.cprot = NT_PAGE_NOACCESS; -+ else if (__psx_convert_flags_to_native( - __mmap_section_prot, - prot,&m.cprot,0)) - return (void *)__psx_sig_epilog(m.tlca,-EINVAL,EPSXONLY); -diff --git a/src/mman/_mprotect.c b/src/mman/_mprotect.c -new file mode 100644 -index 0000000..7ac46d3 ---- /dev/null -+++ b/src/mman/_mprotect.c -@@ -0,0 +1,61 @@ -+/********************************************************/ -+/* psxscl: a thread-safe system call layer library */ -+/* Copyright (C) 2013--2016 Z. Gilboa */ -+/* Released under GPLv2 and GPLv3; see COPYING.PSXSCL. */ -+/********************************************************/ -+ -+#include <ntapi/ntapi.h> -+#include "psx_systypes.h" -+#include "psx_tlca.h" -+#include "psx_errno.h" -+#include "psx_flags.h" -+#include "psx_mman.h" -+#include "psx_signal.h" -+#include "psx_ofd.h" -+#include "psx_acl.h" -+#include "psx.h" -+ -+static const struct __flag_set __mmap_section_prot[] = { -+ {PROT_READ, NT_PAGE_READONLY}, -+ {PROT_WRITE, NT_PAGE_READWRITE}, -+ {PROT_EXEC, NT_PAGE_EXECUTE}, -+ {PROT_NONE, 0}, -+ {0, 0}}; -+ -+ -+__psx_api -+intptr_t __sys_mprotect( -+ void * addr, -+ size_t length, -+ int prot) -+{ -+ int32_t status; -+ struct __psx_tlca * tlca; -+ struct __psx_ctx * ctx; -+ uint32_t cprot, protect_type_old; -+ -+ /* prolog */ -+ tlca = __tlca_self(); -+ if (!(ctx = __tlca_shared_ctx(tlca))) return 0; -+ __psx_sig_prolog(tlca); -+ -+ -+ /* protection */ -+ if (!prot) -+ cprot = NT_PAGE_NOACCESS; -+ else if (__psx_convert_flags_to_native( -+ __mmap_section_prot, -+ prot,&cprot,0)) -+ return __psx_sig_epilog(tlca,-EINVAL,EPSXONLY); -+ -+ if (cprot & NT_PAGE_READWRITE) -+ cprot = NT_PAGE_READWRITE; -+ -+ if ((status = __ntapi->zw_protect_virtual_memory( -+ NT_CURRENT_PROCESS_HANDLE, -+ &addr, &length, -+ cprot, &protect_type_old))) -+ return __psx_sig_epilog(tlca,-ENOMEM,status); -+ -+ return __psx_sig_epilog(tlca,0,status); -+} |