glue_manager.h 2.3 KB

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