ncm.cpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <memory>
  5. #include "core/file_sys/romfs_factory.h"
  6. #include "core/hle/ipc_helpers.h"
  7. #include "core/hle/service/ncm/ncm.h"
  8. #include "core/hle/service/service.h"
  9. #include "core/hle/service/sm/sm.h"
  10. namespace Service::NCM {
  11. class ILocationResolver final : public ServiceFramework<ILocationResolver> {
  12. public:
  13. explicit ILocationResolver(Core::System& system_, FileSys::StorageId id)
  14. : ServiceFramework{system_, "ILocationResolver"}, storage{id} {
  15. // clang-format off
  16. static const FunctionInfo functions[] = {
  17. {0, nullptr, "ResolveProgramPath"},
  18. {1, nullptr, "RedirectProgramPath"},
  19. {2, nullptr, "ResolveApplicationControlPath"},
  20. {3, nullptr, "ResolveApplicationHtmlDocumentPath"},
  21. {4, nullptr, "ResolveDataPath"},
  22. {5, nullptr, "RedirectApplicationControlPath"},
  23. {6, nullptr, "RedirectApplicationHtmlDocumentPath"},
  24. {7, nullptr, "ResolveApplicationLegalInformationPath"},
  25. {8, nullptr, "RedirectApplicationLegalInformationPath"},
  26. {9, nullptr, "Refresh"},
  27. {10, nullptr, "RedirectApplicationProgramPath"},
  28. {11, nullptr, "ClearApplicationRedirection"},
  29. {12, nullptr, "EraseProgramRedirection"},
  30. {13, nullptr, "EraseApplicationControlRedirection"},
  31. {14, nullptr, "EraseApplicationHtmlDocumentRedirection"},
  32. {15, nullptr, "EraseApplicationLegalInformationRedirection"},
  33. {16, nullptr, "ResolveProgramPathForDebug"},
  34. {17, nullptr, "RedirectProgramPathForDebug"},
  35. {18, nullptr, "RedirectApplicationProgramPathForDebug"},
  36. {19, nullptr, "EraseProgramRedirectionForDebug"},
  37. };
  38. // clang-format on
  39. RegisterHandlers(functions);
  40. }
  41. private:
  42. [[maybe_unused]] FileSys::StorageId storage;
  43. };
  44. class IRegisteredLocationResolver final : public ServiceFramework<IRegisteredLocationResolver> {
  45. public:
  46. explicit IRegisteredLocationResolver(Core::System& system_)
  47. : ServiceFramework{system_, "IRegisteredLocationResolver"} {
  48. // clang-format off
  49. static const FunctionInfo functions[] = {
  50. {0, nullptr, "ResolveProgramPath"},
  51. {1, nullptr, "RegisterProgramPath"},
  52. {2, nullptr, "UnregisterProgramPath"},
  53. {3, nullptr, "RedirectProgramPath"},
  54. {4, nullptr, "ResolveHtmlDocumentPath"},
  55. {5, nullptr, "RegisterHtmlDocumentPath"},
  56. {6, nullptr, "UnregisterHtmlDocumentPath"},
  57. {7, nullptr, "RedirectHtmlDocumentPath"},
  58. {8, nullptr, "Refresh"},
  59. {9, nullptr, "RefreshExcluding"},
  60. };
  61. // clang-format on
  62. RegisterHandlers(functions);
  63. }
  64. };
  65. class IAddOnContentLocationResolver final : public ServiceFramework<IAddOnContentLocationResolver> {
  66. public:
  67. explicit IAddOnContentLocationResolver(Core::System& system_)
  68. : ServiceFramework{system_, "IAddOnContentLocationResolver"} {
  69. // clang-format off
  70. static const FunctionInfo functions[] = {
  71. {0, nullptr, "ResolveAddOnContentPath"},
  72. {1, nullptr, "RegisterAddOnContentStorage"},
  73. {2, nullptr, "UnregisterAllAddOnContentPath"},
  74. {3, nullptr, "RefreshApplicationAddOnContent"},
  75. {4, nullptr, "UnregisterApplicationAddOnContent"},
  76. };
  77. // clang-format on
  78. RegisterHandlers(functions);
  79. }
  80. };
  81. class LR final : public ServiceFramework<LR> {
  82. public:
  83. explicit LR(Core::System& system_) : ServiceFramework{system_, "lr"} {
  84. // clang-format off
  85. static const FunctionInfo functions[] = {
  86. {0, nullptr, "OpenLocationResolver"},
  87. {1, nullptr, "OpenRegisteredLocationResolver"},
  88. {2, nullptr, "RefreshLocationResolver"},
  89. {3, nullptr, "OpenAddOnContentLocationResolver"},
  90. };
  91. // clang-format on
  92. RegisterHandlers(functions);
  93. }
  94. };
  95. class NCM final : public ServiceFramework<NCM> {
  96. public:
  97. explicit NCM(Core::System& system_) : ServiceFramework{system_, "ncm"} {
  98. // clang-format off
  99. static const FunctionInfo functions[] = {
  100. {0, nullptr, "CreateContentStorage"},
  101. {1, nullptr, "CreateContentMetaDatabase"},
  102. {2, nullptr, "VerifyContentStorage"},
  103. {3, nullptr, "VerifyContentMetaDatabase"},
  104. {4, nullptr, "OpenContentStorage"},
  105. {5, nullptr, "OpenContentMetaDatabase"},
  106. {6, nullptr, "CloseContentStorageForcibly"},
  107. {7, nullptr, "CloseContentMetaDatabaseForcibly"},
  108. {8, nullptr, "CleanupContentMetaDatabase"},
  109. {9, nullptr, "ActivateContentStorage"},
  110. {10, nullptr, "InactivateContentStorage"},
  111. {11, nullptr, "ActivateContentMetaDatabase"},
  112. {12, nullptr, "InactivateContentMetaDatabase"},
  113. {13, nullptr, "InvalidateRightsIdCache"},
  114. {14, nullptr, "GetMemoryReport"},
  115. };
  116. // clang-format on
  117. RegisterHandlers(functions);
  118. }
  119. };
  120. void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
  121. std::make_shared<LR>(system)->InstallAsService(sm);
  122. std::make_shared<NCM>(system)->InstallAsService(sm);
  123. }
  124. } // namespace Service::NCM