From 6f45b402e751ba7bcaed6ee5c7afbd79f7f4f875 Mon Sep 17 00:00:00 2001 From: mnml <1373374+mnml@users.noreply.github.com> Date: Sat, 5 Dec 2020 16:27:57 -0500 Subject: [PATCH] UDS: implement GetApplicationData (#5533) --- src/core/hle/service/nwm/nwm_uds.cpp | 21 ++++++++++++++++++++- src/core/hle/service/nwm/nwm_uds.h | 12 ++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 6454a2bdd..32b7ca2b8 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -1275,6 +1275,25 @@ void NWM_UDS::SetApplicationData(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); } +void NWM_UDS::GetApplicationData(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x11, 1, 0); + u32 input_size = rp.Pop(); + u8 appdata_size = network_info.application_data_size; + + IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); + rb.Push(RESULT_SUCCESS); + + if (input_size < appdata_size) { + rb.Push(0); + return; + } + + rb.Push(appdata_size); + std::vector appdata(appdata_size); + std::memcpy(appdata.data(), network_info.application_data.data(), appdata_size); + rb.PushStaticBuffer(std::move(appdata), 0); +} + void NWM_UDS::DecryptBeaconData(Kernel::HLERequestContext& ctx, u16 command_id) { IPC::RequestParser rp(ctx, command_id, 0, 6); @@ -1386,7 +1405,7 @@ NWM_UDS::NWM_UDS(Core::System& system) : ServiceFramework("nwm::UDS"), system(sy {0x000E0006, &NWM_UDS::DecryptBeaconData<0x0E>, "DecryptBeaconData (deprecated)"}, {0x000F0404, &NWM_UDS::RecvBeaconBroadcastData, "RecvBeaconBroadcastData"}, {0x00100042, &NWM_UDS::SetApplicationData, "SetApplicationData"}, - {0x00110040, nullptr, "GetApplicationData"}, + {0x00110040, &NWM_UDS::GetApplicationData, "GetApplicationData"}, {0x00120100, &NWM_UDS::Bind, "Bind"}, {0x00130040, &NWM_UDS::Unbind, "Unbind"}, {0x001400C0, &NWM_UDS::PullPacket, "PullPacket"}, diff --git a/src/core/hle/service/nwm/nwm_uds.h b/src/core/hle/service/nwm/nwm_uds.h index 7ae471a53..eeacf9676 100644 --- a/src/core/hle/service/nwm/nwm_uds.h +++ b/src/core/hle/service/nwm/nwm_uds.h @@ -229,6 +229,18 @@ private: */ void SetApplicationData(Kernel::HLERequestContext& ctx); + /** + * NWM_UDS::GetApplicationData service function. + * Loads the application data from the current beacon. + * Inputs: + * 1 : Data size. + * Outputs: + * 0 : Return header + * 1 : Result of function, always 0 + * 2 : Actual data size + */ + void GetApplicationData(Kernel::HLERequestContext& ctx); + /** * NWM_UDS::Bind service function. * Binds a BindNodeId to a data channel and retrieves a data event.