2022-05-03 21:28:32 +00:00
|
|
|
|
using Ryujinx.HLE.HOS.Ipc;
|
|
|
|
|
using Ryujinx.HLE.HOS.Kernel;
|
|
|
|
|
using Ryujinx.HLE.HOS.Kernel.Process;
|
2023-01-04 22:15:45 +00:00
|
|
|
|
using Ryujinx.Horizon.Common;
|
2022-05-03 21:28:32 +00:00
|
|
|
|
|
|
|
|
|
namespace Ryujinx.HLE.HOS.Services.Pm
|
2019-09-19 00:45:11 +00:00
|
|
|
|
{
|
|
|
|
|
[Service("pm:dmnt")]
|
|
|
|
|
class IDebugMonitorInterface : IpcService
|
|
|
|
|
{
|
|
|
|
|
public IDebugMonitorInterface(ServiceCtx context) { }
|
2022-05-03 21:28:32 +00:00
|
|
|
|
|
2023-04-14 23:00:34 +00:00
|
|
|
|
[CommandCmif(4)]
|
2023-01-15 21:16:24 +00:00
|
|
|
|
// GetProgramId() -> sf::Out<ncm::ProgramId> out_process_id
|
|
|
|
|
public ResultCode GetApplicationProcessId(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
// TODO: Not correct as it shouldn't be directly using kernel objects here
|
|
|
|
|
foreach (KProcess process in context.Device.System.KernelContext.Processes.Values)
|
|
|
|
|
{
|
|
|
|
|
if (process.IsApplication)
|
|
|
|
|
{
|
|
|
|
|
context.ResponseData.Write(process.Pid);
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultCode.ProcessNotFound;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 23:00:34 +00:00
|
|
|
|
[CommandCmif(65000)]
|
2022-05-03 21:28:32 +00:00
|
|
|
|
// AtmosphereGetProcessInfo(os::ProcessId process_id) -> sf::OutCopyHandle out_process_handle, sf::Out<ncm::ProgramLocation> out_loc, sf::Out<cfg::OverrideStatus> out_status
|
|
|
|
|
public ResultCode GetProcessInfo(ServiceCtx context)
|
|
|
|
|
{
|
|
|
|
|
ulong pid = context.RequestData.ReadUInt64();
|
|
|
|
|
|
|
|
|
|
KProcess process = KernelStatic.GetProcessByPid(pid);
|
|
|
|
|
|
2023-01-04 22:15:45 +00:00
|
|
|
|
if (context.Process.HandleTable.GenerateHandle(process, out int processHandle) != Result.Success)
|
2022-05-03 21:28:32 +00:00
|
|
|
|
{
|
|
|
|
|
throw new System.Exception("Out of handles!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(processHandle);
|
|
|
|
|
|
|
|
|
|
return ResultCode.Success;
|
|
|
|
|
}
|
2019-09-19 00:45:11 +00:00
|
|
|
|
}
|
|
|
|
|
}
|