[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);
        }
        [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);
        }
Ejemplo n.º 3
0
        // 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);
        }
Ejemplo n.º 4
0
        // 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);
        }
Ejemplo n.º 6
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);
        }