aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Horizon/Arp/Ipc/Updater.cs
blob: f7531d712dd7b89cf4d059a3102ef119d691cd65 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using Ryujinx.Horizon.Common;
using Ryujinx.Horizon.Sdk.Arp;
using Ryujinx.Horizon.Sdk.Arp.Detail;
using Ryujinx.Horizon.Sdk.Sf;
using Ryujinx.Horizon.Sdk.Sf.Hipc;
using System;

namespace Ryujinx.Horizon.Arp.Ipc
{
    partial class Updater : IUpdater, IServiceObject
    {
        private readonly ApplicationInstanceManager _applicationInstanceManager;
        private readonly ulong _applicationInstanceId;
        private readonly bool _forCertificate;

        public Updater(ApplicationInstanceManager applicationInstanceManager, ulong applicationInstanceId, bool forCertificate)
        {
            _applicationInstanceManager = applicationInstanceManager;
            _applicationInstanceId = applicationInstanceId;
            _forCertificate = forCertificate;
        }

        [CmifCommand(0)]
        public Result Issue()
        {
            throw new NotImplementedException();
        }

        [CmifCommand(1)]
        public Result SetApplicationProcessProperty(ulong pid, ApplicationProcessProperty applicationProcessProperty)
        {
            if (_forCertificate)
            {
                return ArpResult.DataAlreadyBound;
            }

            if (pid == 0)
            {
                return ArpResult.InvalidPid;
            }

            _applicationInstanceManager.Entries[_applicationInstanceId].Pid = pid;
            _applicationInstanceManager.Entries[_applicationInstanceId].ProcessProperty = applicationProcessProperty;

            return Result.Success;
        }

        [CmifCommand(2)]
        public Result DeleteApplicationProcessProperty()
        {
            if (_forCertificate)
            {
                return ArpResult.DataAlreadyBound;
            }

            _applicationInstanceManager.Entries[_applicationInstanceId].ProcessProperty = new ApplicationProcessProperty();

            return Result.Success;
        }

        [CmifCommand(3)]
        public Result SetApplicationCertificate([Buffer(HipcBufferFlags.In | HipcBufferFlags.AutoSelect)] ApplicationCertificate applicationCertificate)
        {
            if (!_forCertificate)
            {
                return ArpResult.DataAlreadyBound;
            }

            _applicationInstanceManager.Entries[_applicationInstanceId].Certificate = applicationCertificate;

            return Result.Success;
        }
    }
}