public void GetProgramIndexForAccessLog_IsMultiProgram_ReturnsCorrectIndex()
        {
            const int count = 7;

            Horizon hos = HorizonFactory.CreateBasicHorizon();

            var programs = new HorizonClient[count];

            programs[0] = hos.CreateHorizonClient(new ProgramId(1), AccessControlBits.Bits.RegisterProgramIndexMapInfo);

            for (int i = 1; i < programs.Length; i++)
            {
                programs[i] = hos.CreateHorizonClient(new ProgramId((ulong)(i + 1)), AccessControlBits.Bits.None);
            }

            var map = new ProgramIndexMapInfo[count];

            for (int i = 0; i < map.Length; i++)
            {
                map[i].MainProgramId = new ProgramId(1);
                map[i].ProgramId     = new ProgramId((ulong)(i + 1));
                map[i].ProgramIndex  = (byte)i;
            }

            Assert.Success(programs[0].Fs.RegisterProgramIndexMapInfo(map));

            for (int i = 0; i < programs.Length; i++)
            {
                Assert.Success(programs[i].Fs.GetFileSystemProxyServiceObject()
                               .GetProgramIndexForAccessLog(out int programIndex, out int programCount));

                Assert.Equal(i, programIndex);
                Assert.Equal(count, programCount);
            }
        }
Esempio n. 2
0
        public void OpenFileSystemWithPermissions_ReturnsInvalidNcaMountPoint()
        {
            Horizon hos = HorizonFactory.CreateBasicHorizon();

            HorizonClient regClient = hos.CreatePrivilegedHorizonClient();
            HorizonClient client    = hos.CreateHorizonClient();

            var dataHeader = new AccessControlDataHeader();
            var descriptor = new AccessControlDescriptor();

            descriptor.Version = 123;
            dataHeader.Version = 123;

            descriptor.AccessFlags = (ulong)AccessControlBits.Bits.ApplicationInfo;
            dataHeader.AccessFlags = (ulong)AccessControlBits.Bits.ApplicationInfo;

            Assert.Success(regClient.Fs.RegisterProgram(client.ProcessId.Value, new ProgramId(123),
                                                        StorageId.BuiltInUser, SpanHelpers.AsReadOnlyByteSpan(in dataHeader),
                                                        SpanHelpers.AsReadOnlyByteSpan(in descriptor)));

            // We should get UnexpectedInNcaFileSystemServiceImplA because mounting NCAs from @System isn't allowed
            Result rc = client.Fs.MountContent("test".ToU8Span(), "@System:/fake.nca".ToU8Span(), ContentType.Control);

            Assert.Result(ResultFs.UnexpectedInNcaFileSystemServiceImplA, rc);
        }
Esempio n. 3
0
        public void GetProgramIndexForAccessLog_IsMultiProgram_ReturnsCorrectIndex()
        {
            const int count = 7;

            Horizon hos = HorizonFactory.CreateBasicHorizon();

            var programs = new HorizonClient[count];

            programs[0] = hos.CreateHorizonClient(new ProgramLocation(new ProgramId(1), StorageId.BuiltInSystem),
                                                  AccessControlBits.Bits.RegisterProgramIndexMapInfo);

            for (int i = 1; i < programs.Length; i++)
            {
                programs[i] =
                    hos.CreateHorizonClient(new ProgramLocation(new ProgramId((ulong)(i + 1)), StorageId.BuiltInSystem),
                                            AccessControlBits.Bits.None);
            }

            var map = new ProgramIndexMapInfo[count];

            for (int i = 0; i < map.Length; i++)
            {
                map[i].MainProgramId = new ProgramId(1);
                map[i].ProgramId     = new ProgramId((ulong)(i + 1));
                map[i].ProgramIndex  = (byte)i;
            }

            Assert.Success(programs[0].Fs.RegisterProgramIndexMapInfo(map));

            for (int i = 0; i < programs.Length; i++)
            {
                using ReferenceCountedDisposable <LibHac.FsSrv.Sf.IFileSystemProxy> fsProxy =
                          programs[i].Fs.Impl.GetFileSystemProxyServiceObject();
                Assert.Success(fsProxy.Target.GetProgramIndexForAccessLog(out int programIndex, out int programCount));

                Assert.Equal(i, programIndex);
                Assert.Equal(count, programCount);
            }
        }
Esempio n. 4
0
        public void OpenFileSystemWithNoPermissions_ReturnsPermissionDenied()
        {
            Horizon hos = HorizonFactory.CreateBasicHorizon();

            HorizonClient regClient = hos.CreatePrivilegedHorizonClient();
            HorizonClient client    = hos.CreateHorizonClient();

            var dataHeader = new AccessControlDataHeader();
            var descriptor = new AccessControlDescriptor();

            descriptor.Version = 123;
            dataHeader.Version = 123;

            descriptor.AccessFlags = (ulong)AccessControlBits.Bits.None;
            dataHeader.AccessFlags = (ulong)AccessControlBits.Bits.None;

            Assert.Success(regClient.Fs.RegisterProgram(client.ProcessId.Value, new ProgramId(123),
                                                        StorageId.BuiltInUser, SpanHelpers.AsReadOnlyByteSpan(in dataHeader),
                                                        SpanHelpers.AsReadOnlyByteSpan(in descriptor)));

            Result rc = client.Fs.MountContent("test".ToU8Span(), "@System:/fake.nca".ToU8Span(), ContentType.Control);

            Assert.Result(ResultFs.PermissionDenied, rc);
        }