From 1968cc7b106159e2bd2166459c3cb04d5f79601f Mon Sep 17 00:00:00 2001 From: german77 Date: Mon, 8 May 2023 22:03:32 -0600 Subject: service: nfp: Allow to load with a different amiibo id --- src/core/hle/service/nfc/common/device.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/core/hle/service/nfc') diff --git a/src/core/hle/service/nfc/common/device.cpp b/src/core/hle/service/nfc/common/device.cpp index e5de65ce0..9b0685bdb 100644 --- a/src/core/hle/service/nfc/common/device.cpp +++ b/src/core/hle/service/nfc/common/device.cpp @@ -227,11 +227,20 @@ Result NfcDevice::GetTagInfo(NFP::TagInfo& tag_info, bool is_mifare) const { return ResultWrongDeviceState; } + UniqueSerialNumber uuid = encrypted_tag_data.uuid.uid; + + // Generate random UUID to bypass amiibo load limits + if (Settings::values.random_amiibo_id) { + Common::TinyMT rng{}; + rng.GenerateRandomBytes(uuid.data(), sizeof(UniqueSerialNumber)); + uuid[3] = 0x88 ^ uuid[0] ^ uuid[1] ^ uuid[2]; + } + if (is_mifare) { tag_info = { - .uuid = encrypted_tag_data.uuid.uid, + .uuid = uuid, .uuid_extension = {}, - .uuid_length = static_cast(encrypted_tag_data.uuid.uid.size()), + .uuid_length = static_cast(uuid.size()), .protocol = NfcProtocol::TypeA, .tag_type = TagType::Type4, }; @@ -240,9 +249,9 @@ Result NfcDevice::GetTagInfo(NFP::TagInfo& tag_info, bool is_mifare) const { // Protocol and tag type may change here tag_info = { - .uuid = encrypted_tag_data.uuid.uid, + .uuid = uuid, .uuid_extension = {}, - .uuid_length = static_cast(encrypted_tag_data.uuid.uid.size()), + .uuid_length = static_cast(uuid.size()), .protocol = NfcProtocol::TypeA, .tag_type = TagType::Type2, }; -- cgit v1.2.3