From 237835a8b6d8f6e9543eedf8439789b0e3706e55 Mon Sep 17 00:00:00 2001 From: B3n30 Date: Thu, 15 Feb 2018 23:00:32 +0100 Subject: [PATCH] NWM_UDS: More of wwyleles comments --- src/core/hle/service/nwm/nwm_uds.cpp | 25 +++++++++++-------------- src/core/hle/service/nwm/nwm_uds.h | 2 ++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 8b0ea6180..e1fe0d17e 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -519,8 +519,7 @@ void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) { Kernel::MappedBuffer out_buffer = rp.PopMappedBuffer(); ASSERT(out_buffer.GetSize() == out_buffer_size); - size_t offset = sizeof(BeaconDataReplyHeader); - u32 total_size = sizeof(BeaconDataReplyHeader); + size_t cur_buffer_size = sizeof(BeaconDataReplyHeader); // Retrieve all beacon frames that were received from the desired mac address. auto beacons = GetReceivedBeacons(mac_address); @@ -539,20 +538,18 @@ void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) { entry.header_size = sizeof(BeaconEntryHeader); entry.mac_address = beacon.transmitter_address; - ASSERT(offset < out_buffer_size); + ASSERT(cur_buffer_size < out_buffer_size); - out_buffer.Write(&entry, offset, sizeof(BeaconEntryHeader)); - offset += sizeof(BeaconEntryHeader); + out_buffer.Write(&entry, cur_buffer_size, sizeof(BeaconEntryHeader)); + cur_buffer_size += sizeof(BeaconEntryHeader); const unsigned char* beacon_data = beacon.data.data(); - out_buffer.Write(beacon_data, offset, + out_buffer.Write(beacon_data, cur_buffer_size, beacon.data.size()); - offset += beacon.data.size(); - - total_size += static_cast(sizeof(BeaconEntryHeader) + beacon.data.size()); + cur_buffer_size += beacon.data.size(); } // Update the total size in the structure and write it to the buffer again. - data_reply_header.total_size = total_size; + data_reply_header.total_size = cur_buffer_size; out_buffer.Write(&data_reply_header, 0, sizeof(BeaconDataReplyHeader)); IPC::RequestBuilder rb = rp.MakeBuilder(1, 1); @@ -561,7 +558,7 @@ void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_NWM, "called out_buffer_size=0x%08X, wlan_comm_id=0x%08X, id=0x%08X," "unk1=0x%08X, unk2=0x%08X, offset=%zu", - out_buffer_size, wlan_comm_id, id, unk1, unk2, offset); + out_buffer_size, wlan_comm_id, id, unk1, unk2, cur_buffer_size); } void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) { @@ -1087,8 +1084,8 @@ void NWM_UDS::SetApplicationData(Kernel::HLERequestContext& ctx) { u32 size = rp.Pop(); - const std::vector address = rp.PopStaticBuffer(); - ASSERT(address.size() == size); + const std::vector application_data = rp.PopStaticBuffer(); + ASSERT(application_data.size() == size); LOG_DEBUG(Service_NWM, "called"); @@ -1101,7 +1098,7 @@ void NWM_UDS::SetApplicationData(Kernel::HLERequestContext& ctx) { } network_info.application_data_size = size; - std::memcpy(network_info.application_data.data(), address.data(), size); + std::memcpy(network_info.application_data.data(), application_data.data(), size); rb.Push(RESULT_SUCCESS); } diff --git a/src/core/hle/service/nwm/nwm_uds.h b/src/core/hle/service/nwm/nwm_uds.h index e389b96d0..763eb8dc0 100644 --- a/src/core/hle/service/nwm/nwm_uds.h +++ b/src/core/hle/service/nwm/nwm_uds.h @@ -181,6 +181,7 @@ private: * Outputs: * 0 : Return header * 1 : Result of function, 0 on success, otherwise error code + * 2, 3: output buffer return descriptor & ptr */ void RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx); @@ -337,6 +338,7 @@ private: * Outputs: * 0 : Return header * 1 : Result of function, 0 on success, otherwise error code + * 2, 3: output buffer return descriptor & ptr */ void DecryptBeaconData(Kernel::HLERequestContext& ctx); };