Squashed commit of the following:

commit b5d616bbed
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 21:17:13 2024 +0200

    Fixed wrong dummy data

commit 60ee7abc38
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 20:56:11 2024 +0200

    Potential fix of cmd buffer header

commit e47d9af750
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 19:54:04 2024 +0200

    Additional logging

commit d5d0301702
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 19:36:55 2024 +0200

    Added temp logging for debugging

commit a41fc80eab
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 18:59:48 2024 +0200

    Fixed use of mapped buffer

commit f88ebb65a3
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 18:51:48 2024 +0200

    Reverted 4th value to unknown

commit b1d1757eaa
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 17:26:24 2024 +0200

    Updated includes

commit 60c453b5bb
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 17:21:11 2024 +0200

    Fixed argument

commit b7777a7b47
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 17:00:49 2024 +0200

    Added include

commit 4b3ac391d8
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 16:53:56 2024 +0200

    Fixed wrong arguments

commit 13f32bd384
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 16:33:54 2024 +0200

    Fixed call return value

commit 826d6bed2d
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 16:32:37 2024 +0200

    Changed implementation to rely on parser instead of raw

commit 5dea8a125b
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 16:00:35 2024 +0200

    Moved kernel retrieval to argument

commit bb4de89652
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 15:50:37 2024 +0200

    Fixed method call

commit 8b9e04c541
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 15:48:58 2024 +0200

    Fixed type name

commit 29fc438086
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 15:41:35 2024 +0200

    Fixed includes

commit a6fe44f81f
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 15:41:29 2024 +0200

    Fixed method name

commit 67380edbc9
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 15:41:09 2024 +0200

    Fixed method call

commit babec1bb5c
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 15:34:32 2024 +0200

    Fixed kernel reference

commit 6238f52819
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 15:30:10 2024 +0200

    Fixed missing namespace

commit c4a99ccbe9
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 15:29:29 2024 +0200

    Fixed missing argument

commit 916849691b
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 15:26:39 2024 +0200

    Fixed wrong mac

commit 7a997ea8ae
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 15:19:13 2024 +0200

    Potentially fixed calling NWM_INF

commit 320a82bb5d
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 15:05:24 2024 +0200

    Potential fix for calling NWM_UDS version

commit 0b0534400d
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 13:56:05 2024 +0200

    Added include for NWM_UDS

commit d61dfdaf2e
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 13:51:03 2024 +0200

    Fixed cast to u32 and dummy value

commit a14e398157
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 13:50:17 2024 +0200

    Added correct transition from INF to UDS

commit 54e4da1753
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 13:30:13 2024 +0200

    Initial full ScanAPs implementation

commit aeb1e224f3
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 13:18:17 2024 +0200

    Fixed member reference

commit c3b1beae1c
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 13:11:30 2024 +0200

    Readded NWM_UDS header

commit 6b03ca58a2
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 12:44:40 2024 +0200

    Updated include statements

commit 36c4adf431
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 00:58:25 2024 +0200

    Potential member reference fix

commit 6d28737856
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 00:48:51 2024 +0200

    Fixed missing void return type

commit 14eb312678
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Fri Aug 23 00:14:41 2024 +0200

    Using correct way to call UDS service

commit 2acc2a35a9
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Thu Aug 22 22:39:15 2024 +0200

    Updated API

commit d204bfa05c
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Thu Aug 22 22:38:49 2024 +0200

    Initial NWM_INF::RecvBeaconBroadcastData implementation

commit 01baadf7a4
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Thu Aug 22 19:23:17 2024 +0200

    Included member type

commit 36f416469f
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Thu Aug 22 19:06:52 2024 +0200

    Coding style fixes

commit 4e73a1d057
Author: PTRCoder <pj.de.bruijne@gmail.com>
Date:   Thu Aug 22 19:02:37 2024 +0200

    Starting tests
This commit is contained in:
PTRCoder 2024-08-24 20:03:24 +02:00
parent 8a8552bef9
commit 4e6e3d3abe
3 changed files with 109 additions and 14 deletions

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <vector>
#include <boost/serialization/shared_ptr.hpp>
#include "common/archives.h"
#include "common/common_types.h"
#include "common/logging/log.h"
@ -18,7 +19,10 @@
#include "core/hle/service/ac/ac.h"
#include "core/hle/service/ac/ac_i.h"
#include "core/hle/service/ac/ac_u.h"
#include "core/hle/service/nwm/nwm_inf.h"
#include "core/hle/service/soc/soc_u.h"
#include "network/network.h"
#include "network/room.h"
#include "core/memory.h"
SERIALIZE_EXPORT_IMPL(Service::AC::Module)
@ -182,20 +186,69 @@ void Module::Interface::GetStatus(Kernel::HLERequestContext& ctx) {
void Module::Interface::ScanAPs(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
const u32 arg1 = rp.Pop<u32>();
LOG_WARNING(Service_AC, "val1: {}", arg1);
const u32 arg2 = rp.Pop<u32>();
LOG_WARNING(Service_AC, "val2: {}", arg2);
const u32 arg3 = rp.Pop<u32>();
LOG_WARNING(Service_AC, "val3: {}", arg3);
const u32 arg4 = rp.Pop<u32>();
LOG_WARNING(Service_AC, "val4: {}", arg4);
const u32 arg5 = rp.Pop<u32>();
LOG_WARNING(Service_AC, "val5: {}", arg5);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 0);
rb.Push(ResultUnknown);
LOG_WARNING(Service_AC, "(STUBBED) called");
// I used 3dbrew.org for the information on the individual request inputs
// Arg 0 is Header code, which is ignored
// Arg 1 is Size
const u32 size = rp.Pop<u32>();
LOG_WARNING(Service_AC, "Size: {}", size);
// Arg 2 is CallingPID value (PID Header)
// Arg 3 is PID
const u32 pid = rp.PopPID();
LOG_WARNING(Service_AC, "PID: {}", pid);
// Likely time transpired between consecutive calls of this method.
// First call has value 0 or 1. Second call has value 0xFFFF0000.
const u32 unknown = rp.Pop<u32>();
LOG_WARNING(Service_AC, "val4: {}", unknown);
std::vector<u8> buffer(size);
Network::MacAddress mac = Network::BroadcastMac;
u32 mac1 = (mac[0] << 8) | (mac[1]);
u32 mac2 = (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | (mac[5]);
std::array<u32, IPC::COMMAND_BUFFER_LENGTH + 2 * IPC::MAX_STATIC_BUFFERS> cmd_buf;
cmd_buf[0] = 0x000603C4;
cmd_buf[1] = size;
cmd_buf[2] = 0; // dummy data
cmd_buf[3] = 0; // dummy data
cmd_buf[4] = mac1;
cmd_buf[5] = mac2;
cmd_buf[16] = 0;
cmd_buf[17] = 0; // set to 0 to ignore it
cmd_buf[18] = (size << 4) | 12; // should be considered correct for mapped buffer
cmd_buf[19] = 0; // if i interpreted the code correctly, this value won't matter
LOG_WARNING(Service_AC, "Finished setting up command buffer");
std::shared_ptr<Kernel::Thread> thread = ctx.ClientThread();
auto current_process = thread->owner_process.lock();
LOG_WARNING(Service_AC, "Retrieved thread and process");
auto context =
std::make_shared<Kernel::HLERequestContext>(Core::System::GetInstance().Kernel(),
ctx.Session(), thread);
LOG_WARNING(Service_AC, "Created context");
context->PopulateFromIncomingCommandBuffer(cmd_buf.data(), current_process);
LOG_WARNING(Service_AC, "Finished setting up context");
auto nwm_inf =
Core::System::GetInstance().ServiceManager().GetService<Service::NWM::NWM_INF>("nwm::INF");
LOG_WARNING(Service_AC, "Calling NWM_INF::RecvBeaconBroadcastData");
nwm_inf->HandleSyncRequest(*context);
LOG_WARNING(Service_AC, "Returned to AC::ScanAPs");
// Response should be
// 0: Header Code (ignored)
// 1: Result Code (Success/Unknown/etc.)
// 2: ¿Parsed? beacon data
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
IPC::RequestParser rp2(*context);
rb.Push(rp2.Pop<u32>());
Kernel::MappedBuffer mapped_buffer = rp2.PopMappedBuffer();
mapped_buffer.Read(buffer.data(), 0, buffer.size());
rb.PushStaticBuffer(buffer, 0);
LOG_WARNING(Service_AC, "(STUBBED) called, pid={}, unknown={}", pid, unknown);
}
void Module::Interface::GetInfraPriority(Kernel::HLERequestContext& ctx) {

View File

@ -2,8 +2,12 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <boost/serialization/shared_ptr.hpp>
#include "common/archives.h"
#include "common/logging/log.h"
#include "core/core.h"
#include "core/hle/ipc.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/nwm/nwm_inf.h"
#include "core/hle/service/nwm/nwm_uds.h"
@ -12,9 +16,46 @@ SERIALIZE_EXPORT_IMPL(Service::NWM::NWM_INF)
namespace Service::NWM {
void NWM_INF::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) {
IPC::RequestParser rp(ctx);
// TODO(PTR) Update implementation to cover differences between NWM_INF and NWM_UDS
LOG_WARNING(Service_NWM, "Started NWM_INF::RecvBeaconBroadcastData");
// adding in extra context value for transition from INF to UDS
std::array<u32, IPC::COMMAND_BUFFER_LENGTH + 2 * IPC::MAX_STATIC_BUFFERS> cmd_buf;
cmd_buf[0] = 0x000F0404;
int i;
for (i = 1; i < 15; i++) {
cmd_buf[i] = rp.Pop<u32>();
}
rp.Pop<u32>();
cmd_buf[15] = 0; // dummy wlan_comm_id
cmd_buf[16] = 0; // dummy id
for (i = 17; i <= 20; i++) {
cmd_buf[i] = rp.Pop<u32>();
}
std::shared_ptr<Kernel::Thread> thread = ctx.ClientThread();
auto current_process = thread->owner_process.lock();
auto context =
std::make_shared<Kernel::HLERequestContext>(Core::System::GetInstance().Kernel(),
ctx.Session(), thread);
context->PopulateFromIncomingCommandBuffer(cmd_buf.data(), current_process);
LOG_WARNING(Service_NWM, "Finished converting context");
auto nwm_uds = Core::System::GetInstance().ServiceManager().GetService<Service::NWM::NWM_UDS>("nwm::UDS");
nwm_uds->HandleSyncRequest(ctx);
LOG_WARNING(Service_NWM, "Calling NWM_UDS::RecvBeaconBroadcastData");
nwm_uds->HandleSyncRequest(*context);
LOG_WARNING(Service_NWM, "Returned to NWM_INF::RecvBeaconBroadcastData");
IPC::RequestParser rp2(*context);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
rb.Push(rp2.Pop<u32>());
rb.PushMappedBuffer(rp2.PopMappedBuffer());
LOG_WARNING(Service_NWM, "Finished NWM_INF::RecvBeaconBroadcastData");
}
NWM_INF::NWM_INF() : ServiceFramework("nwm::INF") {

View File

@ -14,6 +14,7 @@
#include "core/core_timing.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/kernel/shared_page.h"
#include "core/hle/result.h"