Implement GetApplicationPid atmosphere extension

This commit is contained in:
gdk 2022-01-01 22:04:13 -03:00
parent f8c6a6edf4
commit a23274cb3c
3 changed files with 36 additions and 1 deletions

View file

@ -59,5 +59,15 @@ namespace Ryujinx.HLE.HOS.Kernel
{
return GetCurrentThread().Owner;
}
internal static KProcess GetProcessByPid(long pid)
{
if (Context.Processes.TryGetValue(pid, out KProcess process))
{
return process;
}
return null;
}
}
}

View file

@ -1539,6 +1539,8 @@ namespace Ryujinx.HLE.HOS.Kernel.SupervisorCall
return result;
}
srcProcess.Context.InvalidateCacheRegion(src, size);
return KernelResult.Success;
}

View file

@ -1,8 +1,31 @@
namespace Ryujinx.HLE.HOS.Services.Pm
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel;
using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Process;
namespace Ryujinx.HLE.HOS.Services.Pm
{
[Service("pm:dmnt")]
class IDebugMonitorInterface : IpcService
{
public IDebugMonitorInterface(ServiceCtx context) { }
[CommandHipc(65000)]
// AtmosphereGetProcessInfo(os::ProcessId process_id) -> sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status
public ResultCode GetApplicationPid(ServiceCtx context)
{
long pid = context.RequestData.ReadInt64();
KProcess process = KernelStatic.GetProcessByPid(pid);
if (context.Process.HandleTable.GenerateHandle(process, out int processHandle) != KernelResult.Success)
{
throw new System.Exception("Out of handles!");
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(processHandle);
return ResultCode.Success;
}
}
}