From 0cb34b7bc35a7dd9c473dea70b894901c70d7312 Mon Sep 17 00:00:00 2001 From: darktux Date: Fri, 5 Apr 2024 01:58:30 +0200 Subject: [PATCH 1/5] Always report command ID in log and implement LoadUserSetting stub --- src/core/hle/service/friend/friend.cpp | 32 +++++++++++++++++++++++++- src/core/hle/service/service.cpp | 6 ++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index 38e62761bf..cf7287a87c 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -62,7 +62,7 @@ public: {20600, nullptr, "GetUserPresenceView"}, {20700, nullptr, "GetPlayHistoryList"}, {20701, &IFriendService::GetPlayHistoryStatistics, "GetPlayHistoryStatistics"}, - {20800, nullptr, "LoadUserSetting"}, + {20800, &IFriendService::LoadUserSetting, "LoadUserSetting"}, {20801, nullptr, "SyncUserSetting"}, {20900, nullptr, "RequestListSummaryOverlayNotification"}, {21000, nullptr, "GetExternalApplicationCatalog"}, @@ -136,6 +136,17 @@ private: }; static_assert(sizeof(SizedFriendFilter) == 0x10, "SizedFriendFilter is an invalid size"); + struct FriendsUserSetting { + Common::UUID uuid; + u32 presence_permission; + u32 play_log_permission; + u64 friend_request_reception; + char friend_code[0x20]; + u64 friend_code_next_issuable_time; + u8 unk_x48[0x7C8]; + }; + static_assert(sizeof(FriendsUserSetting) == 0x810, "FriendsUserSetting is an invalid size"); + void GetCompletionEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_Friend, "called"); @@ -248,6 +259,25 @@ private: rb.Push(ResultSuccess); } + void LoadUserSetting(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto uuid = rp.PopRaw(); + + LOG_WARNING(Service_Friend, "(STUBBED) called"); + + FriendsUserSetting setting{}; + setting.uuid = uuid; + setting.presence_permission = 2; + setting.play_log_permission = 5; + setting.friend_request_reception = 1; + setting.friend_code_next_issuable_time = 99999999999; + strcpy(setting.friend_code, "0000-0000-0000"); + ctx.WriteBuffer(setting); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } + void GetReceivedFriendInvitationCountCache(HLERequestContext& ctx) { LOG_DEBUG(Service_Friend, "(STUBBED) called, check in out"); diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index ce5e3b5b4c..68527ac8ef 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -63,11 +63,11 @@ void ServiceFrameworkBase::RegisterHandlersBaseTipc(const FunctionInfoBase* func void ServiceFrameworkBase::ReportUnimplementedFunction(HLERequestContext& ctx, const FunctionInfoBase* info) { auto cmd_buf = ctx.CommandBuffer(); - std::string function_name = info == nullptr ? fmt::format("{}", ctx.GetCommand()) : info->name; + std::string function_name = info == nullptr ? "" : info->name; fmt::memory_buffer buf; - fmt::format_to(std::back_inserter(buf), "function '{}': port='{}' cmd_buf={{[0]=0x{:X}", - function_name, service_name, cmd_buf[0]); + fmt::format_to(std::back_inserter(buf), "function '{}({})': port='{}' cmd_buf={{[0]=0x{:X}", + ctx.GetCommand(), function_name, service_name, cmd_buf[0]); for (int i = 1; i <= 8; ++i) { fmt::format_to(std::back_inserter(buf), ", [{}]=0x{:X}", i, cmd_buf[i]); } From d75906a3e2e322241b18db50d184b897efb18d8e Mon Sep 17 00:00:00 2001 From: darktux Date: Fri, 5 Apr 2024 01:58:30 +0200 Subject: [PATCH 2/5] Implemented IFriendService::GetUserPresenceView stub to get QLaunch friends list running --- src/core/hle/service/friend/friend.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index cf7287a87c..2258223c87 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -59,7 +59,7 @@ public: {20401, nullptr, "SyncBlockedUserList"}, {20500, nullptr, "GetProfileExtraList"}, {20501, nullptr, "GetRelationship"}, - {20600, nullptr, "GetUserPresenceView"}, + {20600, &IFriendService::GetUserPresenceView, "GetUserPresenceView"}, {20700, nullptr, "GetPlayHistoryList"}, {20701, &IFriendService::GetPlayHistoryStatistics, "GetPlayHistoryStatistics"}, {20800, &IFriendService::LoadUserSetting, "LoadUserSetting"}, @@ -245,6 +245,19 @@ private: } void GetReceivedFriendRequestCount(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + [[maybe_unused]] const auto uuid = rp.PopRaw(); + + LOG_DEBUG(Service_Friend, "(STUBBED) called"); + + u8 buf[0xe0]; + ctx.WriteBuffer(buf); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); + } + + void GetUserPresenceView(HLERequestContext& ctx) { LOG_DEBUG(Service_Friend, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 3}; From 268ee291a18ab37b5924701a95b9d60b2d170c22 Mon Sep 17 00:00:00 2001 From: darktux Date: Fri, 5 Apr 2024 01:58:30 +0200 Subject: [PATCH 3/5] Fixed minor issues from previous PR related to buffers and a typo in npns --- src/core/hle/service/friend/friend.cpp | 11 +++++------ src/core/hle/service/npns/npns.cpp | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index 2258223c87..cc5d1ef051 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -143,9 +143,9 @@ private: u64 friend_request_reception; char friend_code[0x20]; u64 friend_code_next_issuable_time; - u8 unk_x48[0x7C8]; + u8 unk_x48[0x7B8]; }; - static_assert(sizeof(FriendsUserSetting) == 0x810, "FriendsUserSetting is an invalid size"); + static_assert(sizeof(FriendsUserSetting) == 0x800, "FriendsUserSetting is an invalid size"); void GetCompletionEvent(HLERequestContext& ctx) { LOG_DEBUG(Service_Friend, "called"); @@ -250,9 +250,6 @@ private: LOG_DEBUG(Service_Friend, "(STUBBED) called"); - u8 buf[0xe0]; - ctx.WriteBuffer(buf); - IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } @@ -260,9 +257,11 @@ private: void GetUserPresenceView(HLERequestContext& ctx) { LOG_DEBUG(Service_Friend, "(STUBBED) called"); + u8 buf[0xe0]{}; + ctx.WriteBuffer(buf); + IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); - rb.Push(0); } void GetPlayHistoryStatistics(HLERequestContext& ctx) { diff --git a/src/core/hle/service/npns/npns.cpp b/src/core/hle/service/npns/npns.cpp index e54827efef..ff8c901889 100644 --- a/src/core/hle/service/npns/npns.cpp +++ b/src/core/hle/service/npns/npns.cpp @@ -24,7 +24,7 @@ public: {4, nullptr, "ReceiveRaw"}, {5, C<&INpnsSystem::GetReceiveEvent>, "GetReceiveEvent"}, {6, nullptr, "ListenUndelivered"}, - {7, nullptr, "GetStateChangeEVent"}, + {7, nullptr, "GetStateChangeEvent"}, {11, nullptr, "SubscribeTopic"}, {12, nullptr, "UnsubscribeTopic"}, {13, nullptr, "QueryIsTopicExist"}, From 30bd90424fae35181dc31f96dba6615e94c73a27 Mon Sep 17 00:00:00 2001 From: darktux Date: Fri, 5 Apr 2024 01:58:30 +0200 Subject: [PATCH 4/5] Actually return 0 in IFriendService::GetReceivedFriendRequestCount --- src/core/hle/service/friend/friend.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index cc5d1ef051..c6b060b1b8 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -252,6 +252,7 @@ private: IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); + rb.Push(0); } void GetUserPresenceView(HLERequestContext& ctx) { From d0ef57274a84d22b83f728709b42b90b0a492429 Mon Sep 17 00:00:00 2001 From: darktux Date: Fri, 5 Apr 2024 01:58:30 +0200 Subject: [PATCH 5/5] Return correct amount of values from IFriendService::GetReceivedFriendRequestCount --- src/core/hle/service/friend/friend.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index c6b060b1b8..59691bf2e3 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp @@ -250,9 +250,10 @@ private: LOG_DEBUG(Service_Friend, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; + IPC::ResponseBuilder rb{ctx, 4}; rb.Push(ResultSuccess); rb.Push(0); + rb.Push(0); } void GetUserPresenceView(HLERequestContext& ctx) {