diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/file_sys/system_archive/shared_font.cpp | 14 | ||||
| -rw-r--r-- | src/core/hle/service/ns/pl_u.cpp | 18 | ||||
| -rw-r--r-- | src/core/hle/service/ns/pl_u.h | 4 |
3 files changed, 17 insertions, 19 deletions
diff --git a/src/core/file_sys/system_archive/shared_font.cpp b/src/core/file_sys/system_archive/shared_font.cpp index 5bb596824..2c05eb42e 100644 --- a/src/core/file_sys/system_archive/shared_font.cpp +++ b/src/core/file_sys/system_archive/shared_font.cpp | |||
| @@ -18,16 +18,14 @@ namespace { | |||
| 18 | 18 | ||
| 19 | template <std::size_t Size> | 19 | template <std::size_t Size> |
| 20 | VirtualFile PackBFTTF(const std::array<u8, Size>& data, const std::string& name) { | 20 | VirtualFile PackBFTTF(const std::array<u8, Size>& data, const std::string& name) { |
| 21 | std::vector<u8> vec(Size); | 21 | std::vector<u32> vec(Size / sizeof(u32)); |
| 22 | std::memcpy(vec.data(), data.data(), vec.size()); | 22 | std::memcpy(vec.data(), data.data(), vec.size() * sizeof(u32)); |
| 23 | 23 | ||
| 24 | Kernel::PhysicalMemory bfttf(Size + sizeof(u64)); | 24 | std::vector<u8> bfttf(Size + sizeof(u64)); |
| 25 | 25 | ||
| 26 | Service::NS::EncryptSharedFont(vec, bfttf); | 26 | u64 offset = 0; |
| 27 | 27 | Service::NS::EncryptSharedFont(vec, bfttf, offset); | |
| 28 | std::vector<u8> bfttf_vec(Size + sizeof(u64)); | 28 | return std::make_shared<VectorVfsFile>(std::move(bfttf), name); |
| 29 | std::memcpy(bfttf_vec.data(), bfttf.data(), bfttf_vec.size()); | ||
| 30 | return std::make_shared<VectorVfsFile>(std::move(bfttf_vec), name); | ||
| 31 | } | 29 | } |
| 32 | 30 | ||
| 33 | } // Anonymous namespace | 31 | } // Anonymous namespace |
diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp index b9c0f4b43..23477315f 100644 --- a/src/core/hle/service/ns/pl_u.cpp +++ b/src/core/hle/service/ns/pl_u.cpp | |||
| @@ -6,13 +6,6 @@ | |||
| 6 | #include <cstring> | 6 | #include <cstring> |
| 7 | #include <vector> | 7 | #include <vector> |
| 8 | 8 | ||
| 9 | #include <FontChineseSimplified.h> | ||
| 10 | #include <FontChineseTraditional.h> | ||
| 11 | #include <FontExtendedChineseSimplified.h> | ||
| 12 | #include <FontKorean.h> | ||
| 13 | #include <FontNintendoExtended.h> | ||
| 14 | #include <FontStandard.h> | ||
| 15 | |||
| 16 | #include "common/assert.h" | 9 | #include "common/assert.h" |
| 17 | #include "common/common_paths.h" | 10 | #include "common/common_paths.h" |
| 18 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| @@ -26,6 +19,7 @@ | |||
| 26 | #include "core/file_sys/romfs.h" | 19 | #include "core/file_sys/romfs.h" |
| 27 | #include "core/file_sys/system_archive/system_archive.h" | 20 | #include "core/file_sys/system_archive/system_archive.h" |
| 28 | #include "core/hle/ipc_helpers.h" | 21 | #include "core/hle/ipc_helpers.h" |
| 22 | #include "core/hle/kernel/physical_memory.h" | ||
| 29 | #include "core/hle/kernel/shared_memory.h" | 23 | #include "core/hle/kernel/shared_memory.h" |
| 30 | #include "core/hle/service/filesystem/filesystem.h" | 24 | #include "core/hle/service/filesystem/filesystem.h" |
| 31 | #include "core/hle/service/ns/pl_u.h" | 25 | #include "core/hle/service/ns/pl_u.h" |
| @@ -95,8 +89,10 @@ static void DecryptSharedFont(const std::vector<u32>& input, Kernel::PhysicalMem | |||
| 95 | offset += transformed_font.size() * sizeof(u32); | 89 | offset += transformed_font.size() * sizeof(u32); |
| 96 | } | 90 | } |
| 97 | 91 | ||
| 98 | void EncryptSharedFont(const std::vector<u8>& input, Kernel::PhysicalMemory& output) { | 92 | void EncryptSharedFont(const std::vector<u32>& input, std::vector<u8>& output, |
| 99 | ASSERT_MSG(input.size() * sizeof(u32) < SHARED_FONT_MEM_SIZE, "Shared fonts exceeds 17mb!"); | 93 | std::size_t& offset) { |
| 94 | ASSERT_MSG(offset + (input.size() * sizeof(u32)) < SHARED_FONT_MEM_SIZE, | ||
| 95 | "Shared fonts exceeds 17mb!"); | ||
| 100 | 96 | ||
| 101 | const auto key = Common::swap32(EXPECTED_RESULT ^ EXPECTED_MAGIC); | 97 | const auto key = Common::swap32(EXPECTED_RESULT ^ EXPECTED_MAGIC); |
| 102 | std::vector<u32> transformed_font(input.size() + 2); | 98 | std::vector<u32> transformed_font(input.size() + 2); |
| @@ -104,7 +100,9 @@ void EncryptSharedFont(const std::vector<u8>& input, Kernel::PhysicalMemory& out | |||
| 104 | transformed_font[1] = Common::swap32(input.size() * sizeof(u32)) ^ key; | 100 | transformed_font[1] = Common::swap32(input.size() * sizeof(u32)) ^ key; |
| 105 | std::transform(input.begin(), input.end(), transformed_font.begin() + 2, | 101 | std::transform(input.begin(), input.end(), transformed_font.begin() + 2, |
| 106 | [key](u32 in) { return in ^ key; }); | 102 | [key](u32 in) { return in ^ key; }); |
| 107 | std::memcpy(output.data(), transformed_font.data(), transformed_font.size() * sizeof(u32)); | 103 | std::memcpy(output.data() + offset, transformed_font.data(), |
| 104 | transformed_font.size() * sizeof(u32)); | ||
| 105 | offset += transformed_font.size() * sizeof(u32); | ||
| 108 | } | 106 | } |
| 109 | 107 | ||
| 110 | // Helper function to make BuildSharedFontsRawRegions a bit nicer | 108 | // Helper function to make BuildSharedFontsRawRegions a bit nicer |
diff --git a/src/core/hle/service/ns/pl_u.h b/src/core/hle/service/ns/pl_u.h index a8aa358a2..27161bd7a 100644 --- a/src/core/hle/service/ns/pl_u.h +++ b/src/core/hle/service/ns/pl_u.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include "core/hle/kernel/physical_memory.h" | 8 | #include <vector> |
| 9 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 10 | 10 | ||
| 11 | namespace Service { | 11 | namespace Service { |
| @@ -16,6 +16,8 @@ class FileSystemController; | |||
| 16 | 16 | ||
| 17 | namespace NS { | 17 | namespace NS { |
| 18 | 18 | ||
| 19 | void EncryptSharedFont(const std::vector<u32>& input, std::vector<u8>& output, std::size_t& offset); | ||
| 20 | |||
| 19 | class PL_U final : public ServiceFramework<PL_U> { | 21 | class PL_U final : public ServiceFramework<PL_U> { |
| 20 | public: | 22 | public: |
| 21 | explicit PL_U(Core::System& system); | 23 | explicit PL_U(Core::System& system); |