[Command(140)] // 6.0.0+
        // InitializeApplicationInfo(u64, pid)
        // Both calls (100, 140) use the same submethod, maybe there's something different further along when arp:r is called?
        public ResultCode InitializeApplicationInfo(ServiceCtx context)
        {
            if (_applicationLaunchProperty != null)
            {
                return(ResultCode.ApplicationLaunchPropertyAlreadyInit);
            }

            // The u64 argument seems to be unused by account.
            long unknown = context.RequestData.ReadInt64();

            // TODO: Account actually calls nn::arp::detail::IReader::GetApplicationLaunchProperty() with the current PID and store the result (ApplicationLaunchProperty) internally.
            //       For now we can hardcode values, and fix it after GetApplicationLaunchProperty is implemented.

            /*
             * if (nn::arp::detail::IReader::GetApplicationLaunchProperty() == 0xCC9D) // InvalidProcessId
             * {
             *  _applicationLaunchProperty = ApplicationLaunchProperty.Default;
             *
             *  return ResultCode.InvalidArgument;
             * }
             * else
             */
            {
                _applicationLaunchProperty = ApplicationLaunchProperty.GetByPid(context);
            }

            Logger.PrintStub(LogClass.ServiceAcc, new { unknown });

            return(ResultCode.Success);
        }
Esempio n. 2
0
        public IManagerForApplication(UInt128 userId, ApplicationLaunchProperty applicationLaunchProperty)
        {
            _commands = new Dictionary <int, ServiceProcessRequest>
            {
                { 0, CheckAvailability },
                { 1, GetAccountId }
            };

            _userId = userId;
            _applicationLaunchProperty = applicationLaunchProperty;
        }
        [CommandHipc(4)] // 10.0.0+
        // IsLargeResourceAvailable(pid) -> b8
        public ResultCode IsLargeResourceAvailable(ServiceCtx context)
        {
            // TODO: Service calls arp:r GetApplicationInstanceId (10.0.0+) then if it fails it calls arp:r GetMicroApplicationInstanceId (10.0.0+)
            //       then if it fails it returns the arp:r result code.

            // NOTE: Firmare 10.0.0+ don't use the Pid here anymore, but the returned InstanceId. We don't support that for now so we can just use the Pid instead.
            StorageId baseStorageId = (StorageId)ApplicationLaunchProperty.GetByPid(context).BaseGameStorageId;

            // NOTE: Service returns ResultCode.InvalidArgument if baseStorageId is null, doesn't occur in our case.

            context.ResponseData.Write(baseStorageId == StorageId.Host);

            return(ResultCode.Success);
        }
        // CreateDeliveryCacheStorageService(u64, pid) -> object<nn::bcat::detail::ipc::IDeliveryCacheStorageService>
        public ResultCode CreateDeliveryCacheStorageService(ServiceCtx context)
        {
            // TODO: Call arp:r GetApplicationLaunchProperty with the pid to get the TitleId.
            //       Add an instance of nn::bcat::detail::service::core::ApplicationStorageManager who load "bcat-dc-X:/" system save data,
            //       return ResultCode.NullSaveData if failed.
            //       Where X depend of the ApplicationLaunchProperty stored in an array (range 0-3).
            //       Add an instance of nn::bcat::detail::service::ServiceMemoryManager.

            MakeObject(context, new IDeliveryCacheStorageService(context, ApplicationLaunchProperty.GetByPid(context)));

            // NOTE: If the IDeliveryCacheStorageService is null this error is returned, Doesn't occur in our case.
            //       return ResultCode.NullObject;

            return(ResultCode.Success);
        }
        // CreateBcatService(u64, pid) -> object<nn::bcat::detail::ipc::IBcatService>
        public ResultCode CreateBcatService(ServiceCtx context)
        {
            // TODO: Call arp:r GetApplicationLaunchProperty with the pid to get the TitleId.
            //       Add an instance of nn::bcat::detail::service::core::PassphraseManager.
            //       Add an instance of nn::bcat::detail::service::ServiceMemoryManager.
            //       Add an instance of nn::bcat::detail::service::core::TaskManager who load "bcat-sys:/" system save data and open "dc/task.bin".
            //       If the file don't exist, create a new one (size of 0x800) and write 2 empty struct with a size of 0x400.

            MakeObject(context, new IBcatService(ApplicationLaunchProperty.GetByPid(context)));

            // NOTE: If the IBcatService is null this error is returned, Doesn't occur in our case.
            //       return ResultCode.NullObject;

            return(ResultCode.Success);
        }
        [Command(1)] // 4.0.0+
        // Initialize()
        public ResultCode Initialize(ServiceCtx context)
        {
            if ((_permissionFlag & 0x8001) == 0)
            {
                return(ResultCode.PermissionDenied);
            }

            ResultCode resultCode = ResultCode.InvalidPid;

            if (context.Process.Pid != 0)
            {
                if ((_permissionFlag & 0x40) == 0)
                {
                    ulong titleId = ApplicationLaunchProperty.GetByPid(context).TitleId;

                    if (titleId != 0)
                    {
                        _titleId = titleId;

                        // TODO: Call nn::arp::GetApplicationControlProperty here when implemented, if it return ResultCode.Success we assign fields.
                        _ratingAge = Array.ConvertAll(context.Device.Application.ControlData.Value.RatingAge.ToArray(), Convert.ToInt32);
                        _freeCommunicationEnabled = context.Device.Application.ControlData.Value.ParentalControl == LibHac.Ns.ParentalControlFlagValue.FreeCommunication;
                    }
                }

                if (_titleId != 0)
                {
                    // TODO: Service store some private fields in another static object.

                    if ((_permissionFlag & 0x8040) == 0)
                    {
                        // TODO: Service store TitleId and FreeCommunicationEnabled in another static object.
                        //       When it's done it signal an event in this static object.
                        Logger.Stub?.PrintStub(LogClass.ServicePctl);
                    }
                }

                resultCode = ResultCode.Success;
            }

            return(resultCode);
        }
Esempio n. 7
0
        // InitializeApplicationInfo(u64, pid)
        // Both calls (100, 140) use the same submethod, maybe there's something different further along when arp:r is called?
        public long InitializeApplicationInfo(ServiceCtx context)
        {
            if (_applicationLaunchProperty != null)
            {
                return(MakeError(ErrorModule.Account, AccErr.ApplicationLaunchPropertyAlreadyInit));
            }

            // The u64 argument seems to be unused by account.
            long unknown = context.RequestData.ReadInt64();

            // TODO: Account actually calls nn::arp::detail::IReader::GetApplicationLaunchProperty() with the current PID and store the result (ApplicationLaunchProperty) internally.
            //       For now we can hardcode values, and fix it after GetApplicationLaunchProperty is implemented.

            /*
             * if (nn::arp::detail::IReader::GetApplicationLaunchProperty() == 0xCC9D) // InvalidProcessId
             * {
             *  _applicationLaunchProperty = new ApplicationLaunchProperty
             *  {
             *      TitleId             = 0x00;
             *      Version             = 0x00;
             *      BaseGameStorageId   = 0x03;
             *      UpdateGameStorageId = 0x00;
             *  }
             *
             *  return MakeError(ErrorModule.Account, AccErr.InvalidArgument);
             * }
             * else
             */
            {
                _applicationLaunchProperty = new ApplicationLaunchProperty
                {
                    TitleId             = BitConverter.ToInt64(StringUtils.HexToBytes(context.Device.System.TitleID), 0),
                    Version             = 0x00,
                    BaseGameStorageId   = (byte)StorageId.NandSystem,
                    UpdateGameStorageId = (byte)StorageId.None
                };
            }

            Logger.PrintStub(LogClass.ServiceAcc, new { unknown });

            return(0);
        }
Esempio n. 8
0
        [CommandHipc(160)] // 13.0.0+
        // InitializeApplicationInfo(u64 pid_placeholder, pid)
        public ResultCode InitializeApplicationInfo(ServiceCtx context)
        {
            // NOTE: In call 100, account service use the pid_placeholder instead of the real pid, which is wrong, call 140 fix that.

            /*
             *
             * // TODO: Account actually calls nn::arp::detail::IReader::GetApplicationLaunchProperty() with the current PID and store the result (ApplicationLaunchProperty) internally.
             * //       For now we can hardcode values, and fix it after GetApplicationLaunchProperty is implemented.
             * if (nn::arp::detail::IReader::GetApplicationLaunchProperty() == 0xCC9D) // ResultCode.InvalidProcessId
             * {
             *  return ResultCode.InvalidArgument;
             * }
             *
             */

            // TODO: Determine where ApplicationLaunchProperty is used.
            ApplicationLaunchProperty applicationLaunchProperty = ApplicationLaunchProperty.GetByPid(context);

            Logger.Stub?.PrintStub(LogClass.ServiceAcc, new { applicationLaunchProperty.TitleId });

            return(ResultCode.Success);
        }
Esempio n. 9
0
 public IDeliveryCacheDirectoryService(ServiceCtx context, ApplicationLaunchProperty applicationLaunchProperty)
 {
 }
Esempio n. 10
0
 public IManagerForApplication(UserId userId, ApplicationLaunchProperty applicationLaunchProperty)
 {
     _userId = userId;
     _applicationLaunchProperty = applicationLaunchProperty;
 }
Esempio n. 11
0
 public IBcatService(ApplicationLaunchProperty applicationLaunchProperty)
 {
 }
 public IDeliveryCacheStorageService(ServiceCtx context, ApplicationLaunchProperty applicationLaunchProperty)
 {
     // TODO: Read directories.meta file from the save data (loaded in IServiceCreator) in _deliveryCacheDirectories.
 }