From ffe94421b2719ad20f032396350370ab5a7f9fd6 Mon Sep 17 00:00:00 2001 From: James Rowe Date: Fri, 16 Feb 2018 18:38:28 -0700 Subject: [PATCH] UDS: Add non zero mac address to the shared page Apparently several games check the shared page mac address and wifi link level values, and will refuse to start UDS if they are not correct. This change gives a default value (in case you aren't connected to a network) and will read the value from Room if you are connected. --- src/core/hle/service/nwm/nwm_uds.cpp | 7 +++++++ src/core/hle/shared_page.cpp | 11 +++++++++++ src/core/hle/shared_page.h | 15 +++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 43dbe5902..19bcf87e2 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -23,6 +23,7 @@ #include "core/hle/service/nwm/uds_beacon.h" #include "core/hle/service/nwm/uds_connection.h" #include "core/hle/service/nwm/uds_data.h" +#include "core/hle/shared_page.h" #include "core/memory.h" #include "network/network.h" @@ -592,6 +593,12 @@ void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) { node_info.push_back(current_node); } + if (auto room_member = Network::GetRoomMember().lock()) { + if (room_member->IsConnected()) { + SharedPage::SetMacAddress(static_cast(room_member->GetMacAddress())); + } + } + IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); rb.Push(RESULT_SUCCESS); rb.PushCopyObjects(connection_status_event); diff --git a/src/core/hle/shared_page.cpp b/src/core/hle/shared_page.cpp index eb9a87438..47e6369ef 100644 --- a/src/core/hle/shared_page.cpp +++ b/src/core/hle/shared_page.cpp @@ -83,6 +83,17 @@ void Init() { update_time_event = CoreTiming::RegisterEvent("SharedPage::UpdateTimeCallback", UpdateTimeCallback); CoreTiming::ScheduleEvent(0, update_time_event); + + SetWifiLinkLevel(WifiLinkLevel::POOR); + SetMacAddress(DefaultMac); +} + +void SetMacAddress(const MacAddress& addr) { + std::memcpy(shared_page.wifi_macaddr, addr.data(), sizeof(MacAddress)); +} + +void SetWifiLinkLevel(WifiLinkLevel level) { + shared_page.wifi_link_level = static_cast(level); } } // namespace diff --git a/src/core/hle/shared_page.h b/src/core/hle/shared_page.h index 864695ae1..181932c4b 100644 --- a/src/core/hle/shared_page.h +++ b/src/core/hle/shared_page.h @@ -37,6 +37,17 @@ union BatteryState { BitField<2, 3, u8> charge_level; }; +using MacAddress = std::array; + +// Default MAC address in the nintendo 3ds range +constexpr MacAddress DefaultMac = { 0x40, 0xF4, 0x07, 0x00, 0x00, 0x00 }; + +enum class WifiLinkLevel : u8 { + POOR = 0, + GOOD = 1, + BEST = 2, +}; + struct SharedPageDef { // Most of these names are taken from the 3dbrew page linked above. u32_le date_time_counter; // 0 @@ -66,4 +77,8 @@ extern SharedPageDef shared_page; void Init(); +void SetMacAddress(const MacAddress&); + +void SetWifiLinkLevel(WifiLinkLevel); + } // namespace