diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2021-09-29 05:42:50 +0200 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2021-10-02 05:38:59 +0200 |
commit | fadcee14f8fca1b76b4ea48b1cfd136ccae8d182 (patch) | |
tree | a5787938bc73ff1b0b539e0945d3544d06a7d6d2 /src/core/hle/service/nifm/nifm.cpp | |
parent | Merge pull request #7102 from Morph1984/remove-boxcat (diff) | |
download | yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.gz yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.bz2 yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.lz yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.xz yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.tar.zst yuzu-fadcee14f8fca1b76b4ea48b1cfd136ccae8d182.zip |
Diffstat (limited to 'src/core/hle/service/nifm/nifm.cpp')
-rw-r--r-- | src/core/hle/service/nifm/nifm.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 9decb9290..f13dc8b0d 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -6,10 +6,21 @@ #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" -#include "core/hle/kernel/k_readable_event.h" #include "core/hle/kernel/kernel.h" +#include "core/hle/service/kernel_helpers.h" #include "core/hle/service/nifm/nifm.h" #include "core/hle/service/service.h" + +namespace { + +// Avoids name conflict with Windows' CreateEvent macro. +[[nodiscard]] Kernel::KEvent* CreateKEvent(Service::KernelHelpers::ServiceContext& service_context, + std::string&& name) { + return service_context.CreateEvent(std::move(name)); +} + +} // Anonymous namespace + #include "core/network/network.h" #include "core/network/network_interface.h" @@ -129,7 +140,7 @@ public: class IRequest final : public ServiceFramework<IRequest> { public: explicit IRequest(Core::System& system_) - : ServiceFramework{system_, "IRequest"}, event1{system.Kernel()}, event2{system.Kernel()} { + : ServiceFramework{system_, "IRequest"}, service_context{system_, "IRequest"} { static const FunctionInfo functions[] = { {0, &IRequest::GetRequestState, "GetRequestState"}, {1, &IRequest::GetResult, "GetResult"}, @@ -159,11 +170,13 @@ public: }; RegisterHandlers(functions); - Kernel::KAutoObject::Create(std::addressof(event1)); - Kernel::KAutoObject::Create(std::addressof(event2)); + event1 = CreateKEvent(service_context, "IRequest:Event1"); + event2 = CreateKEvent(service_context, "IRequest:Event2"); + } - event1.Initialize("IRequest:Event1"); - event2.Initialize("IRequest:Event2"); + ~IRequest() override { + service_context.CloseEvent(event1); + service_context.CloseEvent(event2); } private: @@ -199,7 +212,7 @@ private: IPC::ResponseBuilder rb{ctx, 2, 2}; rb.Push(ResultSuccess); - rb.PushCopyObjects(event1.GetReadableEvent(), event2.GetReadableEvent()); + rb.PushCopyObjects(event1->GetReadableEvent(), event2->GetReadableEvent()); } void Cancel(Kernel::HLERequestContext& ctx) { @@ -230,7 +243,10 @@ private: rb.Push<u32>(0); } - Kernel::KEvent event1, event2; + KernelHelpers::ServiceContext service_context; + + Kernel::KEvent* event1; + Kernel::KEvent* event2; }; class INetworkProfile final : public ServiceFramework<INetworkProfile> { |