aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Services/Pm/IInformationInterface.cs
blob: 500d121ea70189d92a9f1f20407774d373885f01 (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
using Ryujinx.HLE.HOS.Kernel.Process;

namespace Ryujinx.HLE.HOS.Services.Pm
{
    [Service("pm:info")]
    class IInformationInterface : IpcService
    {
        public IInformationInterface(ServiceCtx context) { }

        [CommandCmif(0)]
        // GetProgramId(os::ProcessId process_id) -> sf::Out<ncm::ProgramId> out
        public ResultCode GetProgramId(ServiceCtx context)
        {
            ulong pid = context.RequestData.ReadUInt64();

            // TODO: Not correct as it shouldn't be directly using kernel objects here
            if (context.Device.System.KernelContext.Processes.TryGetValue(pid, out KProcess process))
            {
                context.ResponseData.Write(process.TitleId);

                return ResultCode.Success;
            }

            return ResultCode.ProcessNotFound;
        }
    }
}