[VFS] Fix sketchy ReadMagic function...
Haven't been able to test yet though - hope it's reading in the correct endian!
This commit is contained in:
parent
79081ca272
commit
7eb5fa230a
|
@ -698,11 +698,9 @@ StfsContainerDevice::BlockHash StfsContainerDevice::STFSGetLevel0HashEntry(
|
||||||
return STFSGetLevelNHashEntry(map_ptr, block_index, 0, use_secondary_block);
|
return STFSGetLevelNHashEntry(map_ptr, block_index, 0, use_secondary_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* StfsContainerDevice::ReadMagic(const std::wstring& path) {
|
uint32_t StfsContainerDevice::ReadMagic(const std::wstring& path) {
|
||||||
auto map = MappedMemory::Open(path, MappedMemory::Mode::kRead, 0, 4);
|
auto map = MappedMemory::Open(path, MappedMemory::Mode::kRead, 0, 4);
|
||||||
auto magic_data = xe::load<uint32_t>(map->data());
|
return xe::load_and_swap<uint32_t>(map->data());
|
||||||
auto magic_bytes = static_cast<char*>(static_cast<void*>(&magic_data));
|
|
||||||
return std::move(magic_bytes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StfsContainerDevice::ResolveFromFolder(const std::wstring& path) {
|
bool StfsContainerDevice::ResolveFromFolder(const std::wstring& path) {
|
||||||
|
@ -728,8 +726,9 @@ bool StfsContainerDevice::ResolveFromFolder(const std::wstring& path) {
|
||||||
auto path = xe::join_paths(current_file.path, current_file.name);
|
auto path = xe::join_paths(current_file.path, current_file.name);
|
||||||
auto magic = ReadMagic(path);
|
auto magic = ReadMagic(path);
|
||||||
|
|
||||||
if (memcmp(magic, "LIVE", 4) == 0 || memcmp(magic, "PIRS", 4) == 0 ||
|
if (magic == XContentPackageType::kPackageTypeCon ||
|
||||||
memcmp(magic, "CON ", 4) == 0) {
|
magic == XContentPackageType::kPackageTypeLive ||
|
||||||
|
magic == XContentPackageType::kPackageTypePirs) {
|
||||||
local_path_ = xe::join_paths(current_file.path, current_file.name);
|
local_path_ = xe::join_paths(current_file.path, current_file.name);
|
||||||
XELOGI("STFS Package found: %s", xe::to_string(local_path_).c_str());
|
XELOGI("STFS Package found: %s", xe::to_string(local_path_).c_str());
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -448,7 +448,7 @@ class StfsContainerDevice : public Device {
|
||||||
|
|
||||||
const uint32_t kSTFSDataBlocksPerHashLevel[3] = {0xAA, 0x70E4, 0x4AF768};
|
const uint32_t kSTFSDataBlocksPerHashLevel[3] = {0xAA, 0x70E4, 0x4AF768};
|
||||||
|
|
||||||
const char* ReadMagic(const std::wstring& path);
|
uint32_t ReadMagic(const std::wstring& path);
|
||||||
bool ResolveFromFolder(const std::wstring& path);
|
bool ResolveFromFolder(const std::wstring& path);
|
||||||
|
|
||||||
Error MapFiles();
|
Error MapFiles();
|
||||||
|
|
Loading…
Reference in New Issue