aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Pm/IDebugMonitorInterface.cs
blob: c9c6354df08ad079fa4e70dfdc0065cb9a527503 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel;
using Ryujinx.HLE.HOS.Kernel.Process;
using Ryujinx.Horizon.Common;

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 GetProcessInfo(ServiceCtx context)
        {
            ulong pid = context.RequestData.ReadUInt64();

            KProcess process = KernelStatic.GetProcessByPid(pid);

            if (context.Process.HandleTable.GenerateHandle(process, out int processHandle) != Result.Success)
            {
                throw new System.Exception("Out of handles!");
            }

            context.Response.HandleDesc = IpcHandleDesc.MakeCopy(processHandle);

            return ResultCode.Success;
        }
    }
}