From e121c595830b13fa6ac2a602afac44937956021d Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Tue, 12 Mar 2019 23:02:44 -0400 Subject: [PATCH] UDS: implement BeginHostingNetworkDeprecated and forward params to BeginHostingNetwork --- src/core/hle/service/nwm/nwm_uds.cpp | 21 ++++++++++++++++++++- src/core/hle/service/nwm/nwm_uds.h | 13 +++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index f93edfc946..380417cc25 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -899,6 +899,25 @@ void NWM_UDS::BeginHostingNetwork(Kernel::HLERequestContext& ctx) { rb.Push(result); } +void NWM_UDS::BeginHostingNetworkDeprecated(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x04, 0x10, 2); + // Real NWM module reads 0x108 bytes from the command buffer into the network info, where the + // last 0xCC bytes (application_data and size) are undefined values. Here we just read the first + // 0x3C defined bytes and zero application_data in BeginHostingNetwork. + const auto network_info_buffer = rp.PopRaw>(); + const u32 passphrase_size = rp.Pop(); + std::vector passphrase = rp.PopStaticBuffer(); + ASSERT(passphrase.size() == passphrase_size); + + LOG_DEBUG(Service_NWM, "called"); + auto result = BeginHostingNetwork(network_info_buffer.data(), network_info_buffer.size(), + std::move(passphrase)); + LOG_DEBUG(Service_NWM, "An UDS network has been created."); + + IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); + rb.Push(result); +} + void NWM_UDS::UpdateNetworkAttribute(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx, 0x07, 2, 0); rp.Skip(2, false); @@ -1298,7 +1317,7 @@ NWM_UDS::NWM_UDS(Core::System& system) : ServiceFramework("nwm::UDS"), system(sy {0x000102C2, &NWM_UDS::InitializeDeprecated, "Initialize (deprecated)"}, {0x00020000, nullptr, "Scrap"}, {0x00030000, &NWM_UDS::Shutdown, "Shutdown"}, - {0x00040402, nullptr, "CreateNetwork (deprecated)"}, + {0x00040402, &NWM_UDS::BeginHostingNetworkDeprecated, "BeginHostingNetwork (deprecated)"}, {0x00050040, nullptr, "EjectClient"}, {0x00060000, nullptr, "EjectSpectator"}, {0x00070080, &NWM_UDS::UpdateNetworkAttribute, "UpdateNetworkAttribute"}, diff --git a/src/core/hle/service/nwm/nwm_uds.h b/src/core/hle/service/nwm/nwm_uds.h index 61482ac456..25898f7e42 100644 --- a/src/core/hle/service/nwm/nwm_uds.h +++ b/src/core/hle/service/nwm/nwm_uds.h @@ -348,6 +348,19 @@ private: */ void BeginHostingNetwork(Kernel::HLERequestContext& ctx); + /** + * NWM_UDS::BeginHostingNetworkDeprecated service function. + * Creates a network and starts broadcasting its presence. + * Inputs: + * 1 - 15 : the NetworkInfo structure, excluding application data + * 16 : passphrase size + * 18 : VAddr of the passphrase. + * Outputs: + * 0 : Return header + * 1 : Result of function, 0 on success, otherwise error code + */ + void BeginHostingNetworkDeprecated(Kernel::HLERequestContext& ctx); + /** * NWM_UDS::ConnectToNetwork service function. * This connects to the specified network