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); } }
public GameTableContextMenu(MainWindow parent, VirtualFileSystem virtualFileSystem, AccountManager accountManager, HorizonClient horizonClient, string titleFilePath, string titleName, string titleId, BlitStruct <ApplicationControlProperty> controlData) { _parent = parent; InitializeComponent(); _virtualFileSystem = virtualFileSystem; _accountManager = accountManager; _horizonClient = horizonClient; _titleFilePath = titleFilePath; _titleName = titleName; _titleIdText = titleId; _controlData = controlData; if (!ulong.TryParse(_titleIdText, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out _titleId)) { GtkDialog.CreateErrorDialog("The selected game did not have a valid Title Id"); return; } _openSaveUserDirMenuItem.Sensitive = !Utilities.IsZeros(controlData.ByteSpan) && controlData.Value.UserAccountSaveDataSize > 0; _openSaveDeviceDirMenuItem.Sensitive = !Utilities.IsZeros(controlData.ByteSpan) && controlData.Value.DeviceSaveDataSize > 0; _openSaveBcatDirMenuItem.Sensitive = !Utilities.IsZeros(controlData.ByteSpan) && controlData.Value.BcatDeliveryCacheStorageSize > 0; string fileExt = System.IO.Path.GetExtension(_titleFilePath).ToLower(); bool hasNca = fileExt == ".nca" || fileExt == ".nsp" || fileExt == ".pfs0" || fileExt == ".xci"; _extractRomFsMenuItem.Sensitive = hasNca; _extractExeFsMenuItem.Sensitive = hasNca; _extractLogoMenuItem.Sensitive = hasNca; PopupAtPointer(null); }
public void InitializeFsServer(LibHac.Horizon horizon, out HorizonClient fsServerClient) { LocalFileSystem serverBaseFs = new LocalFileSystem(AppDataManager.BaseDirPath); fsServerClient = horizon.CreatePrivilegedHorizonClient(); var fsServer = new FileSystemServer(fsServerClient); DefaultFsServerObjects fsServerObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(serverBaseFs, KeySet, fsServer); // Use our own encrypted fs creator that always uses all-zero keys fsServerObjects.FsCreators.EncryptedFileSystemCreator = new EncryptedFileSystemCreator(); GameCard = fsServerObjects.GameCard; SdCard = fsServerObjects.SdCard; SdCard.SetSdCardInsertionStatus(true); var fsServerConfig = new FileSystemServerConfig { DeviceOperator = fsServerObjects.DeviceOperator, ExternalKeySet = KeySet.ExternalKeySet, FsCreators = fsServerObjects.FsCreators }; FileSystemServerInitializer.InitializeWithConfig(fsServerClient, fsServer, fsServerConfig); }
public MultiCommitManager( ref ReferenceCountedDisposable <ISaveDataMultiCommitCoreInterface> multiCommitInterface, HorizonClient client) { Hos = client; MultiCommitInterface = Shared.Move(ref multiCommitInterface); }
private static Result FixExtraDataInSpaceId(HorizonClient hos, SaveDataSpaceId spaceId) { Span <SaveDataInfo> info = stackalloc SaveDataInfo[8]; using var iterator = new UniqueRef <SaveDataIterator>(); Result rc = hos.Fs.OpenSaveDataIterator(ref iterator.Ref(), spaceId); if (rc.IsFailure()) { return(rc); } while (true) { rc = iterator.Get.ReadSaveDataInfo(out long count, info); if (rc.IsFailure()) { return(rc); } if (count == 0) { return(Result.Success); } for (int i = 0; i < count; i++) { rc = FixExtraData(out bool wasFixNeeded, hos, in info[i]);
// Save data created before we supported extra data in directory save data will not work properly if // given empty extra data. Luckily some of that extra data can be created using the data from the // save data indexer, which should be enough to check access permissions for user saves. // Every single save data's extra data will be checked and fixed if needed each time the emulator is opened. // Consider removing this at some point in the future when we don't need to worry about old saves. public static Result FixExtraData(HorizonClient hos) { Result rc = GetSystemSaveList(hos, out List <ulong> systemSaveIds); if (rc.IsFailure()) { return(rc); } rc = FixUnindexedSystemSaves(hos, systemSaveIds); if (rc.IsFailure()) { return(rc); } rc = FixExtraDataInSpaceId(hos, SaveDataSpaceId.System); if (rc.IsFailure()) { return(rc); } rc = FixExtraDataInSpaceId(hos, SaveDataSpaceId.User); if (rc.IsFailure()) { return(rc); } return(Result.Success); }
public static void Initialize(VirtualFileSystem virtualFileSystem, AccountManager accountManager, HorizonClient horizonClient, StyleableWindow owner) { _owner = owner; _virtualFileSystem = virtualFileSystem; _horizonClient = horizonClient; _accountManager = accountManager; }
public AccountManager(HorizonClient horizonClient, string initialProfileName = null) { _horizonClient = horizonClient; _profiles = new ConcurrentDictionary <string, UserProfile>(); _accountSaveDataManager = new AccountSaveDataManager(_profiles); if (!_profiles.TryGetValue(DefaultUserId.ToString(), out _)) { byte[] defaultUserImage = EmbeddedResources.Read("Ryujinx.HLE/HOS/Services/Account/Acc/DefaultUserImage.jpg"); AddUser("RyuPlayer", defaultUserImage, DefaultUserId); OpenUser(DefaultUserId); } else { UserId commandLineUserProfileOverride = default; if (!string.IsNullOrEmpty(initialProfileName)) { commandLineUserProfileOverride = _profiles.Values.FirstOrDefault(x => x.Name == initialProfileName)?.UserId ?? default; if (commandLineUserProfileOverride.IsNull) { Logger.Warning?.Print(LogClass.Application, $"The command line specified profile named '{initialProfileName}' was not found"); } } OpenUser(commandLineUserProfileOverride.IsNull ? _accountSaveDataManager.LastOpened : commandLineUserProfileOverride); } }
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); }
public FileSystemClient(HorizonClient horizonClient) { Hos = horizonClient; Time = horizonClient.Time; Assert.NotNull(Time); }
public static Horizon CreateBasicHorizon() { IFileSystem rootFs = new InMemoryFileSystem(); var keySet = new KeySet(); var horizon = new Horizon(new HorizonConfiguration()); HorizonClient fsServerClient = horizon.CreatePrivilegedHorizonClient(); var fsServer = new FileSystemServer(fsServerClient); var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, keySet, fsServer); var config = new FileSystemServerConfig(); config.FsCreators = defaultObjects.FsCreators; config.DeviceOperator = defaultObjects.DeviceOperator; config.ExternalKeySet = new ExternalKeySet(); FileSystemServerInitializer.InitializeWithConfig(fsServerClient, fsServer, config); HorizonClient bcatServerClient = horizon.CreateHorizonClient(); _ = new BcatServer(bcatServerClient); return(horizon); }
public void InitializeSystemClients() { AccountClient = Server.CreateHorizonClient(new ProgramLocation(SystemProgramId.Account, StorageId.BuiltInSystem), AccountFsPermissions); AmClient = Server.CreateHorizonClient(new ProgramLocation(SystemProgramId.Am, StorageId.BuiltInSystem), AmFsPermissions); NsClient = Server.CreateHorizonClient(new ProgramLocation(SystemProgramId.Ns, StorageId.BuiltInSystem), NsFsPermissions); SdbClient = Server.CreateHorizonClient(new ProgramLocation(SystemProgramId.Sdb, StorageId.BuiltInSystem), SdbFacData, SdbFacDescriptor); }
public void Initialize(HorizonClient horizonClient, FileSystemServer fsServer) { Hos = horizonClient; InitMutex = new object(); SaveDataSharedFileStorage.Initialize(fsServer); }
public Result LoadFromFile(HorizonClient hos, FileHandle file) { _isValid = false; // Get file size Result rc = hos.Fs.GetFileSize(out long npdmSize, file); if (rc.IsFailure()) { return(rc); } if (npdmSize > MetaCacheBufferSize) { return(ResultLoader.TooLargeMeta.Log()); } // Read data into cache buffer rc = hos.Fs.ReadFile(file, 0, _npdmBuffer.AsSpan(0, (int)npdmSize)); if (rc.IsFailure()) { return(rc); } // Validate the meta rc = GetNpdmFromBuffer(out _, _npdmBuffer); if (rc.IsFailure()) { return(rc); } _isValid = true; return(Result.Success); }
private static FileSystemClient CreateClientImpl(bool sdCardInserted, out IFileSystem rootFs) { Horizon horizon = CreateHorizonImpl(sdCardInserted, out rootFs); HorizonClient horizonClient = horizon.CreatePrivilegedHorizonClient(); return(horizonClient.Fs); }
public void Initialize(FileSystemClient fsClient, HorizonClient horizonClient) { Hos = horizonClient; InitMutex = new object(); AccessLog.Initialize(fsClient); UserMountTable.Initialize(fsClient); FsContextHandler.Initialize(fsClient); }
public ResultCode InitializeDatabase(HorizonClient horizonClient) { _miiDatabase.InitializeDatabase(horizonClient); _miiDatabase.LoadFromFile(out _isBroken); // Nintendo ignore any error code from before return(ResultCode.Success); }
public static ReferenceCountedDisposable <IMultiCommitManager> CreateShared( ref ReferenceCountedDisposable <ISaveDataMultiCommitCoreInterface> multiCommitInterface, HorizonClient client) { var manager = new MultiCommitManager(ref multiCommitInterface, client); return(new ReferenceCountedDisposable <IMultiCommitManager>(manager)); }
public BcatServer(HorizonClient horizonClient) { Hos = horizonClient; InitBcatService(BcatServiceType.BcatU, "bcat:u", AccessControl.MountOwnDeliveryCacheStorage); InitBcatService(BcatServiceType.BcatS, "bcat:s", AccessControl.MountOthersDeliveryCacheStorage); InitBcatService(BcatServiceType.BcatM, "bcat:m", AccessControl.MountOthersDeliveryCacheStorage | AccessControl.DeliveryTaskManagement); InitBcatService(BcatServiceType.BcatA, "bcat:a", AccessControl.All); }
public void InitializeDatabase(HorizonClient horizonClient) { _horizonClient = horizonClient; // Ensure we have valid data in the database _database.Format(); MountSave(); }
//Ctor for tests public DepositTrackerJob( IAccountsRepository accountRepository, HorizonClient horizonClient, IUserRepository userRepository) { this.accountRepository = accountRepository; this.userRepository = userRepository; this.horizonClient = horizonClient; }
//Ctor for tests public WithdrawJob( ITransactionRepository transactionRepository, HorizonClient horizonClient, IUserRepository userRepository) { this.transactionRepository = transactionRepository; this.userRepository = userRepository; this.horizonClient = horizonClient; }
public ResultCode InitializeDatabase(ITickSource tickSource, HorizonClient horizonClient) { _utilityImpl = new UtilityImpl(tickSource); _miiDatabase.InitializeDatabase(horizonClient); _miiDatabase.LoadFromFile(out _isBroken); // Nintendo ignores any error code from before. return(ResultCode.Success); }
public IApplicationFunctions(Horizon system) { // TODO: Find where they are signaled. _gpuErrorDetectedSystemEvent = new KEvent(system.KernelContext); _friendInvitationStorageChannelEvent = new KEvent(system.KernelContext); _notificationStorageChannelEvent = new KEvent(system.KernelContext); _healthWarningDisappearedSystemEvent = new KEvent(system.KernelContext); _horizon = system.LibHacHorizonManager.AmClient; }
public void Initialize(FileSystemClient fsClient, HorizonClient horizonClient) { Hos = horizonClient; InitMutex = new object(); AccessLog.Initialize(fsClient); UserMountTable.Initialize(fsClient); FsContextHandler.Initialize(fsClient); PathUtility.Initialize(fsClient); DirectorySaveDataFileSystem.Initialize(fsClient); }
private void InitLibHacHorizon() { LibHac.Horizon horizon = new LibHac.Horizon(null, Device.FileSystem.FsServer); horizon.CreateHorizonClient(out HorizonClient ryujinxClient).ThrowIfFailure(); horizon.CreateHorizonClient(out HorizonClient bcatClient).ThrowIfFailure(); ryujinxClient.Sm.RegisterService(new LibHacIReader(this), "arp:r").ThrowIfFailure(); new BcatServer(bcatClient); LibHacHorizonServer = horizon; LibHacHorizonClient = ryujinxClient; }
/// <summary> /// Creates a new <see cref="FileSystemServer"/> and registers its services using the provided HOS client. /// </summary> /// <param name="horizonClient">The <see cref="HorizonClient"/> that will be used by this server.</param> /// <param name="config">The configuration for the created <see cref="FileSystemServer"/>.</param> public FileSystemServer(HorizonClient horizonClient, FileSystemServerConfig config) { if (config.FsCreators == null) { throw new ArgumentException("FsCreators must not be null"); } if (config.DeviceOperator == null) { throw new ArgumentException("DeviceOperator must not be null"); } Hos = horizonClient; IsDebugMode = false; ExternalKeySet externalKeySet = config.ExternalKeySet ?? new ExternalKeySet(); Timer = config.TimeSpanGenerator ?? new StopWatchTimeSpanGenerator(); var fspConfig = new FileSystemProxyConfiguration { FsCreatorInterfaces = config.FsCreators, ProgramRegistryServiceImpl = new ProgramRegistryServiceImpl(this) }; FsProxyCore = new FileSystemProxyCore(fspConfig, externalKeySet, config.DeviceOperator); FsProxyCore.SetSaveDataIndexerManager(new SaveDataIndexerManager(Hos.Fs, SaveIndexerId, new ArrayPoolMemoryResource(), new SdHandleManager(), false)); FileSystemProxy fsProxy = GetFileSystemProxyServiceObject(); fsProxy.SetCurrentProcess(Hos.Os.GetCurrentProcessId().Value).IgnoreResult(); fsProxy.CleanUpTemporaryStorage().IgnoreResult(); Hos.Sm.RegisterService(new FileSystemProxyService(this), "fsp-srv").IgnoreResult(); Hos.Sm.RegisterService(new FileSystemProxyForLoaderService(this), "fsp-ldr").IgnoreResult(); Hos.Sm.RegisterService(new ProgramRegistryService(this), "fsp-pr").IgnoreResult(); // NS usually takes care of this if (Hos.Fs.IsSdCardInserted()) { Hos.Fs.SetSdCardAccessibility(true); } }
private static FileSystemClient CreateClientImpl(bool sdCardInserted, out IFileSystem rootFs) { rootFs = new InMemoryFileSystem(); var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, new KeySet()); defaultObjects.SdCard.SetSdCardInsertionStatus(sdCardInserted); var config = new FileSystemServerConfig(); config.FsCreators = defaultObjects.FsCreators; config.DeviceOperator = defaultObjects.DeviceOperator; config.ExternalKeySet = new ExternalKeySet(); Horizon horizon = LibHac.HorizonFactory.CreateWithFsConfig(new HorizonConfiguration(), config); HorizonClient horizonClient = horizon.CreatePrivilegedHorizonClient(); return(horizonClient.Fs); }
public AccountManager(HorizonClient horizonClient) { _horizonClient = horizonClient; _profiles = new ConcurrentDictionary <string, UserProfile>(); _accountSaveDataManager = new AccountSaveDataManager(_profiles); if (!_profiles.TryGetValue(DefaultUserId.ToString(), out _)) { byte[] defaultUserImage = EmbeddedResources.Read("Ryujinx.HLE/HOS/Services/Account/Acc/DefaultUserImage.jpg"); AddUser("RyuPlayer", defaultUserImage, DefaultUserId); OpenUser(DefaultUserId); } else { OpenUser(_accountSaveDataManager.LastOpened); } }
/// <summary> /// If services was not injected by constructor GetRepositories method will extracts them form job context /// </summary> /// <param name="context"></param> private void GetRepositories(IJobExecutionContext context) { //Get account repository instance if (accountRepository == null) { accountRepository = context.Scheduler.Context[Constans.DATA_MAP_ACCOUNT_REPO] as IAccountsRepository; } if (userRepository == null) { userRepository = context.Scheduler.Context[Constans.DATA_MAP_USER_REPO] as IUserRepository; } if (horizonClient == null) { horizonClient = context.Scheduler.Context[Constans.DATA_MAP_HORIZON_CLIENT] as HorizonClient; } }