diff options
Diffstat (limited to 'src/core/hle/service/nfp')
-rw-r--r-- | src/core/hle/service/nfp/amiibo_crypto.cpp | 18 | ||||
-rw-r--r-- | src/core/hle/service/nfp/amiibo_crypto.h | 2 | ||||
-rw-r--r-- | src/core/hle/service/nfp/nfp.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/service/nfp/nfp_device.cpp | 235 | ||||
-rw-r--r-- | src/core/hle/service/nfp/nfp_device.h | 9 | ||||
-rw-r--r-- | src/core/hle/service/nfp/nfp_types.h | 51 | ||||
-rw-r--r-- | src/core/hle/service/nfp/nfp_user.cpp | 52 | ||||
-rw-r--r-- | src/core/hle/service/nfp/nfp_user.h | 50 |
8 files changed, 314 insertions, 107 deletions
diff --git a/src/core/hle/service/nfp/amiibo_crypto.cpp b/src/core/hle/service/nfp/amiibo_crypto.cpp index ffb2f959c..bba862fb2 100644 --- a/src/core/hle/service/nfp/amiibo_crypto.cpp +++ b/src/core/hle/service/nfp/amiibo_crypto.cpp @@ -80,13 +80,17 @@ NTAG215File NfcDataToEncodedData(const EncryptedNTAG215File& nfc_data) { encoded_data.hmac_data = nfc_data.user_memory.hmac_data; encoded_data.constant_value = nfc_data.user_memory.constant_value; encoded_data.write_counter = nfc_data.user_memory.write_counter; + encoded_data.amiibo_version = nfc_data.user_memory.amiibo_version; encoded_data.settings = nfc_data.user_memory.settings; encoded_data.owner_mii = nfc_data.user_memory.owner_mii; - encoded_data.title_id = nfc_data.user_memory.title_id; - encoded_data.applicaton_write_counter = nfc_data.user_memory.applicaton_write_counter; + encoded_data.application_id = nfc_data.user_memory.application_id; + encoded_data.application_write_counter = nfc_data.user_memory.application_write_counter; encoded_data.application_area_id = nfc_data.user_memory.application_area_id; + encoded_data.application_id_byte = nfc_data.user_memory.application_id_byte; encoded_data.unknown = nfc_data.user_memory.unknown; + encoded_data.mii_extension = nfc_data.user_memory.mii_extension; encoded_data.unknown2 = nfc_data.user_memory.unknown2; + encoded_data.register_info_crc = nfc_data.user_memory.register_info_crc; encoded_data.application_area = nfc_data.user_memory.application_area; encoded_data.hmac_tag = nfc_data.user_memory.hmac_tag; encoded_data.lock_bytes = nfc_data.uuid.lock_bytes; @@ -111,13 +115,17 @@ EncryptedNTAG215File EncodedDataToNfcData(const NTAG215File& encoded_data) { nfc_data.user_memory.hmac_data = encoded_data.hmac_data; nfc_data.user_memory.constant_value = encoded_data.constant_value; nfc_data.user_memory.write_counter = encoded_data.write_counter; + nfc_data.user_memory.amiibo_version = encoded_data.amiibo_version; nfc_data.user_memory.settings = encoded_data.settings; nfc_data.user_memory.owner_mii = encoded_data.owner_mii; - nfc_data.user_memory.title_id = encoded_data.title_id; - nfc_data.user_memory.applicaton_write_counter = encoded_data.applicaton_write_counter; + nfc_data.user_memory.application_id = encoded_data.application_id; + nfc_data.user_memory.application_write_counter = encoded_data.application_write_counter; nfc_data.user_memory.application_area_id = encoded_data.application_area_id; + nfc_data.user_memory.application_id_byte = encoded_data.application_id_byte; nfc_data.user_memory.unknown = encoded_data.unknown; + nfc_data.user_memory.mii_extension = encoded_data.mii_extension; nfc_data.user_memory.unknown2 = encoded_data.unknown2; + nfc_data.user_memory.register_info_crc = encoded_data.register_info_crc; nfc_data.user_memory.application_area = encoded_data.application_area; nfc_data.user_memory.hmac_tag = encoded_data.hmac_tag; nfc_data.user_memory.model_info = encoded_data.model_info; @@ -131,7 +139,7 @@ EncryptedNTAG215File EncodedDataToNfcData(const NTAG215File& encoded_data) { } u32 GetTagPassword(const TagUuid& uuid) { - // Verifiy that the generated password is correct + // Verify that the generated password is correct u32 password = 0xAA ^ (uuid.uid[1] ^ uuid.uid[3]); password &= (0x55 ^ (uuid.uid[2] ^ uuid.uid[4])) << 8; password &= (0xAA ^ (uuid.uid[3] ^ uuid.uid[5])) << 16; diff --git a/src/core/hle/service/nfp/amiibo_crypto.h b/src/core/hle/service/nfp/amiibo_crypto.h index 1fa61174e..c9fd67a39 100644 --- a/src/core/hle/service/nfp/amiibo_crypto.h +++ b/src/core/hle/service/nfp/amiibo_crypto.h @@ -94,7 +94,7 @@ bool LoadKeys(InternalKey& locked_secret, InternalKey& unfixed_info); /// Returns true if key_retail.bin exist bool IsKeyAvailable(); -/// Decodes encripted amiibo data returns true if output is valid +/// Decodes encrypted amiibo data returns true if output is valid bool DecodeAmiibo(const EncryptedNTAG215File& encrypted_tag_data, NTAG215File& tag_data); /// Encodes plain amiibo data returns true if output is valid diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 1b59aba8e..e262dc2f2 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" -#include "core/hle/ipc_helpers.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/nfp/nfp.h" #include "core/hle/service/nfp/nfp_user.h" #include "core/hle/service/server_manager.h" @@ -22,7 +22,7 @@ public: } private: - void CreateUserInterface(Kernel::HLERequestContext& ctx) { + void CreateUserInterface(HLERequestContext& ctx) { LOG_DEBUG(Service_NFP, "called"); if (user_interface == nullptr) { diff --git a/src/core/hle/service/nfp/nfp_device.cpp b/src/core/hle/service/nfp/nfp_device.cpp index 7a6bbbba7..268337d2e 100644 --- a/src/core/hle/service/nfp/nfp_device.cpp +++ b/src/core/hle/service/nfp/nfp_device.cpp @@ -3,6 +3,17 @@ #include <array> +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4701) // Potentially uninitialized local variable 'result' used +#endif + +#include <boost/crc.hpp> + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + #include "common/input.h" #include "common/logging/log.h" #include "common/string_util.h" @@ -11,8 +22,8 @@ #include "core/hid/emulated_controller.h" #include "core/hid/hid_core.h" #include "core/hid/hid_types.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/mii/mii_manager.h" #include "core/hle/service/mii/types.h" #include "core/hle/service/nfp/amiibo_crypto.h" @@ -174,8 +185,8 @@ Result NfpDevice::StopDetection() { if (device_state == DeviceState::TagFound || device_state == DeviceState::TagMounted) { CloseAmiibo(); - return ResultSuccess; } + if (device_state == DeviceState::SearchingForTag || device_state == DeviceState::TagRemoved) { device_state = DeviceState::Initialized; return ResultSuccess; @@ -204,9 +215,7 @@ Result NfpDevice::Flush() { const auto& current_date = GetAmiiboDate(current_posix_time); if (settings.write_date.raw_date != current_date.raw_date) { settings.write_date = current_date; - settings.crc_counter++; - // TODO: Find how to calculate the crc check - // settings.crc = CalculateCRC(settings); + UpdateSettingsCrc(); } tag_data.write_counter++; @@ -318,7 +327,7 @@ Result NfpDevice::GetCommonInfo(CommonInfo& common_info) const { common_info = { .last_write_date = settings.write_date.GetWriteDate(), .write_counter = tag_data.write_counter, - .version = 0, + .version = tag_data.amiibo_version, .application_area_size = sizeof(ApplicationArea), }; return ResultSuccess; @@ -370,13 +379,95 @@ Result NfpDevice::GetRegisterInfo(RegisterInfo& register_info) const { .mii_char_info = manager.ConvertV3ToCharInfo(tag_data.owner_mii), .creation_date = settings.init_date.GetWriteDate(), .amiibo_name = GetAmiiboName(settings), - .font_region = {}, + .font_region = settings.settings.font_region, }; return ResultSuccess; } -Result NfpDevice::SetNicknameAndOwner(const AmiiboName& amiibo_name) { +Result NfpDevice::GetAdminInfo(AdminInfo& admin_info) const { + if (device_state != DeviceState::TagMounted) { + LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); + if (device_state == DeviceState::TagRemoved) { + return TagRemoved; + } + return WrongDeviceState; + } + + if (mount_target == MountTarget::None || mount_target == MountTarget::Rom) { + LOG_ERROR(Service_NFC, "Amiibo is read only", device_state); + return WrongDeviceState; + } + + u8 flags = static_cast<u8>(tag_data.settings.settings.raw >> 0x4); + if (tag_data.settings.settings.amiibo_initialized == 0) { + flags = flags & 0xfe; + } + + u64 application_id = 0; + u32 application_area_id = 0; + AppAreaVersion app_area_version = AppAreaVersion::NotSet; + if (tag_data.settings.settings.appdata_initialized != 0) { + application_id = tag_data.application_id; + app_area_version = + static_cast<AppAreaVersion>(application_id >> application_id_version_offset & 0xf); + + // Restore application id to original value + if (application_id >> 0x38 != 0) { + const u8 application_byte = tag_data.application_id_byte & 0xf; + application_id = RemoveVersionByte(application_id) | + (static_cast<u64>(application_byte) << application_id_version_offset); + } + + application_area_id = tag_data.application_area_id; + } + + // TODO: Validate this data + admin_info = { + .application_id = application_id, + .application_area_id = application_area_id, + .crc_change_counter = tag_data.settings.crc_counter, + .flags = flags, + .tag_type = PackedTagType::Type2, + .app_area_version = app_area_version, + }; + + return ResultSuccess; +} + +Result NfpDevice::DeleteRegisterInfo() { + if (device_state != DeviceState::TagMounted) { + LOG_ERROR(Service_NFC, "Wrong device state {}", device_state); + if (device_state == DeviceState::TagRemoved) { + return TagRemoved; + } + return WrongDeviceState; + } + + if (mount_target == MountTarget::None || mount_target == MountTarget::Rom) { + LOG_ERROR(Service_NFC, "Amiibo is read only", device_state); + return WrongDeviceState; + } + + if (tag_data.settings.settings.amiibo_initialized == 0) { + return RegistrationIsNotInitialized; + } + + Common::TinyMT rng{}; + rng.GenerateRandomBytes(&tag_data.owner_mii, sizeof(tag_data.owner_mii)); + rng.GenerateRandomBytes(&tag_data.settings.amiibo_name, sizeof(tag_data.settings.amiibo_name)); + rng.GenerateRandomBytes(&tag_data.unknown, sizeof(u8)); + rng.GenerateRandomBytes(&tag_data.unknown2[0], sizeof(u32)); + rng.GenerateRandomBytes(&tag_data.unknown2[1], sizeof(u32)); + rng.GenerateRandomBytes(&tag_data.register_info_crc, sizeof(u32)); + rng.GenerateRandomBytes(&tag_data.settings.init_date, sizeof(u32)); + tag_data.settings.settings.font_region.Assign(0); + tag_data.settings.settings.amiibo_initialized.Assign(0); + + return Flush(); +} + +Result NfpDevice::SetRegisterInfoPrivate(const AmiiboName& amiibo_name) { if (device_state != DeviceState::TagMounted) { LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); if (device_state == DeviceState::TagRemoved) { @@ -391,18 +482,25 @@ Result NfpDevice::SetNicknameAndOwner(const AmiiboName& amiibo_name) { } Service::Mii::MiiManager manager; + const auto mii = manager.BuildDefault(0); auto& settings = tag_data.settings; - settings.init_date = GetAmiiboDate(current_posix_time); - settings.write_date = GetAmiiboDate(current_posix_time); - settings.crc_counter++; - // TODO: Find how to calculate the crc check - // settings.crc = CalculateCRC(settings); + if (tag_data.settings.settings.amiibo_initialized == 0) { + settings.init_date = GetAmiiboDate(current_posix_time); + settings.write_date.raw_date = 0; + } SetAmiiboName(settings, amiibo_name); - tag_data.owner_mii = manager.ConvertCharInfoToV3(manager.BuildDefault(0)); + tag_data.owner_mii = manager.BuildFromStoreData(mii); + tag_data.mii_extension = manager.SetFromStoreData(mii); + tag_data.unknown = 0; + tag_data.unknown2 = {}; + settings.country_code_id = 0; + settings.settings.font_region.Assign(0); settings.settings.amiibo_initialized.Assign(1); + UpdateRegisterInfoCrc(); + return Flush(); } @@ -425,23 +523,17 @@ Result NfpDevice::RestoreAmiibo() { return ResultSuccess; } -Result NfpDevice::DeleteAllData() { - const auto result = DeleteApplicationArea(); - if (result.IsError()) { - return result; - } +Result NfpDevice::Format() { + auto result1 = DeleteApplicationArea(); + auto result2 = DeleteRegisterInfo(); - if (device_state != DeviceState::TagMounted) { - LOG_ERROR(Service_NFP, "Wrong device state {}", device_state); - if (device_state == DeviceState::TagRemoved) { - return TagRemoved; - } - return WrongDeviceState; + if (result1.IsError()) { + return result1; } - Common::TinyMT rng{}; - rng.GenerateRandomBytes(&tag_data.owner_mii, sizeof(tag_data.owner_mii)); - tag_data.settings.settings.amiibo_initialized.Assign(0); + if (result2.IsError()) { + return result2; + } return Flush(); } @@ -569,7 +661,10 @@ Result NfpDevice::SetApplicationArea(std::span<const u8> data) { rng.GenerateRandomBytes(tag_data.application_area.data() + data.size(), sizeof(ApplicationArea) - data.size()); - tag_data.applicaton_write_counter++; + if (tag_data.application_write_counter != counter_limit) { + tag_data.application_write_counter++; + } + is_data_moddified = true; return ResultSuccess; @@ -601,6 +696,11 @@ Result NfpDevice::RecreateApplicationArea(u32 access_id, std::span<const u8> dat return WrongDeviceState; } + if (is_app_area_open) { + LOG_ERROR(Service_NFP, "Application area is open"); + return WrongDeviceState; + } + if (mount_target == MountTarget::None || mount_target == MountTarget::Rom) { LOG_ERROR(Service_NFP, "Amiibo is read only", device_state); return WrongDeviceState; @@ -617,13 +717,23 @@ Result NfpDevice::RecreateApplicationArea(u32 access_id, std::span<const u8> dat rng.GenerateRandomBytes(tag_data.application_area.data() + data.size(), sizeof(ApplicationArea) - data.size()); - // TODO: Investigate why the title id needs to be moddified - tag_data.title_id = system.GetApplicationProcessProgramID(); - tag_data.title_id = tag_data.title_id | 0x30000000ULL; + if (tag_data.application_write_counter != counter_limit) { + tag_data.application_write_counter++; + } + + const u64 application_id = system.GetApplicationProcessProgramID(); + + tag_data.application_id_byte = + static_cast<u8>(application_id >> application_id_version_offset & 0xf); + tag_data.application_id = + RemoveVersionByte(application_id) | + (static_cast<u64>(AppAreaVersion::NintendoSwitch) << application_id_version_offset); tag_data.settings.settings.appdata_initialized.Assign(1); tag_data.application_area_id = access_id; - tag_data.applicaton_write_counter++; tag_data.unknown = {}; + tag_data.unknown2 = {}; + + UpdateRegisterInfoCrc(); return Flush(); } @@ -642,13 +752,25 @@ Result NfpDevice::DeleteApplicationArea() { return WrongDeviceState; } + if (tag_data.settings.settings.appdata_initialized == 0) { + return ApplicationAreaIsNotInitialized; + } + + if (tag_data.application_write_counter != counter_limit) { + tag_data.application_write_counter++; + } + Common::TinyMT rng{}; rng.GenerateRandomBytes(tag_data.application_area.data(), sizeof(ApplicationArea)); - rng.GenerateRandomBytes(&tag_data.title_id, sizeof(u64)); + rng.GenerateRandomBytes(&tag_data.application_id, sizeof(u64)); rng.GenerateRandomBytes(&tag_data.application_area_id, sizeof(u32)); + rng.GenerateRandomBytes(&tag_data.application_id_byte, sizeof(u8)); tag_data.settings.settings.appdata_initialized.Assign(0); - tag_data.applicaton_write_counter++; tag_data.unknown = {}; + tag_data.unknown2 = {}; + is_app_area_open = false; + + UpdateRegisterInfoCrc(); return Flush(); } @@ -719,4 +841,47 @@ AmiiboDate NfpDevice::GetAmiiboDate(s64 posix_time) const { return amiibo_date; } +u64 NfpDevice::RemoveVersionByte(u64 application_id) const { + return application_id & ~(0xfULL << application_id_version_offset); +} + +void NfpDevice::UpdateSettingsCrc() { + auto& settings = tag_data.settings; + + if (settings.crc_counter != counter_limit) { + settings.crc_counter++; + } + + // TODO: this reads data from a global, find what it is + std::array<u8, 8> unknown_input{}; + boost::crc_32_type crc; + crc.process_bytes(&unknown_input, sizeof(unknown_input)); + settings.crc = crc.checksum(); +} + +void NfpDevice::UpdateRegisterInfoCrc() { +#pragma pack(push, 1) + struct CrcData { + Mii::Ver3StoreData mii; + u8 application_id_byte; + u8 unknown; + Mii::NfpStoreDataExtension mii_extension; + std::array<u32, 0x5> unknown2; + }; + static_assert(sizeof(CrcData) == 0x7e, "CrcData is an invalid size"); +#pragma pack(pop) + + const CrcData crc_data{ + .mii = tag_data.owner_mii, + .application_id_byte = tag_data.application_id_byte, + .unknown = tag_data.unknown, + .mii_extension = tag_data.mii_extension, + .unknown2 = tag_data.unknown2, + }; + + boost::crc_32_type crc; + crc.process_bytes(&crc_data, sizeof(CrcData)); + tag_data.register_info_crc = crc.checksum(); +} + } // namespace Service::NFP diff --git a/src/core/hle/service/nfp/nfp_device.h b/src/core/hle/service/nfp/nfp_device.h index b6a46f2ac..8813df998 100644 --- a/src/core/hle/service/nfp/nfp_device.h +++ b/src/core/hle/service/nfp/nfp_device.h @@ -47,10 +47,12 @@ public: Result GetCommonInfo(CommonInfo& common_info) const; Result GetModelInfo(ModelInfo& model_info) const; Result GetRegisterInfo(RegisterInfo& register_info) const; + Result GetAdminInfo(AdminInfo& admin_info) const; - Result SetNicknameAndOwner(const AmiiboName& amiibo_name); + Result DeleteRegisterInfo(); + Result SetRegisterInfoPrivate(const AmiiboName& amiibo_name); Result RestoreAmiibo(); - Result DeleteAllData(); + Result Format(); Result OpenApplicationArea(u32 access_id); Result GetApplicationAreaId(u32& application_area_id) const; @@ -76,6 +78,9 @@ private: AmiiboName GetAmiiboName(const AmiiboSettings& settings) const; void SetAmiiboName(AmiiboSettings& settings, const AmiiboName& amiibo_name); AmiiboDate GetAmiiboDate(s64 posix_time) const; + u64 RemoveVersionByte(u64 application_id) const; + void UpdateSettingsCrc(); + void UpdateRegisterInfoCrc(); bool is_controller_set{}; int callback_key; diff --git a/src/core/hle/service/nfp/nfp_types.h b/src/core/hle/service/nfp/nfp_types.h index fc228c2b2..b3599a513 100644 --- a/src/core/hle/service/nfp/nfp_types.h +++ b/src/core/hle/service/nfp/nfp_types.h @@ -10,6 +10,8 @@ namespace Service::NFP { static constexpr std::size_t amiibo_name_length = 0xA; +static constexpr std::size_t application_id_version_offset = 0x1c; +static constexpr std::size_t counter_limit = 0xffff; enum class ServiceType : u32 { User, @@ -99,6 +101,14 @@ enum class TagProtocol : u32 { All = 0xFFFFFFFFU, }; +enum class AppAreaVersion : u8 { + Nintendo3DS = 0, + NintendoWiiU = 1, + Nintendo3DSv2 = 2, + NintendoSwitch = 3, + NotSet = 0xFF, +}; + enum class CabinetMode : u8 { StartNicknameAndOwnerSettings, StartGameDataEraser, @@ -197,6 +207,7 @@ struct Settings { union { u8 raw{}; + BitField<0, 4, u8> font_region; BitField<4, 1, u8> amiibo_initialized; BitField<5, 1, u8> appdata_initialized; }; @@ -236,18 +247,21 @@ static_assert(sizeof(NTAG215Password) == 0x8, "NTAG215Password is an invalid siz struct EncryptedAmiiboFile { u8 constant_value; // Must be A5 u16_be write_counter; // Number of times the amiibo has been written? - INSERT_PADDING_BYTES(0x1); // Unknown 1 + u8 amiibo_version; // Amiibo file version AmiiboSettings settings; // Encrypted amiibo settings HashData hmac_tag; // Hash AmiiboModelInfo model_info; // Encrypted amiibo model info HashData keygen_salt; // Salt HashData hmac_data; // Hash Service::Mii::Ver3StoreData owner_mii; // Encrypted Mii data - u64_be title_id; // Encrypted Game id - u16_be applicaton_write_counter; // Encrypted Counter + u64_be application_id; // Encrypted Game id + u16_be application_write_counter; // Encrypted Counter u32_be application_area_id; // Encrypted Game id - std::array<u8, 0x2> unknown; - std::array<u32, 0x8> unknown2; + u8 application_id_byte; + u8 unknown; + Service::Mii::NfpStoreDataExtension mii_extension; + std::array<u32, 0x5> unknown2; + u32_be register_info_crc; ApplicationArea application_area; // Encrypted Game data }; static_assert(sizeof(EncryptedAmiiboFile) == 0x1F8, "AmiiboFile is an invalid size"); @@ -259,14 +273,17 @@ struct NTAG215File { HashData hmac_data; // Hash u8 constant_value; // Must be A5 u16_be write_counter; // Number of times the amiibo has been written? - INSERT_PADDING_BYTES(0x1); // Unknown 1 + u8 amiibo_version; // Amiibo file version AmiiboSettings settings; - Service::Mii::Ver3StoreData owner_mii; // Encrypted Mii data - u64_be title_id; - u16_be applicaton_write_counter; // Encrypted Counter + Service::Mii::Ver3StoreData owner_mii; // Mii data + u64_be application_id; // Game id + u16_be application_write_counter; // Counter u32_be application_area_id; - std::array<u8, 0x2> unknown; - std::array<u32, 0x8> unknown2; + u8 application_id_byte; + u8 unknown; + Service::Mii::NfpStoreDataExtension mii_extension; + std::array<u32, 0x5> unknown2; + u32_be register_info_crc; ApplicationArea application_area; // Encrypted Game data HashData hmac_tag; // Hash UniqueSerialNumber uid; // Unique serial number @@ -336,6 +353,18 @@ struct RegisterInfo { }; static_assert(sizeof(RegisterInfo) == 0x100, "RegisterInfo is an invalid size"); +struct AdminInfo { + u64 application_id; + u32 application_area_id; + u16 crc_change_counter; + u8 flags; + PackedTagType tag_type; + AppAreaVersion app_area_version; + INSERT_PADDING_BYTES(0x7); + INSERT_PADDING_BYTES(0x28); +}; +static_assert(sizeof(AdminInfo) == 0x40, "AdminInfo is an invalid size"); + struct SectorKey { MifareCmd command; u8 unknown; // Usually 1 diff --git a/src/core/hle/service/nfp/nfp_user.cpp b/src/core/hle/service/nfp/nfp_user.cpp index a4d3d1bc7..4e8534113 100644 --- a/src/core/hle/service/nfp/nfp_user.cpp +++ b/src/core/hle/service/nfp/nfp_user.cpp @@ -4,8 +4,8 @@ #include "common/logging/log.h" #include "core/core.h" #include "core/hid/hid_types.h" -#include "core/hle/ipc_helpers.h" #include "core/hle/kernel/k_event.h" +#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/nfp/nfp_device.h" #include "core/hle/service/nfp/nfp_result.h" #include "core/hle/service/nfp/nfp_user.h" @@ -56,7 +56,7 @@ IUser ::~IUser() { availability_change_event->Close(); } -void IUser::Initialize(Kernel::HLERequestContext& ctx) { +void IUser::Initialize(HLERequestContext& ctx) { LOG_INFO(Service_NFP, "called"); state = State::Initialized; @@ -69,7 +69,7 @@ void IUser::Initialize(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IUser::Finalize(Kernel::HLERequestContext& ctx) { +void IUser::Finalize(HLERequestContext& ctx) { LOG_INFO(Service_NFP, "called"); state = State::NonInitialized; @@ -82,7 +82,7 @@ void IUser::Finalize(Kernel::HLERequestContext& ctx) { rb.Push(ResultSuccess); } -void IUser::ListDevices(Kernel::HLERequestContext& ctx) { +void IUser::ListDevices(HLERequestContext& ctx) { LOG_DEBUG(Service_NFP, "called"); if (state == State::NonInitialized) { @@ -128,7 +128,7 @@ void IUser::ListDevices(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<s32>(nfp_devices.size())); } -void IUser::StartDetection(Kernel::HLERequestContext& ctx) { +void IUser::StartDetection(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto nfp_protocol{rp.PopEnum<TagProtocol>()}; @@ -153,7 +153,7 @@ void IUser::StartDetection(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::StopDetection(Kernel::HLERequestContext& ctx) { +void IUser::StopDetection(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -177,7 +177,7 @@ void IUser::StopDetection(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::Mount(Kernel::HLERequestContext& ctx) { +void IUser::Mount(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto model_type{rp.PopEnum<ModelType>()}; @@ -204,7 +204,7 @@ void IUser::Mount(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::Unmount(Kernel::HLERequestContext& ctx) { +void IUser::Unmount(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -228,7 +228,7 @@ void IUser::Unmount(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::OpenApplicationArea(Kernel::HLERequestContext& ctx) { +void IUser::OpenApplicationArea(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto access_id{rp.Pop<u32>()}; @@ -253,7 +253,7 @@ void IUser::OpenApplicationArea(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::GetApplicationArea(Kernel::HLERequestContext& ctx) { +void IUser::GetApplicationArea(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto data_size = ctx.GetWriteBufferSize(); @@ -287,7 +287,7 @@ void IUser::GetApplicationArea(Kernel::HLERequestContext& ctx) { rb.Push(static_cast<u32>(data_size)); } -void IUser::SetApplicationArea(Kernel::HLERequestContext& ctx) { +void IUser::SetApplicationArea(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto data{ctx.ReadBuffer()}; @@ -318,7 +318,7 @@ void IUser::SetApplicationArea(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::Flush(Kernel::HLERequestContext& ctx) { +void IUser::Flush(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -342,7 +342,7 @@ void IUser::Flush(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::Restore(Kernel::HLERequestContext& ctx) { +void IUser::Restore(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_WARNING(Service_NFP, "(STUBBED) called, device_handle={}", device_handle); @@ -366,7 +366,7 @@ void IUser::Restore(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::CreateApplicationArea(Kernel::HLERequestContext& ctx) { +void IUser::CreateApplicationArea(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto access_id{rp.Pop<u32>()}; @@ -399,7 +399,7 @@ void IUser::CreateApplicationArea(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::GetTagInfo(Kernel::HLERequestContext& ctx) { +void IUser::GetTagInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -425,7 +425,7 @@ void IUser::GetTagInfo(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::GetRegisterInfo(Kernel::HLERequestContext& ctx) { +void IUser::GetRegisterInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -451,7 +451,7 @@ void IUser::GetRegisterInfo(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::GetCommonInfo(Kernel::HLERequestContext& ctx) { +void IUser::GetCommonInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -477,7 +477,7 @@ void IUser::GetCommonInfo(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::GetModelInfo(Kernel::HLERequestContext& ctx) { +void IUser::GetModelInfo(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_INFO(Service_NFP, "called, device_handle={}", device_handle); @@ -503,7 +503,7 @@ void IUser::GetModelInfo(Kernel::HLERequestContext& ctx) { rb.Push(result); } -void IUser::AttachActivateEvent(Kernel::HLERequestContext& ctx) { +void IUser::AttachActivateEvent(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFP, "called, device_handle={}", device_handle); @@ -527,7 +527,7 @@ void IUser::AttachActivateEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(device.value()->GetActivateEvent()); } -void IUser::AttachDeactivateEvent(Kernel::HLERequestContext& ctx) { +void IUser::AttachDeactivateEvent(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFP, "called, device_handle={}", device_handle); @@ -551,7 +551,7 @@ void IUser::AttachDeactivateEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(device.value()->GetDeactivateEvent()); } -void IUser::GetState(Kernel::HLERequestContext& ctx) { +void IUser::GetState(HLERequestContext& ctx) { LOG_DEBUG(Service_NFP, "called"); IPC::ResponseBuilder rb{ctx, 3}; @@ -559,7 +559,7 @@ void IUser::GetState(Kernel::HLERequestContext& ctx) { rb.PushEnum(state); } -void IUser::GetDeviceState(Kernel::HLERequestContext& ctx) { +void IUser::GetDeviceState(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFP, "called, device_handle={}", device_handle); @@ -577,7 +577,7 @@ void IUser::GetDeviceState(Kernel::HLERequestContext& ctx) { rb.PushEnum(device.value()->GetCurrentState()); } -void IUser::GetNpadId(Kernel::HLERequestContext& ctx) { +void IUser::GetNpadId(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFP, "called, device_handle={}", device_handle); @@ -601,7 +601,7 @@ void IUser::GetNpadId(Kernel::HLERequestContext& ctx) { rb.PushEnum(device.value()->GetNpadId()); } -void IUser::GetApplicationAreaSize(Kernel::HLERequestContext& ctx) { +void IUser::GetApplicationAreaSize(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; LOG_DEBUG(Service_NFP, "called, device_handle={}", device_handle); @@ -619,7 +619,7 @@ void IUser::GetApplicationAreaSize(Kernel::HLERequestContext& ctx) { rb.Push(device.value()->GetApplicationAreaSize()); } -void IUser::AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx) { +void IUser::AttachAvailabilityChangeEvent(HLERequestContext& ctx) { LOG_INFO(Service_NFP, "called"); if (state == State::NonInitialized) { @@ -633,7 +633,7 @@ void IUser::AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(availability_change_event->GetReadableEvent()); } -void IUser::RecreateApplicationArea(Kernel::HLERequestContext& ctx) { +void IUser::RecreateApplicationArea(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto device_handle{rp.Pop<u64>()}; const auto access_id{rp.Pop<u32>()}; diff --git a/src/core/hle/service/nfp/nfp_user.h b/src/core/hle/service/nfp/nfp_user.h index 7e9a90af8..1f3ff2ea8 100644 --- a/src/core/hle/service/nfp/nfp_user.h +++ b/src/core/hle/service/nfp/nfp_user.h @@ -24,31 +24,31 @@ private: Initialized, }; - void Initialize(Kernel::HLERequestContext& ctx); - void Finalize(Kernel::HLERequestContext& ctx); - void ListDevices(Kernel::HLERequestContext& ctx); - void StartDetection(Kernel::HLERequestContext& ctx); - void StopDetection(Kernel::HLERequestContext& ctx); - void Mount(Kernel::HLERequestContext& ctx); - void Unmount(Kernel::HLERequestContext& ctx); - void OpenApplicationArea(Kernel::HLERequestContext& ctx); - void GetApplicationArea(Kernel::HLERequestContext& ctx); - void SetApplicationArea(Kernel::HLERequestContext& ctx); - void Flush(Kernel::HLERequestContext& ctx); - void Restore(Kernel::HLERequestContext& ctx); - void CreateApplicationArea(Kernel::HLERequestContext& ctx); - void GetTagInfo(Kernel::HLERequestContext& ctx); - void GetRegisterInfo(Kernel::HLERequestContext& ctx); - void GetCommonInfo(Kernel::HLERequestContext& ctx); - void GetModelInfo(Kernel::HLERequestContext& ctx); - void AttachActivateEvent(Kernel::HLERequestContext& ctx); - void AttachDeactivateEvent(Kernel::HLERequestContext& ctx); - void GetState(Kernel::HLERequestContext& ctx); - void GetDeviceState(Kernel::HLERequestContext& ctx); - void GetNpadId(Kernel::HLERequestContext& ctx); - void GetApplicationAreaSize(Kernel::HLERequestContext& ctx); - void AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx); - void RecreateApplicationArea(Kernel::HLERequestContext& ctx); + void Initialize(HLERequestContext& ctx); + void Finalize(HLERequestContext& ctx); + void ListDevices(HLERequestContext& ctx); + void StartDetection(HLERequestContext& ctx); + void StopDetection(HLERequestContext& ctx); + void Mount(HLERequestContext& ctx); + void Unmount(HLERequestContext& ctx); + void OpenApplicationArea(HLERequestContext& ctx); + void GetApplicationArea(HLERequestContext& ctx); + void SetApplicationArea(HLERequestContext& ctx); + void Flush(HLERequestContext& ctx); + void Restore(HLERequestContext& ctx); + void CreateApplicationArea(HLERequestContext& ctx); + void GetTagInfo(HLERequestContext& ctx); + void GetRegisterInfo(HLERequestContext& ctx); + void GetCommonInfo(HLERequestContext& ctx); + void GetModelInfo(HLERequestContext& ctx); + void AttachActivateEvent(HLERequestContext& ctx); + void AttachDeactivateEvent(HLERequestContext& ctx); + void GetState(HLERequestContext& ctx); + void GetDeviceState(HLERequestContext& ctx); + void GetNpadId(HLERequestContext& ctx); + void GetApplicationAreaSize(HLERequestContext& ctx); + void AttachAvailabilityChangeEvent(HLERequestContext& ctx); + void RecreateApplicationArea(HLERequestContext& ctx); std::optional<std::shared_ptr<NfpDevice>> GetNfpDevice(u64 handle); |