summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 76a8b0191..3cd948bb5 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -1983,6 +1983,43 @@ static ResultCode SetResourceLimitLimitValue(Handle resource_limit, u32 resource
1983 return RESULT_SUCCESS; 1983 return RESULT_SUCCESS;
1984} 1984}
1985 1985
1986static ResultCode GetProcessList(u32* out_num_processes, VAddr out_process_ids,
1987 u32 out_process_ids_size) {
1988 LOG_DEBUG(Kernel_SVC, "called. out_process_ids=0x{:016X}, out_process_ids_size={}",
1989 out_process_ids, out_process_ids_size);
1990
1991 // If the supplied size is negative or greater than INT32_MAX / sizeof(u64), bail.
1992 if ((out_process_ids_size & 0xF0000000) != 0) {
1993 LOG_ERROR(Kernel_SVC,
1994 "Supplied size outside [0, 0x0FFFFFFF] range. out_process_ids_size={}",
1995 out_process_ids_size);
1996 return ERR_OUT_OF_RANGE;
1997 }
1998
1999 const auto& kernel = Core::System::GetInstance().Kernel();
2000 const auto& vm_manager = kernel.CurrentProcess()->VMManager();
2001 const auto total_copy_size = out_process_ids_size * sizeof(u64);
2002
2003 if (out_process_ids_size > 0 &&
2004 !vm_manager.IsWithinAddressSpace(out_process_ids, total_copy_size)) {
2005 LOG_ERROR(Kernel_SVC, "Address range outside address space. begin=0x{:016X}, end=0x{:016X}",
2006 out_process_ids, out_process_ids + total_copy_size);
2007 return ERR_INVALID_ADDRESS_STATE;
2008 }
2009
2010 const auto& process_list = kernel.GetProcessList();
2011 const auto num_processes = process_list.size();
2012 const auto copy_amount = std::min(std::size_t{out_process_ids_size}, num_processes);
2013
2014 for (std::size_t i = 0; i < copy_amount; ++i) {
2015 Memory::Write64(out_process_ids, process_list[i]->GetProcessID());
2016 out_process_ids += sizeof(u64);
2017 }
2018
2019 *out_num_processes = static_cast<u32>(num_processes);
2020 return RESULT_SUCCESS;
2021}
2022
1986namespace { 2023namespace {
1987struct FunctionDef { 2024struct FunctionDef {
1988 using Func = void(); 2025 using Func = void();
@@ -2095,7 +2132,7 @@ static const FunctionDef SVC_Table[] = {
2095 {0x62, nullptr, "TerminateDebugProcess"}, 2132 {0x62, nullptr, "TerminateDebugProcess"},
2096 {0x63, nullptr, "GetDebugEvent"}, 2133 {0x63, nullptr, "GetDebugEvent"},
2097 {0x64, nullptr, "ContinueDebugEvent"}, 2134 {0x64, nullptr, "ContinueDebugEvent"},
2098 {0x65, nullptr, "GetProcessList"}, 2135 {0x65, SvcWrap<GetProcessList>, "GetProcessList"},
2099 {0x66, nullptr, "GetThreadList"}, 2136 {0x66, nullptr, "GetThreadList"},
2100 {0x67, nullptr, "GetDebugThreadContext"}, 2137 {0x67, nullptr, "GetDebugThreadContext"},
2101 {0x68, nullptr, "SetDebugThreadContext"}, 2138 {0x68, nullptr, "SetDebugThreadContext"},