From 29bbe81dfbd96053f7f2f91d6250f47a06ee6eb4 Mon Sep 17 00:00:00 2001 From: mailwl Date: Thu, 19 May 2016 12:46:21 +0300 Subject: [PATCH 1/8] Set client SDK version to Service APIs --- src/common/logging/backend.cpp | 1 + src/common/logging/log.h | 1 + src/core/hle/service/ac_u.cpp | 19 ++++++++++++++++++- src/core/hle/service/frd/frd.cpp | 10 ++++++++++ src/core/hle/service/frd/frd.h | 9 +++++++++ src/core/hle/service/frd/frd_u.cpp | 2 +- src/core/hle/service/fs/fs_user.cpp | 13 ++++--------- src/core/hle/service/mic_u.cpp | 22 +++++++++++++++++++++- src/core/hle/service/service.h | 9 +++++++++ 9 files changed, 74 insertions(+), 12 deletions(-) diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index d7008fc66..239608fdc 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -43,6 +43,7 @@ namespace Log { SUB(Service, AM) \ SUB(Service, PTM) \ SUB(Service, LDR) \ + SUB(Service, MIC) \ SUB(Service, NDM) \ SUB(Service, NIM) \ SUB(Service, NWM) \ diff --git a/src/common/logging/log.h b/src/common/logging/log.h index c6910b1c7..5355720f9 100644 --- a/src/common/logging/log.h +++ b/src/common/logging/log.h @@ -58,6 +58,7 @@ enum class Class : ClassType { Service_AM, ///< The AM (Application manager) service Service_PTM, ///< The PTM (Power status & misc.) service Service_LDR, ///< The LDR (3ds dll loader) service + Service_MIC, ///< The MIC (Microphone) service Service_NDM, ///< The NDM (Network daemon manager) service Service_NIM, ///< The NIM (Network interface manager) service Service_NWM, ///< The NWM (Network wlan manager) service diff --git a/src/core/hle/service/ac_u.cpp b/src/core/hle/service/ac_u.cpp index 5241dd3e7..19dc5c330 100644 --- a/src/core/hle/service/ac_u.cpp +++ b/src/core/hle/service/ac_u.cpp @@ -67,6 +67,23 @@ static void IsConnected(Service::Interface* self) { LOG_WARNING(Service_AC, "(STUBBED) called"); } +/** + * AC_U::SetClientVersion service function + * Inputs: + * 1 : Used SDK Version + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ +static void SetClientVersion(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + self->SetVersion(cmd_buff[1]); + + cmd_buff[1] = RESULT_SUCCESS.raw; // No error + + LOG_WARNING(Service_AC, "(STUBBED) called"); +} + const Interface::FunctionInfo FunctionTable[] = { {0x00010000, nullptr, "CreateDefaultConfig"}, {0x00040006, nullptr, "ConnectAsync"}, @@ -84,7 +101,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x00300004, nullptr, "RegisterDisconnectEvent"}, {0x003C0042, nullptr, "GetAPSSIDList"}, {0x003E0042, IsConnected, "IsConnected"}, - {0x00400042, nullptr, "SetClientVersion"}, + {0x00400042, SetClientVersion, "SetClientVersion"}, }; //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cpp index 15d604bb6..1c9470e97 100644 --- a/src/core/hle/service/frd/frd.cpp +++ b/src/core/hle/service/frd/frd.cpp @@ -101,6 +101,16 @@ void GetMyScreenName(Service::Interface* self) { LOG_WARNING(Service_FRD, "(STUBBED) called"); } +void SetClientSdkVersion(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + self->SetVersion(cmd_buff[1]); + + cmd_buff[1] = RESULT_SUCCESS.raw; // No error + + LOG_WARNING(Service_AC, "(STUBBED) called"); +} + void Init() { using namespace Kernel; diff --git a/src/core/hle/service/frd/frd.h b/src/core/hle/service/frd/frd.h index c8283a7f3..e61940ea0 100644 --- a/src/core/hle/service/frd/frd.h +++ b/src/core/hle/service/frd/frd.h @@ -95,6 +95,15 @@ void GetMyFriendKey(Service::Interface* self); */ void GetMyScreenName(Service::Interface* self); +/** + * FRD::SetClientSdkVersion service function + * Inputs: + * 1 : Used SDK Version + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ +void SetClientSdkVersion(Service::Interface* self); + /// Initialize FRD service(s) void Init(); diff --git a/src/core/hle/service/frd/frd_u.cpp b/src/core/hle/service/frd/frd_u.cpp index db8666416..23d172ee6 100644 --- a/src/core/hle/service/frd/frd_u.cpp +++ b/src/core/hle/service/frd/frd_u.cpp @@ -58,7 +58,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x002F0040, nullptr, "AllowHalfAwake"}, {0x00300000, nullptr, "GetServerTypes"}, {0x00310082, nullptr, "GetFriendComment"}, - {0x00320042, nullptr, "SetClientSdkVersion"}, + {0x00320042, SetClientSdkVersion, "SetClientSdkVersion"}, {0x00330000, nullptr, "GetMyApproachContext"}, {0x00340046, nullptr, "AddFriendWithApproach"}, {0x00350082, nullptr, "DecryptApproachContext"}, diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 7df7da5a4..19f9775d4 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -674,24 +674,19 @@ static void CreateSystemSaveData(Service::Interface* self) { /** * FS_User::InitializeWithSdkVersion service function. * Inputs: - * 0 : 0x08610042 - * 1 : Unknown - * 2 : Unknown - * 3 : Unknown + * 1 : Used SDK Version + * 2 : ProcessId Header (must be 0x20) * Outputs: * 1 : Result of function, 0 on success, otherwise error code */ static void InitializeWithSdkVersion(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); - u32 unk1 = cmd_buff[1]; - u32 unk2 = cmd_buff[2]; - u32 unk3 = cmd_buff[3]; + self->SetVersion(cmd_buff[1]); cmd_buff[1] = RESULT_SUCCESS.raw; - LOG_WARNING(Service_FS, "(STUBBED) called unk1=0x%08X, unk2=0x%08X, unk3=0x%08X", - unk1, unk2, unk3); + LOG_WARNING(Service_FS, "(STUBBED) called"); } /** diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp index f792bc9cd..af4cd5c46 100644 --- a/src/core/hle/service/mic_u.cpp +++ b/src/core/hle/service/mic_u.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/logging/log.h" + #include "core/hle/service/mic_u.h" //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -9,6 +11,24 @@ namespace MIC_U { +/** + * MIC_U::SetClientVersion service function + * Inputs: + * 1 : Used SDK Version + * Outputs: + * 1 : Result of function, 0 on success, otherwise error code + */ +static void SetClientVersion(Service::Interface* self) { + u32* cmd_buff = Kernel::GetCommandBuffer(); + + self->SetVersion(cmd_buff[1]); + + cmd_buff[1] = RESULT_SUCCESS.raw; // No error + + LOG_WARNING(Service_MIC, "(STUBBED) called"); +} + + const Interface::FunctionInfo FunctionTable[] = { {0x00010042, nullptr, "MapSharedMem"}, {0x00020000, nullptr, "UnmapSharedMem"}, @@ -25,7 +45,7 @@ const Interface::FunctionInfo FunctionTable[] = { {0x000D0040, nullptr, "SetClamp"}, {0x000E0000, nullptr, "GetClamp"}, {0x000F0040, nullptr, "SetAllowShellClosed"}, - {0x00100040, nullptr, "unknown_input2"}, + {0x00100040, SetClientVersion, "SetClientVersion"}, }; //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index f31135212..8b183abc7 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -29,6 +29,7 @@ class Interface : public Kernel::Session { // processes. public: std::string GetName() const override { return GetPortName(); } + virtual void SetVersion(u32 raw_version) { version.raw = raw_version; } typedef void (*Function)(Interface*); @@ -60,6 +61,14 @@ protected: void Register(const FunctionInfo* functions, size_t n); + union { + u32 raw; + BitField< 0, 8, u32> major; + BitField< 8, 8, u32> minor; + BitField<16, 8, u32> build; + BitField<24, 8, u32> revision; + } version = {}; + private: boost::container::flat_map m_functions; From 7b365fd6ad4ae4ae0ada3c6bb9b1d1dac57ad2f0 Mon Sep 17 00:00:00 2001 From: mailwl Date: Thu, 19 May 2016 13:12:57 +0300 Subject: [PATCH 2/8] Fix frd:GetMyFriendKey copy --- src/core/hle/service/frd/frd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cpp index 1c9470e97..821677e52 100644 --- a/src/core/hle/service/frd/frd.cpp +++ b/src/core/hle/service/frd/frd.cpp @@ -88,7 +88,7 @@ void GetMyFriendKey(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); cmd_buff[1] = RESULT_SUCCESS.raw; // No error - Memory::WriteBlock(cmd_buff[2], reinterpret_cast(&my_friend_key), sizeof(FriendKey)); + std::memcpy(&cmd_buff[2], &my_friend_key, sizeof(FriendKey)); LOG_WARNING(Service_FRD, "(STUBBED) called"); } From 7b226d40803c9e8cf9ff6a8e305d82a78aec7839 Mon Sep 17 00:00:00 2001 From: mailwl Date: Thu, 19 May 2016 14:25:48 +0300 Subject: [PATCH 3/8] Log 'SDK version' input parameter --- src/core/hle/service/ac_u.cpp | 4 ++-- src/core/hle/service/frd/frd.cpp | 4 ++-- src/core/hle/service/fs/fs_user.cpp | 6 ++++-- src/core/hle/service/mic_u.cpp | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/core/hle/service/ac_u.cpp b/src/core/hle/service/ac_u.cpp index 19dc5c330..bc2589232 100644 --- a/src/core/hle/service/ac_u.cpp +++ b/src/core/hle/service/ac_u.cpp @@ -79,9 +79,9 @@ static void SetClientVersion(Service::Interface* self) { self->SetVersion(cmd_buff[1]); - cmd_buff[1] = RESULT_SUCCESS.raw; // No error + LOG_WARNING(Service_AC, "(STUBBED) called, version: 0x%08X", cmd_buff[1]); - LOG_WARNING(Service_AC, "(STUBBED) called"); + cmd_buff[1] = RESULT_SUCCESS.raw; // No error } const Interface::FunctionInfo FunctionTable[] = { diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cpp index 821677e52..d4718080f 100644 --- a/src/core/hle/service/frd/frd.cpp +++ b/src/core/hle/service/frd/frd.cpp @@ -106,9 +106,9 @@ void SetClientSdkVersion(Service::Interface* self) { self->SetVersion(cmd_buff[1]); - cmd_buff[1] = RESULT_SUCCESS.raw; // No error + LOG_WARNING(Service_FRD, "(STUBBED) called, version: 0x%08X", cmd_buff[1]); - LOG_WARNING(Service_AC, "(STUBBED) called"); + cmd_buff[1] = RESULT_SUCCESS.raw; // No error } void Init() { diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 19f9775d4..33a1a9996 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -684,9 +684,11 @@ static void InitializeWithSdkVersion(Service::Interface* self) { self->SetVersion(cmd_buff[1]); - cmd_buff[1] = RESULT_SUCCESS.raw; + ASSERT_MSG(cmd_buff[2] == 0x20, "ProcessId Header must be 0x20"); - LOG_WARNING(Service_FS, "(STUBBED) called"); + LOG_WARNING(Service_FS, "(STUBBED) called, version: 0x%08X", cmd_buff[1]); + + cmd_buff[1] = RESULT_SUCCESS.raw; } /** diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp index af4cd5c46..545c2360d 100644 --- a/src/core/hle/service/mic_u.cpp +++ b/src/core/hle/service/mic_u.cpp @@ -23,9 +23,9 @@ static void SetClientVersion(Service::Interface* self) { self->SetVersion(cmd_buff[1]); - cmd_buff[1] = RESULT_SUCCESS.raw; // No error + LOG_WARNING(Service_MIC, "(STUBBED) called, version: 0x%08X", cmd_buff[1]); - LOG_WARNING(Service_MIC, "(STUBBED) called"); + cmd_buff[1] = RESULT_SUCCESS.raw; // No error } From fcf2d8f0449d83de28537528d7ecadcbd434f05b Mon Sep 17 00:00:00 2001 From: mailwl Date: Fri, 20 May 2016 09:45:34 +0300 Subject: [PATCH 4/8] Return right error code in InitializeWithSdkVersion --- src/core/hle/service/fs/fs_user.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 33a1a9996..5353e3585 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -684,11 +684,17 @@ static void InitializeWithSdkVersion(Service::Interface* self) { self->SetVersion(cmd_buff[1]); - ASSERT_MSG(cmd_buff[2] == 0x20, "ProcessId Header must be 0x20"); + if (cmd_buff[2] == IPC::CallingPidDesc()) { + LOG_WARNING(Service_FS, "(STUBBED) called, version: 0x%08X", cmd_buff[1]); - LOG_WARNING(Service_FS, "(STUBBED) called, version: 0x%08X", cmd_buff[1]); + cmd_buff[1] = RESULT_SUCCESS.raw; + } + else { + LOG_ERROR(Service_FS, "ProcessId Header must be 0x20"); - cmd_buff[1] = RESULT_SUCCESS.raw; + cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS, + ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw; + } } /** From 0ca3f8b7b611189869860c4a8e2aabdf1e622d22 Mon Sep 17 00:00:00 2001 From: mailwl Date: Sat, 20 Aug 2016 10:28:56 +0300 Subject: [PATCH 5/8] fixes --- src/core/hle/service/ac_u.cpp | 5 +++-- src/core/hle/service/frd/frd.cpp | 6 ++++-- src/core/hle/service/fs/fs_user.cpp | 10 ++++------ src/core/hle/service/mic_u.cpp | 5 +++-- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/core/hle/service/ac_u.cpp b/src/core/hle/service/ac_u.cpp index bc2589232..0d54533a5 100644 --- a/src/core/hle/service/ac_u.cpp +++ b/src/core/hle/service/ac_u.cpp @@ -77,9 +77,10 @@ static void IsConnected(Service::Interface* self) { static void SetClientVersion(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); - self->SetVersion(cmd_buff[1]); + const u32 version = cmd_buff[1]; + self->SetVersion(version); - LOG_WARNING(Service_AC, "(STUBBED) called, version: 0x%08X", cmd_buff[1]); + LOG_WARNING(Service_AC, "(STUBBED) called, version: 0x%08X", version); cmd_buff[1] = RESULT_SUCCESS.raw; // No error } diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cpp index d4718080f..4e4917bcb 100644 --- a/src/core/hle/service/frd/frd.cpp +++ b/src/core/hle/service/frd/frd.cpp @@ -104,9 +104,11 @@ void GetMyScreenName(Service::Interface* self) { void SetClientSdkVersion(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); - self->SetVersion(cmd_buff[1]); + const u32 version = cmd_buff[1]; - LOG_WARNING(Service_FRD, "(STUBBED) called, version: 0x%08X", cmd_buff[1]); + self->SetVersion(version); + + LOG_WARNING(Service_FRD, "(STUBBED) called, version: 0x%08X", version); cmd_buff[1] = RESULT_SUCCESS.raw; // No error } diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 3ed16fe8d..59e899887 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -713,16 +713,14 @@ static void CreateLegacySystemSaveData(Service::Interface* self) { static void InitializeWithSdkVersion(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); - self->SetVersion(cmd_buff[1]); + const u32 version = cmd_buff[1]; + self->SetVersion(version); if (cmd_buff[2] == IPC::CallingPidDesc()) { - LOG_WARNING(Service_FS, "(STUBBED) called, version: 0x%08X", cmd_buff[1]); - + LOG_WARNING(Service_FS, "(STUBBED) called, version: 0x%08X", version); cmd_buff[1] = RESULT_SUCCESS.raw; - } - else { + } else { LOG_ERROR(Service_FS, "ProcessId Header must be 0x20"); - cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS, ErrorSummary::WrongArgument, ErrorLevel::Permanent).raw; } diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp index 545c2360d..4a03775c2 100644 --- a/src/core/hle/service/mic_u.cpp +++ b/src/core/hle/service/mic_u.cpp @@ -21,9 +21,10 @@ namespace MIC_U { static void SetClientVersion(Service::Interface* self) { u32* cmd_buff = Kernel::GetCommandBuffer(); - self->SetVersion(cmd_buff[1]); + const u32 version = cmd_buff[1]; + self->SetVersion(version); - LOG_WARNING(Service_MIC, "(STUBBED) called, version: 0x%08X", cmd_buff[1]); + LOG_WARNING(Service_MIC, "(STUBBED) called, version: 0x%08X", version); cmd_buff[1] = RESULT_SUCCESS.raw; // No error } From 27341a8c2d2d7f8854a40b6d2ce103b08a0e944b Mon Sep 17 00:00:00 2001 From: mailwl Date: Sat, 20 Aug 2016 10:36:51 +0300 Subject: [PATCH 6/8] bad merge fix --- src/core/hle/service/frd/frd.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cpp index 4e4917bcb..62c895998 100644 --- a/src/core/hle/service/frd/frd.cpp +++ b/src/core/hle/service/frd/frd.cpp @@ -23,7 +23,7 @@ void GetMyPresence(Service::Interface* self) { ASSERT(shifted_out_size == ((sizeof(MyPresence) << 14) | 2)); - Memory::WriteBlock(my_presence_addr, reinterpret_cast(&my_presence), sizeof(MyPresence)); + Memory::WriteBlock(my_presence_addr, &my_presence, sizeof(MyPresence)); cmd_buff[1] = RESULT_SUCCESS.raw; // No error @@ -39,8 +39,7 @@ void GetFriendKeyList(Service::Interface* self) { FriendKey zero_key = {}; for (u32 i = 0; i < frd_count; ++i) { - Memory::WriteBlock(frd_key_addr + i * sizeof(FriendKey), - reinterpret_cast(&zero_key), sizeof(FriendKey)); + Memory::WriteBlock(frd_key_addr + i * sizeof(FriendKey), &zero_key, sizeof(FriendKey)); } cmd_buff[1] = RESULT_SUCCESS.raw; // No error @@ -58,8 +57,7 @@ void GetFriendProfile(Service::Interface* self) { Profile zero_profile = {}; for (u32 i = 0; i < count; ++i) { - Memory::WriteBlock(profiles_addr + i * sizeof(Profile), - reinterpret_cast(&zero_profile), sizeof(Profile)); + Memory::WriteBlock(profiles_addr + i * sizeof(Profile), &zero_profile, sizeof(Profile)); } cmd_buff[1] = RESULT_SUCCESS.raw; // No error From 78882091e968f82b9c6956eabe00786f379dc649 Mon Sep 17 00:00:00 2001 From: mailwl Date: Sat, 20 Aug 2016 10:46:48 +0300 Subject: [PATCH 7/8] restore info.plist --- src/citra_qt/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/citra_qt/Info.plist b/src/citra_qt/Info.plist index 57fd29ac4..7d46b39d1 100644 --- a/src/citra_qt/Info.plist +++ b/src/citra_qt/Info.plist @@ -5,7 +5,7 @@ CFBundleDevelopmentRegion English CFBundleExecutable - ${EXECUTABLE_NAME} + ${EXECUTABLE_NAME} CFBundleGetInfoString CFBundleIconFile From e42b1ee5eaa1bd00394d2573524e7feda8dbd3a6 Mon Sep 17 00:00:00 2001 From: mailwl Date: Sat, 20 Aug 2016 15:35:10 +0300 Subject: [PATCH 8/8] remove redundant comment --- src/core/hle/service/fs/fs_user.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 59e899887..29b65f4ca 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -706,7 +706,7 @@ static void CreateLegacySystemSaveData(Service::Interface* self) { * FS_User::InitializeWithSdkVersion service function. * Inputs: * 1 : Used SDK Version - * 2 : ProcessId Header (must be 0x20) + * 2 : ProcessId Header * Outputs: * 1 : Result of function, 0 on success, otherwise error code */