NWM_UDS: Addressed wwyleles comments
This commit is contained in:
parent
cc6a83621c
commit
cbf514190e
1 changed files with 18 additions and 12 deletions
|
@ -510,7 +510,11 @@ void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) {
|
||||||
|
|
||||||
u32 wlan_comm_id = rp.Pop<u32>();
|
u32 wlan_comm_id = rp.Pop<u32>();
|
||||||
u32 id = rp.Pop<u32>();
|
u32 id = rp.Pop<u32>();
|
||||||
Kernel::Handle input_handle = rp.PopHandle();
|
// From 3dbrew:
|
||||||
|
// 'Official user processes create a new event handle which is then passed to this command.
|
||||||
|
// However, those user processes don't save that handle anywhere afterwards.'
|
||||||
|
// So we don't save/use that event too.
|
||||||
|
Kernel::SharedPtr<Kernel::Event> input_event = rp.PopObject<Kernel::Event>();
|
||||||
|
|
||||||
Kernel::MappedBuffer out_buffer = rp.PopMappedBuffer();
|
Kernel::MappedBuffer out_buffer = rp.PopMappedBuffer();
|
||||||
ASSERT(out_buffer.GetSize() == out_buffer_size);
|
ASSERT(out_buffer.GetSize() == out_buffer_size);
|
||||||
|
@ -540,7 +544,7 @@ void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) {
|
||||||
out_buffer.Write(&entry, offset, sizeof(BeaconEntryHeader));
|
out_buffer.Write(&entry, offset, sizeof(BeaconEntryHeader));
|
||||||
offset += sizeof(BeaconEntryHeader);
|
offset += sizeof(BeaconEntryHeader);
|
||||||
const unsigned char* beacon_data = beacon.data.data();
|
const unsigned char* beacon_data = beacon.data.data();
|
||||||
out_buffer.Write(const_cast<void*>(static_cast<const void*>(beacon_data)), offset,
|
out_buffer.Write(beacon_data, offset,
|
||||||
beacon.data.size());
|
beacon.data.size());
|
||||||
offset += beacon.data.size();
|
offset += beacon.data.size();
|
||||||
|
|
||||||
|
@ -551,12 +555,13 @@ void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) {
|
||||||
data_reply_header.total_size = total_size;
|
data_reply_header.total_size = total_size;
|
||||||
out_buffer.Write(&data_reply_header, 0, sizeof(BeaconDataReplyHeader));
|
out_buffer.Write(&data_reply_header, 0, sizeof(BeaconDataReplyHeader));
|
||||||
|
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 1);
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
|
rb.PushMappedBuffer(out_buffer);
|
||||||
|
|
||||||
LOG_DEBUG(Service_NWM, "called out_buffer_size=0x%08X, wlan_comm_id=0x%08X, id=0x%08X,"
|
LOG_DEBUG(Service_NWM, "called out_buffer_size=0x%08X, wlan_comm_id=0x%08X, id=0x%08X,"
|
||||||
"input_handle=0x%08X, unk1=0x%08X, unk2=0x%08X, offset=%d",
|
"unk1=0x%08X, unk2=0x%08X, offset=%zu",
|
||||||
out_buffer_size, wlan_comm_id, id, input_handle, unk1, unk2, offset);
|
out_buffer_size, wlan_comm_id, id, unk1, unk2, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) {
|
void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) {
|
||||||
|
@ -663,7 +668,7 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||||
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS,
|
rb.Push(ResultCode(ErrorDescription::NotAuthorized, ErrorModule::UDS,
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Usage));
|
ErrorSummary::WrongArgument, ErrorLevel::Usage));
|
||||||
LOG_DEBUG(Service_NWM, "data_channel = %d, bind_node_id = %d", data_channel, bind_node_id);
|
LOG_WARNING(Service_NWM, "data_channel = %d, bind_node_id = %d", data_channel, bind_node_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,7 +677,7 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||||
rb.Push(ResultCode(ErrorDescription::OutOfMemory, ErrorModule::UDS,
|
rb.Push(ResultCode(ErrorDescription::OutOfMemory, ErrorModule::UDS,
|
||||||
ErrorSummary::OutOfResource, ErrorLevel::Status));
|
ErrorSummary::OutOfResource, ErrorLevel::Status));
|
||||||
LOG_DEBUG(Service_NWM, "max bind nodes");
|
LOG_WARNING(Service_NWM, "max bind nodes");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -681,7 +686,7 @@ void NWM_UDS::Bind(Kernel::HLERequestContext& ctx) {
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
|
||||||
rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS,
|
rb.Push(ResultCode(ErrorDescription::TooLarge, ErrorModule::UDS,
|
||||||
ErrorSummary::WrongArgument, ErrorLevel::Usage));
|
ErrorSummary::WrongArgument, ErrorLevel::Usage));
|
||||||
LOG_DEBUG(Service_NWM, "MinRecvBufferSize");
|
LOG_WARNING(Service_NWM, "MinRecvBufferSize");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,6 +972,7 @@ void NWM_UDS::PullPacket(Kernel::HLERequestContext& ctx) {
|
||||||
u32 max_out_buff_size_aligned = rp.Pop<u32>();
|
u32 max_out_buff_size_aligned = rp.Pop<u32>();
|
||||||
u32 max_out_buff_size = rp.Pop<u32>();
|
u32 max_out_buff_size = rp.Pop<u32>();
|
||||||
|
|
||||||
|
// This size is hard coded into the uds module. We don't know the meaning yet.
|
||||||
u32 buff_size = std::min<u32>(max_out_buff_size_aligned, 0x172) << 2;
|
u32 buff_size = std::min<u32>(max_out_buff_size_aligned, 0x172) << 2;
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(connection_status_mutex);
|
std::lock_guard<std::mutex> lock(connection_status_mutex);
|
||||||
|
@ -1123,11 +1129,11 @@ void NWM_UDS::DecryptBeaconData(Kernel::HLERequestContext& ctx) {
|
||||||
ASSERT_MSG(encrypted_data0_buffer[3] == static_cast<u8>(NintendoTagId::EncryptedData0),
|
ASSERT_MSG(encrypted_data0_buffer[3] == static_cast<u8>(NintendoTagId::EncryptedData0),
|
||||||
"Unexpected tag id");
|
"Unexpected tag id");
|
||||||
|
|
||||||
std::vector<u8> beacon_data(encrypted_data0_buffer.size() + encrypted_data1_buffer.size());
|
std::vector<u8> beacon_data(encrypted_data0_buffer.size() - 4 + encrypted_data1_buffer.size() - 4);
|
||||||
std::memcpy(beacon_data.data(), encrypted_data0_buffer.data() + 4,
|
std::memcpy(beacon_data.data(), encrypted_data0_buffer.data() + 4,
|
||||||
encrypted_data0_buffer.size());
|
encrypted_data0_buffer.size() - 4);
|
||||||
std::memcpy(beacon_data.data() + encrypted_data0_buffer.size(),
|
std::memcpy(beacon_data.data() + encrypted_data0_buffer.size() - 4,
|
||||||
encrypted_data1_buffer.data() + 4, encrypted_data1_buffer.size());
|
encrypted_data1_buffer.data() + 4, encrypted_data1_buffer.size() - 4);
|
||||||
|
|
||||||
// Decrypt the data
|
// Decrypt the data
|
||||||
DecryptBeacon(net_info, beacon_data);
|
DecryptBeacon(net_info, beacon_data);
|
||||||
|
|
Loading…
Reference in a new issue