mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-20 12:55:45 +00:00
fix integrity store crash on new updates (#177)
credit: Zeuslota Signed-off-by: crueter <swurl@swurl.xyz> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/177 Co-authored-by: crueter <swurl@swurl.xyz> Co-committed-by: crueter <swurl@swurl.xyz>
This commit is contained in:
parent
5b361338c1
commit
c6a87a661a
1 changed files with 30 additions and 9 deletions
|
@ -1,18 +1,26 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "common/alignment.h"
|
|
||||||
#include "core/file_sys/fssystem/fssystem_integrity_verification_storage.h"
|
#include "core/file_sys/fssystem/fssystem_integrity_verification_storage.h"
|
||||||
|
#include "common/alignment.h"
|
||||||
|
|
||||||
namespace FileSys {
|
namespace FileSys {
|
||||||
|
|
||||||
constexpr inline u32 ILog2(u32 val) {
|
constexpr inline u32 ILog2(u32 val)
|
||||||
|
{
|
||||||
ASSERT(val > 0);
|
ASSERT(val > 0);
|
||||||
return static_cast<u32>((sizeof(u32) * 8) - 1 - std::countl_zero<u32>(val));
|
return static_cast<u32>((sizeof(u32) * 8) - 1 - std::countl_zero<u32>(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrityVerificationStorage::Initialize(VirtualFile hs, VirtualFile ds, s64 verif_block_size,
|
void IntegrityVerificationStorage::Initialize(VirtualFile hs,
|
||||||
s64 upper_layer_verif_block_size, bool is_real_data) {
|
VirtualFile ds,
|
||||||
|
s64 verif_block_size,
|
||||||
|
s64 upper_layer_verif_block_size,
|
||||||
|
bool is_real_data)
|
||||||
|
{
|
||||||
// Validate preconditions.
|
// Validate preconditions.
|
||||||
ASSERT(verif_block_size >= HashSize);
|
ASSERT(verif_block_size >= HashSize);
|
||||||
|
|
||||||
|
@ -32,22 +40,28 @@ void IntegrityVerificationStorage::Initialize(VirtualFile hs, VirtualFile ds, s6
|
||||||
ASSERT(m_upper_layer_verification_block_size == 1ll << m_upper_layer_verification_block_order);
|
ASSERT(m_upper_layer_verification_block_size == 1ll << m_upper_layer_verification_block_order);
|
||||||
|
|
||||||
// Validate sizes.
|
// Validate sizes.
|
||||||
{
|
if (m_data_storage != nullptr) {
|
||||||
s64 hash_size = m_hash_storage->GetSize();
|
s64 hash_size = m_hash_storage->GetSize();
|
||||||
s64 data_size = m_data_storage->GetSize();
|
s64 data_size = m_data_storage->GetSize();
|
||||||
ASSERT(((hash_size / HashSize) * m_verification_block_size) >= data_size);
|
ASSERT(((hash_size / HashSize) * m_verification_block_size) >= data_size);
|
||||||
|
} else {
|
||||||
|
LOG_ERROR(Loader,
|
||||||
|
"Failed to initialize integrity verification store. Game, update, or DLC may not "
|
||||||
|
"work.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set data.
|
// Set data.
|
||||||
m_is_real_data = is_real_data;
|
m_is_real_data = is_real_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrityVerificationStorage::Finalize() {
|
void IntegrityVerificationStorage::Finalize()
|
||||||
|
{
|
||||||
m_hash_storage = VirtualFile();
|
m_hash_storage = VirtualFile();
|
||||||
m_data_storage = VirtualFile();
|
m_data_storage = VirtualFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t IntegrityVerificationStorage::Read(u8* buffer, size_t size, size_t offset) const {
|
size_t IntegrityVerificationStorage::Read(u8* buffer, size_t size, size_t offset) const
|
||||||
|
{
|
||||||
// Succeed if zero size.
|
// Succeed if zero size.
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
return size;
|
return size;
|
||||||
|
@ -56,7 +70,13 @@ size_t IntegrityVerificationStorage::Read(u8* buffer, size_t size, size_t offset
|
||||||
// Validate arguments.
|
// Validate arguments.
|
||||||
ASSERT(buffer != nullptr);
|
ASSERT(buffer != nullptr);
|
||||||
|
|
||||||
// Validate the offset.
|
if (m_data_storage == nullptr) {
|
||||||
|
LOG_ERROR(Loader,
|
||||||
|
"Integrity verification store failed read operation. Game, update or DLC may not "
|
||||||
|
"work.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
s64 data_size = m_data_storage->GetSize();
|
s64 data_size = m_data_storage->GetSize();
|
||||||
ASSERT(offset <= static_cast<size_t>(data_size));
|
ASSERT(offset <= static_cast<size_t>(data_size));
|
||||||
|
|
||||||
|
@ -84,7 +104,8 @@ size_t IntegrityVerificationStorage::Read(u8* buffer, size_t size, size_t offset
|
||||||
return m_data_storage->Read(buffer, read_size, offset);
|
return m_data_storage->Read(buffer, read_size, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t IntegrityVerificationStorage::GetSize() const {
|
size_t IntegrityVerificationStorage::GetSize() const
|
||||||
|
{
|
||||||
return m_data_storage->GetSize();
|
return m_data_storage->GetSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue