summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/ns/pl_u.cpp26
-rw-r--r--src/core/hle/service/ns/pl_u.h2
2 files changed, 14 insertions, 14 deletions
diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp
index 2a522136d..6d6fdb4ed 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"
@@ -96,13 +89,18 @@ static void DecryptSharedFont(const std::vector<u32>& input, Kernel::PhysicalMem
96 89
97static void EncryptSharedFont(const std::vector<u8>& input, Kernel::PhysicalMemory& output, 90static void EncryptSharedFont(const std::vector<u8>& input, Kernel::PhysicalMemory& output,
98 std::size_t& offset) { 91 std::size_t& offset) {
99 ASSERT_MSG(offset + input.size() + 8 < SHARED_FONT_MEM_SIZE, "Shared fonts exceeds 17mb!"); 92 ASSERT_MSG(offset + (input.size() * sizeof(u32)) < SHARED_FONT_MEM_SIZE,
100 const u32 KEY = EXPECTED_MAGIC ^ EXPECTED_RESULT; 93 "Shared fonts exceeds 17mb!");
101 std::memcpy(output.data() + offset, &EXPECTED_RESULT, sizeof(u32)); // Magic header 94
102 const u32 ENC_SIZE = static_cast<u32>(input.size()) ^ KEY; 95 const auto key = Common::swap32(EXPECTED_RESULT ^ EXPECTED_MAGIC);
103 std::memcpy(output.data() + offset + sizeof(u32), &ENC_SIZE, sizeof(u32)); 96 std::vector<u32> transformed_font(input.size() + 2);
104 std::memcpy(output.data() + offset + (sizeof(u32) * 2), input.data(), input.size()); 97 transformed_font[0] = Common::swap32(EXPECTED_MAGIC);
105 offset += input.size() + (sizeof(u32) * 2); 98 transformed_font[1] = Common::swap32(input.size() * sizeof(u32)) ^ key;
99 std::transform(input.begin(), input.end(), transformed_font.begin() + 2,
100 [key](u32 in) { return in ^ key; });
101 std::memcpy(output.data() + offset, transformed_font.data(),
102 transformed_font.size() * sizeof(u32));
103 offset += transformed_font.size() * sizeof(u32);
106} 104}
107 105
108// Helper function to make BuildSharedFontsRawRegions a bit nicer 106// 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 253f26a2a..d62459667 100644
--- a/src/core/hle/service/ns/pl_u.h
+++ b/src/core/hle/service/ns/pl_u.h
@@ -9,6 +9,8 @@
9 9
10namespace Service::NS { 10namespace Service::NS {
11 11
12void EncryptSharedFont(const std::vector<u32>& input, std::vector<u8>& output, std::size_t& offset);
13
12class PL_U final : public ServiceFramework<PL_U> { 14class PL_U final : public ServiceFramework<PL_U> {
13public: 15public:
14 PL_U(); 16 PL_U();