Fix various issues with firmware generation (#2058)

This commit is contained in:
CasualPokePlayer 2024-07-11 06:55:06 -07:00 committed by GitHub
parent 841e3eb060
commit a812a43bda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 4 deletions

View File

@ -80,6 +80,7 @@ void Firmware::WifiAccessPoint::UpdateChecksum()
Firmware::ExtendedWifiAccessPoint::ExtendedWifiAccessPoint()
{
memset(Bytes, 0, sizeof(Bytes));
Data.Base = WifiAccessPoint();
UpdateChecksum();
@ -93,6 +94,7 @@ void Firmware::ExtendedWifiAccessPoint::UpdateChecksum()
Firmware::FirmwareHeader::FirmwareHeader(int consoletype)
{
memset(Bytes, 0, sizeof(Bytes));
if (consoletype == 1)
{
ConsoleType = FirmwareConsoleType::DSi;
@ -156,7 +158,7 @@ void Firmware::FirmwareHeader::UpdateChecksum()
Firmware::UserData::UserData()
{
memset(Bytes, 0, 0x74);
memset(Bytes, 0, sizeof(Bytes));
Version = 5;
BirthdayMonth = 1;
BirthdayDay = 1;
@ -273,7 +275,8 @@ Firmware::Firmware(const u8* data, u32 length) : FirmwareBuffer(nullptr), Firmwa
if (data)
{
FirmwareBuffer = new u8[FirmwareBufferLength];
memcpy(FirmwareBuffer, data, FirmwareBufferLength);
memset(FirmwareBuffer, 0, FirmwareBufferLength);
memcpy(FirmwareBuffer, data, std::min(length, FirmwareBufferLength));
FirmwareMask = FirmwareBufferLength - 1;
}
}
@ -345,7 +348,7 @@ const Firmware::UserData& Firmware::GetEffectiveUserData() const {
if (userdata0ChecksumOk && userdata1ChecksumOk)
{
return userdata[0].UpdateCounter > userdata[1].UpdateCounter ? userdata[0] : userdata[1];
return userdata[0].UpdateCounter >= userdata[1].UpdateCounter ? userdata[0] : userdata[1];
}
else if (userdata0ChecksumOk)
{
@ -368,7 +371,7 @@ Firmware::UserData& Firmware::GetEffectiveUserData() {
if (userdata0ChecksumOk && userdata1ChecksumOk)
{
return userdata[0].UpdateCounter > userdata[1].UpdateCounter ? userdata[0] : userdata[1];
return userdata[0].UpdateCounter >= userdata[1].UpdateCounter ? userdata[0] : userdata[1];
}
else if (userdata0ChecksumOk)
{