Explorar o código

Merge pull request #5018 from lioncash/service-global

service: Eliminate usages of the global system instance
Rodrigo Locatti %!s(int64=5) %!d(string=hai) anos
pai
achega
ee5e77fbf9
Modificáronse 100 ficheiros con 514 adicións e 401 borrados
  1. 48 40
      src/core/hle/service/acc/acc.cpp
  2. 2 3
      src/core/hle/service/acc/acc.h
  3. 40 34
      src/core/hle/service/am/am.cpp
  4. 11 19
      src/core/hle/service/am/am.h
  5. 24 25
      src/core/hle/service/am/applet_ae.cpp
  6. 2 3
      src/core/hle/service/am/applet_ae.h
  7. 12 12
      src/core/hle/service/am/applet_oe.cpp
  8. 2 3
      src/core/hle/service/am/applet_oe.h
  9. 2 2
      src/core/hle/service/am/applets/controller.cpp
  10. 1 0
      src/core/hle/service/am/applets/controller.h
  11. 2 2
      src/core/hle/service/am/applets/error.cpp
  12. 13 11
      src/core/hle/service/am/applets/general_backend.cpp
  13. 2 1
      src/core/hle/service/am/applets/general_backend.h
  14. 3 3
      src/core/hle/service/am/applets/profile_select.cpp
  15. 1 0
      src/core/hle/service/am/applets/profile_select.h
  16. 8 6
      src/core/hle/service/am/applets/software_keyboard.cpp
  17. 1 0
      src/core/hle/service/am/applets/software_keyboard.h
  18. 1 1
      src/core/hle/service/am/applets/web_browser.cpp
  19. 1 1
      src/core/hle/service/am/idle.cpp
  20. 5 1
      src/core/hle/service/am/idle.h
  21. 1 1
      src/core/hle/service/am/omm.cpp
  22. 5 1
      src/core/hle/service/am/omm.h
  23. 1 1
      src/core/hle/service/am/spsm.cpp
  24. 5 1
      src/core/hle/service/am/spsm.h
  25. 1 1
      src/core/hle/service/am/tcap.cpp
  26. 5 1
      src/core/hle/service/am/tcap.h
  27. 2 2
      src/core/hle/service/aoc/aoc_u.cpp
  28. 4 1
      src/core/hle/service/aoc/aoc_u.h
  29. 5 4
      src/core/hle/service/apm/apm.cpp
  30. 3 1
      src/core/hle/service/apm/apm.h
  31. 9 6
      src/core/hle/service/apm/interface.cpp
  32. 3 2
      src/core/hle/service/apm/interface.h
  33. 1 1
      src/core/hle/service/audio/audctl.cpp
  34. 5 1
      src/core/hle/service/audio/audctl.h
  35. 1 1
      src/core/hle/service/audio/auddbg.cpp
  36. 5 1
      src/core/hle/service/audio/auddbg.h
  37. 1 1
      src/core/hle/service/audio/audin_a.cpp
  38. 5 1
      src/core/hle/service/audio/audin_a.h
  39. 3 3
      src/core/hle/service/audio/audin_u.cpp
  40. 5 1
      src/core/hle/service/audio/audin_u.h
  41. 13 13
      src/core/hle/service/audio/audio.cpp
  42. 1 1
      src/core/hle/service/audio/audout_a.cpp
  43. 5 1
      src/core/hle/service/audio/audout_a.h
  44. 6 6
      src/core/hle/service/audio/audout_u.cpp
  45. 0 2
      src/core/hle/service/audio/audout_u.h
  46. 1 1
      src/core/hle/service/audio/audrec_a.cpp
  47. 5 1
      src/core/hle/service/audio/audrec_a.h
  48. 3 2
      src/core/hle/service/audio/audrec_u.cpp
  49. 3 3
      src/core/hle/service/audio/audrec_u.h
  50. 1 1
      src/core/hle/service/audio/audren_a.cpp
  51. 5 1
      src/core/hle/service/audio/audren_a.h
  52. 4 4
      src/core/hle/service/audio/audren_u.cpp
  53. 0 1
      src/core/hle/service/audio/audren_u.h
  54. 1 4
      src/core/hle/service/audio/codecctl.cpp
  55. 3 3
      src/core/hle/service/audio/codecctl.h
  56. 5 4
      src/core/hle/service/audio/hwopus.cpp
  57. 5 1
      src/core/hle/service/audio/hwopus.h
  58. 20 20
      src/core/hle/service/bcat/module.cpp
  59. 0 3
      src/core/hle/service/bcat/module.h
  60. 5 5
      src/core/hle/service/bpc/bpc.cpp
  61. 5 1
      src/core/hle/service/bpc/bpc.h
  62. 3 3
      src/core/hle/service/btdrv/btdrv.cpp
  63. 10 12
      src/core/hle/service/btm/btm.cpp
  64. 7 7
      src/core/hle/service/caps/caps.cpp
  65. 5 1
      src/core/hle/service/caps/caps.h
  66. 3 2
      src/core/hle/service/caps/caps_a.cpp
  67. 5 1
      src/core/hle/service/caps/caps_a.h
  68. 3 2
      src/core/hle/service/caps/caps_c.cpp
  69. 5 1
      src/core/hle/service/caps/caps_c.h
  70. 1 1
      src/core/hle/service/caps/caps_sc.cpp
  71. 3 3
      src/core/hle/service/caps/caps_sc.h
  72. 1 1
      src/core/hle/service/caps/caps_ss.cpp
  73. 3 3
      src/core/hle/service/caps/caps_ss.h
  74. 1 1
      src/core/hle/service/caps/caps_su.cpp
  75. 5 1
      src/core/hle/service/caps/caps_su.h
  76. 3 3
      src/core/hle/service/caps/caps_u.cpp
  77. 5 1
      src/core/hle/service/caps/caps_u.h
  78. 5 5
      src/core/hle/service/erpt/erpt.cpp
  79. 5 1
      src/core/hle/service/erpt/erpt.h
  80. 3 3
      src/core/hle/service/es/es.cpp
  81. 5 1
      src/core/hle/service/es/es.h
  82. 5 5
      src/core/hle/service/eupld/eupld.cpp
  83. 5 1
      src/core/hle/service/eupld/eupld.h
  84. 3 2
      src/core/hle/service/fatal/fatal.cpp
  85. 2 2
      src/core/hle/service/fatal/fatal.h
  86. 2 2
      src/core/hle/service/fatal/fatal_p.cpp
  87. 1 1
      src/core/hle/service/fatal/fatal_p.h
  88. 2 2
      src/core/hle/service/fatal/fatal_u.cpp
  89. 1 1
      src/core/hle/service/fatal/fatal_u.h
  90. 9 9
      src/core/hle/service/fgm/fgm.cpp
  91. 5 1
      src/core/hle/service/fgm/fgm.h
  92. 3 5
      src/core/hle/service/filesystem/filesystem.cpp
  93. 1 1
      src/core/hle/service/filesystem/fsp_ldr.cpp
  94. 5 1
      src/core/hle/service/filesystem/fsp_ldr.h
  95. 1 1
      src/core/hle/service/filesystem/fsp_pr.cpp
  96. 5 1
      src/core/hle/service/filesystem/fsp_pr.h
  97. 31 26
      src/core/hle/service/filesystem/fsp_srv.cpp
  98. 1 2
      src/core/hle/service/filesystem/fsp_srv.h
  99. 7 6
      src/core/hle/service/friend/friend.cpp
  100. 2 2
      src/core/hle/service/friend/friend.h

+ 48 - 40
src/core/hle/service/acc/acc.cpp

@@ -47,8 +47,8 @@ static constexpr u32 SanitizeJPEGSize(std::size_t size) {
 
 class IManagerForSystemService final : public ServiceFramework<IManagerForSystemService> {
 public:
-    explicit IManagerForSystemService(Common::UUID user_id)
-        : ServiceFramework("IManagerForSystemService") {
+    explicit IManagerForSystemService(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "IManagerForSystemService"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "CheckAvailability"},
@@ -83,8 +83,8 @@ public:
 // 3.0.0+
 class IFloatingRegistrationRequest final : public ServiceFramework<IFloatingRegistrationRequest> {
 public:
-    explicit IFloatingRegistrationRequest(Common::UUID user_id)
-        : ServiceFramework("IFloatingRegistrationRequest") {
+    explicit IFloatingRegistrationRequest(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "IFloatingRegistrationRequest"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "GetSessionId"},
@@ -108,7 +108,8 @@ public:
 
 class IAdministrator final : public ServiceFramework<IAdministrator> {
 public:
-    explicit IAdministrator(Common::UUID user_id) : ServiceFramework("IAdministrator") {
+    explicit IAdministrator(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "IAdministrator"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "CheckAvailability"},
@@ -165,8 +166,8 @@ public:
 
 class IAuthorizationRequest final : public ServiceFramework<IAuthorizationRequest> {
 public:
-    explicit IAuthorizationRequest(Common::UUID user_id)
-        : ServiceFramework("IAuthorizationRequest") {
+    explicit IAuthorizationRequest(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "IAuthorizationRequest"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "GetSessionId"},
@@ -184,7 +185,8 @@ public:
 
 class IOAuthProcedure final : public ServiceFramework<IOAuthProcedure> {
 public:
-    explicit IOAuthProcedure(Common::UUID user_id) : ServiceFramework("IOAuthProcedure") {
+    explicit IOAuthProcedure(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "IOAuthProcedure"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "PrepareAsync"},
@@ -202,8 +204,8 @@ public:
 // 3.0.0+
 class IOAuthProcedureForExternalNsa final : public ServiceFramework<IOAuthProcedureForExternalNsa> {
 public:
-    explicit IOAuthProcedureForExternalNsa(Common::UUID user_id)
-        : ServiceFramework("IOAuthProcedureForExternalNsa") {
+    explicit IOAuthProcedureForExternalNsa(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "IOAuthProcedureForExternalNsa"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "PrepareAsync"},
@@ -225,8 +227,8 @@ public:
 class IOAuthProcedureForNintendoAccountLinkage final
     : public ServiceFramework<IOAuthProcedureForNintendoAccountLinkage> {
 public:
-    explicit IOAuthProcedureForNintendoAccountLinkage(Common::UUID user_id)
-        : ServiceFramework("IOAuthProcedureForNintendoAccountLinkage") {
+    explicit IOAuthProcedureForNintendoAccountLinkage(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "IOAuthProcedureForNintendoAccountLinkage"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "PrepareAsync"},
@@ -246,7 +248,8 @@ public:
 
 class INotifier final : public ServiceFramework<INotifier> {
 public:
-    explicit INotifier(Common::UUID user_id) : ServiceFramework("INotifier") {
+    explicit INotifier(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "INotifier"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "GetSystemEvent"},
@@ -259,9 +262,9 @@ public:
 
 class IProfileCommon : public ServiceFramework<IProfileCommon> {
 public:
-    explicit IProfileCommon(const char* name, bool editor_commands, Common::UUID user_id,
-                            ProfileManager& profile_manager)
-        : ServiceFramework(name), profile_manager(profile_manager), user_id(user_id) {
+    explicit IProfileCommon(Core::System& system_, const char* name, bool editor_commands,
+                            Common::UUID user_id_, ProfileManager& profile_manager_)
+        : ServiceFramework{system_, name}, profile_manager{profile_manager_}, user_id{user_id_} {
         static const FunctionInfo functions[] = {
             {0, &IProfileCommon::Get, "Get"},
             {1, &IProfileCommon::GetBase, "GetBase"},
@@ -427,19 +430,21 @@ protected:
 
 class IProfile final : public IProfileCommon {
 public:
-    IProfile(Common::UUID user_id, ProfileManager& profile_manager)
-        : IProfileCommon("IProfile", false, user_id, profile_manager) {}
+    explicit IProfile(Core::System& system_, Common::UUID user_id_,
+                      ProfileManager& profile_manager_)
+        : IProfileCommon{system_, "IProfile", false, user_id_, profile_manager_} {}
 };
 
 class IProfileEditor final : public IProfileCommon {
 public:
-    IProfileEditor(Common::UUID user_id, ProfileManager& profile_manager)
-        : IProfileCommon("IProfileEditor", true, user_id, profile_manager) {}
+    explicit IProfileEditor(Core::System& system_, Common::UUID user_id_,
+                            ProfileManager& profile_manager_)
+        : IProfileCommon{system_, "IProfileEditor", true, user_id_, profile_manager_} {}
 };
 
 class IAsyncContext final : public ServiceFramework<IAsyncContext> {
 public:
-    explicit IAsyncContext(Common::UUID user_id) : ServiceFramework("IAsyncContext") {
+    explicit IAsyncContext(Core::System& system_) : ServiceFramework{system_, "IAsyncContext"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "GetSystemEvent"},
@@ -455,7 +460,8 @@ public:
 
 class ISessionObject final : public ServiceFramework<ISessionObject> {
 public:
-    explicit ISessionObject(Common::UUID user_id) : ServiceFramework("ISessionObject") {
+    explicit ISessionObject(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "ISessionObject"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {999, nullptr, "Dummy"},
@@ -468,7 +474,8 @@ public:
 
 class IGuestLoginRequest final : public ServiceFramework<IGuestLoginRequest> {
 public:
-    explicit IGuestLoginRequest(Common::UUID) : ServiceFramework("IGuestLoginRequest") {
+    explicit IGuestLoginRequest(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "IGuestLoginRequest"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "GetSessionId"},
@@ -487,8 +494,8 @@ public:
 
 class IManagerForApplication final : public ServiceFramework<IManagerForApplication> {
 public:
-    explicit IManagerForApplication(Common::UUID user_id)
-        : ServiceFramework("IManagerForApplication"), user_id(user_id) {
+    explicit IManagerForApplication(Core::System& system_, Common::UUID user_id_)
+        : ServiceFramework{system_, "IManagerForApplication"}, user_id{user_id_} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &IManagerForApplication::CheckAvailability, "CheckAvailability"},
@@ -534,8 +541,8 @@ private:
 class IAsyncNetworkServiceLicenseKindContext final
     : public ServiceFramework<IAsyncNetworkServiceLicenseKindContext> {
 public:
-    explicit IAsyncNetworkServiceLicenseKindContext(Common::UUID user_id)
-        : ServiceFramework("IAsyncNetworkServiceLicenseKindContext") {
+    explicit IAsyncNetworkServiceLicenseKindContext(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "IAsyncNetworkServiceLicenseKindContext"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "GetSystemEvent"},
@@ -554,8 +561,8 @@ public:
 class IOAuthProcedureForUserRegistration final
     : public ServiceFramework<IOAuthProcedureForUserRegistration> {
 public:
-    explicit IOAuthProcedureForUserRegistration(Common::UUID user_id)
-        : ServiceFramework("IOAuthProcedureForUserRegistration") {
+    explicit IOAuthProcedureForUserRegistration(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "IOAuthProcedureForUserRegistration"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "PrepareAsync"},
@@ -578,7 +585,7 @@ public:
 
 class DAUTH_O final : public ServiceFramework<DAUTH_O> {
 public:
-    explicit DAUTH_O(Common::UUID) : ServiceFramework("dauth:o") {
+    explicit DAUTH_O(Core::System& system_, Common::UUID) : ServiceFramework{system_, "dauth:o"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "EnsureAuthenticationTokenCacheAsync"}, // [5.0.0-5.1.0] GeneratePostData
@@ -597,7 +604,8 @@ public:
 // 6.0.0+
 class IAsyncResult final : public ServiceFramework<IAsyncResult> {
 public:
-    explicit IAsyncResult(Common::UUID user_id) : ServiceFramework("IAsyncResult") {
+    explicit IAsyncResult(Core::System& system_, Common::UUID)
+        : ServiceFramework{system_, "IAsyncResult"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "GetResult"},
@@ -656,7 +664,7 @@ void Module::Interface::GetProfile(Kernel::HLERequestContext& ctx) {
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<IProfile>(user_id, *profile_manager);
+    rb.PushIpcInterface<IProfile>(system, user_id, *profile_manager);
 }
 
 void Module::Interface::IsUserRegistrationRequestPermitted(Kernel::HLERequestContext& ctx) {
@@ -731,7 +739,7 @@ void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestCo
     LOG_DEBUG(Service_ACC, "called");
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<IManagerForApplication>(profile_manager->GetLastOpenedUser());
+    rb.PushIpcInterface<IManagerForApplication>(system, profile_manager->GetLastOpenedUser());
 }
 
 void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx) {
@@ -769,7 +777,7 @@ void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) {
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<IProfileEditor>(user_id, *profile_manager);
+    rb.PushIpcInterface<IProfileEditor>(system, user_id, *profile_manager);
 }
 
 void Module::Interface::ListQualifiedUsers(Kernel::HLERequestContext& ctx) {
@@ -791,7 +799,7 @@ void Module::Interface::LoadOpenContext(Kernel::HLERequestContext& ctx) {
     // TODO: Find the differences between this and GetBaasAccountManagerForApplication
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<IManagerForApplication>(profile_manager->GetLastOpenedUser());
+    rb.PushIpcInterface<IManagerForApplication>(system, profile_manager->GetLastOpenedUser());
 }
 
 void Module::Interface::ListOpenContextStoredUsers(Kernel::HLERequestContext& ctx) {
@@ -827,11 +835,11 @@ void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContex
     rb.PushRaw<u128>(profile_manager->GetUser(0)->uuid);
 }
 
-Module::Interface::Interface(std::shared_ptr<Module> module,
-                             std::shared_ptr<ProfileManager> profile_manager, Core::System& system,
-                             const char* name)
-    : ServiceFramework(name), module(std::move(module)),
-      profile_manager(std::move(profile_manager)), system(system) {}
+Module::Interface::Interface(std::shared_ptr<Module> module_,
+                             std::shared_ptr<ProfileManager> profile_manager_,
+                             Core::System& system_, const char* name)
+    : ServiceFramework{system_, name}, module{std::move(module_)}, profile_manager{std::move(
+                                                                       profile_manager_)} {}
 
 Module::Interface::~Interface() = default;
 

+ 2 - 3
src/core/hle/service/acc/acc.h

@@ -15,8 +15,8 @@ class Module final {
 public:
     class Interface : public ServiceFramework<Interface> {
     public:
-        explicit Interface(std::shared_ptr<Module> module,
-                           std::shared_ptr<ProfileManager> profile_manager, Core::System& system,
+        explicit Interface(std::shared_ptr<Module> module_,
+                           std::shared_ptr<ProfileManager> profile_manager_, Core::System& system_,
                            const char* name);
         ~Interface() override;
 
@@ -60,7 +60,6 @@ public:
     protected:
         std::shared_ptr<Module> module;
         std::shared_ptr<ProfileManager> profile_manager;
-        Core::System& system;
     };
 };
 

+ 40 - 34
src/core/hle/service/am/am.cpp

@@ -64,7 +64,7 @@ struct LaunchParameterAccountPreselectedUser {
 static_assert(sizeof(LaunchParameterAccountPreselectedUser) == 0x88);
 
 IWindowController::IWindowController(Core::System& system_)
-    : ServiceFramework("IWindowController"), system{system_} {
+    : ServiceFramework{system_, "IWindowController"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "CreateWindow"},
@@ -99,7 +99,8 @@ void IWindowController::AcquireForegroundRights(Kernel::HLERequestContext& ctx)
     rb.Push(RESULT_SUCCESS);
 }
 
-IAudioController::IAudioController() : ServiceFramework("IAudioController") {
+IAudioController::IAudioController(Core::System& system_)
+    : ServiceFramework{system_, "IAudioController"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, &IAudioController::SetExpectedMasterVolume, "SetExpectedMasterVolume"},
@@ -180,7 +181,8 @@ void IAudioController::SetTransparentAudioRate(Kernel::HLERequestContext& ctx) {
     rb.Push(RESULT_SUCCESS);
 }
 
-IDisplayController::IDisplayController() : ServiceFramework("IDisplayController") {
+IDisplayController::IDisplayController(Core::System& system_)
+    : ServiceFramework{system_, "IDisplayController"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "GetLastForegroundCaptureImage"},
@@ -219,7 +221,8 @@ IDisplayController::IDisplayController() : ServiceFramework("IDisplayController"
 
 IDisplayController::~IDisplayController() = default;
 
-IDebugFunctions::IDebugFunctions() : ServiceFramework{"IDebugFunctions"} {
+IDebugFunctions::IDebugFunctions(Core::System& system_)
+    : ServiceFramework{system_, "IDebugFunctions"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "NotifyMessageToHomeMenuForDebug"},
@@ -246,8 +249,8 @@ IDebugFunctions::IDebugFunctions() : ServiceFramework{"IDebugFunctions"} {
 
 IDebugFunctions::~IDebugFunctions() = default;
 
-ISelfController::ISelfController(Core::System& system, NVFlinger::NVFlinger& nvflinger)
-    : ServiceFramework("ISelfController"), system(system), nvflinger(nvflinger) {
+ISelfController::ISelfController(Core::System& system_, NVFlinger::NVFlinger& nvflinger_)
+    : ServiceFramework{system_, "ISelfController"}, nvflinger{nvflinger_} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, &ISelfController::Exit, "Exit"},
@@ -605,9 +608,9 @@ void AppletMessageQueue::RequestExit() {
     PushMessage(AppletMessage::ExitRequested);
 }
 
-ICommonStateGetter::ICommonStateGetter(Core::System& system,
-                                       std::shared_ptr<AppletMessageQueue> msg_queue)
-    : ServiceFramework("ICommonStateGetter"), system(system), msg_queue(std::move(msg_queue)) {
+ICommonStateGetter::ICommonStateGetter(Core::System& system_,
+                                       std::shared_ptr<AppletMessageQueue> msg_queue_)
+    : ServiceFramework{system_, "ICommonStateGetter"}, msg_queue{std::move(msg_queue_)} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, &ICommonStateGetter::GetEventHandle, "GetEventHandle"},
@@ -795,8 +798,9 @@ private:
     std::vector<u8> buffer;
 };
 
-IStorage::IStorage(std::vector<u8>&& buffer)
-    : ServiceFramework("IStorage"), impl{std::make_shared<StorageDataImpl>(std::move(buffer))} {
+IStorage::IStorage(Core::System& system_, std::vector<u8>&& buffer)
+    : ServiceFramework{system_, "IStorage"}, impl{std::make_shared<StorageDataImpl>(
+                                                 std::move(buffer))} {
     Register();
 }
 
@@ -819,7 +823,7 @@ void IStorage::Open(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
 
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<IStorageAccessor>(*this);
+    rb.PushIpcInterface<IStorageAccessor>(system, *this);
 }
 
 void ICommonStateGetter::GetOperationMode(Kernel::HLERequestContext& ctx) {
@@ -841,8 +845,8 @@ void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
 
 class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> {
 public:
-    explicit ILibraryAppletAccessor(std::shared_ptr<Applets::Applet> applet)
-        : ServiceFramework("ILibraryAppletAccessor"), applet(std::move(applet)) {
+    explicit ILibraryAppletAccessor(Core::System& system_, std::shared_ptr<Applets::Applet> applet_)
+        : ServiceFramework{system_, "ILibraryAppletAccessor"}, applet{std::move(applet_)} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"},
@@ -997,8 +1001,8 @@ private:
     std::shared_ptr<Applets::Applet> applet;
 };
 
-IStorageAccessor::IStorageAccessor(IStorage& storage)
-    : ServiceFramework("IStorageAccessor"), backing(storage) {
+IStorageAccessor::IStorageAccessor(Core::System& system_, IStorage& backing_)
+    : ServiceFramework{system_, "IStorageAccessor"}, backing{backing_} {
     // clang-format off
         static const FunctionInfo functions[] = {
             {0, &IStorageAccessor::GetSize, "GetSize"},
@@ -1069,7 +1073,7 @@ void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) {
 }
 
 ILibraryAppletCreator::ILibraryAppletCreator(Core::System& system_)
-    : ServiceFramework("ILibraryAppletCreator"), system{system_} {
+    : ServiceFramework{system_, "ILibraryAppletCreator"} {
     static const FunctionInfo functions[] = {
         {0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"},
         {1, nullptr, "TerminateAllLibraryApplets"},
@@ -1105,7 +1109,7 @@ void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx)
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
 
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<AM::ILibraryAppletAccessor>(applet);
+    rb.PushIpcInterface<ILibraryAppletAccessor>(system, applet);
 }
 
 void ILibraryAppletCreator::CreateStorage(Kernel::HLERequestContext& ctx) {
@@ -1117,7 +1121,7 @@ void ILibraryAppletCreator::CreateStorage(Kernel::HLERequestContext& ctx) {
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<AM::IStorage>(std::move(buffer));
+    rb.PushIpcInterface<IStorage>(system, std::move(buffer));
 }
 
 void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx) {
@@ -1144,11 +1148,11 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<IStorage>(std::move(memory));
+    rb.PushIpcInterface<IStorage>(system, std::move(memory));
 }
 
 IApplicationFunctions::IApplicationFunctions(Core::System& system_)
-    : ServiceFramework("IApplicationFunctions"), system{system_} {
+    : ServiceFramework{system_, "IApplicationFunctions"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"},
@@ -1300,7 +1304,7 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
         if (data.has_value()) {
             IPC::ResponseBuilder rb{ctx, 2, 0, 1};
             rb.Push(RESULT_SUCCESS);
-            rb.PushIpcInterface<IStorage>(std::move(*data));
+            rb.PushIpcInterface<IStorage>(system, std::move(*data));
             launch_popped_application_specific = true;
             return;
         }
@@ -1323,7 +1327,7 @@ void IApplicationFunctions::PopLaunchParameter(Kernel::HLERequestContext& ctx) {
         std::vector<u8> buffer(sizeof(LaunchParameterAccountPreselectedUser));
         std::memcpy(buffer.data(), &params, buffer.size());
 
-        rb.PushIpcInterface<IStorage>(std::move(buffer));
+        rb.PushIpcInterface<IStorage>(system, std::move(buffer));
         launch_popped_account_preselect = true;
         return;
     }
@@ -1621,14 +1625,14 @@ void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger
 
     std::make_shared<AppletAE>(nvflinger, message_queue, system)->InstallAsService(service_manager);
     std::make_shared<AppletOE>(nvflinger, message_queue, system)->InstallAsService(service_manager);
-    std::make_shared<IdleSys>()->InstallAsService(service_manager);
-    std::make_shared<OMM>()->InstallAsService(service_manager);
-    std::make_shared<SPSM>()->InstallAsService(service_manager);
-    std::make_shared<TCAP>()->InstallAsService(service_manager);
+    std::make_shared<IdleSys>(system)->InstallAsService(service_manager);
+    std::make_shared<OMM>(system)->InstallAsService(service_manager);
+    std::make_shared<SPSM>(system)->InstallAsService(service_manager);
+    std::make_shared<TCAP>(system)->InstallAsService(service_manager);
 }
 
-IHomeMenuFunctions::IHomeMenuFunctions(Kernel::KernelCore& kernel)
-    : ServiceFramework("IHomeMenuFunctions"), kernel(kernel) {
+IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_)
+    : ServiceFramework{system_, "IHomeMenuFunctions"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {10, &IHomeMenuFunctions::RequestToGetForeground, "RequestToGetForeground"},
@@ -1647,7 +1651,7 @@ IHomeMenuFunctions::IHomeMenuFunctions(Kernel::KernelCore& kernel)
     RegisterHandlers(functions);
 
     pop_from_general_channel_event = Kernel::WritableEvent::CreateEventPair(
-        kernel, "IHomeMenuFunctions:PopFromGeneralChannelEvent");
+        system.Kernel(), "IHomeMenuFunctions:PopFromGeneralChannelEvent");
 }
 
 IHomeMenuFunctions::~IHomeMenuFunctions() = default;
@@ -1667,7 +1671,8 @@ void IHomeMenuFunctions::GetPopFromGeneralChannelEvent(Kernel::HLERequestContext
     rb.PushCopyObjects(pop_from_general_channel_event.readable);
 }
 
-IGlobalStateController::IGlobalStateController() : ServiceFramework("IGlobalStateController") {
+IGlobalStateController::IGlobalStateController(Core::System& system_)
+    : ServiceFramework{system_, "IGlobalStateController"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "RequestToEnterSleep"},
@@ -1690,7 +1695,8 @@ IGlobalStateController::IGlobalStateController() : ServiceFramework("IGlobalStat
 
 IGlobalStateController::~IGlobalStateController() = default;
 
-IApplicationCreator::IApplicationCreator() : ServiceFramework("IApplicationCreator") {
+IApplicationCreator::IApplicationCreator(Core::System& system_)
+    : ServiceFramework{system_, "IApplicationCreator"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "CreateApplication"},
@@ -1705,8 +1711,8 @@ IApplicationCreator::IApplicationCreator() : ServiceFramework("IApplicationCreat
 
 IApplicationCreator::~IApplicationCreator() = default;
 
-IProcessWindingController::IProcessWindingController()
-    : ServiceFramework("IProcessWindingController") {
+IProcessWindingController::IProcessWindingController(Core::System& system_)
+    : ServiceFramework{system_, "IProcessWindingController"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "GetLaunchReason"},

+ 11 - 19
src/core/hle/service/am/am.h

@@ -77,13 +77,11 @@ public:
 private:
     void GetAppletResourceUserId(Kernel::HLERequestContext& ctx);
     void AcquireForegroundRights(Kernel::HLERequestContext& ctx);
-
-    Core::System& system;
 };
 
 class IAudioController final : public ServiceFramework<IAudioController> {
 public:
-    IAudioController();
+    explicit IAudioController(Core::System& system_);
     ~IAudioController() override;
 
 private:
@@ -109,13 +107,13 @@ private:
 
 class IDisplayController final : public ServiceFramework<IDisplayController> {
 public:
-    IDisplayController();
+    explicit IDisplayController(Core::System& system_);
     ~IDisplayController() override;
 };
 
 class IDebugFunctions final : public ServiceFramework<IDebugFunctions> {
 public:
-    IDebugFunctions();
+    explicit IDebugFunctions(Core::System& system_);
     ~IDebugFunctions() override;
 };
 
@@ -154,7 +152,6 @@ private:
         Disable = 2,
     };
 
-    Core::System& system;
     NVFlinger::NVFlinger& nvflinger;
     Kernel::EventPair launchable_event;
     Kernel::EventPair accumulated_suspended_tick_changed_event;
@@ -167,8 +164,8 @@ private:
 
 class ICommonStateGetter final : public ServiceFramework<ICommonStateGetter> {
 public:
-    explicit ICommonStateGetter(Core::System& system,
-                                std::shared_ptr<AppletMessageQueue> msg_queue);
+    explicit ICommonStateGetter(Core::System& system_,
+                                std::shared_ptr<AppletMessageQueue> msg_queue_);
     ~ICommonStateGetter() override;
 
 private:
@@ -196,7 +193,6 @@ private:
     void GetDefaultDisplayResolution(Kernel::HLERequestContext& ctx);
     void SetCpuBoostMode(Kernel::HLERequestContext& ctx);
 
-    Core::System& system;
     std::shared_ptr<AppletMessageQueue> msg_queue;
     bool vr_mode_state{};
 };
@@ -211,7 +207,7 @@ public:
 
 class IStorage final : public ServiceFramework<IStorage> {
 public:
-    explicit IStorage(std::vector<u8>&& buffer);
+    explicit IStorage(Core::System& system_, std::vector<u8>&& buffer);
     ~IStorage() override;
 
     std::vector<u8>& GetData() {
@@ -235,7 +231,7 @@ private:
 
 class IStorageAccessor final : public ServiceFramework<IStorageAccessor> {
 public:
-    explicit IStorageAccessor(IStorage& backing);
+    explicit IStorageAccessor(Core::System& system_, IStorage& backing_);
     ~IStorageAccessor() override;
 
 private:
@@ -255,8 +251,6 @@ private:
     void CreateLibraryApplet(Kernel::HLERequestContext& ctx);
     void CreateStorage(Kernel::HLERequestContext& ctx);
     void CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx);
-
-    Core::System& system;
 };
 
 class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> {
@@ -299,12 +293,11 @@ private:
     s32 previous_program_index{-1};
     Kernel::EventPair gpu_error_detected_event;
     Kernel::EventPair friend_invitation_storage_channel_event;
-    Core::System& system;
 };
 
 class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> {
 public:
-    explicit IHomeMenuFunctions(Kernel::KernelCore& kernel);
+    explicit IHomeMenuFunctions(Core::System& system_);
     ~IHomeMenuFunctions() override;
 
 private:
@@ -312,24 +305,23 @@ private:
     void GetPopFromGeneralChannelEvent(Kernel::HLERequestContext& ctx);
 
     Kernel::EventPair pop_from_general_channel_event;
-    Kernel::KernelCore& kernel;
 };
 
 class IGlobalStateController final : public ServiceFramework<IGlobalStateController> {
 public:
-    IGlobalStateController();
+    explicit IGlobalStateController(Core::System& system_);
     ~IGlobalStateController() override;
 };
 
 class IApplicationCreator final : public ServiceFramework<IApplicationCreator> {
 public:
-    IApplicationCreator();
+    explicit IApplicationCreator(Core::System& system_);
     ~IApplicationCreator() override;
 };
 
 class IProcessWindingController final : public ServiceFramework<IProcessWindingController> {
 public:
-    IProcessWindingController();
+    explicit IProcessWindingController(Core::System& system_);
     ~IProcessWindingController() override;
 };
 

+ 24 - 25
src/core/hle/service/am/applet_ae.cpp

@@ -13,11 +13,11 @@ namespace Service::AM {
 
 class ILibraryAppletProxy final : public ServiceFramework<ILibraryAppletProxy> {
 public:
-    explicit ILibraryAppletProxy(NVFlinger::NVFlinger& nvflinger,
-                                 std::shared_ptr<AppletMessageQueue> msg_queue,
-                                 Core::System& system)
-        : ServiceFramework("ILibraryAppletProxy"), nvflinger(nvflinger),
-          msg_queue(std::move(msg_queue)), system(system) {
+    explicit ILibraryAppletProxy(NVFlinger::NVFlinger& nvflinger_,
+                                 std::shared_ptr<AppletMessageQueue> msg_queue_,
+                                 Core::System& system_)
+        : ServiceFramework{system_, "ILibraryAppletProxy"}, nvflinger{nvflinger_},
+          msg_queue{std::move(msg_queue_)} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &ILibraryAppletProxy::GetCommonStateGetter, "GetCommonStateGetter"},
@@ -66,7 +66,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IAudioController>();
+        rb.PushIpcInterface<IAudioController>(system);
     }
 
     void GetDisplayController(Kernel::HLERequestContext& ctx) {
@@ -74,7 +74,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IDisplayController>();
+        rb.PushIpcInterface<IDisplayController>(system);
     }
 
     void GetProcessWindingController(Kernel::HLERequestContext& ctx) {
@@ -82,7 +82,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IProcessWindingController>();
+        rb.PushIpcInterface<IProcessWindingController>(system);
     }
 
     void GetDebugFunctions(Kernel::HLERequestContext& ctx) {
@@ -90,7 +90,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IDebugFunctions>();
+        rb.PushIpcInterface<IDebugFunctions>(system);
     }
 
     void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) {
@@ -111,15 +111,15 @@ private:
 
     NVFlinger::NVFlinger& nvflinger;
     std::shared_ptr<AppletMessageQueue> msg_queue;
-    Core::System& system;
 };
 
 class ISystemAppletProxy final : public ServiceFramework<ISystemAppletProxy> {
 public:
-    explicit ISystemAppletProxy(NVFlinger::NVFlinger& nvflinger,
-                                std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system)
-        : ServiceFramework("ISystemAppletProxy"), nvflinger(nvflinger),
-          msg_queue(std::move(msg_queue)), system(system) {
+    explicit ISystemAppletProxy(NVFlinger::NVFlinger& nvflinger_,
+                                std::shared_ptr<AppletMessageQueue> msg_queue_,
+                                Core::System& system_)
+        : ServiceFramework{system_, "ISystemAppletProxy"}, nvflinger{nvflinger_},
+          msg_queue{std::move(msg_queue_)} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &ISystemAppletProxy::GetCommonStateGetter, "GetCommonStateGetter"},
@@ -170,7 +170,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IAudioController>();
+        rb.PushIpcInterface<IAudioController>(system);
     }
 
     void GetDisplayController(Kernel::HLERequestContext& ctx) {
@@ -178,7 +178,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IDisplayController>();
+        rb.PushIpcInterface<IDisplayController>(system);
     }
 
     void GetDebugFunctions(Kernel::HLERequestContext& ctx) {
@@ -186,7 +186,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IDebugFunctions>();
+        rb.PushIpcInterface<IDebugFunctions>(system);
     }
 
     void GetLibraryAppletCreator(Kernel::HLERequestContext& ctx) {
@@ -202,7 +202,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IHomeMenuFunctions>(system.Kernel());
+        rb.PushIpcInterface<IHomeMenuFunctions>(system);
     }
 
     void GetGlobalStateController(Kernel::HLERequestContext& ctx) {
@@ -210,7 +210,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IGlobalStateController>();
+        rb.PushIpcInterface<IGlobalStateController>(system);
     }
 
     void GetApplicationCreator(Kernel::HLERequestContext& ctx) {
@@ -218,12 +218,11 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IApplicationCreator>();
+        rb.PushIpcInterface<IApplicationCreator>(system);
     }
 
     NVFlinger::NVFlinger& nvflinger;
     std::shared_ptr<AppletMessageQueue> msg_queue;
-    Core::System& system;
 };
 
 void AppletAE::OpenSystemAppletProxy(Kernel::HLERequestContext& ctx) {
@@ -250,10 +249,10 @@ void AppletAE::OpenLibraryAppletProxyOld(Kernel::HLERequestContext& ctx) {
     rb.PushIpcInterface<ILibraryAppletProxy>(nvflinger, msg_queue, system);
 }
 
-AppletAE::AppletAE(NVFlinger::NVFlinger& nvflinger, std::shared_ptr<AppletMessageQueue> msg_queue,
-                   Core::System& system)
-    : ServiceFramework("appletAE"), nvflinger(nvflinger), msg_queue(std::move(msg_queue)),
-      system(system) {
+AppletAE::AppletAE(NVFlinger::NVFlinger& nvflinger_, std::shared_ptr<AppletMessageQueue> msg_queue_,
+                   Core::System& system_)
+    : ServiceFramework{system_, "appletAE"}, nvflinger{nvflinger_}, msg_queue{
+                                                                        std::move(msg_queue_)} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {100, &AppletAE::OpenSystemAppletProxy, "OpenSystemAppletProxy"},

+ 2 - 3
src/core/hle/service/am/applet_ae.h

@@ -23,8 +23,8 @@ class AppletMessageQueue;
 
 class AppletAE final : public ServiceFramework<AppletAE> {
 public:
-    explicit AppletAE(NVFlinger::NVFlinger& nvflinger,
-                      std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system);
+    explicit AppletAE(NVFlinger::NVFlinger& nvflinger_,
+                      std::shared_ptr<AppletMessageQueue> msg_queue_, Core::System& system_);
     ~AppletAE() override;
 
     const std::shared_ptr<AppletMessageQueue>& GetMessageQueue() const;
@@ -36,7 +36,6 @@ private:
 
     NVFlinger::NVFlinger& nvflinger;
     std::shared_ptr<AppletMessageQueue> msg_queue;
-    Core::System& system;
 };
 
 } // namespace AM

+ 12 - 12
src/core/hle/service/am/applet_oe.cpp

@@ -12,10 +12,11 @@ namespace Service::AM {
 
 class IApplicationProxy final : public ServiceFramework<IApplicationProxy> {
 public:
-    explicit IApplicationProxy(NVFlinger::NVFlinger& nvflinger,
-                               std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system)
-        : ServiceFramework("IApplicationProxy"), nvflinger(nvflinger),
-          msg_queue(std::move(msg_queue)), system(system) {
+    explicit IApplicationProxy(NVFlinger::NVFlinger& nvflinger_,
+                               std::shared_ptr<AppletMessageQueue> msg_queue_,
+                               Core::System& system_)
+        : ServiceFramework{system_, "IApplicationProxy"}, nvflinger{nvflinger_},
+          msg_queue{std::move(msg_queue_)} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &IApplicationProxy::GetCommonStateGetter, "GetCommonStateGetter"},
@@ -39,7 +40,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IAudioController>();
+        rb.PushIpcInterface<IAudioController>(system);
     }
 
     void GetDisplayController(Kernel::HLERequestContext& ctx) {
@@ -47,7 +48,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IDisplayController>();
+        rb.PushIpcInterface<IDisplayController>(system);
     }
 
     void GetDebugFunctions(Kernel::HLERequestContext& ctx) {
@@ -55,7 +56,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IDebugFunctions>();
+        rb.PushIpcInterface<IDebugFunctions>(system);
     }
 
     void GetWindowController(Kernel::HLERequestContext& ctx) {
@@ -100,7 +101,6 @@ private:
 
     NVFlinger::NVFlinger& nvflinger;
     std::shared_ptr<AppletMessageQueue> msg_queue;
-    Core::System& system;
 };
 
 void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) {
@@ -111,10 +111,10 @@ void AppletOE::OpenApplicationProxy(Kernel::HLERequestContext& ctx) {
     rb.PushIpcInterface<IApplicationProxy>(nvflinger, msg_queue, system);
 }
 
-AppletOE::AppletOE(NVFlinger::NVFlinger& nvflinger, std::shared_ptr<AppletMessageQueue> msg_queue,
-                   Core::System& system)
-    : ServiceFramework("appletOE"), nvflinger(nvflinger), msg_queue(std::move(msg_queue)),
-      system(system) {
+AppletOE::AppletOE(NVFlinger::NVFlinger& nvflinger_, std::shared_ptr<AppletMessageQueue> msg_queue_,
+                   Core::System& system_)
+    : ServiceFramework{system_, "appletOE"}, nvflinger{nvflinger_}, msg_queue{
+                                                                        std::move(msg_queue_)} {
     static const FunctionInfo functions[] = {
         {0, &AppletOE::OpenApplicationProxy, "OpenApplicationProxy"},
     };

+ 2 - 3
src/core/hle/service/am/applet_oe.h

@@ -23,8 +23,8 @@ class AppletMessageQueue;
 
 class AppletOE final : public ServiceFramework<AppletOE> {
 public:
-    explicit AppletOE(NVFlinger::NVFlinger& nvflinger,
-                      std::shared_ptr<AppletMessageQueue> msg_queue, Core::System& system);
+    explicit AppletOE(NVFlinger::NVFlinger& nvflinger_,
+                      std::shared_ptr<AppletMessageQueue> msg_queue_, Core::System& system_);
     ~AppletOE() override;
 
     const std::shared_ptr<AppletMessageQueue>& GetMessageQueue() const;
@@ -34,7 +34,6 @@ private:
 
     NVFlinger::NVFlinger& nvflinger;
     std::shared_ptr<AppletMessageQueue> msg_queue;
-    Core::System& system;
 };
 
 } // namespace AM

+ 2 - 2
src/core/hle/service/am/applets/controller.cpp

@@ -46,7 +46,7 @@ static Core::Frontend::ControllerParameters ConvertToFrontendParameters(
 }
 
 Controller::Controller(Core::System& system_, const Core::Frontend::ControllerApplet& frontend_)
-    : Applet{system_.Kernel()}, frontend(frontend_) {}
+    : Applet{system_.Kernel()}, frontend{frontend_}, system{system_} {}
 
 Controller::~Controller() = default;
 
@@ -245,7 +245,7 @@ void Controller::ConfigurationComplete() {
     complete = true;
     out_data = std::vector<u8>(sizeof(ControllerSupportResultInfo));
     std::memcpy(out_data.data(), &result_info, out_data.size());
-    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(out_data)));
+    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(system, std::move(out_data)));
     broker.SignalStateChanged();
 }
 

+ 1 - 0
src/core/hle/service/am/applets/controller.h

@@ -120,6 +120,7 @@ public:
 
 private:
     const Core::Frontend::ControllerApplet& frontend;
+    Core::System& system;
 
     ControllerAppletVersion controller_applet_version;
     ControllerSupportArgPrivate controller_private_arg;

+ 2 - 2
src/core/hle/service/am/applets/error.cpp

@@ -87,7 +87,7 @@ ResultCode Decode64BitError(u64 error) {
 } // Anonymous namespace
 
 Error::Error(Core::System& system_, const Core::Frontend::ErrorApplet& frontend_)
-    : Applet{system_.Kernel()}, frontend(frontend_), system{system_} {}
+    : Applet{system_.Kernel()}, frontend{frontend_}, system{system_} {}
 
 Error::~Error() = default;
 
@@ -186,7 +186,7 @@ void Error::Execute() {
 
 void Error::DisplayCompleted() {
     complete = true;
-    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::vector<u8>{}));
+    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(system, std::vector<u8>{}));
     broker.SignalStateChanged();
 }
 

+ 13 - 11
src/core/hle/service/am/applets/general_backend.cpp

@@ -38,7 +38,7 @@ static void LogCurrentStorage(AppletDataBroker& broker, std::string_view prefix)
 }
 
 Auth::Auth(Core::System& system_, Core::Frontend::ParentalControlsApplet& frontend_)
-    : Applet{system_.Kernel()}, frontend(frontend_) {}
+    : Applet{system_.Kernel()}, frontend{frontend_}, system{system_} {}
 
 Auth::~Auth() = default;
 
@@ -135,8 +135,8 @@ void Auth::Execute() {
     }
 }
 
-void Auth::AuthFinished(bool successful) {
-    this->successful = successful;
+void Auth::AuthFinished(bool is_successful) {
+    this->successful = is_successful;
 
     struct Return {
         ResultCode result_code;
@@ -148,12 +148,12 @@ void Auth::AuthFinished(bool successful) {
     std::vector<u8> out(sizeof(Return));
     std::memcpy(out.data(), &return_, sizeof(Return));
 
-    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(out)));
+    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(system, std::move(out)));
     broker.SignalStateChanged();
 }
 
 PhotoViewer::PhotoViewer(Core::System& system_, const Core::Frontend::PhotoViewerApplet& frontend_)
-    : Applet{system_.Kernel()}, frontend(frontend_), system{system_} {}
+    : Applet{system_.Kernel()}, frontend{frontend_}, system{system_} {}
 
 PhotoViewer::~PhotoViewer() = default;
 
@@ -198,12 +198,12 @@ void PhotoViewer::Execute() {
 }
 
 void PhotoViewer::ViewFinished() {
-    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::vector<u8>{}));
+    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(system, std::vector<u8>{}));
     broker.SignalStateChanged();
 }
 
 StubApplet::StubApplet(Core::System& system_, AppletId id_)
-    : Applet{system_.Kernel()}, id(id_), system{system_} {}
+    : Applet{system_.Kernel()}, id{id_}, system{system_} {}
 
 StubApplet::~StubApplet() = default;
 
@@ -234,8 +234,9 @@ void StubApplet::ExecuteInteractive() {
     LOG_WARNING(Service_AM, "called (STUBBED)");
     LogCurrentStorage(broker, "ExecuteInteractive");
 
-    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::vector<u8>(0x1000)));
-    broker.PushInteractiveDataFromApplet(std::make_shared<IStorage>(std::vector<u8>(0x1000)));
+    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(system, std::vector<u8>(0x1000)));
+    broker.PushInteractiveDataFromApplet(
+        std::make_shared<IStorage>(system, std::vector<u8>(0x1000)));
     broker.SignalStateChanged();
 }
 
@@ -243,8 +244,9 @@ void StubApplet::Execute() {
     LOG_WARNING(Service_AM, "called (STUBBED)");
     LogCurrentStorage(broker, "Execute");
 
-    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::vector<u8>(0x1000)));
-    broker.PushInteractiveDataFromApplet(std::make_shared<IStorage>(std::vector<u8>(0x1000)));
+    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(system, std::vector<u8>(0x1000)));
+    broker.PushInteractiveDataFromApplet(
+        std::make_shared<IStorage>(system, std::vector<u8>(0x1000)));
     broker.SignalStateChanged();
 }
 

+ 2 - 1
src/core/hle/service/am/applets/general_backend.h

@@ -29,10 +29,11 @@ public:
     void ExecuteInteractive() override;
     void Execute() override;
 
-    void AuthFinished(bool successful = true);
+    void AuthFinished(bool is_successful = true);
 
 private:
     Core::Frontend::ParentalControlsApplet& frontend;
+    Core::System& system;
     bool complete = false;
     bool successful = false;
 

+ 3 - 3
src/core/hle/service/am/applets/profile_select.cpp

@@ -17,7 +17,7 @@ constexpr ResultCode ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1};
 
 ProfileSelect::ProfileSelect(Core::System& system_,
                              const Core::Frontend::ProfileSelectApplet& frontend_)
-    : Applet{system_.Kernel()}, frontend(frontend_) {}
+    : Applet{system_.Kernel()}, frontend{frontend_}, system{system_} {}
 
 ProfileSelect::~ProfileSelect() = default;
 
@@ -50,7 +50,7 @@ void ProfileSelect::ExecuteInteractive() {
 
 void ProfileSelect::Execute() {
     if (complete) {
-        broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(final_data)));
+        broker.PushNormalDataFromApplet(std::make_shared<IStorage>(system, std::move(final_data)));
         return;
     }
 
@@ -71,7 +71,7 @@ void ProfileSelect::SelectionComplete(std::optional<Common::UUID> uuid) {
 
     final_data = std::vector<u8>(sizeof(UserSelectionOutput));
     std::memcpy(final_data.data(), &output, final_data.size());
-    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(final_data)));
+    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(system, std::move(final_data)));
     broker.SignalStateChanged();
 }
 

+ 1 - 0
src/core/hle/service/am/applets/profile_select.h

@@ -53,6 +53,7 @@ private:
     bool complete = false;
     ResultCode status = RESULT_SUCCESS;
     std::vector<u8> final_data;
+    Core::System& system;
 };
 
 } // namespace Service::AM::Applets

+ 8 - 6
src/core/hle/service/am/applets/software_keyboard.cpp

@@ -53,7 +53,7 @@ static Core::Frontend::SoftwareKeyboardParameters ConvertToFrontendParameters(
 
 SoftwareKeyboard::SoftwareKeyboard(Core::System& system_,
                                    const Core::Frontend::SoftwareKeyboardApplet& frontend_)
-    : Applet{system_.Kernel()}, frontend(frontend_) {}
+    : Applet{system_.Kernel()}, frontend{frontend_}, system{system_} {}
 
 SoftwareKeyboard::~SoftwareKeyboard() = default;
 
@@ -122,7 +122,7 @@ void SoftwareKeyboard::ExecuteInteractive() {
 
         switch (request) {
         case Request::Calc: {
-            broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::vector<u8>{1}));
+            broker.PushNormalDataFromApplet(std::make_shared<IStorage>(system, std::vector<u8>{1}));
             broker.SignalStateChanged();
             break;
         }
@@ -135,7 +135,7 @@ void SoftwareKeyboard::ExecuteInteractive() {
 
 void SoftwareKeyboard::Execute() {
     if (complete) {
-        broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(final_data)));
+        broker.PushNormalDataFromApplet(std::make_shared<IStorage>(system, std::move(final_data)));
         broker.SignalStateChanged();
         return;
     }
@@ -179,15 +179,17 @@ void SoftwareKeyboard::WriteText(std::optional<std::u16string> text) {
         final_data = output_main;
 
         if (complete) {
-            broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(output_main)));
+            broker.PushNormalDataFromApplet(
+                std::make_shared<IStorage>(system, std::move(output_main)));
             broker.SignalStateChanged();
         } else {
-            broker.PushInteractiveDataFromApplet(std::make_shared<IStorage>(std::move(output_sub)));
+            broker.PushInteractiveDataFromApplet(
+                std::make_shared<IStorage>(system, std::move(output_sub)));
         }
     } else {
         output_main[0] = 1;
         complete = true;
-        broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(output_main)));
+        broker.PushNormalDataFromApplet(std::make_shared<IStorage>(system, std::move(output_main)));
         broker.SignalStateChanged();
     }
 }

+ 1 - 0
src/core/hle/service/am/applets/software_keyboard.h

@@ -80,6 +80,7 @@ private:
     bool complete = false;
     bool is_inline = false;
     std::vector<u8> final_data;
+    Core::System& system;
 };
 
 } // namespace Service::AM::Applets

+ 1 - 1
src/core/hle/service/am/applets/web_browser.cpp

@@ -290,7 +290,7 @@ void WebBrowser::Finalize() {
     std::vector<u8> data(sizeof(WebCommonReturnValue));
     std::memcpy(data.data(), &out, sizeof(WebCommonReturnValue));
 
-    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(std::move(data)));
+    broker.PushNormalDataFromApplet(std::make_shared<IStorage>(system, std::move(data)));
     broker.SignalStateChanged();
 
     if (!temporary_dir.empty() && Common::FS::IsDirectory(temporary_dir)) {

+ 1 - 1
src/core/hle/service/am/idle.cpp

@@ -6,7 +6,7 @@
 
 namespace Service::AM {
 
-IdleSys::IdleSys() : ServiceFramework{"idle:sys"} {
+IdleSys::IdleSys(Core::System& system_) : ServiceFramework{system_, "idle:sys"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "GetAutoPowerDownEvent"},

+ 5 - 1
src/core/hle/service/am/idle.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::AM {
 
 class IdleSys final : public ServiceFramework<IdleSys> {
 public:
-    explicit IdleSys();
+    explicit IdleSys(Core::System& system_);
     ~IdleSys() override;
 };
 

+ 1 - 1
src/core/hle/service/am/omm.cpp

@@ -6,7 +6,7 @@
 
 namespace Service::AM {
 
-OMM::OMM() : ServiceFramework{"omm"} {
+OMM::OMM(Core::System& system_) : ServiceFramework{system_, "omm"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "GetOperationMode"},

+ 5 - 1
src/core/hle/service/am/omm.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::AM {
 
 class OMM final : public ServiceFramework<OMM> {
 public:
-    explicit OMM();
+    explicit OMM(Core::System& system_);
     ~OMM() override;
 };
 

+ 1 - 1
src/core/hle/service/am/spsm.cpp

@@ -6,7 +6,7 @@
 
 namespace Service::AM {
 
-SPSM::SPSM() : ServiceFramework{"spsm"} {
+SPSM::SPSM(Core::System& system_) : ServiceFramework{system_, "spsm"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "GetState"},

+ 5 - 1
src/core/hle/service/am/spsm.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::AM {
 
 class SPSM final : public ServiceFramework<SPSM> {
 public:
-    explicit SPSM();
+    explicit SPSM(Core::System& system_);
     ~SPSM() override;
 };
 

+ 1 - 1
src/core/hle/service/am/tcap.cpp

@@ -6,7 +6,7 @@
 
 namespace Service::AM {
 
-TCAP::TCAP() : ServiceFramework{"tcap"} {
+TCAP::TCAP(Core::System& system_) : ServiceFramework{system_, "tcap"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "GetContinuousHighSkinTemperatureEvent"},

+ 5 - 1
src/core/hle/service/am/tcap.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::AM {
 
 class TCAP final : public ServiceFramework<TCAP> {
 public:
-    explicit TCAP();
+    explicit TCAP(Core::System& system_);
     ~TCAP() override;
 };
 

+ 2 - 2
src/core/hle/service/aoc/aoc_u.cpp

@@ -48,8 +48,8 @@ static std::vector<u64> AccumulateAOCTitleIDs(Core::System& system) {
     return add_on_content;
 }
 
-AOC_U::AOC_U(Core::System& system)
-    : ServiceFramework("aoc:u"), add_on_content(AccumulateAOCTitleIDs(system)), system(system) {
+AOC_U::AOC_U(Core::System& system_)
+    : ServiceFramework{system_, "aoc:u"}, add_on_content{AccumulateAOCTitleIDs(system)} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "CountAddOnContentByApplicationId"},

+ 4 - 1
src/core/hle/service/aoc/aoc_u.h

@@ -6,6 +6,10 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Kernel {
 class WritableEvent;
 }
@@ -26,7 +30,6 @@ private:
 
     std::vector<u64> add_on_content;
     Kernel::EventPair aoc_change_event;
-    Core::System& system;
 };
 
 /// Registers all AOC services with the specified service manager.

+ 5 - 4
src/core/hle/service/apm/apm.cpp

@@ -14,13 +14,14 @@ Module::~Module() = default;
 
 void InstallInterfaces(Core::System& system) {
     auto module_ = std::make_shared<Module>();
-    std::make_shared<APM>(module_, system.GetAPMController(), "apm")
+    std::make_shared<APM>(system, module_, system.GetAPMController(), "apm")
         ->InstallAsService(system.ServiceManager());
-    std::make_shared<APM>(module_, system.GetAPMController(), "apm:p")
+    std::make_shared<APM>(system, module_, system.GetAPMController(), "apm:p")
         ->InstallAsService(system.ServiceManager());
-    std::make_shared<APM>(module_, system.GetAPMController(), "apm:am")
+    std::make_shared<APM>(system, module_, system.GetAPMController(), "apm:am")
+        ->InstallAsService(system.ServiceManager());
+    std::make_shared<APM_Sys>(system, system.GetAPMController())
         ->InstallAsService(system.ServiceManager());
-    std::make_shared<APM_Sys>(system.GetAPMController())->InstallAsService(system.ServiceManager());
 }
 
 } // namespace Service::APM

+ 3 - 1
src/core/hle/service/apm/apm.h

@@ -4,7 +4,9 @@
 
 #pragma once
 
-#include "core/hle/service/service.h"
+namespace Core {
+class System;
+}
 
 namespace Service::APM {
 

+ 9 - 6
src/core/hle/service/apm/interface.cpp

@@ -12,7 +12,8 @@ namespace Service::APM {
 
 class ISession final : public ServiceFramework<ISession> {
 public:
-    ISession(Controller& controller) : ServiceFramework("ISession"), controller(controller) {
+    explicit ISession(Core::System& system_, Controller& controller_)
+        : ServiceFramework{system_, "ISession"}, controller{controller_} {
         static const FunctionInfo functions[] = {
             {0, &ISession::SetPerformanceConfiguration, "SetPerformanceConfiguration"},
             {1, &ISession::GetPerformanceConfiguration, "GetPerformanceConfiguration"},
@@ -50,8 +51,9 @@ private:
     Controller& controller;
 };
 
-APM::APM(std::shared_ptr<Module> apm, Controller& controller, const char* name)
-    : ServiceFramework(name), apm(std::move(apm)), controller(controller) {
+APM::APM(Core::System& system_, std::shared_ptr<Module> apm_, Controller& controller_,
+         const char* name)
+    : ServiceFramework{system_, name}, apm(std::move(apm_)), controller{controller_} {
     static const FunctionInfo functions[] = {
         {0, &APM::OpenSession, "OpenSession"},
         {1, &APM::GetPerformanceMode, "GetPerformanceMode"},
@@ -67,7 +69,7 @@ void APM::OpenSession(Kernel::HLERequestContext& ctx) {
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<ISession>(controller);
+    rb.PushIpcInterface<ISession>(system, controller);
 }
 
 void APM::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
@@ -77,7 +79,8 @@ void APM::GetPerformanceMode(Kernel::HLERequestContext& ctx) {
     rb.PushEnum(controller.GetCurrentPerformanceMode());
 }
 
-APM_Sys::APM_Sys(Controller& controller) : ServiceFramework{"apm:sys"}, controller(controller) {
+APM_Sys::APM_Sys(Core::System& system_, Controller& controller_)
+    : ServiceFramework{system_, "apm:sys"}, controller{controller_} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "RequestPerformanceMode"},
@@ -101,7 +104,7 @@ void APM_Sys::GetPerformanceEvent(Kernel::HLERequestContext& ctx) {
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<ISession>(controller);
+    rb.PushIpcInterface<ISession>(system, controller);
 }
 
 void APM_Sys::SetCpuBoostMode(Kernel::HLERequestContext& ctx) {

+ 3 - 2
src/core/hle/service/apm/interface.h

@@ -13,7 +13,8 @@ class Module;
 
 class APM final : public ServiceFramework<APM> {
 public:
-    explicit APM(std::shared_ptr<Module> apm, Controller& controller, const char* name);
+    explicit APM(Core::System& system_, std::shared_ptr<Module> apm_, Controller& controller_,
+                 const char* name);
     ~APM() override;
 
 private:
@@ -26,7 +27,7 @@ private:
 
 class APM_Sys final : public ServiceFramework<APM_Sys> {
 public:
-    explicit APM_Sys(Controller& controller);
+    explicit APM_Sys(Core::System& system_, Controller& controller);
     ~APM_Sys() override;
 
     void SetCpuBoostMode(Kernel::HLERequestContext& ctx);

+ 1 - 1
src/core/hle/service/audio/audctl.cpp

@@ -8,7 +8,7 @@
 
 namespace Service::Audio {
 
-AudCtl::AudCtl() : ServiceFramework{"audctl"} {
+AudCtl::AudCtl(Core::System& system_) : ServiceFramework{system_, "audctl"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "GetTargetVolume"},

+ 5 - 1
src/core/hle/service/audio/audctl.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::Audio {
 
 class AudCtl final : public ServiceFramework<AudCtl> {
 public:
-    explicit AudCtl();
+    explicit AudCtl(Core::System& system_);
     ~AudCtl() override;
 
 private:

+ 1 - 1
src/core/hle/service/audio/auddbg.cpp

@@ -6,7 +6,7 @@
 
 namespace Service::Audio {
 
-AudDbg::AudDbg(const char* name) : ServiceFramework{name} {
+AudDbg::AudDbg(Core::System& system_, const char* name) : ServiceFramework{system_, name} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "RequestSuspendForDebug"},

+ 5 - 1
src/core/hle/service/audio/auddbg.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::Audio {
 
 class AudDbg final : public ServiceFramework<AudDbg> {
 public:
-    explicit AudDbg(const char* name);
+    explicit AudDbg(Core::System& system_, const char* name);
     ~AudDbg() override;
 };
 

+ 1 - 1
src/core/hle/service/audio/audin_a.cpp

@@ -6,7 +6,7 @@
 
 namespace Service::Audio {
 
-AudInA::AudInA() : ServiceFramework{"audin:a"} {
+AudInA::AudInA(Core::System& system_) : ServiceFramework{system_, "audin:a"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "RequestSuspendAudioIns"},

+ 5 - 1
src/core/hle/service/audio/audin_a.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::Audio {
 
 class AudInA final : public ServiceFramework<AudInA> {
 public:
-    explicit AudInA();
+    explicit AudInA(Core::System& system_);
     ~AudInA() override;
 };
 

+ 3 - 3
src/core/hle/service/audio/audin_u.cpp

@@ -11,7 +11,7 @@ namespace Service::Audio {
 
 class IAudioIn final : public ServiceFramework<IAudioIn> {
 public:
-    IAudioIn() : ServiceFramework("IAudioIn") {
+    explicit IAudioIn(Core::System& system_) : ServiceFramework{system_, "IAudioIn"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "GetAudioInState"},
@@ -36,7 +36,7 @@ public:
     }
 };
 
-AudInU::AudInU() : ServiceFramework("audin:u") {
+AudInU::AudInU(Core::System& system_) : ServiceFramework{system_, "audin:u"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, &AudInU::ListAudioIns, "ListAudioIns"},
@@ -96,7 +96,7 @@ void AudInU::OpenInOutImpl(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 6, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushRaw<AudInOutParams>(params);
-    rb.PushIpcInterface<IAudioIn>();
+    rb.PushIpcInterface<IAudioIn>(system);
 }
 
 void AudInU::OpenAudioIn(Kernel::HLERequestContext& ctx) {

+ 5 - 1
src/core/hle/service/audio/audin_u.h

@@ -6,6 +6,10 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Kernel {
 class HLERequestContext;
 }
@@ -14,7 +18,7 @@ namespace Service::Audio {
 
 class AudInU final : public ServiceFramework<AudInU> {
 public:
-    explicit AudInU();
+    explicit AudInU(Core::System& system_);
     ~AudInU() override;
 
 private:

+ 13 - 13
src/core/hle/service/audio/audio.cpp

@@ -20,22 +20,22 @@
 namespace Service::Audio {
 
 void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
-    std::make_shared<AudCtl>()->InstallAsService(service_manager);
-    std::make_shared<AudOutA>()->InstallAsService(service_manager);
+    std::make_shared<AudCtl>(system)->InstallAsService(service_manager);
+    std::make_shared<AudOutA>(system)->InstallAsService(service_manager);
     std::make_shared<AudOutU>(system)->InstallAsService(service_manager);
-    std::make_shared<AudInA>()->InstallAsService(service_manager);
-    std::make_shared<AudInU>()->InstallAsService(service_manager);
-    std::make_shared<AudRecA>()->InstallAsService(service_manager);
-    std::make_shared<AudRecU>()->InstallAsService(service_manager);
-    std::make_shared<AudRenA>()->InstallAsService(service_manager);
+    std::make_shared<AudInA>(system)->InstallAsService(service_manager);
+    std::make_shared<AudInU>(system)->InstallAsService(service_manager);
+    std::make_shared<AudRecA>(system)->InstallAsService(service_manager);
+    std::make_shared<AudRecU>(system)->InstallAsService(service_manager);
+    std::make_shared<AudRenA>(system)->InstallAsService(service_manager);
     std::make_shared<AudRenU>(system)->InstallAsService(service_manager);
-    std::make_shared<CodecCtl>()->InstallAsService(service_manager);
-    std::make_shared<HwOpus>()->InstallAsService(service_manager);
+    std::make_shared<CodecCtl>(system)->InstallAsService(service_manager);
+    std::make_shared<HwOpus>(system)->InstallAsService(service_manager);
 
-    std::make_shared<AudDbg>("audin:d")->InstallAsService(service_manager);
-    std::make_shared<AudDbg>("audout:d")->InstallAsService(service_manager);
-    std::make_shared<AudDbg>("audrec:d")->InstallAsService(service_manager);
-    std::make_shared<AudDbg>("audren:d")->InstallAsService(service_manager);
+    std::make_shared<AudDbg>(system, "audin:d")->InstallAsService(service_manager);
+    std::make_shared<AudDbg>(system, "audout:d")->InstallAsService(service_manager);
+    std::make_shared<AudDbg>(system, "audrec:d")->InstallAsService(service_manager);
+    std::make_shared<AudDbg>(system, "audren:d")->InstallAsService(service_manager);
 }
 
 } // namespace Service::Audio

+ 1 - 1
src/core/hle/service/audio/audout_a.cpp

@@ -6,7 +6,7 @@
 
 namespace Service::Audio {
 
-AudOutA::AudOutA() : ServiceFramework{"audout:a"} {
+AudOutA::AudOutA(Core::System& system_) : ServiceFramework{system_, "audout:a"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "RequestSuspendAudioOuts"},

+ 5 - 1
src/core/hle/service/audio/audout_a.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::Audio {
 
 class AudOutA final : public ServiceFramework<AudOutA> {
 public:
-    explicit AudOutA();
+    explicit AudOutA(Core::System& system_);
     ~AudOutA() override;
 };
 

+ 6 - 6
src/core/hle/service/audio/audout_u.cpp

@@ -40,11 +40,11 @@ enum class AudioState : u32 {
 
 class IAudioOut final : public ServiceFramework<IAudioOut> {
 public:
-    IAudioOut(Core::System& system, AudoutParams audio_params, AudioCore::AudioOut& audio_core,
-              std::string&& device_name, std::string&& unique_name)
-        : ServiceFramework("IAudioOut"), audio_core(audio_core),
-          device_name(std::move(device_name)),
-          audio_params(audio_params), main_memory{system.Memory()} {
+    IAudioOut(Core::System& system_, AudoutParams audio_params_, AudioCore::AudioOut& audio_core_,
+              std::string&& device_name_, std::string&& unique_name)
+        : ServiceFramework{system_, "IAudioOut"}, audio_core{audio_core_},
+          device_name{std::move(device_name_)}, audio_params{audio_params_}, main_memory{
+                                                                                 system.Memory()} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &IAudioOut::GetAudioOutState, "GetAudioOutState"},
@@ -213,7 +213,7 @@ private:
     Core::Memory::Memory& main_memory;
 };
 
-AudOutU::AudOutU(Core::System& system_) : ServiceFramework("audout:u"), system{system_} {
+AudOutU::AudOutU(Core::System& system_) : ServiceFramework{system_, "audout:u"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, &AudOutU::ListAudioOutsImpl, "ListAudioOuts"},

+ 0 - 2
src/core/hle/service/audio/audout_u.h

@@ -34,8 +34,6 @@ private:
 
     std::vector<std::shared_ptr<IAudioOut>> audio_out_interfaces;
     std::unique_ptr<AudioCore::AudioOut> audio_core;
-
-    Core::System& system;
 };
 
 } // namespace Service::Audio

+ 1 - 1
src/core/hle/service/audio/audrec_a.cpp

@@ -6,7 +6,7 @@
 
 namespace Service::Audio {
 
-AudRecA::AudRecA() : ServiceFramework{"audrec:a"} {
+AudRecA::AudRecA(Core::System& system_) : ServiceFramework{system_, "audrec:a"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "RequestSuspendFinalOutputRecorders"},

+ 5 - 1
src/core/hle/service/audio/audrec_a.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::Audio {
 
 class AudRecA final : public ServiceFramework<AudRecA> {
 public:
-    explicit AudRecA();
+    explicit AudRecA(Core::System& system_);
     ~AudRecA() override;
 };
 

+ 3 - 2
src/core/hle/service/audio/audrec_u.cpp

@@ -8,7 +8,8 @@ namespace Service::Audio {
 
 class IFinalOutputRecorder final : public ServiceFramework<IFinalOutputRecorder> {
 public:
-    IFinalOutputRecorder() : ServiceFramework("IFinalOutputRecorder") {
+    explicit IFinalOutputRecorder(Core::System& system_)
+        : ServiceFramework{system_, "IFinalOutputRecorder"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "GetFinalOutputRecorderState"},
@@ -29,7 +30,7 @@ public:
     }
 };
 
-AudRecU::AudRecU() : ServiceFramework("audrec:u") {
+AudRecU::AudRecU(Core::System& system_) : ServiceFramework{system_, "audrec:u"} {
     static const FunctionInfo functions[] = {
         {0, nullptr, "OpenFinalOutputRecorder"},
     };

+ 3 - 3
src/core/hle/service/audio/audrec_u.h

@@ -6,15 +6,15 @@
 
 #include "core/hle/service/service.h"
 
-namespace Kernel {
-class HLERequestContext;
+namespace Core {
+class System;
 }
 
 namespace Service::Audio {
 
 class AudRecU final : public ServiceFramework<AudRecU> {
 public:
-    explicit AudRecU();
+    explicit AudRecU(Core::System& system_);
     ~AudRecU() override;
 };
 

+ 1 - 1
src/core/hle/service/audio/audren_a.cpp

@@ -6,7 +6,7 @@
 
 namespace Service::Audio {
 
-AudRenA::AudRenA() : ServiceFramework{"audren:a"} {
+AudRenA::AudRenA(Core::System& system_) : ServiceFramework{system_, "audren:a"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "RequestSuspendAudioRenderers"},

+ 5 - 1
src/core/hle/service/audio/audren_a.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::Audio {
 
 class AudRenA final : public ServiceFramework<AudRenA> {
 public:
-    explicit AudRenA();
+    explicit AudRenA(Core::System& system_);
     ~AudRenA() override;
 };
 

+ 4 - 4
src/core/hle/service/audio/audren_u.cpp

@@ -28,7 +28,7 @@ class IAudioRenderer final : public ServiceFramework<IAudioRenderer> {
 public:
     explicit IAudioRenderer(Core::System& system, AudioCommon::AudioRendererParameter audren_params,
                             const std::size_t instance_number)
-        : ServiceFramework("IAudioRenderer") {
+        : ServiceFramework{system, "IAudioRenderer"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &IAudioRenderer::GetSampleRate, "GetSampleRate"},
@@ -167,8 +167,8 @@ private:
 
 class IAudioDevice final : public ServiceFramework<IAudioDevice> {
 public:
-    explicit IAudioDevice(Core::System& system, u32_le revision_num)
-        : ServiceFramework("IAudioDevice"), revision{revision_num} {
+    explicit IAudioDevice(Core::System& system_, u32_le revision_num)
+        : ServiceFramework{system_, "IAudioDevice"}, revision{revision_num} {
         static const FunctionInfo functions[] = {
             {0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"},
             {1, &IAudioDevice::SetAudioDeviceOutputVolume, "SetAudioDeviceOutputVolume"},
@@ -325,7 +325,7 @@ private:
 
 }; // namespace Audio
 
-AudRenU::AudRenU(Core::System& system_) : ServiceFramework("audren:u"), system{system_} {
+AudRenU::AudRenU(Core::System& system_) : ServiceFramework{system_, "audren:u"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, &AudRenU::OpenAudioRenderer, "OpenAudioRenderer"},

+ 0 - 1
src/core/hle/service/audio/audren_u.h

@@ -31,7 +31,6 @@ private:
     void OpenAudioRendererImpl(Kernel::HLERequestContext& ctx);
 
     std::size_t audren_instance_count = 0;
-    Core::System& system;
 };
 
 // Describes a particular audio feature that may be supported in a particular revision.

+ 1 - 4
src/core/hle/service/audio/codecctl.cpp

@@ -2,14 +2,11 @@
 // Licensed under GPLv2 or any later version
 // Refer to the license.txt file included.
 
-#include "common/logging/log.h"
-#include "core/hle/ipc_helpers.h"
-#include "core/hle/kernel/hle_ipc.h"
 #include "core/hle/service/audio/codecctl.h"
 
 namespace Service::Audio {
 
-CodecCtl::CodecCtl() : ServiceFramework("codecctl") {
+CodecCtl::CodecCtl(Core::System& system_) : ServiceFramework{system_, "codecctl"} {
     static const FunctionInfo functions[] = {
         {0, nullptr, "InitializeCodecController"},
         {1, nullptr, "FinalizeCodecController"},

+ 3 - 3
src/core/hle/service/audio/codecctl.h

@@ -6,15 +6,15 @@
 
 #include "core/hle/service/service.h"
 
-namespace Kernel {
-class HLERequestContext;
+namespace Core {
+class System;
 }
 
 namespace Service::Audio {
 
 class CodecCtl final : public ServiceFramework<CodecCtl> {
 public:
-    explicit CodecCtl();
+    explicit CodecCtl(Core::System& system_);
     ~CodecCtl() override;
 };
 

+ 5 - 4
src/core/hle/service/audio/hwopus.cpp

@@ -160,8 +160,9 @@ private:
 
 class IHardwareOpusDecoderManager final : public ServiceFramework<IHardwareOpusDecoderManager> {
 public:
-    explicit IHardwareOpusDecoderManager(OpusDecoderState decoder_state)
-        : ServiceFramework("IHardwareOpusDecoderManager"), decoder_state{std::move(decoder_state)} {
+    explicit IHardwareOpusDecoderManager(Core::System& system_, OpusDecoderState decoder_state)
+        : ServiceFramework{system_, "IHardwareOpusDecoderManager"}, decoder_state{
+                                                                        std::move(decoder_state)} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &IHardwareOpusDecoderManager::DecodeInterleavedOld, "DecodeInterleavedOld"},
@@ -287,10 +288,10 @@ void HwOpus::OpenOpusDecoder(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
     rb.PushIpcInterface<IHardwareOpusDecoderManager>(
-        OpusDecoderState{std::move(decoder), sample_rate, channel_count});
+        system, OpusDecoderState{std::move(decoder), sample_rate, channel_count});
 }
 
-HwOpus::HwOpus() : ServiceFramework("hwopus") {
+HwOpus::HwOpus(Core::System& system_) : ServiceFramework{system_, "hwopus"} {
     static const FunctionInfo functions[] = {
         {0, &HwOpus::OpenOpusDecoder, "OpenOpusDecoder"},
         {1, &HwOpus::GetWorkBufferSize, "GetWorkBufferSize"},

+ 5 - 1
src/core/hle/service/audio/hwopus.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::Audio {
 
 class HwOpus final : public ServiceFramework<HwOpus> {
 public:
-    explicit HwOpus();
+    explicit HwOpus(Core::System& system_);
     ~HwOpus() override;
 
 private:

+ 20 - 20
src/core/hle/service/bcat/module.cpp

@@ -88,9 +88,11 @@ struct DeliveryCacheDirectoryEntry {
 
 class IDeliveryCacheProgressService final : public ServiceFramework<IDeliveryCacheProgressService> {
 public:
-    IDeliveryCacheProgressService(std::shared_ptr<Kernel::ReadableEvent> event,
-                                  const DeliveryCacheProgressImpl& impl)
-        : ServiceFramework{"IDeliveryCacheProgressService"}, event(std::move(event)), impl(impl) {
+    explicit IDeliveryCacheProgressService(Core::System& system_,
+                                           std::shared_ptr<Kernel::ReadableEvent> event_,
+                                           const DeliveryCacheProgressImpl& impl_)
+        : ServiceFramework{system_, "IDeliveryCacheProgressService"}, event{std::move(event_)},
+          impl{impl_} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &IDeliveryCacheProgressService::GetEvent, "GetEvent"},
@@ -126,7 +128,7 @@ private:
 class IBcatService final : public ServiceFramework<IBcatService> {
 public:
     explicit IBcatService(Core::System& system_, Backend& backend_)
-        : ServiceFramework("IBcatService"), system{system_}, backend{backend_},
+        : ServiceFramework{system_, "IBcatService"}, backend{backend_},
           progress{{
               ProgressServiceBackend{system_.Kernel(), "Normal"},
               ProgressServiceBackend{system_.Kernel(), "Directory"},
@@ -171,7 +173,7 @@ private:
 
     std::shared_ptr<IDeliveryCacheProgressService> CreateProgressService(SyncType type) {
         auto& backend{progress.at(static_cast<std::size_t>(type))};
-        return std::make_shared<IDeliveryCacheProgressService>(backend.GetEvent(),
+        return std::make_shared<IDeliveryCacheProgressService>(system, backend.GetEvent(),
                                                                backend.GetImpl());
     }
 
@@ -261,7 +263,6 @@ private:
         rb.Push(RESULT_SUCCESS);
     }
 
-    Core::System& system;
     Backend& backend;
 
     std::array<ProgressServiceBackend, static_cast<std::size_t>(SyncType::Count)> progress;
@@ -277,8 +278,8 @@ void Module::Interface::CreateBcatService(Kernel::HLERequestContext& ctx) {
 
 class IDeliveryCacheFileService final : public ServiceFramework<IDeliveryCacheFileService> {
 public:
-    IDeliveryCacheFileService(FileSys::VirtualDir root_)
-        : ServiceFramework{"IDeliveryCacheFileService"}, root(std::move(root_)) {
+    explicit IDeliveryCacheFileService(Core::System& system_, FileSys::VirtualDir root_)
+        : ServiceFramework{system_, "IDeliveryCacheFileService"}, root(std::move(root_)) {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &IDeliveryCacheFileService::Open, "Open"},
@@ -394,8 +395,8 @@ private:
 class IDeliveryCacheDirectoryService final
     : public ServiceFramework<IDeliveryCacheDirectoryService> {
 public:
-    IDeliveryCacheDirectoryService(FileSys::VirtualDir root_)
-        : ServiceFramework{"IDeliveryCacheDirectoryService"}, root(std::move(root_)) {
+    explicit IDeliveryCacheDirectoryService(Core::System& system_, FileSys::VirtualDir root_)
+        : ServiceFramework{system_, "IDeliveryCacheDirectoryService"}, root(std::move(root_)) {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &IDeliveryCacheDirectoryService::Open, "Open"},
@@ -492,8 +493,8 @@ private:
 
 class IDeliveryCacheStorageService final : public ServiceFramework<IDeliveryCacheStorageService> {
 public:
-    IDeliveryCacheStorageService(FileSys::VirtualDir root_)
-        : ServiceFramework{"IDeliveryCacheStorageService"}, root(std::move(root_)) {
+    explicit IDeliveryCacheStorageService(Core::System& system_, FileSys::VirtualDir root_)
+        : ServiceFramework{system_, "IDeliveryCacheStorageService"}, root(std::move(root_)) {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &IDeliveryCacheStorageService::CreateFileService, "CreateFileService"},
@@ -518,7 +519,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IDeliveryCacheFileService>(root);
+        rb.PushIpcInterface<IDeliveryCacheFileService>(system, root);
     }
 
     void CreateDirectoryService(Kernel::HLERequestContext& ctx) {
@@ -526,7 +527,7 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IDeliveryCacheDirectoryService>(root);
+        rb.PushIpcInterface<IDeliveryCacheDirectoryService>(system, root);
     }
 
     void EnumerateDeliveryCacheDirectory(Kernel::HLERequestContext& ctx) {
@@ -551,10 +552,10 @@ private:
 void Module::Interface::CreateDeliveryCacheStorageService(Kernel::HLERequestContext& ctx) {
     LOG_DEBUG(Service_BCAT, "called");
 
+    const auto title_id = system.CurrentProcess()->GetTitleID();
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<IDeliveryCacheStorageService>(
-        fsc.GetBCATDirectory(system.CurrentProcess()->GetTitleID()));
+    rb.PushIpcInterface<IDeliveryCacheStorageService>(system, fsc.GetBCATDirectory(title_id));
 }
 
 void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId(
@@ -566,7 +567,7 @@ void Module::Interface::CreateDeliveryCacheStorageServiceWithApplicationId(
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<IDeliveryCacheStorageService>(fsc.GetBCATDirectory(title_id));
+    rb.PushIpcInterface<IDeliveryCacheStorageService>(system, fsc.GetBCATDirectory(title_id));
 }
 
 std::unique_ptr<Backend> CreateBackendFromSettings([[maybe_unused]] Core::System& system,
@@ -582,10 +583,9 @@ std::unique_ptr<Backend> CreateBackendFromSettings([[maybe_unused]] Core::System
 
 Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> module_,
                              FileSystem::FileSystemController& fsc_, const char* name)
-    : ServiceFramework(name), fsc{fsc_}, module{std::move(module_)},
+    : ServiceFramework{system_, name}, fsc{fsc_}, module{std::move(module_)},
       backend{CreateBackendFromSettings(system_,
-                                        [&fsc_](u64 tid) { return fsc_.GetBCATDirectory(tid); })},
-      system{system_} {}
+                                        [&fsc_](u64 tid) { return fsc_.GetBCATDirectory(tid); })} {}
 
 Module::Interface::~Interface() = default;
 

+ 0 - 3
src/core/hle/service/bcat/module.h

@@ -37,9 +37,6 @@ public:
 
         std::shared_ptr<Module> module;
         std::unique_ptr<Backend> backend;
-
-    private:
-        Core::System& system;
     };
 };
 

+ 5 - 5
src/core/hle/service/bpc/bpc.cpp

@@ -12,7 +12,7 @@ namespace Service::BPC {
 
 class BPC final : public ServiceFramework<BPC> {
 public:
-    explicit BPC() : ServiceFramework{"bpc"} {
+    explicit BPC(Core::System& system_) : ServiceFramework{system_, "bpc"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "ShutdownSystem"},
@@ -40,7 +40,7 @@ public:
 
 class BPC_R final : public ServiceFramework<BPC_R> {
 public:
-    explicit BPC_R() : ServiceFramework{"bpc:r"} {
+    explicit BPC_R(Core::System& system_) : ServiceFramework{system_, "bpc:r"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "GetRtcTime"},
@@ -55,9 +55,9 @@ public:
     }
 };
 
-void InstallInterfaces(SM::ServiceManager& sm) {
-    std::make_shared<BPC>()->InstallAsService(sm);
-    std::make_shared<BPC_R>()->InstallAsService(sm);
+void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
+    std::make_shared<BPC>(system)->InstallAsService(sm);
+    std::make_shared<BPC_R>(system)->InstallAsService(sm);
 }
 
 } // namespace Service::BPC

+ 5 - 1
src/core/hle/service/bpc/bpc.h

@@ -4,12 +4,16 @@
 
 #pragma once
 
+namespace Core {
+class System;
+}
+
 namespace Service::SM {
 class ServiceManager;
 }
 
 namespace Service::BPC {
 
-void InstallInterfaces(SM::ServiceManager& sm);
+void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
 
 } // namespace Service::BPC

+ 3 - 3
src/core/hle/service/btdrv/btdrv.cpp

@@ -17,7 +17,7 @@ namespace Service::BtDrv {
 
 class Bt final : public ServiceFramework<Bt> {
 public:
-    explicit Bt(Core::System& system) : ServiceFramework{"bt"} {
+    explicit Bt(Core::System& system_) : ServiceFramework{system_, "bt"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "LeClientReadCharacteristic"},
@@ -52,7 +52,7 @@ private:
 
 class BtDrv final : public ServiceFramework<BtDrv> {
 public:
-    explicit BtDrv() : ServiceFramework{"btdrv"} {
+    explicit BtDrv(Core::System& system_) : ServiceFramework{system_, "btdrv"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "InitializeBluetoothDriver"},
@@ -166,7 +166,7 @@ public:
 };
 
 void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
-    std::make_shared<BtDrv>()->InstallAsService(sm);
+    std::make_shared<BtDrv>(system)->InstallAsService(sm);
     std::make_shared<Bt>(system)->InstallAsService(sm);
 }
 

+ 10 - 12
src/core/hle/service/btm/btm.cpp

@@ -18,7 +18,7 @@ namespace Service::BTM {
 
 class IBtmUserCore final : public ServiceFramework<IBtmUserCore> {
 public:
-    explicit IBtmUserCore(Core::System& system) : ServiceFramework{"IBtmUserCore"} {
+    explicit IBtmUserCore(Core::System& system_) : ServiceFramework{system_, "IBtmUserCore"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &IBtmUserCore::AcquireBleScanEvent, "AcquireBleScanEvent"},
@@ -107,7 +107,7 @@ private:
 
 class BTM_USR final : public ServiceFramework<BTM_USR> {
 public:
-    explicit BTM_USR(Core::System& system) : ServiceFramework{"btm:u"}, system(system) {
+    explicit BTM_USR(Core::System& system_) : ServiceFramework{system_, "btm:u"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &BTM_USR::GetCore, "GetCore"},
@@ -124,13 +124,11 @@ private:
         rb.Push(RESULT_SUCCESS);
         rb.PushIpcInterface<IBtmUserCore>(system);
     }
-
-    Core::System& system;
 };
 
 class BTM final : public ServiceFramework<BTM> {
 public:
-    explicit BTM() : ServiceFramework{"btm"} {
+    explicit BTM(Core::System& system_) : ServiceFramework{system_, "btm"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "GetState"},
@@ -207,7 +205,7 @@ public:
 
 class BTM_DBG final : public ServiceFramework<BTM_DBG> {
 public:
-    explicit BTM_DBG() : ServiceFramework{"btm:dbg"} {
+    explicit BTM_DBG(Core::System& system_) : ServiceFramework{system_, "btm:dbg"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "AcquireDiscoveryEvent"},
@@ -232,7 +230,7 @@ public:
 
 class IBtmSystemCore final : public ServiceFramework<IBtmSystemCore> {
 public:
-    explicit IBtmSystemCore() : ServiceFramework{"IBtmSystemCore"} {
+    explicit IBtmSystemCore(Core::System& system_) : ServiceFramework{system_, "IBtmSystemCore"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "StartGamepadPairing"},
@@ -254,7 +252,7 @@ public:
 
 class BTM_SYS final : public ServiceFramework<BTM_SYS> {
 public:
-    explicit BTM_SYS() : ServiceFramework{"btm:sys"} {
+    explicit BTM_SYS(Core::System& system_) : ServiceFramework{system_, "btm:sys"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &BTM_SYS::GetCore, "GetCore"},
@@ -270,14 +268,14 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IBtmSystemCore>();
+        rb.PushIpcInterface<IBtmSystemCore>(system);
     }
 };
 
 void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
-    std::make_shared<BTM>()->InstallAsService(sm);
-    std::make_shared<BTM_DBG>()->InstallAsService(sm);
-    std::make_shared<BTM_SYS>()->InstallAsService(sm);
+    std::make_shared<BTM>(system)->InstallAsService(sm);
+    std::make_shared<BTM_DBG>(system)->InstallAsService(sm);
+    std::make_shared<BTM_SYS>(system)->InstallAsService(sm);
     std::make_shared<BTM_USR>(system)->InstallAsService(sm);
 }
 

+ 7 - 7
src/core/hle/service/caps/caps.cpp

@@ -13,13 +13,13 @@
 
 namespace Service::Capture {
 
-void InstallInterfaces(SM::ServiceManager& sm) {
-    std::make_shared<CAPS_A>()->InstallAsService(sm);
-    std::make_shared<CAPS_C>()->InstallAsService(sm);
-    std::make_shared<CAPS_U>()->InstallAsService(sm);
-    std::make_shared<CAPS_SC>()->InstallAsService(sm);
-    std::make_shared<CAPS_SS>()->InstallAsService(sm);
-    std::make_shared<CAPS_SU>()->InstallAsService(sm);
+void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
+    std::make_shared<CAPS_A>(system)->InstallAsService(sm);
+    std::make_shared<CAPS_C>(system)->InstallAsService(sm);
+    std::make_shared<CAPS_U>(system)->InstallAsService(sm);
+    std::make_shared<CAPS_SC>(system)->InstallAsService(sm);
+    std::make_shared<CAPS_SS>(system)->InstallAsService(sm);
+    std::make_shared<CAPS_SU>(system)->InstallAsService(sm);
 }
 
 } // namespace Service::Capture

+ 5 - 1
src/core/hle/service/caps/caps.h

@@ -6,6 +6,10 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::SM {
 class ServiceManager;
 }
@@ -87,6 +91,6 @@ static_assert(sizeof(ApplicationAlbumFileEntry) == 0x30,
               "ApplicationAlbumFileEntry has incorrect size.");
 
 /// Registers all Capture services with the specified service manager.
-void InstallInterfaces(SM::ServiceManager& sm);
+void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
 
 } // namespace Service::Capture

+ 3 - 2
src/core/hle/service/caps/caps_a.cpp

@@ -8,7 +8,8 @@ namespace Service::Capture {
 
 class IAlbumAccessorSession final : public ServiceFramework<IAlbumAccessorSession> {
 public:
-    explicit IAlbumAccessorSession() : ServiceFramework{"IAlbumAccessorSession"} {
+    explicit IAlbumAccessorSession(Core::System& system_)
+        : ServiceFramework{system_, "IAlbumAccessorSession"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {2001, nullptr, "OpenAlbumMovieReadStream"},
@@ -26,7 +27,7 @@ public:
     }
 };
 
-CAPS_A::CAPS_A() : ServiceFramework("caps:a") {
+CAPS_A::CAPS_A(Core::System& system_) : ServiceFramework{system_, "caps:a"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "GetAlbumFileCount"},

+ 5 - 1
src/core/hle/service/caps/caps_a.h

@@ -6,6 +6,10 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Kernel {
 class HLERequestContext;
 }
@@ -14,7 +18,7 @@ namespace Service::Capture {
 
 class CAPS_A final : public ServiceFramework<CAPS_A> {
 public:
-    explicit CAPS_A();
+    explicit CAPS_A(Core::System& system_);
     ~CAPS_A() override;
 };
 

+ 3 - 2
src/core/hle/service/caps/caps_c.cpp

@@ -10,7 +10,8 @@ namespace Service::Capture {
 
 class IAlbumControlSession final : public ServiceFramework<IAlbumControlSession> {
 public:
-    explicit IAlbumControlSession() : ServiceFramework{"IAlbumControlSession"} {
+    explicit IAlbumControlSession(Core::System& system_)
+        : ServiceFramework{system_, "IAlbumControlSession"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {2001, nullptr, "OpenAlbumMovieReadStream"},
@@ -44,7 +45,7 @@ public:
     }
 };
 
-CAPS_C::CAPS_C() : ServiceFramework("caps:c") {
+CAPS_C::CAPS_C(Core::System& system_) : ServiceFramework{system_, "caps:c"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {1, nullptr, "CaptureRawImage"},

+ 5 - 1
src/core/hle/service/caps/caps_c.h

@@ -6,6 +6,10 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Kernel {
 class HLERequestContext;
 }
@@ -14,7 +18,7 @@ namespace Service::Capture {
 
 class CAPS_C final : public ServiceFramework<CAPS_C> {
 public:
-    explicit CAPS_C();
+    explicit CAPS_C(Core::System& system_);
     ~CAPS_C() override;
 
 private:

+ 1 - 1
src/core/hle/service/caps/caps_sc.cpp

@@ -6,7 +6,7 @@
 
 namespace Service::Capture {
 
-CAPS_SC::CAPS_SC() : ServiceFramework("caps:sc") {
+CAPS_SC::CAPS_SC(Core::System& system_) : ServiceFramework{system_, "caps:sc"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {1, nullptr, "CaptureRawImage"},

+ 3 - 3
src/core/hle/service/caps/caps_sc.h

@@ -6,15 +6,15 @@
 
 #include "core/hle/service/service.h"
 
-namespace Kernel {
-class HLERequestContext;
+namespace Core {
+class System;
 }
 
 namespace Service::Capture {
 
 class CAPS_SC final : public ServiceFramework<CAPS_SC> {
 public:
-    explicit CAPS_SC();
+    explicit CAPS_SC(Core::System& system_);
     ~CAPS_SC() override;
 };
 

+ 1 - 1
src/core/hle/service/caps/caps_ss.cpp

@@ -6,7 +6,7 @@
 
 namespace Service::Capture {
 
-CAPS_SS::CAPS_SS() : ServiceFramework("caps:ss") {
+CAPS_SS::CAPS_SS(Core::System& system_) : ServiceFramework{system_, "caps:ss"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {201, nullptr, "SaveScreenShot"},

+ 3 - 3
src/core/hle/service/caps/caps_ss.h

@@ -6,15 +6,15 @@
 
 #include "core/hle/service/service.h"
 
-namespace Kernel {
-class HLERequestContext;
+namespace Core {
+class System;
 }
 
 namespace Service::Capture {
 
 class CAPS_SS final : public ServiceFramework<CAPS_SS> {
 public:
-    explicit CAPS_SS();
+    explicit CAPS_SS(Core::System& system_);
     ~CAPS_SS() override;
 };
 

+ 1 - 1
src/core/hle/service/caps/caps_su.cpp

@@ -8,7 +8,7 @@
 
 namespace Service::Capture {
 
-CAPS_SU::CAPS_SU() : ServiceFramework("caps:su") {
+CAPS_SU::CAPS_SU(Core::System& system_) : ServiceFramework{system_, "caps:su"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {32, &CAPS_SU::SetShimLibraryVersion, "SetShimLibraryVersion"},

+ 5 - 1
src/core/hle/service/caps/caps_su.h

@@ -6,6 +6,10 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Kernel {
 class HLERequestContext;
 }
@@ -14,7 +18,7 @@ namespace Service::Capture {
 
 class CAPS_SU final : public ServiceFramework<CAPS_SU> {
 public:
-    explicit CAPS_SU();
+    explicit CAPS_SU(Core::System& system_);
     ~CAPS_SU() override;
 
 private:

+ 3 - 3
src/core/hle/service/caps/caps_u.cpp

@@ -12,8 +12,8 @@ namespace Service::Capture {
 class IAlbumAccessorApplicationSession final
     : public ServiceFramework<IAlbumAccessorApplicationSession> {
 public:
-    explicit IAlbumAccessorApplicationSession()
-        : ServiceFramework{"IAlbumAccessorApplicationSession"} {
+    explicit IAlbumAccessorApplicationSession(Core::System& system_)
+        : ServiceFramework{system_, "IAlbumAccessorApplicationSession"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {2001, nullptr, "OpenAlbumMovieReadStream"},
@@ -28,7 +28,7 @@ public:
     }
 };
 
-CAPS_U::CAPS_U() : ServiceFramework("caps:u") {
+CAPS_U::CAPS_U(Core::System& system_) : ServiceFramework{system_, "caps:u"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {32, &CAPS_U::SetShimLibraryVersion, "SetShimLibraryVersion"},

+ 5 - 1
src/core/hle/service/caps/caps_u.h

@@ -6,6 +6,10 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Kernel {
 class HLERequestContext;
 }
@@ -14,7 +18,7 @@ namespace Service::Capture {
 
 class CAPS_U final : public ServiceFramework<CAPS_U> {
 public:
-    explicit CAPS_U();
+    explicit CAPS_U(Core::System& system_);
     ~CAPS_U() override;
 
 private:

+ 5 - 5
src/core/hle/service/erpt/erpt.cpp

@@ -12,7 +12,7 @@ namespace Service::ERPT {
 
 class ErrorReportContext final : public ServiceFramework<ErrorReportContext> {
 public:
-    explicit ErrorReportContext() : ServiceFramework{"erpt:c"} {
+    explicit ErrorReportContext(Core::System& system_) : ServiceFramework{system_, "erpt:c"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "SubmitContext"},
@@ -35,7 +35,7 @@ public:
 
 class ErrorReportSession final : public ServiceFramework<ErrorReportSession> {
 public:
-    explicit ErrorReportSession() : ServiceFramework{"erpt:r"} {
+    explicit ErrorReportSession(Core::System& system_) : ServiceFramework{system_, "erpt:r"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "OpenReport"},
@@ -48,9 +48,9 @@ public:
     }
 };
 
-void InstallInterfaces(SM::ServiceManager& sm) {
-    std::make_shared<ErrorReportContext>()->InstallAsService(sm);
-    std::make_shared<ErrorReportSession>()->InstallAsService(sm);
+void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
+    std::make_shared<ErrorReportContext>(system)->InstallAsService(sm);
+    std::make_shared<ErrorReportSession>(system)->InstallAsService(sm);
 }
 
 } // namespace Service::ERPT

+ 5 - 1
src/core/hle/service/erpt/erpt.h

@@ -4,6 +4,10 @@
 
 #pragma once
 
+namespace Core {
+class System;
+}
+
 namespace Service::SM {
 class ServiceManager;
 }
@@ -11,6 +15,6 @@ class ServiceManager;
 namespace Service::ERPT {
 
 /// Registers all ERPT services with the specified service manager.
-void InstallInterfaces(SM::ServiceManager& sm);
+void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
 
 } // namespace Service::ERPT

+ 3 - 3
src/core/hle/service/es/es.cpp

@@ -14,7 +14,7 @@ constexpr ResultCode ERROR_INVALID_RIGHTS_ID{ErrorModule::ETicket, 3};
 
 class ETicket final : public ServiceFramework<ETicket> {
 public:
-    explicit ETicket() : ServiceFramework{"es"} {
+    explicit ETicket(Core::System& system_) : ServiceFramework{system_, "es"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {1, &ETicket::ImportTicket, "ImportTicket"},
@@ -305,8 +305,8 @@ private:
     Core::Crypto::KeyManager& keys = Core::Crypto::KeyManager::Instance();
 };
 
-void InstallInterfaces(SM::ServiceManager& service_manager) {
-    std::make_shared<ETicket>()->InstallAsService(service_manager);
+void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
+    std::make_shared<ETicket>(system)->InstallAsService(service_manager);
 }
 
 } // namespace Service::ES

+ 5 - 1
src/core/hle/service/es/es.h

@@ -4,6 +4,10 @@
 
 #pragma once
 
+namespace Core {
+class System;
+}
+
 namespace Service::SM {
 class ServiceManager;
 }
@@ -11,6 +15,6 @@ class ServiceManager;
 namespace Service::ES {
 
 /// Registers all ES services with the specified service manager.
-void InstallInterfaces(SM::ServiceManager& service_manager);
+void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
 
 } // namespace Service::ES

+ 5 - 5
src/core/hle/service/eupld/eupld.cpp

@@ -12,7 +12,7 @@ namespace Service::EUPLD {
 
 class ErrorUploadContext final : public ServiceFramework<ErrorUploadContext> {
 public:
-    explicit ErrorUploadContext() : ServiceFramework{"eupld:c"} {
+    explicit ErrorUploadContext(Core::System& system_) : ServiceFramework{system_, "eupld:c"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "SetUrl"},
@@ -29,7 +29,7 @@ public:
 
 class ErrorUploadRequest final : public ServiceFramework<ErrorUploadRequest> {
 public:
-    explicit ErrorUploadRequest() : ServiceFramework{"eupld:r"} {
+    explicit ErrorUploadRequest(Core::System& system_) : ServiceFramework{system_, "eupld:r"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "Initialize"},
@@ -45,9 +45,9 @@ public:
     }
 };
 
-void InstallInterfaces(SM::ServiceManager& sm) {
-    std::make_shared<ErrorUploadContext>()->InstallAsService(sm);
-    std::make_shared<ErrorUploadRequest>()->InstallAsService(sm);
+void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
+    std::make_shared<ErrorUploadContext>(system)->InstallAsService(sm);
+    std::make_shared<ErrorUploadRequest>(system)->InstallAsService(sm);
 }
 
 } // namespace Service::EUPLD

+ 5 - 1
src/core/hle/service/eupld/eupld.h

@@ -4,6 +4,10 @@
 
 #pragma once
 
+namespace Core {
+class System;
+}
+
 namespace Service::SM {
 class ServiceManager;
 }
@@ -11,6 +15,6 @@ class ServiceManager;
 namespace Service::EUPLD {
 
 /// Registers all EUPLD services with the specified service manager.
-void InstallInterfaces(SM::ServiceManager& sm);
+void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
 
 } // namespace Service::EUPLD

+ 3 - 2
src/core/hle/service/fatal/fatal.cpp

@@ -20,8 +20,9 @@
 
 namespace Service::Fatal {
 
-Module::Interface::Interface(std::shared_ptr<Module> module, Core::System& system, const char* name)
-    : ServiceFramework(name), module(std::move(module)), system(system) {}
+Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_,
+                             const char* name)
+    : ServiceFramework{system_, name}, module{std::move(module_)} {}
 
 Module::Interface::~Interface() = default;
 

+ 2 - 2
src/core/hle/service/fatal/fatal.h

@@ -16,7 +16,8 @@ class Module final {
 public:
     class Interface : public ServiceFramework<Interface> {
     public:
-        explicit Interface(std::shared_ptr<Module> module, Core::System& system, const char* name);
+        explicit Interface(std::shared_ptr<Module> module_, Core::System& system_,
+                           const char* name);
         ~Interface() override;
 
         void ThrowFatal(Kernel::HLERequestContext& ctx);
@@ -25,7 +26,6 @@ public:
 
     protected:
         std::shared_ptr<Module> module;
-        Core::System& system;
     };
 };
 

+ 2 - 2
src/core/hle/service/fatal/fatal_p.cpp

@@ -6,8 +6,8 @@
 
 namespace Service::Fatal {
 
-Fatal_P::Fatal_P(std::shared_ptr<Module> module, Core::System& system)
-    : Module::Interface(std::move(module), system, "fatal:p") {}
+Fatal_P::Fatal_P(std::shared_ptr<Module> module_, Core::System& system_)
+    : Interface(std::move(module_), system_, "fatal:p") {}
 
 Fatal_P::~Fatal_P() = default;
 

+ 1 - 1
src/core/hle/service/fatal/fatal_p.h

@@ -10,7 +10,7 @@ namespace Service::Fatal {
 
 class Fatal_P final : public Module::Interface {
 public:
-    explicit Fatal_P(std::shared_ptr<Module> module, Core::System& system);
+    explicit Fatal_P(std::shared_ptr<Module> module_, Core::System& system_);
     ~Fatal_P() override;
 };
 

+ 2 - 2
src/core/hle/service/fatal/fatal_u.cpp

@@ -6,8 +6,8 @@
 
 namespace Service::Fatal {
 
-Fatal_U::Fatal_U(std::shared_ptr<Module> module, Core::System& system)
-    : Module::Interface(std::move(module), system, "fatal:u") {
+Fatal_U::Fatal_U(std::shared_ptr<Module> module_, Core::System& system_)
+    : Interface(std::move(module_), system_, "fatal:u") {
     static const FunctionInfo functions[] = {
         {0, &Fatal_U::ThrowFatal, "ThrowFatal"},
         {1, &Fatal_U::ThrowFatalWithPolicy, "ThrowFatalWithPolicy"},

+ 1 - 1
src/core/hle/service/fatal/fatal_u.h

@@ -10,7 +10,7 @@ namespace Service::Fatal {
 
 class Fatal_U final : public Module::Interface {
 public:
-    explicit Fatal_U(std::shared_ptr<Module> module, Core::System& system);
+    explicit Fatal_U(std::shared_ptr<Module> module_, Core::System& system_);
     ~Fatal_U() override;
 };
 

+ 9 - 9
src/core/hle/service/fgm/fgm.cpp

@@ -14,7 +14,7 @@ namespace Service::FGM {
 
 class IRequest final : public ServiceFramework<IRequest> {
 public:
-    explicit IRequest() : ServiceFramework{"IRequest"} {
+    explicit IRequest(Core::System& system_) : ServiceFramework{system_, "IRequest"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "Initialize"},
@@ -30,7 +30,7 @@ public:
 
 class FGM final : public ServiceFramework<FGM> {
 public:
-    explicit FGM(const char* name) : ServiceFramework{name} {
+    explicit FGM(Core::System& system_, const char* name) : ServiceFramework{system_, name} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &FGM::Initialize, "Initialize"},
@@ -46,13 +46,13 @@ private:
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
-        rb.PushIpcInterface<IRequest>();
+        rb.PushIpcInterface<IRequest>(system);
     }
 };
 
 class FGM_DBG final : public ServiceFramework<FGM_DBG> {
 public:
-    explicit FGM_DBG() : ServiceFramework{"fgm:dbg"} {
+    explicit FGM_DBG(Core::System& system_) : ServiceFramework{system_, "fgm:dbg"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "Initialize"},
@@ -65,11 +65,11 @@ public:
     }
 };
 
-void InstallInterfaces(SM::ServiceManager& sm) {
-    std::make_shared<FGM>("fgm")->InstallAsService(sm);
-    std::make_shared<FGM>("fgm:0")->InstallAsService(sm);
-    std::make_shared<FGM>("fgm:9")->InstallAsService(sm);
-    std::make_shared<FGM_DBG>()->InstallAsService(sm);
+void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
+    std::make_shared<FGM>(system, "fgm")->InstallAsService(sm);
+    std::make_shared<FGM>(system, "fgm:0")->InstallAsService(sm);
+    std::make_shared<FGM>(system, "fgm:9")->InstallAsService(sm);
+    std::make_shared<FGM_DBG>(system)->InstallAsService(sm);
 }
 
 } // namespace Service::FGM

+ 5 - 1
src/core/hle/service/fgm/fgm.h

@@ -4,12 +4,16 @@
 
 #pragma once
 
+namespace Core {
+class System;
+}
+
 namespace Service::SM {
 class ServiceManager;
 }
 
 namespace Service::FGM {
 
-void InstallInterfaces(SM::ServiceManager& sm);
+void InstallInterfaces(SM::ServiceManager& sm, Core::System& system);
 
 } // namespace Service::FGM

+ 3 - 5
src/core/hle/service/filesystem/filesystem.cpp

@@ -728,11 +728,9 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove
 }
 
 void InstallInterfaces(Core::System& system) {
-    std::make_shared<FSP_LDR>()->InstallAsService(system.ServiceManager());
-    std::make_shared<FSP_PR>()->InstallAsService(system.ServiceManager());
-    std::make_shared<FSP_SRV>(system.GetFileSystemController(), system.GetContentProvider(),
-                              system.GetReporter())
-        ->InstallAsService(system.ServiceManager());
+    std::make_shared<FSP_LDR>(system)->InstallAsService(system.ServiceManager());
+    std::make_shared<FSP_PR>(system)->InstallAsService(system.ServiceManager());
+    std::make_shared<FSP_SRV>(system)->InstallAsService(system.ServiceManager());
 }
 
 } // namespace Service::FileSystem

+ 1 - 1
src/core/hle/service/filesystem/fsp_ldr.cpp

@@ -7,7 +7,7 @@
 
 namespace Service::FileSystem {
 
-FSP_LDR::FSP_LDR() : ServiceFramework{"fsp:ldr"} {
+FSP_LDR::FSP_LDR(Core::System& system_) : ServiceFramework{system_, "fsp:ldr"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "OpenCodeFileSystem"},

+ 5 - 1
src/core/hle/service/filesystem/fsp_ldr.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::FileSystem {
 
 class FSP_LDR final : public ServiceFramework<FSP_LDR> {
 public:
-    explicit FSP_LDR();
+    explicit FSP_LDR(Core::System& system_);
     ~FSP_LDR() override;
 };
 

+ 1 - 1
src/core/hle/service/filesystem/fsp_pr.cpp

@@ -7,7 +7,7 @@
 
 namespace Service::FileSystem {
 
-FSP_PR::FSP_PR() : ServiceFramework{"fsp:pr"} {
+FSP_PR::FSP_PR(Core::System& system_) : ServiceFramework{system_, "fsp:pr"} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "RegisterProgram"},

+ 5 - 1
src/core/hle/service/filesystem/fsp_pr.h

@@ -6,11 +6,15 @@
 
 #include "core/hle/service/service.h"
 
+namespace Core {
+class System;
+}
+
 namespace Service::FileSystem {
 
 class FSP_PR final : public ServiceFramework<FSP_PR> {
 public:
-    explicit FSP_PR();
+    explicit FSP_PR(Core::System& system_);
     ~FSP_PR() override;
 };
 

+ 31 - 26
src/core/hle/service/filesystem/fsp_srv.cpp

@@ -14,6 +14,7 @@
 #include "common/hex_util.h"
 #include "common/logging/log.h"
 #include "common/string_util.h"
+#include "core/core.h"
 #include "core/file_sys/directory.h"
 #include "core/file_sys/errors.h"
 #include "core/file_sys/mode.h"
@@ -56,8 +57,8 @@ enum class FileSystemType : u8 {
 
 class IStorage final : public ServiceFramework<IStorage> {
 public:
-    explicit IStorage(FileSys::VirtualFile backend_)
-        : ServiceFramework("IStorage"), backend(std::move(backend_)) {
+    explicit IStorage(Core::System& system_, FileSys::VirtualFile backend_)
+        : ServiceFramework{system_, "IStorage"}, backend(std::move(backend_)) {
         static const FunctionInfo functions[] = {
             {0, &IStorage::Read, "Read"},
             {1, nullptr, "Write"},
@@ -114,8 +115,8 @@ private:
 
 class IFile final : public ServiceFramework<IFile> {
 public:
-    explicit IFile(FileSys::VirtualFile backend_)
-        : ServiceFramework("IFile"), backend(std::move(backend_)) {
+    explicit IFile(Core::System& system_, FileSys::VirtualFile backend_)
+        : ServiceFramework{system_, "IFile"}, backend(std::move(backend_)) {
         static const FunctionInfo functions[] = {
             {0, &IFile::Read, "Read"},       {1, &IFile::Write, "Write"},
             {2, &IFile::Flush, "Flush"},     {3, &IFile::SetSize, "SetSize"},
@@ -246,8 +247,8 @@ static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vec
 
 class IDirectory final : public ServiceFramework<IDirectory> {
 public:
-    explicit IDirectory(FileSys::VirtualDir backend_)
-        : ServiceFramework("IDirectory"), backend(std::move(backend_)) {
+    explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_)
+        : ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) {
         static const FunctionInfo functions[] = {
             {0, &IDirectory::Read, "Read"},
             {1, &IDirectory::GetEntryCount, "GetEntryCount"},
@@ -302,8 +303,9 @@ private:
 
 class IFileSystem final : public ServiceFramework<IFileSystem> {
 public:
-    explicit IFileSystem(FileSys::VirtualDir backend, SizeGetter size)
-        : ServiceFramework("IFileSystem"), backend(std::move(backend)), size(std::move(size)) {
+    explicit IFileSystem(Core::System& system_, FileSys::VirtualDir backend_, SizeGetter size_)
+        : ServiceFramework{system_, "IFileSystem"}, backend{std::move(backend_)}, size{std::move(
+                                                                                      size_)} {
         static const FunctionInfo functions[] = {
             {0, &IFileSystem::CreateFile, "CreateFile"},
             {1, &IFileSystem::DeleteFile, "DeleteFile"},
@@ -420,7 +422,7 @@ public:
             return;
         }
 
-        auto file = std::make_shared<IFile>(result.Unwrap());
+        auto file = std::make_shared<IFile>(system, result.Unwrap());
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
@@ -445,7 +447,7 @@ public:
             return;
         }
 
-        auto directory = std::make_shared<IDirectory>(result.Unwrap());
+        auto directory = std::make_shared<IDirectory>(system, result.Unwrap());
 
         IPC::ResponseBuilder rb{ctx, 2, 0, 1};
         rb.Push(RESULT_SUCCESS);
@@ -500,8 +502,9 @@ private:
 
 class ISaveDataInfoReader final : public ServiceFramework<ISaveDataInfoReader> {
 public:
-    explicit ISaveDataInfoReader(FileSys::SaveDataSpaceId space, FileSystemController& fsc)
-        : ServiceFramework("ISaveDataInfoReader"), fsc(fsc) {
+    explicit ISaveDataInfoReader(Core::System& system_, FileSys::SaveDataSpaceId space,
+                                 FileSystemController& fsc_)
+        : ServiceFramework{system_, "ISaveDataInfoReader"}, fsc{fsc_} {
         static const FunctionInfo functions[] = {
             {0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"},
         };
@@ -650,10 +653,9 @@ private:
     u64 next_entry_index = 0;
 };
 
-FSP_SRV::FSP_SRV(FileSystemController& fsc_, const FileSys::ContentProvider& content_provider_,
-                 const Core::Reporter& reporter_)
-    : ServiceFramework("fsp-srv"), fsc(fsc_), content_provider{content_provider_},
-      reporter(reporter_) {
+FSP_SRV::FSP_SRV(Core::System& system_)
+    : ServiceFramework{system_, "fsp-srv"}, fsc{system.GetFileSystemController()},
+      content_provider{system.GetContentProvider()}, reporter{system.GetReporter()} {
     // clang-format off
     static const FunctionInfo functions[] = {
         {0, nullptr, "OpenFileSystem"},
@@ -803,8 +805,9 @@ void FSP_SRV::OpenFileSystemWithPatch(Kernel::HLERequestContext& ctx) {
 void FSP_SRV::OpenSdCardFileSystem(Kernel::HLERequestContext& ctx) {
     LOG_DEBUG(Service_FS, "called");
 
-    auto filesystem = std::make_shared<IFileSystem>(
-        fsc.OpenSDMC().Unwrap(), SizeGetter::FromStorageId(fsc, FileSys::StorageId::SdCard));
+    auto filesystem =
+        std::make_shared<IFileSystem>(system, fsc.OpenSDMC().Unwrap(),
+                                      SizeGetter::FromStorageId(fsc, FileSys::StorageId::SdCard));
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
@@ -864,8 +867,8 @@ void FSP_SRV::OpenSaveDataFileSystem(Kernel::HLERequestContext& ctx) {
         UNREACHABLE();
     }
 
-    auto filesystem =
-        std::make_shared<IFileSystem>(std::move(dir.Unwrap()), SizeGetter::FromStorageId(fsc, id));
+    auto filesystem = std::make_shared<IFileSystem>(system, std::move(dir.Unwrap()),
+                                                    SizeGetter::FromStorageId(fsc, id));
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
@@ -884,7 +887,8 @@ void FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId(Kernel::HLERequestContext&
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<ISaveDataInfoReader>(std::make_shared<ISaveDataInfoReader>(space, fsc));
+    rb.PushIpcInterface<ISaveDataInfoReader>(
+        std::make_shared<ISaveDataInfoReader>(system, space, fsc));
 }
 
 void FSP_SRV::WriteSaveDataFileSystemExtraDataBySaveDataAttribute(Kernel::HLERequestContext& ctx) {
@@ -933,7 +937,7 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) {
         return;
     }
 
-    auto storage = std::make_shared<IStorage>(std::move(romfs.Unwrap()));
+    auto storage = std::make_shared<IStorage>(system, std::move(romfs.Unwrap()));
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
@@ -957,7 +961,7 @@ void FSP_SRV::OpenDataStorageByDataId(Kernel::HLERequestContext& ctx) {
         if (archive != nullptr) {
             IPC::ResponseBuilder rb{ctx, 2, 0, 1};
             rb.Push(RESULT_SUCCESS);
-            rb.PushIpcInterface(std::make_shared<IStorage>(archive));
+            rb.PushIpcInterface(std::make_shared<IStorage>(system, archive));
             return;
         }
 
@@ -973,7 +977,7 @@ void FSP_SRV::OpenDataStorageByDataId(Kernel::HLERequestContext& ctx) {
     const FileSys::PatchManager pm{title_id, fsc, content_provider};
 
     auto storage = std::make_shared<IStorage>(
-        pm.PatchRomFS(std::move(data.Unwrap()), 0, FileSys::ContentRecordType::Data));
+        system, pm.PatchRomFS(std::move(data.Unwrap()), 0, FileSys::ContentRecordType::Data));
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
@@ -1035,7 +1039,8 @@ void FSP_SRV::GetAccessLogVersionInfo(Kernel::HLERequestContext& ctx) {
 
 class IMultiCommitManager final : public ServiceFramework<IMultiCommitManager> {
 public:
-    explicit IMultiCommitManager() : ServiceFramework("IMultiCommitManager") {
+    explicit IMultiCommitManager(Core::System& system_)
+        : ServiceFramework{system_, "IMultiCommitManager"} {
         static const FunctionInfo functions[] = {
             {1, &IMultiCommitManager::Add, "Add"},
             {2, &IMultiCommitManager::Commit, "Commit"},
@@ -1066,7 +1071,7 @@ void FSP_SRV::OpenMultiCommitManager(Kernel::HLERequestContext& ctx) {
 
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<IMultiCommitManager>(std::make_shared<IMultiCommitManager>());
+    rb.PushIpcInterface<IMultiCommitManager>(std::make_shared<IMultiCommitManager>(system));
 }
 
 } // namespace Service::FileSystem

+ 1 - 2
src/core/hle/service/filesystem/fsp_srv.h

@@ -33,8 +33,7 @@ enum class LogMode : u32 {
 
 class FSP_SRV final : public ServiceFramework<FSP_SRV> {
 public:
-    explicit FSP_SRV(FileSystemController& fsc_, const FileSys::ContentProvider& content_provider_,
-                     const Core::Reporter& reporter_);
+    explicit FSP_SRV(Core::System& system_);
     ~FSP_SRV() override;
 
 private:

+ 7 - 6
src/core/hle/service/friend/friend.cpp

@@ -17,7 +17,7 @@ namespace Service::Friend {
 
 class IFriendService final : public ServiceFramework<IFriendService> {
 public:
-    IFriendService() : ServiceFramework("IFriendService") {
+    explicit IFriendService(Core::System& system_) : ServiceFramework{system_, "IFriendService"} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, nullptr, "GetCompletionEvent"},
@@ -171,8 +171,8 @@ private:
 
 class INotificationService final : public ServiceFramework<INotificationService> {
 public:
-    INotificationService(Common::UUID uuid, Core::System& system)
-        : ServiceFramework("INotificationService"), uuid(uuid) {
+    explicit INotificationService(Common::UUID uuid_, Core::System& system_)
+        : ServiceFramework{system_, "INotificationService"}, uuid{uuid_} {
         // clang-format off
         static const FunctionInfo functions[] = {
             {0, &INotificationService::GetEvent, "GetEvent"},
@@ -267,7 +267,7 @@ private:
 void Module::Interface::CreateFriendService(Kernel::HLERequestContext& ctx) {
     IPC::ResponseBuilder rb{ctx, 2, 0, 1};
     rb.Push(RESULT_SUCCESS);
-    rb.PushIpcInterface<IFriendService>();
+    rb.PushIpcInterface<IFriendService>(system);
     LOG_DEBUG(Service_ACC, "called");
 }
 
@@ -282,8 +282,9 @@ void Module::Interface::CreateNotificationService(Kernel::HLERequestContext& ctx
     rb.PushIpcInterface<INotificationService>(uuid, system);
 }
 
-Module::Interface::Interface(std::shared_ptr<Module> module, Core::System& system, const char* name)
-    : ServiceFramework(name), module(std::move(module)), system(system) {}
+Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_,
+                             const char* name)
+    : ServiceFramework{system_, name}, module{std::move(module_)} {}
 
 Module::Interface::~Interface() = default;
 

+ 2 - 2
src/core/hle/service/friend/friend.h

@@ -16,7 +16,8 @@ class Module final {
 public:
     class Interface : public ServiceFramework<Interface> {
     public:
-        explicit Interface(std::shared_ptr<Module> module, Core::System& system, const char* name);
+        explicit Interface(std::shared_ptr<Module> module_, Core::System& system_,
+                           const char* name);
         ~Interface() override;
 
         void CreateFriendService(Kernel::HLERequestContext& ctx);
@@ -24,7 +25,6 @@ public:
 
     protected:
         std::shared_ptr<Module> module;
-        Core::System& system;
     };
 };
 

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio