hle: kernel: svc: Use new handle table API for Process.

This commit is contained in:
bunnei 2021-04-17 22:21:59 -07:00
parent c7d8b7421c
commit 126aaeb6d3
2 changed files with 17 additions and 16 deletions

View file

@ -686,7 +686,7 @@ static void OutputDebugString(Core::System& system, VAddr address, u64 len) {
} }
/// Gets system/memory information for the current process /// Gets system/memory information for the current process
static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 handle, static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle,
u64 info_sub_id) { u64 info_sub_id) {
std::lock_guard lock{HLE::g_hle_lock}; std::lock_guard lock{HLE::g_hle_lock};
LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id,
@ -752,10 +752,9 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
return ResultInvalidEnumValue; return ResultInvalidEnumValue;
} }
const auto& current_process_handle_table = const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
system.Kernel().CurrentProcess()->GetHandleTable(); KScopedAutoObject process = handle_table.GetObject<Process>(handle);
const auto process = current_process_handle_table.Get<Process>(static_cast<Handle>(handle)); if (process.IsNull()) {
if (!process) {
LOG_ERROR(Kernel_SVC, "Process is not valid! info_id={}, info_sub_id={}, handle={:08X}", LOG_ERROR(Kernel_SVC, "Process is not valid! info_id={}, info_sub_id={}, handle={:08X}",
info_id, info_sub_id, handle); info_id, info_sub_id, handle);
return ResultInvalidHandle; return ResultInvalidHandle;
@ -1287,8 +1286,8 @@ static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_add
std::lock_guard lock{HLE::g_hle_lock}; std::lock_guard lock{HLE::g_hle_lock};
LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address);
const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
auto process = handle_table.Get<Process>(process_handle); KScopedAutoObject process = handle_table.GetObject<Process>(process_handle);
if (!process) { if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}", LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}",
process_handle); process_handle);
return ResultInvalidHandle; return ResultInvalidHandle;
@ -1369,8 +1368,8 @@ static ResultCode MapProcessCodeMemory(Core::System& system, Handle process_hand
} }
const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
auto process = handle_table.Get<Process>(process_handle); KScopedAutoObject process = handle_table.GetObject<Process>(process_handle);
if (!process) { if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).", LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).",
process_handle); process_handle);
return ResultInvalidHandle; return ResultInvalidHandle;
@ -1437,8 +1436,8 @@ static ResultCode UnmapProcessCodeMemory(Core::System& system, Handle process_ha
} }
const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
auto process = handle_table.Get<Process>(process_handle); KScopedAutoObject process = handle_table.GetObject<Process>(process_handle);
if (!process) { if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).", LOG_ERROR(Kernel_SVC, "Invalid process handle specified (handle=0x{:08X}).",
process_handle); process_handle);
return ResultInvalidHandle; return ResultInvalidHandle;
@ -2100,8 +2099,8 @@ static ResultCode GetProcessInfo(Core::System& system, u64* out, Handle process_
}; };
const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable();
const auto process = handle_table.Get<Process>(process_handle); KScopedAutoObject process = handle_table.GetObject<Process>(process_handle);
if (!process) { if (process.IsNull()) {
LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}", LOG_ERROR(Kernel_SVC, "Process handle does not exist, process_handle=0x{:08X}",
process_handle); process_handle);
return ResultInvalidHandle; return ResultInvalidHandle;

View file

@ -252,11 +252,13 @@ void SvcWrap64(Core::System& system) {
.raw); .raw);
} }
template <ResultCode func(Core::System&, u64*, u64, u64, u64)> // Used by GetInfo
template <ResultCode func(Core::System&, u64*, u64, Handle, u64)>
void SvcWrap64(Core::System& system) { void SvcWrap64(Core::System& system) {
u64 param_1 = 0; u64 param_1 = 0;
const u32 retval = const u32 retval = func(system, &param_1, Param(system, 1),
func(system, &param_1, Param(system, 1), Param(system, 2), Param(system, 3)).raw; static_cast<Handle>(Param(system, 2)), Param(system, 3))
.raw;
system.CurrentArmInterface().SetReg(1, param_1); system.CurrentArmInterface().SetReg(1, param_1);
FuncReturn(system, retval); FuncReturn(system, retval);