ncm.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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(FileSys::StorageId id)
  14. : ServiceFramework{"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. FileSys::StorageId storage;
  43. };
  44. class IRegisteredLocationResolver final : public ServiceFramework<IRegisteredLocationResolver> {
  45. public:
  46. explicit IRegisteredLocationResolver() : ServiceFramework{"IRegisteredLocationResolver"} {
  47. // clang-format off
  48. static const FunctionInfo functions[] = {
  49. {0, nullptr, "ResolveProgramPath"},
  50. {1, nullptr, "RegisterProgramPath"},
  51. {2, nullptr, "UnregisterProgramPath"},
  52. {3, nullptr, "RedirectProgramPath"},
  53. {4, nullptr, "ResolveHtmlDocumentPath"},
  54. {5, nullptr, "RegisterHtmlDocumentPath"},
  55. {6, nullptr, "UnregisterHtmlDocumentPath"},
  56. {7, nullptr, "RedirectHtmlDocumentPath"},
  57. {8, nullptr, "Refresh"},
  58. {9, nullptr, "RefreshExcluding"},
  59. };
  60. // clang-format on
  61. RegisterHandlers(functions);
  62. }
  63. };
  64. class IAddOnContentLocationResolver final : public ServiceFramework<IAddOnContentLocationResolver> {
  65. public:
  66. explicit IAddOnContentLocationResolver() : ServiceFramework{"IAddOnContentLocationResolver"} {
  67. // clang-format off
  68. static const FunctionInfo functions[] = {
  69. {0, nullptr, "ResolveAddOnContentPath"},
  70. {1, nullptr, "RegisterAddOnContentStorage"},
  71. {2, nullptr, "UnregisterAllAddOnContentPath"},
  72. {3, nullptr, "RefreshApplicationAddOnContent"},
  73. {4, nullptr, "UnregisterApplicationAddOnContent"},
  74. };
  75. // clang-format on
  76. RegisterHandlers(functions);
  77. }
  78. };
  79. class LR final : public ServiceFramework<LR> {
  80. public:
  81. explicit LR() : ServiceFramework{"lr"} {
  82. // clang-format off
  83. static const FunctionInfo functions[] = {
  84. {0, nullptr, "OpenLocationResolver"},
  85. {1, nullptr, "OpenRegisteredLocationResolver"},
  86. {2, nullptr, "RefreshLocationResolver"},
  87. {3, nullptr, "OpenAddOnContentLocationResolver"},
  88. };
  89. // clang-format on
  90. RegisterHandlers(functions);
  91. }
  92. };
  93. class NCM final : public ServiceFramework<NCM> {
  94. public:
  95. explicit NCM() : ServiceFramework{"ncm"} {
  96. // clang-format off
  97. static const FunctionInfo functions[] = {
  98. {0, nullptr, "CreateContentStorage"},
  99. {1, nullptr, "CreateContentMetaDatabase"},
  100. {2, nullptr, "VerifyContentStorage"},
  101. {3, nullptr, "VerifyContentMetaDatabase"},
  102. {4, nullptr, "OpenContentStorage"},
  103. {5, nullptr, "OpenContentMetaDatabase"},
  104. {6, nullptr, "CloseContentStorageForcibly"},
  105. {7, nullptr, "CloseContentMetaDatabaseForcibly"},
  106. {8, nullptr, "CleanupContentMetaDatabase"},
  107. {9, nullptr, "ActivateContentStorage"},
  108. {10, nullptr, "InactivateContentStorage"},
  109. {11, nullptr, "ActivateContentMetaDatabase"},
  110. {12, nullptr, "InactivateContentMetaDatabase"},
  111. {13, nullptr, "InvalidateRightsIdCache"},
  112. {14, nullptr, "GetMemoryReport"},
  113. };
  114. // clang-format on
  115. RegisterHandlers(functions);
  116. }
  117. };
  118. void InstallInterfaces(SM::ServiceManager& sm) {
  119. std::make_shared<LR>()->InstallAsService(sm);
  120. std::make_shared<NCM>()->InstallAsService(sm);
  121. }
  122. } // namespace Service::NCM