From 221524d879bc82077db182a49da027606c944c6c Mon Sep 17 00:00:00 2001 From: Jacobwasbeast <38381609+Jacobwasbeast@users.noreply.github.com> Date: Fri, 20 Dec 2024 13:54:27 -0600 Subject: [PATCH] Added Support for 532-Byte Amiibo BIN Files (#412) Added functionality to load 532-byte Amiibo BIN files, commonly used in Tagmo and similar tools. These files were missing the following pages. * 133 (85h) PWD * 134 (86h) PACK RFUI These pages can be added as null bytes if not present. The system seems to function correctly without them. --- .../Nfc/AmiiboDecryption/AmiiboBinReader.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Ryujinx.HLE/HOS/Services/Nfc/AmiiboDecryption/AmiiboBinReader.cs b/src/Ryujinx.HLE/HOS/Services/Nfc/AmiiboDecryption/AmiiboBinReader.cs index 13a5ef998..d0225da8d 100644 --- a/src/Ryujinx.HLE/HOS/Services/Nfc/AmiiboDecryption/AmiiboBinReader.cs +++ b/src/Ryujinx.HLE/HOS/Services/Nfc/AmiiboDecryption/AmiiboBinReader.cs @@ -33,9 +33,12 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption const int pageSize = 4; const int totalBytes = totalPages * pageSize; - if (fileBytes.Length < totalBytes) + if (fileBytes.Length == 532) { - return new VirtualAmiiboFile(); + // add 8 bytes to the end of the file + byte[] newFileBytes = new byte[totalBytes]; + Array.Copy(fileBytes, newFileBytes, fileBytes.Length); + fileBytes = newFileBytes; } AmiiboDecrypter amiiboDecryptor = new AmiiboDecrypter(keyRetailBinPath); @@ -171,6 +174,14 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption return false; } + if (readBytes.Length == 532) + { + // add 8 bytes to the end of the file + byte[] newFileBytes = new byte[540]; + Array.Copy(readBytes, newFileBytes, readBytes.Length); + readBytes = newFileBytes; + } + AmiiboDecrypter amiiboDecryptor = new AmiiboDecrypter(keyRetailBinPath); AmiiboDump amiiboDump = amiiboDecryptor.DecryptAmiiboDump(readBytes); @@ -231,6 +242,14 @@ namespace Ryujinx.HLE.HOS.Services.Nfc.AmiiboDecryption return false; } + if (readBytes.Length == 532) + { + // add 8 bytes to the end of the file + byte[] newFileBytes = new byte[540]; + Array.Copy(readBytes, newFileBytes, readBytes.Length); + readBytes = newFileBytes; + } + AmiiboDecrypter amiiboDecryptor = new AmiiboDecrypter(keyRetailBinPath); AmiiboDump amiiboDump = amiiboDecryptor.DecryptAmiiboDump(readBytes); amiiboDump.AmiiboNickname = newNickName;