From 210377816d4cb86f9455a6b3040c393886f470b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Fri, 1 Jun 2018 23:44:24 +0200 Subject: [PATCH] WiiSave: Get rid of some magic numbers It would make sense for 0x80 and 0xf0c0 to be respectively sizeof(BkHeader) and sizeof(Header) as Nintendo is signing anything that comes after the header, including the BkHeader. --- Source/Core/Core/HW/WiiSave.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/HW/WiiSave.cpp b/Source/Core/Core/HW/WiiSave.cpp index 1ffe9d36f2..47cfdac4cc 100644 --- a/Source/Core/Core/HW/WiiSave.cpp +++ b/Source/Core/Core/HW/WiiSave.cpp @@ -78,6 +78,7 @@ struct Header DataBinHeader hdr; u8 banner[FULL_BNR_MAX]; }; +static_assert(sizeof(Header) == 0xf0c0, "Header has an incorrect size"); struct BkHeader { @@ -96,6 +97,7 @@ struct BkHeader std::array mac_address; std::array padding; }; +static_assert(sizeof(BkHeader) == 0x80, "BkHeader has an incorrect size"); struct FileHDR { @@ -464,9 +466,9 @@ private: return false; // Read data to sign. - const u32 data_size = bk_header->size_of_files + 0x80; + const u32 data_size = bk_header->size_of_files + sizeof(BkHeader); auto data = std::make_unique(data_size); - m_file.Seek(0xf0c0, SEEK_SET); + m_file.Seek(sizeof(Header), SEEK_SET); if (!m_file.ReadBytes(data.get(), data_size)) return false;