Create a temporary solution to call a 6-arguments system call (specifically, mmap).

This commit is contained in:
Enrico Fraccaroli (Galfurian)
2023-06-09 15:36:03 -04:00
parent a007e4e4c7
commit fb0323c8ce
6 changed files with 105 additions and 15 deletions
+16
View File
@@ -625,3 +625,19 @@ void destroy_process_image(mm_struct_t *mm)
// Free the mm_struct.
kmem_cache_free(mm);
}
void *sys_mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
{
pr_warning("%p\n", addr);
pr_warning("%d\n", length);
pr_warning("%d\n", prot);
pr_warning("%d\n", flags);
pr_warning("%d\n", fd);
pr_warning("%d\n", offset);
return NULL;
}
int sys_munmap(void *addr, size_t length)
{
return 0;
}
+12 -3
View File
@@ -4,7 +4,8 @@
/// See LICENSE.md for details.
// Setup the logging for this file (do this before any other include).
#include "sys/kernel_levels.h" // Include kernel log levels.
#include "sys/kernel_levels.h" // Include kernel log levels.
#include "system/syscall_types.h"
#define __DEBUG_HEADER__ "[SYSCLL]" ///< Change header.
#define __DEBUG_LEVEL__ LOGLEVEL_NOTICE ///< Set log level.
#include "io/debug.h" // Include debugging functions.
@@ -21,6 +22,7 @@
#include "sys/errno.h"
#include "sys/utsname.h"
#include "sys/mman.h"
#include "sys/msg.h"
#include "sys/sem.h"
#include "sys/shm.h"
@@ -129,7 +131,7 @@ void syscall_init()
sys_call_table[__NR_swapon] = (SystemCall)sys_ni_syscall;
sys_call_table[__NR_reboot] = (SystemCall)sys_reboot;
sys_call_table[__NR_readdir] = (SystemCall)sys_ni_syscall;
sys_call_table[__NR_mmap] = (SystemCall)sys_ni_syscall;
sys_call_table[__NR_mmap] = (SystemCall)sys_mmap;
sys_call_table[__NR_munmap] = (SystemCall)sys_ni_syscall;
sys_call_table[__NR_truncate] = (SystemCall)sys_ni_syscall;
sys_call_table[__NR_ftruncate] = (SystemCall)sys_ni_syscall;
@@ -278,7 +280,14 @@ void syscall_handler(pt_regs *f)
(sc_index == __NR_sigreturn)) {
arg0 = (uintptr_t)f;
}
ret = func(arg0, arg1, arg2, arg3, arg4);
if (sc_index == __NR_mmap) {
// Get the arguments.
unsigned *args = (unsigned *)arg0;
// Call the function.
ret = func(args[0], args[1], args[2], args[3], args[4], args[5]);
} else {
ret = func(arg0, arg1, arg2, arg3, arg4);
}
}
f->eax = ret;