示例#1
0
        public Result GetGameCardHandle(out GameCardHandle handle)
        {
            if (!GameCard.IsGameCardInserted())
            {
                handle = default;
                return(ResultFs.GameCardNotInsertedOnGetHandle.Log());
            }

            handle = GameCard.GetGameCardHandle();
            return(Result.Success);
        }
示例#2
0
        public Result GetGameCardHandle(out GameCardHandle handle)
        {
            UnsafeHelpers.SkipParamInit(out handle);

            if (!GameCard.IsGameCardInserted())
            {
                return(ResultFs.GameCardNotInsertedOnGetHandle.Log());
            }

            handle = GameCard.GetGameCardHandle();
            return(Result.Success);
        }
        public Result Read(GameCardHandle handle, long offset, Span <byte> destination)
        {
            if (IsGameCardHandleInvalid(handle))
            {
                return(ResultFs.InvalidGameCardHandleOnRead.Log());
            }
            if (!IsGameCardInserted())
            {
                return(ResultFs.GameCardNotInserted.Log());
            }

            return(CardImageStorage.Read(offset, destination));
        }
        internal Result GetXci(out Xci xci, GameCardHandle handle)
        {
            UnsafeHelpers.SkipParamInit(out xci);

            if (IsGameCardHandleInvalid(handle))
            {
                return(ResultFs.InvalidGameCardHandleOnRead.Log());
            }
            if (!IsGameCardInserted())
            {
                return(ResultFs.GameCardNotInserted.Log());
            }

            xci = CardImage;
            return(Result.Success);
        }
        internal Result GetCardInfo(out GameCardInfo cardInfo, GameCardHandle handle)
        {
            UnsafeHelpers.SkipParamInit(out cardInfo);

            if (IsGameCardHandleInvalid(handle))
            {
                return(ResultFs.InvalidGameCardHandleOnGetCardInfo.Log());
            }
            if (!IsGameCardInserted())
            {
                return(ResultFs.GameCardNotInserted.Log());
            }

            cardInfo = GetCardInfoImpl();
            return(Result.Success);
        }
示例#6
0
        internal Result GetXci(out Xci xci, GameCardHandle handle)
        {
            xci = default;

            if (IsGameCardHandleInvalid(handle))
            {
                return(ResultFs.InvalidGameCardHandleOnRead.Log());
            }
            if (!IsGameCardInserted())
            {
                return(ResultFs.GameCardNotInserted.Log());
            }

            xci = CardImage;
            return(Result.Success);
        }
示例#7
0
        internal Result GetCardInfo(out GameCardInfo cardInfo, GameCardHandle handle)
        {
            cardInfo = default;

            if (IsGameCardHandleInvalid(handle))
            {
                return(ResultFs.InvalidGameCardHandleOnGetCardInfo.Log());
            }
            if (!IsGameCardInserted())
            {
                return(ResultFs.GameCardNotInserted.Log());
            }

            cardInfo = GetCardInfoImpl();
            return(Result.Success);
        }
示例#8
0
        public Result OpenGameCardStorage(out IStorage storage, GameCardHandle handle, GameCardPartitionRaw partitionId)
        {
            switch (partitionId)
            {
            case GameCardPartitionRaw.NormalReadOnly:
                return(FsCreators.GameCardStorageCreator.CreateNormal(handle, out storage));

            case GameCardPartitionRaw.SecureReadOnly:
                return(FsCreators.GameCardStorageCreator.CreateSecure(handle, out storage));

            case GameCardPartitionRaw.RootWriteOnly:
                return(FsCreators.GameCardStorageCreator.CreateWritable(handle, out storage));

            default:
                throw new ArgumentOutOfRangeException(nameof(partitionId), partitionId, null);
            }
        }
示例#9
0
        public Result OpenGameCardFileSystem(out IFileSystem fileSystem, GameCardHandle handle,
                                             GameCardPartition partitionId)
        {
            Result rc;
            int    tries = 0;

            do
            {
                rc = FsCreators.GameCardFileSystemCreator.Create(out fileSystem, handle, partitionId);

                if (!ResultFs.DataCorrupted.Includes(rc))
                {
                    break;
                }

                tries++;
            } while (tries < 2);

            return(rc);
        }
示例#10
0
 public bool IsGameCardHandleInvalid(GameCardHandle handle)
 {
     return(Handle != handle.Value);
 }
示例#11
0
        public Result OpenGameCardStorage(out ReferenceCountedDisposable <IStorageSf> storage, GameCardHandle handle,
                                          GameCardPartitionRaw partitionId)
        {
            UnsafeHelpers.SkipParamInit(out storage);

            Result rc = GetProgramInfo(out ProgramInfo programInfo);

            if (rc.IsFailure())
            {
                return(rc);
            }

            Accessibility accessibility =
                programInfo.AccessControl.GetAccessibilityFor(AccessibilityType.OpenGameCardStorage);

            bool canAccess = accessibility.CanRead && accessibility.CanWrite;

            if (!canAccess)
            {
                return(ResultFs.PermissionDenied.Log());
            }

            ReferenceCountedDisposable <IStorage> tempStorage = null;

            try
            {
                rc = _serviceImpl.OpenGameCardPartition(out tempStorage, handle, partitionId);
                if (rc.IsFailure())
                {
                    return(rc);
                }

                // Todo: Async storage

                storage = StorageInterfaceAdapter.CreateShared(ref tempStorage);
                return(Result.Success);
            }
            finally
            {
                tempStorage?.Dispose();
            }
        }
示例#12
0
        public Result OpenGameCardPartition(out ReferenceCountedDisposable <IStorage> storage, GameCardHandle handle,
                                            GameCardPartitionRaw partitionId)
        {
            switch (partitionId)
            {
            case GameCardPartitionRaw.NormalReadOnly:
                return(Config.GameCardStorageCreator.CreateReadOnly(handle, out storage));

            case GameCardPartitionRaw.SecureReadOnly:
                return(Config.GameCardStorageCreator.CreateSecureReadOnly(handle, out storage));

            case GameCardPartitionRaw.RootWriteOnly:
                return(Config.GameCardStorageCreator.CreateWriteOnly(handle, out storage));

            default:
                UnsafeHelpers.SkipParamInit(out storage);
                return(ResultFs.InvalidArgument.Log());
            }
        }