mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:17:44 +00:00
Kernel+LibC: Add get_process_name() syscall
It does exactly what it sounds like: int get_process_name(char* buffer, int buffer_size);
This commit is contained in:
parent
d64e698bf1
commit
6ad3efe067
6 changed files with 29 additions and 1 deletions
|
@ -2859,3 +2859,19 @@ int Process::sys$set_process_icon(int icon_id)
|
|||
m_icon_id = icon_id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$get_process_name(char* buffer, int buffer_size)
|
||||
{
|
||||
if (buffer_size <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (!validate_write(buffer, buffer_size))
|
||||
return -EFAULT;
|
||||
|
||||
if (m_name.length() >= buffer_size)
|
||||
return -ENAMETOOLONG;
|
||||
|
||||
strncpy(buffer, m_name.characters(), buffer_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@ public:
|
|||
void die();
|
||||
void finalize();
|
||||
|
||||
int sys$get_process_name(char* buffer, int buffer_size);
|
||||
int sys$watch_file(const char* path, int path_length);
|
||||
int sys$dbgputch(u8);
|
||||
int sys$dbgputstr(const u8*, int length);
|
||||
|
|
|
@ -307,6 +307,8 @@ static u32 handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3
|
|||
return current->process().sys$set_process_icon((int)arg1);
|
||||
case Syscall::SC_mprotect:
|
||||
return current->process().sys$mprotect((void*)arg1, (size_t)arg2, (int)arg3);
|
||||
case Syscall::SC_get_process_name:
|
||||
return current->process().sys$get_process_name((char*)arg1, (int)arg2);
|
||||
default:
|
||||
kprintf("<%u> int0x82: Unknown function %u requested {%x, %x, %x}\n", current->process().pid(), function, arg1, arg2, arg3);
|
||||
return -ENOSYS;
|
||||
|
|
|
@ -123,7 +123,8 @@ struct timeval;
|
|||
__ENUMERATE_SYSCALL(watch_file) \
|
||||
__ENUMERATE_SYSCALL(share_buffer_globally) \
|
||||
__ENUMERATE_SYSCALL(set_process_icon) \
|
||||
__ENUMERATE_SYSCALL(mprotect)
|
||||
__ENUMERATE_SYSCALL(mprotect) \
|
||||
__ENUMERATE_SYSCALL(get_process_name)
|
||||
|
||||
namespace Syscall {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue