diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.h b/Userland/DevTools/UserspaceEmulator/Emulator.h index e0ce2644539..318cecd1022 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.h +++ b/Userland/DevTools/UserspaceEmulator/Emulator.h @@ -125,6 +125,7 @@ private: int virt$mkdir(FlatPtr path, size_t path_length, mode_t mode); int virt$unlink(FlatPtr path, size_t path_length); int virt$get_process_name(FlatPtr buffer, int size); + int virt$set_process_name(FlatPtr buffer, int size); int virt$set_mmap_name(FlatPtr); int virt$gettimeofday(FlatPtr); int virt$clock_gettime(int, FlatPtr); diff --git a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp index 586593cbb01..dda6fced3d6 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp @@ -168,6 +168,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3) return virt$getsockopt(arg1); case SC_get_process_name: return virt$get_process_name(arg1, arg2); + case SC_set_process_name: + return virt$set_process_name(arg1, arg2); case SC_dbgputstr: return virt$dbgputstr(arg1, arg2); case SC_dbgputch: @@ -481,6 +483,15 @@ int Emulator::virt$get_process_name(FlatPtr buffer, int size) return rc; } +int Emulator::virt$set_process_name(FlatPtr user_buffer, int size) +{ + if (size < 0) + return -EINVAL; + auto host_buffer = mmu().copy_buffer_from_vm(user_buffer, size); + auto name = String::formatted("(UE) {}", StringView { host_buffer.data(), host_buffer.size() }); + return syscall(SC_set_process_name, name.characters(), name.length()); +} + int Emulator::virt$lseek(int fd, off_t offset, int whence) { return syscall(SC_lseek, fd, offset, whence);