manager.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2019 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <map>
  6. #include <vector>
  7. #include "common/common_types.h"
  8. #include "core/file_sys/control_metadata.h"
  9. #include "core/file_sys/romfs_factory.h"
  10. #include "core/hle/result.h"
  11. namespace Service::Glue {
  12. struct ApplicationLaunchProperty {
  13. u64 title_id;
  14. u32 version;
  15. FileSys::StorageId base_game_storage_id;
  16. FileSys::StorageId update_storage_id;
  17. u8 program_index;
  18. u8 reserved;
  19. };
  20. static_assert(sizeof(ApplicationLaunchProperty) == 0x10,
  21. "ApplicationLaunchProperty has incorrect size.");
  22. // A class to manage state related to the arp:w and arp:r services, specifically the registration
  23. // and unregistration of launch and control properties.
  24. class ARPManager {
  25. public:
  26. ARPManager();
  27. ~ARPManager();
  28. // Returns the ApplicationLaunchProperty corresponding to the provided title ID if it was
  29. // previously registered, otherwise ERR_NOT_REGISTERED if it was never registered or
  30. // ERR_INVALID_PROCESS_ID if the title ID is 0.
  31. ResultVal<ApplicationLaunchProperty> GetLaunchProperty(u64 title_id) const;
  32. // Returns a vector of the raw bytes of NACP data (necessarily 0x4000 in size) corresponding to
  33. // the provided title ID if it was previously registered, otherwise ERR_NOT_REGISTERED if it was
  34. // never registered or ERR_INVALID_PROCESS_ID if the title ID is 0.
  35. ResultVal<std::vector<u8>> GetControlProperty(u64 title_id) const;
  36. // Adds a new entry to the internal database with the provided parameters, returning
  37. // ERR_INVALID_ACCESS if attempting to re-register a title ID without an intermediate Unregister
  38. // step, and ERR_INVALID_PROCESS_ID if the title ID is 0.
  39. ResultCode Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control);
  40. // Removes the registration for the provided title ID from the database, returning
  41. // ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID if the
  42. // title ID is 0.
  43. ResultCode Unregister(u64 title_id);
  44. // Removes all entries from the database, always succeeds. Should only be used when resetting
  45. // system state.
  46. void ResetAll();
  47. private:
  48. struct MapEntry;
  49. std::map<u64, MapEntry> entries;
  50. };
  51. } // namespace Service::Glue