From 48737a4bb2372d4564f369694df7c2ca5812bf25 Mon Sep 17 00:00:00 2001 From: comex Date: Mon, 20 Jun 2022 17:39:10 -0700 Subject: [PATCH 1/3] Support InfoType_MesosphereCurrentProcess --- src/core/hle/kernel/svc.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 2ff6d5fa6d..0aa068f1d4 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -692,6 +692,9 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle // 6.0.0+ TotalPhysicalMemoryAvailableWithoutSystemResource = 21, TotalPhysicalMemoryUsedWithoutSystemResource = 22, + + // Homebrew only + MesosphereCurrentProcess = 65001, }; const auto info_id_type = static_cast(info_id); @@ -914,6 +917,17 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle *result = system.Kernel().CurrentScheduler()->GetIdleThread()->GetCpuTime(); return ResultSuccess; } + case GetInfoType::MesosphereCurrentProcess: { + R_UNLESS(handle == InvalidHandle, ResultInvalidHandle); + R_UNLESS(info_sub_id == 0, ResultInvalidCombination); + + KProcess* const current_process = system.Kernel().CurrentProcess(); + Handle process_handle{}; + R_TRY(current_process->GetHandleTable().Add(&process_handle, current_process)); + + *result = process_handle; + return ResultSuccess; + } default: LOG_ERROR(Kernel_SVC, "Unimplemented svcGetInfo id=0x{:016X}", info_id); return ResultInvalidEnumValue; From a14438d013b96dac4ff6a31cb6fed1e51ef98f40 Mon Sep 17 00:00:00 2001 From: comex Date: Sat, 25 Jun 2022 18:00:29 -0700 Subject: [PATCH 2/3] Update src/core/hle/kernel/svc.cpp Co-authored-by: liamwhite --- src/core/hle/kernel/svc.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 0aa068f1d4..fdfd69ebdc 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -917,17 +917,25 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle *result = system.Kernel().CurrentScheduler()->GetIdleThread()->GetCpuTime(); return ResultSuccess; } - case GetInfoType::MesosphereCurrentProcess: { + // Verify the input handle is invalid. R_UNLESS(handle == InvalidHandle, ResultInvalidHandle); + + // Verify the sub-type is valid. R_UNLESS(info_sub_id == 0, ResultInvalidCombination); - KProcess* const current_process = system.Kernel().CurrentProcess(); - Handle process_handle{}; - R_TRY(current_process->GetHandleTable().Add(&process_handle, current_process)); + // Get the handle table. + KProcess* current_process = system.Kernel().CurrentProcess(); + KHandleTable& handle_table = current_process->GetHandleTable(); - *result = process_handle; + // Get a new handle for the current process. + Handle tmp; + R_TRY(handle_table.Add(&tmp, current_process)); + + // Set the output. + *result = tmp; + + // We succeeded. return ResultSuccess; - } default: LOG_ERROR(Kernel_SVC, "Unimplemented svcGetInfo id=0x{:016X}", info_id); return ResultInvalidEnumValue; From bf7e78795f7dece087ee59c5319735a41773d2ee Mon Sep 17 00:00:00 2001 From: comex Date: Sat, 25 Jun 2022 18:01:56 -0700 Subject: [PATCH 3/3] Re-add missing `case` and braces, and trim whitespace --- src/core/hle/kernel/svc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index fdfd69ebdc..72272a34e8 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -917,6 +917,7 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle *result = system.Kernel().CurrentScheduler()->GetIdleThread()->GetCpuTime(); return ResultSuccess; } + case GetInfoType::MesosphereCurrentProcess: { // Verify the input handle is invalid. R_UNLESS(handle == InvalidHandle, ResultInvalidHandle); @@ -933,9 +934,10 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle // Set the output. *result = tmp; - + // We succeeded. return ResultSuccess; + } default: LOG_ERROR(Kernel_SVC, "Unimplemented svcGetInfo id=0x{:016X}", info_id); return ResultInvalidEnumValue;