mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-06 23:19:57 +01:00
Add support for uninitialized movable
This commit is contained in:
parent
66d8e58dcd
commit
007b809ad7
@ -158,13 +158,14 @@ SecureDataLoadStatus LoadMovable() {
|
||||
if (!file.IsOpen()) {
|
||||
return SecureDataLoadStatus::IOError;
|
||||
}
|
||||
if (file.GetSize() != sizeof(MovableSedFull)) {
|
||||
if (file.GetSize() == sizeof(MovableSed)) {
|
||||
LOG_WARNING(HW, "Uninitialized movable.sed files are not supported");
|
||||
}
|
||||
|
||||
std::size_t size = file.GetSize();
|
||||
if (size != sizeof(MovableSedFull) && size != sizeof(MovableSed)) {
|
||||
return SecureDataLoadStatus::Invalid;
|
||||
}
|
||||
if (file.ReadBytes(&movable, sizeof(MovableSedFull)) != sizeof(MovableSedFull)) {
|
||||
|
||||
std::memset(&movable, 0, sizeof(movable));
|
||||
if (file.ReadBytes(&movable, size) != size) {
|
||||
movable.Invalidate();
|
||||
return SecureDataLoadStatus::IOError;
|
||||
}
|
||||
@ -172,7 +173,7 @@ SecureDataLoadStatus LoadMovable() {
|
||||
HW::AES::InitKeys();
|
||||
movable_signature_valid = movable.VerifySignature();
|
||||
if (!movable_signature_valid) {
|
||||
LOG_WARNING(HW, "LocalFriendCodeSeed_B signature check failed");
|
||||
LOG_WARNING(HW, "movable.sed signature check failed");
|
||||
}
|
||||
|
||||
return movable_signature_valid ? SecureDataLoadStatus::Loaded
|
||||
|
||||
@ -66,7 +66,10 @@ struct MovableSed {
|
||||
static constexpr std::array<u8, 0x4> seed_magic{0x53, 0x45, 0x45, 0x44};
|
||||
|
||||
std::array<u8, 0x4> magic;
|
||||
u32 seed_info;
|
||||
u8 unk0;
|
||||
u8 is_full;
|
||||
u8 unk1;
|
||||
u8 unk2;
|
||||
LocalFriendCodeSeedB lfcs;
|
||||
std::array<u8, 0x8> key_y;
|
||||
|
||||
@ -79,6 +82,10 @@ struct MovableSed {
|
||||
}
|
||||
|
||||
bool VerifySignature() const;
|
||||
|
||||
bool IsFull() {
|
||||
return is_full != 0;
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(MovableSed) == 0x120);
|
||||
|
||||
@ -101,6 +108,14 @@ struct MovableSedFull {
|
||||
// TODO(PabloMK7): Implement AES MAC verification
|
||||
return body.sed.VerifySignature();
|
||||
}
|
||||
|
||||
bool IsFull() {
|
||||
return body.sed.IsFull();
|
||||
}
|
||||
|
||||
size_t GetRealSize() {
|
||||
return IsFull() ? sizeof(MovableSedFull) : sizeof(MovableSed);
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(MovableSedFull) == 0x140);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user