summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/file_sys/ips_layer.cpp69
-rw-r--r--src/core/file_sys/ips_layer.h11
-rw-r--r--src/core/hle/kernel/svc.cpp25
-rw-r--r--src/core/telemetry_session.cpp12
-rw-r--r--src/core/telemetry_session.h4
5 files changed, 89 insertions, 32 deletions
diff --git a/src/core/file_sys/ips_layer.cpp b/src/core/file_sys/ips_layer.cpp
index 0cadbc375..6c072d0a3 100644
--- a/src/core/file_sys/ips_layer.cpp
+++ b/src/core/file_sys/ips_layer.cpp
@@ -2,9 +2,15 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <algorithm>
+#include <cstring>
+#include <map>
#include <sstream>
-#include "common/assert.h"
+#include <string>
+#include <utility>
+
#include "common/hex_util.h"
+#include "common/logging/log.h"
#include "common/swap.h"
#include "core/file_sys/ips_layer.h"
#include "core/file_sys/vfs_vector.h"
@@ -17,22 +23,48 @@ enum class IPSFileType {
Error,
};
-constexpr std::array<std::pair<const char*, const char*>, 11> ESCAPE_CHARACTER_MAP{
- std::pair{"\\a", "\a"}, {"\\b", "\b"}, {"\\f", "\f"}, {"\\n", "\n"},
- {"\\r", "\r"}, {"\\t", "\t"}, {"\\v", "\v"}, {"\\\\", "\\"},
- {"\\\'", "\'"}, {"\\\"", "\""}, {"\\\?", "\?"},
-};
+constexpr std::array<std::pair<const char*, const char*>, 11> ESCAPE_CHARACTER_MAP{{
+ {"\\a", "\a"},
+ {"\\b", "\b"},
+ {"\\f", "\f"},
+ {"\\n", "\n"},
+ {"\\r", "\r"},
+ {"\\t", "\t"},
+ {"\\v", "\v"},
+ {"\\\\", "\\"},
+ {"\\\'", "\'"},
+ {"\\\"", "\""},
+ {"\\\?", "\?"},
+}};
static IPSFileType IdentifyMagic(const std::vector<u8>& magic) {
- if (magic.size() != 5)
+ if (magic.size() != 5) {
return IPSFileType::Error;
- if (magic == std::vector<u8>{'P', 'A', 'T', 'C', 'H'})
+ }
+
+ constexpr std::array<u8, 5> patch_magic{{'P', 'A', 'T', 'C', 'H'}};
+ if (std::equal(magic.begin(), magic.end(), patch_magic.begin())) {
return IPSFileType::IPS;
- if (magic == std::vector<u8>{'I', 'P', 'S', '3', '2'})
+ }
+
+ constexpr std::array<u8, 5> ips32_magic{{'I', 'P', 'S', '3', '2'}};
+ if (std::equal(magic.begin(), magic.end(), ips32_magic.begin())) {
return IPSFileType::IPS32;
+ }
+
return IPSFileType::Error;
}
+static bool IsEOF(IPSFileType type, const std::vector<u8>& data) {
+ constexpr std::array<u8, 3> eof{{'E', 'O', 'F'}};
+ if (type == IPSFileType::IPS && std::equal(data.begin(), data.end(), eof.begin())) {
+ return true;
+ }
+
+ constexpr std::array<u8, 4> eeof{{'E', 'E', 'O', 'F'}};
+ return type == IPSFileType::IPS32 && std::equal(data.begin(), data.end(), eeof.begin());
+}
+
VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) {
if (in == nullptr || ips == nullptr)
return nullptr;
@@ -47,8 +79,7 @@ VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) {
u64 offset = 5; // After header
while (ips->Read(temp.data(), temp.size(), offset) == temp.size()) {
offset += temp.size();
- if (type == IPSFileType::IPS32 && temp == std::vector<u8>{'E', 'E', 'O', 'F'} ||
- type == IPSFileType::IPS && temp == std::vector<u8>{'E', 'O', 'F'}) {
+ if (IsEOF(type, temp)) {
break;
}
@@ -88,11 +119,20 @@ VirtualFile PatchIPS(const VirtualFile& in, const VirtualFile& ips) {
}
}
- if (temp != std::vector<u8>{'E', 'E', 'O', 'F'} && temp != std::vector<u8>{'E', 'O', 'F'})
+ if (!IsEOF(type, temp)) {
return nullptr;
- return std::make_shared<VectorVfsFile>(in_data, in->GetName(), in->GetContainingDirectory());
+ }
+
+ return std::make_shared<VectorVfsFile>(std::move(in_data), in->GetName(),
+ in->GetContainingDirectory());
}
+struct IPSwitchCompiler::IPSwitchPatch {
+ std::string name;
+ bool enabled;
+ std::map<u32, std::vector<u8>> records;
+};
+
IPSwitchCompiler::IPSwitchCompiler(VirtualFile patch_text_) : patch_text(std::move(patch_text_)) {
Parse();
}
@@ -291,7 +331,8 @@ VirtualFile IPSwitchCompiler::Apply(const VirtualFile& in) const {
}
}
- return std::make_shared<VectorVfsFile>(in_data, in->GetName(), in->GetContainingDirectory());
+ return std::make_shared<VectorVfsFile>(std::move(in_data), in->GetName(),
+ in->GetContainingDirectory());
}
} // namespace FileSys
diff --git a/src/core/file_sys/ips_layer.h b/src/core/file_sys/ips_layer.h
index 57da00da8..450b2f71e 100644
--- a/src/core/file_sys/ips_layer.h
+++ b/src/core/file_sys/ips_layer.h
@@ -4,8 +4,11 @@
#pragma once
+#include <array>
#include <memory>
+#include <vector>
+#include "common/common_types.h"
#include "core/file_sys/vfs.h"
namespace FileSys {
@@ -22,17 +25,13 @@ public:
VirtualFile Apply(const VirtualFile& in) const;
private:
+ struct IPSwitchPatch;
+
void ParseFlag(const std::string& flag);
void Parse();
bool valid = false;
- struct IPSwitchPatch {
- std::string name;
- bool enabled;
- std::map<u32, std::vector<u8>> records;
- };
-
VirtualFile patch_text;
std::vector<IPSwitchPatch> patches;
std::array<u8, 0x20> nso_build_id{};
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 6c4af7e47..b488b508d 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -301,13 +301,28 @@ static ResultCode ArbitrateUnlock(VAddr mutex_addr) {
return Mutex::Release(mutex_addr);
}
+struct BreakReason {
+ union {
+ u64 raw;
+ BitField<31, 1, u64> dont_kill_application;
+ };
+};
+
/// Break program execution
static void Break(u64 reason, u64 info1, u64 info2) {
- LOG_CRITICAL(
- Debug_Emulated,
- "Emulated program broke execution! reason=0x{:016X}, info1=0x{:016X}, info2=0x{:016X}",
- reason, info1, info2);
- ASSERT(false);
+ BreakReason break_reason{reason};
+ if (break_reason.dont_kill_application) {
+ LOG_ERROR(
+ Debug_Emulated,
+ "Emulated program broke execution! reason=0x{:016X}, info1=0x{:016X}, info2=0x{:016X}",
+ reason, info1, info2);
+ } else {
+ LOG_CRITICAL(
+ Debug_Emulated,
+ "Emulated program broke execution! reason=0x{:016X}, info1=0x{:016X}, info2=0x{:016X}",
+ reason, info1, info2);
+ ASSERT(false);
+ }
}
/// Used to output a message on a debug hardware unit - does nothing on a retail unit
diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp
index f29fff1e7..7b04792b5 100644
--- a/src/core/telemetry_session.cpp
+++ b/src/core/telemetry_session.cpp
@@ -2,12 +2,16 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include <array>
+
+#include <mbedtls/ctr_drbg.h>
+#include <mbedtls/entropy.h>
+
#include "common/assert.h"
#include "common/common_types.h"
#include "common/file_util.h"
+#include "common/logging/log.h"
-#include <mbedtls/ctr_drbg.h>
-#include <mbedtls/entropy.h>
#include "core/core.h"
#include "core/file_sys/control_metadata.h"
#include "core/file_sys/patch_manager.h"
@@ -28,11 +32,11 @@ static u64 GenerateTelemetryId() {
mbedtls_entropy_context entropy;
mbedtls_entropy_init(&entropy);
mbedtls_ctr_drbg_context ctr_drbg;
- std::string personalization = "yuzu Telemetry ID";
+ constexpr std::array<char, 18> personalization{{"yuzu Telemetry ID"}};
mbedtls_ctr_drbg_init(&ctr_drbg);
ASSERT(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
- reinterpret_cast<const unsigned char*>(personalization.c_str()),
+ reinterpret_cast<const unsigned char*>(personalization.data()),
personalization.size()) == 0);
ASSERT(mbedtls_ctr_drbg_random(&ctr_drbg, reinterpret_cast<unsigned char*>(&telemetry_id),
sizeof(u64)) == 0);
diff --git a/src/core/telemetry_session.h b/src/core/telemetry_session.h
index cec271df0..2a4845797 100644
--- a/src/core/telemetry_session.h
+++ b/src/core/telemetry_session.h
@@ -5,6 +5,7 @@
#pragma once
#include <memory>
+#include <string>
#include "common/telemetry.h"
namespace Core {
@@ -30,8 +31,6 @@ public:
field_collection.AddField(type, name, std::move(value));
}
- static void FinalizeAsyncJob();
-
private:
Telemetry::FieldCollection field_collection; ///< Tracks all added fields for the session
std::unique_ptr<Telemetry::VisitorInterface> backend; ///< Backend interface that logs fields
@@ -53,7 +52,6 @@ u64 RegenerateTelemetryId();
* Verifies the username and token.
* @param username yuzu username to use for authentication.
* @param token yuzu token to use for authentication.
- * @param func A function that gets exectued when the verification is finished
* @returns Future with bool indicating whether the verification succeeded
*/
bool VerifyLogin(const std::string& username, const std::string& token);