summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service')
-rw-r--r--src/core/hle/service/nfc/common/device.cpp35
-rw-r--r--src/core/hle/service/nfc/common/device.h2
2 files changed, 27 insertions, 10 deletions
diff --git a/src/core/hle/service/nfc/common/device.cpp b/src/core/hle/service/nfc/common/device.cpp
index e5de65ce0..322bde2ed 100644
--- a/src/core/hle/service/nfc/common/device.cpp
+++ b/src/core/hle/service/nfc/common/device.cpp
@@ -48,9 +48,6 @@ NfcDevice::NfcDevice(Core::HID::NpadIdType npad_id_, Core::System& system_,
};
is_controller_set = true;
callback_key = npad_device->SetCallback(engine_callback);
-
- auto& standard_steady_clock{system.GetTimeManager().GetStandardSteadyClockCore()};
- current_posix_time = standard_steady_clock.GetCurrentTimePoint(system).time_point;
}
NfcDevice::~NfcDevice() {
@@ -227,11 +224,21 @@ 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.Initialize(static_cast<u32>(GetCurrentPosixTime()));
+ 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<u8>(encrypted_tag_data.uuid.uid.size()),
+ .uuid_length = static_cast<u8>(uuid.size()),
.protocol = NfcProtocol::TypeA,
.tag_type = TagType::Type4,
};
@@ -240,9 +247,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<u8>(encrypted_tag_data.uuid.uid.size()),
+ .uuid_length = static_cast<u8>(uuid.size()),
.protocol = NfcProtocol::TypeA,
.tag_type = TagType::Type2,
};
@@ -406,7 +413,7 @@ Result NfcDevice::Flush() {
auto& settings = tag_data.settings;
- const auto& current_date = GetAmiiboDate(current_posix_time);
+ const auto& current_date = GetAmiiboDate(GetCurrentPosixTime());
if (settings.write_date.raw_date != current_date.raw_date) {
settings.write_date = current_date;
UpdateSettingsCrc();
@@ -525,6 +532,7 @@ Result NfcDevice::GetModelInfo(NFP::ModelInfo& model_info) const {
}
const auto& model_info_data = encrypted_tag_data.user_memory.model_info;
+
model_info = {
.character_id = model_info_data.character_id,
.character_variant = model_info_data.character_variant,
@@ -669,6 +677,7 @@ Result NfcDevice::DeleteRegisterInfo() {
}
Common::TinyMT rng{};
+ rng.Initialize(static_cast<u32>(GetCurrentPosixTime()));
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));
@@ -701,7 +710,7 @@ Result NfcDevice::SetRegisterInfoPrivate(const NFP::RegisterInfoPrivate& registe
auto& settings = tag_data.settings;
if (tag_data.settings.settings.amiibo_initialized == 0) {
- settings.init_date = GetAmiiboDate(current_posix_time);
+ settings.init_date = GetAmiiboDate(GetCurrentPosixTime());
settings.write_date.raw_date = 0;
}
@@ -868,6 +877,7 @@ Result NfcDevice::SetApplicationArea(std::span<const u8> data) {
}
Common::TinyMT rng{};
+ rng.Initialize(static_cast<u32>(GetCurrentPosixTime()));
std::memcpy(tag_data.application_area.data(), data.data(), data.size());
// Fill remaining data with random numbers
rng.GenerateRandomBytes(tag_data.application_area.data() + data.size(),
@@ -924,6 +934,7 @@ Result NfcDevice::RecreateApplicationArea(u32 access_id, std::span<const u8> dat
}
Common::TinyMT rng{};
+ rng.Initialize(static_cast<u32>(GetCurrentPosixTime()));
std::memcpy(tag_data.application_area.data(), data.data(), data.size());
// Fill remaining data with random numbers
rng.GenerateRandomBytes(tag_data.application_area.data() + data.size(),
@@ -973,6 +984,7 @@ Result NfcDevice::DeleteApplicationArea() {
}
Common::TinyMT rng{};
+ rng.Initialize(static_cast<u32>(GetCurrentPosixTime()));
rng.GenerateRandomBytes(tag_data.application_area.data(), sizeof(NFP::ApplicationArea));
rng.GenerateRandomBytes(&tag_data.application_id, sizeof(u64));
rng.GenerateRandomBytes(&tag_data.application_area_id, sizeof(u32));
@@ -1189,6 +1201,11 @@ NFP::AmiiboDate NfcDevice::GetAmiiboDate(s64 posix_time) const {
return amiibo_date;
}
+u64 NfcDevice::GetCurrentPosixTime() const {
+ auto& standard_steady_clock{system.GetTimeManager().GetStandardSteadyClockCore()};
+ return standard_steady_clock.GetCurrentTimePoint(system).time_point;
+}
+
u64 NfcDevice::RemoveVersionByte(u64 application_id) const {
return application_id & ~(0xfULL << NFP::application_id_version_offset);
}
diff --git a/src/core/hle/service/nfc/common/device.h b/src/core/hle/service/nfc/common/device.h
index 654eda98e..98e1945c1 100644
--- a/src/core/hle/service/nfc/common/device.h
+++ b/src/core/hle/service/nfc/common/device.h
@@ -105,6 +105,7 @@ private:
NFP::AmiiboName GetAmiiboName(const NFP::AmiiboSettings& settings) const;
void SetAmiiboName(NFP::AmiiboSettings& settings, const NFP::AmiiboName& amiibo_name);
NFP::AmiiboDate GetAmiiboDate(s64 posix_time) const;
+ u64 GetCurrentPosixTime() const;
u64 RemoveVersionByte(u64 application_id) const;
void UpdateSettingsCrc();
void UpdateRegisterInfoCrc();
@@ -127,7 +128,6 @@ private:
bool is_data_moddified{};
bool is_app_area_open{};
bool is_plain_amiibo{};
- s64 current_posix_time{};
NFP::MountTarget mount_target{NFP::MountTarget::None};
NFP::NTAG215File tag_data{};