mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2024-12-26 21:25:39 +00:00
pl_u: Fix mismatched rebase size error in font encryption
This commit is contained in:
parent
36d829c27b
commit
1911f85391
|
@ -18,16 +18,14 @@ namespace {
|
||||||
|
|
||||||
template <std::size_t Size>
|
template <std::size_t Size>
|
||||||
VirtualFile PackBFTTF(const std::array<u8, Size>& data, const std::string& name) {
|
VirtualFile PackBFTTF(const std::array<u8, Size>& data, const std::string& name) {
|
||||||
std::vector<u8> vec(Size);
|
std::vector<u32> vec(Size / sizeof(u32));
|
||||||
std::memcpy(vec.data(), data.data(), vec.size());
|
std::memcpy(vec.data(), data.data(), vec.size() * sizeof(u32));
|
||||||
|
|
||||||
Kernel::PhysicalMemory bfttf(Size + sizeof(u64));
|
std::vector<u8> bfttf(Size + sizeof(u64));
|
||||||
|
|
||||||
Service::NS::EncryptSharedFont(vec, bfttf);
|
u64 offset = 0;
|
||||||
|
Service::NS::EncryptSharedFont(vec, bfttf, offset);
|
||||||
std::vector<u8> bfttf_vec(Size + sizeof(u64));
|
return std::make_shared<VectorVfsFile>(std::move(bfttf), name);
|
||||||
std::memcpy(bfttf_vec.data(), bfttf.data(), bfttf_vec.size());
|
|
||||||
return std::make_shared<VectorVfsFile>(std::move(bfttf_vec), name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
|
@ -6,13 +6,6 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <FontChineseSimplified.h>
|
|
||||||
#include <FontChineseTraditional.h>
|
|
||||||
#include <FontExtendedChineseSimplified.h>
|
|
||||||
#include <FontKorean.h>
|
|
||||||
#include <FontNintendoExtended.h>
|
|
||||||
#include <FontStandard.h>
|
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/common_paths.h"
|
#include "common/common_paths.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
@ -26,6 +19,7 @@
|
||||||
#include "core/file_sys/romfs.h"
|
#include "core/file_sys/romfs.h"
|
||||||
#include "core/file_sys/system_archive/system_archive.h"
|
#include "core/file_sys/system_archive/system_archive.h"
|
||||||
#include "core/hle/ipc_helpers.h"
|
#include "core/hle/ipc_helpers.h"
|
||||||
|
#include "core/hle/kernel/physical_memory.h"
|
||||||
#include "core/hle/kernel/shared_memory.h"
|
#include "core/hle/kernel/shared_memory.h"
|
||||||
#include "core/hle/service/filesystem/filesystem.h"
|
#include "core/hle/service/filesystem/filesystem.h"
|
||||||
#include "core/hle/service/ns/pl_u.h"
|
#include "core/hle/service/ns/pl_u.h"
|
||||||
|
@ -95,8 +89,10 @@ static void DecryptSharedFont(const std::vector<u32>& input, Kernel::PhysicalMem
|
||||||
offset += transformed_font.size() * sizeof(u32);
|
offset += transformed_font.size() * sizeof(u32);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EncryptSharedFont(const std::vector<u8>& input, Kernel::PhysicalMemory& output) {
|
void EncryptSharedFont(const std::vector<u32>& input, std::vector<u8>& output,
|
||||||
ASSERT_MSG(input.size() * sizeof(u32) < SHARED_FONT_MEM_SIZE, "Shared fonts exceeds 17mb!");
|
std::size_t& offset) {
|
||||||
|
ASSERT_MSG(offset + (input.size() * sizeof(u32)) < SHARED_FONT_MEM_SIZE,
|
||||||
|
"Shared fonts exceeds 17mb!");
|
||||||
|
|
||||||
const auto key = Common::swap32(EXPECTED_RESULT ^ EXPECTED_MAGIC);
|
const auto key = Common::swap32(EXPECTED_RESULT ^ EXPECTED_MAGIC);
|
||||||
std::vector<u32> transformed_font(input.size() + 2);
|
std::vector<u32> transformed_font(input.size() + 2);
|
||||||
|
@ -104,7 +100,9 @@ void EncryptSharedFont(const std::vector<u8>& input, Kernel::PhysicalMemory& out
|
||||||
transformed_font[1] = Common::swap32(input.size() * sizeof(u32)) ^ key;
|
transformed_font[1] = Common::swap32(input.size() * sizeof(u32)) ^ key;
|
||||||
std::transform(input.begin(), input.end(), transformed_font.begin() + 2,
|
std::transform(input.begin(), input.end(), transformed_font.begin() + 2,
|
||||||
[key](u32 in) { return in ^ key; });
|
[key](u32 in) { return in ^ key; });
|
||||||
std::memcpy(output.data(), transformed_font.data(), transformed_font.size() * sizeof(u32));
|
std::memcpy(output.data() + offset, transformed_font.data(),
|
||||||
|
transformed_font.size() * sizeof(u32));
|
||||||
|
offset += transformed_font.size() * sizeof(u32);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to make BuildSharedFontsRawRegions a bit nicer
|
// Helper function to make BuildSharedFontsRawRegions a bit nicer
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "core/hle/kernel/physical_memory.h"
|
#include <vector>
|
||||||
#include "core/hle/service/service.h"
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
namespace Service {
|
namespace Service {
|
||||||
|
@ -16,6 +16,8 @@ class FileSystemController;
|
||||||
|
|
||||||
namespace NS {
|
namespace NS {
|
||||||
|
|
||||||
|
void EncryptSharedFont(const std::vector<u32>& input, std::vector<u8>& output, std::size_t& offset);
|
||||||
|
|
||||||
class PL_U final : public ServiceFramework<PL_U> {
|
class PL_U final : public ServiceFramework<PL_U> {
|
||||||
public:
|
public:
|
||||||
explicit PL_U(Core::System& system);
|
explicit PL_U(Core::System& system);
|
||||||
|
|
Loading…
Reference in a new issue