From d90094e8a722b9e35bda2fef33670b02345b7dd6 Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Sat, 10 Nov 2018 11:27:15 -0500 Subject: [PATCH] Service: release shared memory object when finalize Since last commit SharedMemory only reset source memory set on dtor, service should always release the ref as soon as possible to make the reset happen --- src/core/hle/applets/swkbd.cpp | 1 + src/core/hle/service/http_c.cpp | 13 ++++++++++++- src/core/hle/service/http_c.h | 7 +++++++ src/core/hle/service/mic_u.cpp | 1 + 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/core/hle/applets/swkbd.cpp b/src/core/hle/applets/swkbd.cpp index 750a20849..0de0555c0 100644 --- a/src/core/hle/applets/swkbd.cpp +++ b/src/core/hle/applets/swkbd.cpp @@ -136,6 +136,7 @@ void SoftwareKeyboard::Finalize() { SendParameter(message); is_running = false; + text_memory = nullptr; } Frontend::KeyboardConfig SoftwareKeyboard::ToFrontendConfig( diff --git a/src/core/hle/service/http_c.cpp b/src/core/hle/service/http_c.cpp index 869a3602d..f55d6ed0e 100644 --- a/src/core/hle/service/http_c.cpp +++ b/src/core/hle/service/http_c.cpp @@ -443,6 +443,17 @@ void HTTP_C::CloseClientCertContext(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_HTTP, "called, cert_handle={}", cert_handle); } +void HTTP_C::Finalize(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x39, 0, 0); + + shared_memory = nullptr; + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(RESULT_SUCCESS); + + LOG_WARNING(Service_HTTP, "(STUBBED) called"); +} + void HTTP_C::DecryptClCertA() { static constexpr u32 iv_length = 16; @@ -575,7 +586,7 @@ HTTP_C::HTTP_C() : ServiceFramework("http:C", 32) { {0x00360000, nullptr, "ClearDNSCache"}, {0x00370080, nullptr, "SetKeepAlive"}, {0x003800C0, nullptr, "SetPostDataTypeSize"}, - {0x00390000, nullptr, "Finalize"}, + {0x00390000, &HTTP_C::Finalize, "Finalize"}, }; RegisterHandlers(functions); diff --git a/src/core/hle/service/http_c.h b/src/core/hle/service/http_c.h index 64dc4703b..515572a10 100644 --- a/src/core/hle/service/http_c.h +++ b/src/core/hle/service/http_c.h @@ -240,6 +240,13 @@ private: */ void CloseClientCertContext(Kernel::HLERequestContext& ctx); + /** + * HTTP_C::Finalize service function + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ + void Finalize(Kernel::HLERequestContext& ctx); + void DecryptClCertA(); Kernel::SharedPtr shared_memory = nullptr; diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp index b2c24bd17..ce9594751 100644 --- a/src/core/hle/service/mic_u.cpp +++ b/src/core/hle/service/mic_u.cpp @@ -52,6 +52,7 @@ struct MIC_U::Impl { void UnmapSharedMem(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx, 0x02, 0, 0}; IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + shared_memory = nullptr; rb.Push(RESULT_SUCCESS); LOG_WARNING(Service_MIC, "called"); }