mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-02-12 03:01:11 +00:00
Compare commits
5 commits
f6d4de1130
...
5672528843
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5672528843 | ||
![]() |
3a5f70dceb | ||
![]() |
e51e11a71c | ||
![]() |
57e15f3622 | ||
![]() |
18530d0bf6 |
15 changed files with 106 additions and 85 deletions
|
@ -16,7 +16,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <vapours.hpp>
|
#include <vapours.hpp>
|
||||||
#include <stratosphere/fssystem/fssystem_nca_file_system_driver.hpp>
|
#include <stratosphere/fssystem/fssystem_nca_file_system_driver.hpp>
|
||||||
#include <stratosphere/ldr/ldr_platform_id.hpp>
|
#include <stratosphere/ncm/ncm_content_meta_platform.hpp>
|
||||||
|
|
||||||
namespace ams::fssystem {
|
namespace ams::fssystem {
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@ namespace ams::fssystem {
|
||||||
|
|
||||||
void InvalidateHardwareAesKey();
|
void InvalidateHardwareAesKey();
|
||||||
|
|
||||||
bool IsValidSignatureKeyGeneration(ldr::PlatformId platform, size_t key_generation);
|
bool IsValidSignatureKeyGeneration(ncm::ContentMetaPlatform platform, size_t key_generation);
|
||||||
|
|
||||||
const u8 *GetAcidSignatureKeyModulus(ldr::PlatformId platform, bool prod, size_t key_generation, bool unk_unused);
|
const u8 *GetAcidSignatureKeyModulus(ncm::ContentMetaPlatform platform, bool prod, size_t key_generation, bool unk_unused);
|
||||||
size_t GetAcidSignatureKeyModulusSize(ldr::PlatformId platform, bool unk_unused);
|
size_t GetAcidSignatureKeyModulusSize(ncm::ContentMetaPlatform platform, bool unk_unused);
|
||||||
|
|
||||||
const u8 *GetAcidSignatureKeyPublicExponent();
|
const u8 *GetAcidSignatureKeyPublicExponent();
|
||||||
|
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Atmosphère-NX
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms and conditions of the GNU General Public License,
|
|
||||||
* version 2, as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
||||||
* more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <vapours.hpp>
|
|
||||||
|
|
||||||
namespace ams::ldr {
|
|
||||||
|
|
||||||
/* TODO: Is this really a FS type? What namespace does this actually live inside? */
|
|
||||||
enum PlatformId {
|
|
||||||
PlatformId_Nx = 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <stratosphere/ncm/ncm_ids.hpp>
|
#include <stratosphere/ncm/ncm_ids.hpp>
|
||||||
#include <stratosphere/ncm/ncm_program_location.hpp>
|
#include <stratosphere/ncm/ncm_program_location.hpp>
|
||||||
#include <stratosphere/sf/sf_buffer_tags.hpp>
|
#include <stratosphere/sf/sf_buffer_tags.hpp>
|
||||||
#include <stratosphere/ldr/ldr_platform_id.hpp>
|
#include <stratosphere/ncm/ncm_content_meta_platform.hpp>
|
||||||
|
|
||||||
namespace ams::ldr {
|
namespace ams::ldr {
|
||||||
|
|
||||||
|
|
|
@ -154,12 +154,14 @@ spl_secure_monitor_api.os.generic.o: CXXFLAGS += -I$(ATMOSPHERE_LIBRARIES_DIR)/l
|
||||||
fs_id_string_impl.os.generic.o: CXXFLAGS += -I$(ATMOSPHERE_LIBRARIES_DIR)/libexosphere/include
|
fs_id_string_impl.os.generic.o: CXXFLAGS += -I$(ATMOSPHERE_LIBRARIES_DIR)/libexosphere/include
|
||||||
|
|
||||||
ifeq ($(ATMOSPHERE_OS_NAME),windows)
|
ifeq ($(ATMOSPHERE_OS_NAME),windows)
|
||||||
# I do not remember why these had fno-lto, but it appears to
|
# Audit builds fail when these have lto disabled.
|
||||||
# work without no-lto (2023/03/09), so I am disabling these. I may regret this later.
|
# Noting 10/29/24:
|
||||||
#os_%.o: CXXFLAGS += -fno-lto
|
# In member function '__ct ':
|
||||||
#fssystem_%.o: CXXFLAGS += -fno-lto
|
# internal compiler error: in binds_to_current_def_p, at symtab.cc:2589
|
||||||
#fssrv_%.o: CXXFLAGS += -fno-lto
|
os_%.o: CXXFLAGS += -fno-lto
|
||||||
#fs_%.o: CXXFLAGS += -fno-lto
|
fssystem_%.o: CXXFLAGS += -fno-lto
|
||||||
|
fssrv_%.o: CXXFLAGS += -fno-lto
|
||||||
|
fs_%.o: CXXFLAGS += -fno-lto
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
|
|
@ -537,6 +537,8 @@ namespace ams::erpt::srv {
|
||||||
/* NOTE: Nintendo ignores the result of this call. */
|
/* NOTE: Nintendo ignores the result of this call. */
|
||||||
SubmitFsInfo();
|
SubmitFsInfo();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
AMS_UNUSED(flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -297,20 +297,20 @@ namespace ams::fssystem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsValidSignatureKeyGeneration(ldr::PlatformId platform, size_t key_generation) {
|
bool IsValidSignatureKeyGeneration(ncm::ContentMetaPlatform platform, size_t key_generation) {
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case ldr::PlatformId_Nx:
|
case ncm::ContentMetaPlatform::Nx:
|
||||||
return key_generation <= NxAcidSignatureKeyGenerationMax;
|
return key_generation <= NxAcidSignatureKeyGenerationMax;
|
||||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const u8 *GetAcidSignatureKeyModulus(ldr::PlatformId platform, bool prod, size_t key_generation, bool unk_unused) {
|
const u8 *GetAcidSignatureKeyModulus(ncm::ContentMetaPlatform platform, bool prod, size_t key_generation, bool unk_unused) {
|
||||||
AMS_ASSERT(IsValidSignatureKeyGeneration(platform, key_generation));
|
AMS_ASSERT(IsValidSignatureKeyGeneration(platform, key_generation));
|
||||||
AMS_UNUSED(unk_unused);
|
AMS_UNUSED(unk_unused);
|
||||||
|
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case ldr::PlatformId_Nx:
|
case ncm::ContentMetaPlatform::Nx:
|
||||||
{
|
{
|
||||||
const size_t used_keygen = (key_generation % (NxAcidSignatureKeyGenerationMax + 1));
|
const size_t used_keygen = (key_generation % (NxAcidSignatureKeyGenerationMax + 1));
|
||||||
return prod ? NxAcidSignatureKeyModulusProd[used_keygen] : NxAcidSignatureKeyModulusDev[used_keygen];
|
return prod ? NxAcidSignatureKeyModulusProd[used_keygen] : NxAcidSignatureKeyModulusDev[used_keygen];
|
||||||
|
@ -319,11 +319,11 @@ namespace ams::fssystem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GetAcidSignatureKeyModulusSize(ldr::PlatformId platform, bool unk_unused) {
|
size_t GetAcidSignatureKeyModulusSize(ncm::ContentMetaPlatform platform, bool unk_unused) {
|
||||||
AMS_UNUSED(unk_unused);
|
AMS_UNUSED(unk_unused);
|
||||||
|
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case ldr::PlatformId_Nx:
|
case ncm::ContentMetaPlatform::Nx:
|
||||||
return NxAcidSignatureKeyModulusSize;
|
return NxAcidSignatureKeyModulusSize;
|
||||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1346,7 +1346,7 @@ namespace ams::fssystem {
|
||||||
R_UNLESS(::GetLastError() == ERROR_ACCESS_DENIED, last_error_result);
|
R_UNLESS(::GetLastError() == ERROR_ACCESS_DENIED, last_error_result);
|
||||||
|
|
||||||
/* Check if we tried to open a directory. */
|
/* Check if we tried to open a directory. */
|
||||||
fs::DirectoryEntryType type;
|
fs::DirectoryEntryType type{};
|
||||||
R_TRY(GetEntryTypeImpl(std::addressof(type), native_path.get()));
|
R_TRY(GetEntryTypeImpl(std::addressof(type), native_path.get()));
|
||||||
|
|
||||||
/* If the type is anything other than directory, perform generic result conversion. */
|
/* If the type is anything other than directory, perform generic result conversion. */
|
||||||
|
@ -1459,7 +1459,7 @@ namespace ams::fssystem {
|
||||||
R_TRY(this->ResolveFullPath(std::addressof(native_new_path), new_path, MaxFilePathLength, 0, false));
|
R_TRY(this->ResolveFullPath(std::addressof(native_new_path), new_path, MaxFilePathLength, 0, false));
|
||||||
|
|
||||||
/* Check that the old path is a file. */
|
/* Check that the old path is a file. */
|
||||||
fs::DirectoryEntryType type;
|
fs::DirectoryEntryType type{};
|
||||||
R_TRY(GetEntryTypeImpl(std::addressof(type), native_old_path.get()));
|
R_TRY(GetEntryTypeImpl(std::addressof(type), native_old_path.get()));
|
||||||
R_UNLESS(type == fs::DirectoryEntryType_File, fs::ResultPathNotFound());
|
R_UNLESS(type == fs::DirectoryEntryType_File, fs::ResultPathNotFound());
|
||||||
|
|
||||||
|
@ -1509,7 +1509,7 @@ namespace ams::fssystem {
|
||||||
R_TRY(this->ResolveFullPath(std::addressof(native_new_path), new_path, MaxDirectoryPathLength, 0, false));
|
R_TRY(this->ResolveFullPath(std::addressof(native_new_path), new_path, MaxDirectoryPathLength, 0, false));
|
||||||
|
|
||||||
/* Check that the old path is a file. */
|
/* Check that the old path is a file. */
|
||||||
fs::DirectoryEntryType type;
|
fs::DirectoryEntryType type{};
|
||||||
R_TRY(GetEntryTypeImpl(std::addressof(type), native_old_path.get()));
|
R_TRY(GetEntryTypeImpl(std::addressof(type), native_old_path.get()));
|
||||||
R_UNLESS(type == fs::DirectoryEntryType_Directory, fs::ResultPathNotFound());
|
R_UNLESS(type == fs::DirectoryEntryType_Directory, fs::ResultPathNotFound());
|
||||||
|
|
||||||
|
@ -1577,7 +1577,7 @@ namespace ams::fssystem {
|
||||||
R_UNLESS(::GetLastError() == ERROR_ACCESS_DENIED, last_error_result);
|
R_UNLESS(::GetLastError() == ERROR_ACCESS_DENIED, last_error_result);
|
||||||
|
|
||||||
/* Check if we tried to open a directory. */
|
/* Check if we tried to open a directory. */
|
||||||
fs::DirectoryEntryType type;
|
fs::DirectoryEntryType type{};
|
||||||
R_TRY(GetEntryTypeImpl(std::addressof(type), native_path.get()));
|
R_TRY(GetEntryTypeImpl(std::addressof(type), native_path.get()));
|
||||||
|
|
||||||
/* If the type isn't file, return path not found. */
|
/* If the type isn't file, return path not found. */
|
||||||
|
@ -1623,7 +1623,7 @@ namespace ams::fssystem {
|
||||||
ON_RESULT_FAILURE { ::CloseHandle(dir_handle); };
|
ON_RESULT_FAILURE { ::CloseHandle(dir_handle); };
|
||||||
|
|
||||||
/* Check that we tried to open a directory. */
|
/* Check that we tried to open a directory. */
|
||||||
fs::DirectoryEntryType type;
|
fs::DirectoryEntryType type{};
|
||||||
R_TRY(GetEntryTypeImpl(std::addressof(type), native_path.get()));
|
R_TRY(GetEntryTypeImpl(std::addressof(type), native_path.get()));
|
||||||
|
|
||||||
/* If the type isn't directory, return path not found. */
|
/* If the type isn't directory, return path not found. */
|
||||||
|
|
|
@ -1232,6 +1232,7 @@ namespace ams::dmnt {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reply_cur != send_buffer) {
|
if (reply_cur != send_buffer) {
|
||||||
|
AMS_DMNT2_GDB_LOG_DEBUG("ProcessDebugEvents: %s\n", send_buffer);
|
||||||
bool do_break;
|
bool do_break;
|
||||||
this->SendPacket(std::addressof(do_break), send_buffer);
|
this->SendPacket(std::addressof(do_break), send_buffer);
|
||||||
if (do_break) {
|
if (do_break) {
|
||||||
|
@ -1322,6 +1323,8 @@ namespace ams::dmnt {
|
||||||
/* Clear our reply packet. */
|
/* Clear our reply packet. */
|
||||||
reply[0] = 0;
|
reply[0] = 0;
|
||||||
|
|
||||||
|
bool should_log_result = true;
|
||||||
|
|
||||||
/* Handle the received packet. */
|
/* Handle the received packet. */
|
||||||
switch (m_receive_packet[0]) {
|
switch (m_receive_packet[0]) {
|
||||||
case 'D':
|
case 'D':
|
||||||
|
@ -1358,9 +1361,11 @@ namespace ams::dmnt {
|
||||||
if (!this->g()) {
|
if (!this->g()) {
|
||||||
m_killed = true;
|
m_killed = true;
|
||||||
}
|
}
|
||||||
|
should_log_result = false;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
this->m();
|
this->m();
|
||||||
|
should_log_result = false;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
this->p();
|
this->p();
|
||||||
|
@ -1381,9 +1386,10 @@ namespace ams::dmnt {
|
||||||
this->QuestionMark();
|
this->QuestionMark();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
AMS_DMNT2_GDB_LOG_DEBUG("Not Implemented: %s\n", m_receive_packet);
|
AMS_DMNT2_GDB_LOG_ERROR("Not Implemented: %s\n", m_receive_packet);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
AMS_DMNT2_GDB_LOG_DEBUG("Reply: %s\n", should_log_result ? reply : "[...]");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GdbServerImpl::D() {
|
void GdbServerImpl::D() {
|
||||||
|
@ -1401,6 +1407,7 @@ namespace ams::dmnt {
|
||||||
/* Get thread context. */
|
/* Get thread context. */
|
||||||
svc::ThreadContext ctx;
|
svc::ThreadContext ctx;
|
||||||
if (R_FAILED(m_debug_process.GetThreadContext(std::addressof(ctx), thread_id, svc::ThreadContextFlag_All))) {
|
if (R_FAILED(m_debug_process.GetThreadContext(std::addressof(ctx), thread_id, svc::ThreadContextFlag_All))) {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to get thread context\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1412,6 +1419,7 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.SetThreadContext(std::addressof(ctx), thread_id, svc::ThreadContextFlag_All))) {
|
if (R_SUCCEEDED(m_debug_process.SetThreadContext(std::addressof(ctx), thread_id, svc::ThreadContextFlag_All))) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to set thread context\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1421,9 +1429,11 @@ namespace ams::dmnt {
|
||||||
if (ParsePrefix(m_receive_packet, "Hg") || ParsePrefix(m_receive_packet, "HG")) {
|
if (ParsePrefix(m_receive_packet, "Hg") || ParsePrefix(m_receive_packet, "HG")) {
|
||||||
this->Hg();
|
this->Hg();
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("'H'-command not implemented: %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Cannot use 'H'-command without DebugProcess\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1458,6 +1468,7 @@ namespace ams::dmnt {
|
||||||
if (success) {
|
if (success) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("'Hg'-command failed\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1468,6 +1479,7 @@ namespace ams::dmnt {
|
||||||
/* Validate format. */
|
/* Validate format. */
|
||||||
char *comma = std::strchr(m_receive_packet, ',');
|
char *comma = std::strchr(m_receive_packet, ',');
|
||||||
if (comma == nullptr) {
|
if (comma == nullptr) {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("'M' command formatted incorrectly (no ','): %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1475,6 +1487,7 @@ namespace ams::dmnt {
|
||||||
|
|
||||||
char *colon = std::strchr(comma + 1, ':');
|
char *colon = std::strchr(comma + 1, ':');
|
||||||
if (colon == nullptr) {
|
if (colon == nullptr) {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("'M' command formatted incorrectly (no ':'): %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1484,6 +1497,7 @@ namespace ams::dmnt {
|
||||||
const u64 address = DecodeHex(m_receive_packet);
|
const u64 address = DecodeHex(m_receive_packet);
|
||||||
const u64 length = DecodeHex(comma + 1);
|
const u64 length = DecodeHex(comma + 1);
|
||||||
if (length >= sizeof(m_buffer)) {
|
if (length >= sizeof(m_buffer)) {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Length exceeded buffer size: %ld >= %ld\n", length, sizeof(m_buffer));
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1495,6 +1509,7 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.WriteMemory(m_buffer, address, length))) {
|
if (R_SUCCEEDED(m_debug_process.WriteMemory(m_buffer, address, length))) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to write memory\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1505,6 +1520,7 @@ namespace ams::dmnt {
|
||||||
/* Validate format. */
|
/* Validate format. */
|
||||||
char *equal = std::strchr(m_receive_packet, '=');
|
char *equal = std::strchr(m_receive_packet, '=');
|
||||||
if (equal == nullptr) {
|
if (equal == nullptr) {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("'P' command formatted incorrectly (no '='): %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1530,9 +1546,11 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.SetThreadContext(std::addressof(ctx), thread_id, flags))) {
|
if (R_SUCCEEDED(m_debug_process.SetThreadContext(std::addressof(ctx), thread_id, flags))) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to set thread context");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to get thread context");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1541,7 +1559,7 @@ namespace ams::dmnt {
|
||||||
if (ParsePrefix(m_receive_packet, "QStartNoAckMode")) {
|
if (ParsePrefix(m_receive_packet, "QStartNoAckMode")) {
|
||||||
this->QStartNoAckMode();
|
this->QStartNoAckMode();
|
||||||
} else {
|
} else {
|
||||||
AMS_DMNT2_GDB_LOG_DEBUG("Not Implemented Q: %s\n", m_receive_packet);
|
AMS_DMNT2_GDB_LOG_ERROR("Not Implemented Q: %s\n", m_receive_packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1558,9 +1576,11 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.GetThreadContext(std::addressof(ctx), thread_id, svc::ThreadContextFlag_Control))) {
|
if (R_SUCCEEDED(m_debug_process.GetThreadContext(std::addressof(ctx), thread_id, svc::ThreadContextFlag_Control))) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
AppendReplyFormat(m_reply_cur, m_reply_end, "E01");
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to get thread context");
|
||||||
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("'T' command formatted incorrectly (no '.'): %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1571,6 +1591,7 @@ namespace ams::dmnt {
|
||||||
|
|
||||||
/* Decode the type. */
|
/* Decode the type. */
|
||||||
if (!('0' <= m_receive_packet[0] && m_receive_packet[0] <= '4') || m_receive_packet[1] != ',') {
|
if (!('0' <= m_receive_packet[0] && m_receive_packet[0] <= '4') || m_receive_packet[1] != ',') {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("'Z' command formatted incorrectly (not starting with pattern '[0-4],'): %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1581,6 +1602,7 @@ namespace ams::dmnt {
|
||||||
/* Decode the address/length. */
|
/* Decode the address/length. */
|
||||||
const char *comma = std::strchr(m_receive_packet, ',');
|
const char *comma = std::strchr(m_receive_packet, ',');
|
||||||
if (comma == nullptr) {
|
if (comma == nullptr) {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("'Z' command formatted incorrectly (no ','): %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1596,6 +1618,7 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.SetBreakPoint(address, length, false))) {
|
if (R_SUCCEEDED(m_debug_process.SetBreakPoint(address, length, false))) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to set software breakpoint\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1607,6 +1630,7 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.SetHardwareBreakPoint(address, length, false))) {
|
if (R_SUCCEEDED(m_debug_process.SetHardwareBreakPoint(address, length, false))) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to set hardware breakpoint\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1618,6 +1642,7 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.SetWatchPoint(address, length, false, true))) {
|
if (R_SUCCEEDED(m_debug_process.SetWatchPoint(address, length, false, true))) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to set watchpoint-W\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1629,6 +1654,7 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.SetWatchPoint(address, length, true, false))) {
|
if (R_SUCCEEDED(m_debug_process.SetWatchPoint(address, length, true, false))) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to set watchpoint-R\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1640,6 +1666,7 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.SetWatchPoint(address, length, true, true))) {
|
if (R_SUCCEEDED(m_debug_process.SetWatchPoint(address, length, true, true))) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to set watchpoint-A\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1668,6 +1695,7 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(result)) {
|
if (R_SUCCEEDED(result)) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to continue thread\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1697,6 +1725,7 @@ namespace ams::dmnt {
|
||||||
/* Validate format. */
|
/* Validate format. */
|
||||||
const char *comma = std::strchr(m_receive_packet, ',');
|
const char *comma = std::strchr(m_receive_packet, ',');
|
||||||
if (comma == nullptr) {
|
if (comma == nullptr) {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("'m' command formatted incorrectly (no ','): %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1705,6 +1734,7 @@ namespace ams::dmnt {
|
||||||
const u64 address = DecodeHex(m_receive_packet);
|
const u64 address = DecodeHex(m_receive_packet);
|
||||||
const u64 length = DecodeHex(comma + 1);
|
const u64 length = DecodeHex(comma + 1);
|
||||||
if (length >= sizeof(m_buffer)) {
|
if (length >= sizeof(m_buffer)) {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Length exceeded buffer size: %ld >= %ld\n", length, sizeof(m_buffer));
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1712,6 +1742,7 @@ namespace ams::dmnt {
|
||||||
/* Read the memory. */
|
/* Read the memory. */
|
||||||
/* TODO: Detect partial readability? */
|
/* TODO: Detect partial readability? */
|
||||||
if (R_FAILED(m_debug_process.ReadMemory(m_buffer, address, length))) {
|
if (R_FAILED(m_debug_process.ReadMemory(m_buffer, address, length))) {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to read memory\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1745,6 +1776,7 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.GetThreadContext(std::addressof(ctx), thread_id, flags))) {
|
if (R_SUCCEEDED(m_debug_process.GetThreadContext(std::addressof(ctx), thread_id, flags))) {
|
||||||
SetGdbRegisterPacket(m_reply_cur, m_reply_end, ctx, reg_num, m_debug_process.Is64Bit());
|
SetGdbRegisterPacket(m_reply_cur, m_reply_end, ctx, reg_num, m_debug_process.Is64Bit());
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to get thread context");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1755,7 +1787,7 @@ namespace ams::dmnt {
|
||||||
} else if (ParsePrefix(m_receive_packet, "vCont")) {
|
} else if (ParsePrefix(m_receive_packet, "vCont")) {
|
||||||
this->vCont();
|
this->vCont();
|
||||||
} else {
|
} else {
|
||||||
AMS_DMNT2_GDB_LOG_DEBUG("Not Implemented v: %s\n", m_receive_packet);
|
AMS_DMNT2_GDB_LOG_ERROR("Not Implemented v: %s\n", m_receive_packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1780,12 +1812,15 @@ namespace ams::dmnt {
|
||||||
/* Set the stop reply packet. */
|
/* Set the stop reply packet. */
|
||||||
this->AppendStopReplyPacket(m_debug_process.GetLastSignal());
|
this->AppendStopReplyPacket(m_debug_process.GetLastSignal());
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to attach to process\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Invalid process id: %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Cannot attach to process while already attached\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1937,7 +1972,7 @@ namespace ams::dmnt {
|
||||||
} else if (ParsePrefix(m_receive_packet, "qXfer:")) {
|
} else if (ParsePrefix(m_receive_packet, "qXfer:")) {
|
||||||
this->qXfer();
|
this->qXfer();
|
||||||
} else {
|
} else {
|
||||||
AMS_DMNT2_GDB_LOG_DEBUG("Not Implemented q: %s\n", m_receive_packet);
|
AMS_DMNT2_GDB_LOG_ERROR("Not Implemented q: %s\n", m_receive_packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1945,6 +1980,7 @@ namespace ams::dmnt {
|
||||||
if (this->HasDebugProcess()) {
|
if (this->HasDebugProcess()) {
|
||||||
AppendReplyFormat(m_reply_cur, m_reply_end, "1");
|
AppendReplyFormat(m_reply_cur, m_reply_end, "1");
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Not attached\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1954,6 +1990,7 @@ namespace ams::dmnt {
|
||||||
/* Send the thread id. */
|
/* Send the thread id. */
|
||||||
AppendReplyFormat(m_reply_cur, m_reply_end, "QCp%lx.%lx", m_process_id.value, m_debug_process.GetLastThreadId());
|
AppendReplyFormat(m_reply_cur, m_reply_end, "QCp%lx.%lx", m_process_id.value, m_debug_process.GetLastThreadId());
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Not attached\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2161,6 +2198,7 @@ namespace ams::dmnt {
|
||||||
} else {
|
} else {
|
||||||
/* All other qXfer require debug process. */
|
/* All other qXfer require debug process. */
|
||||||
if (!this->HasDebugProcess()) {
|
if (!this->HasDebugProcess()) {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Not attached\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2171,6 +2209,7 @@ namespace ams::dmnt {
|
||||||
} else if (ParsePrefix(m_receive_packet, "threads:read::")) {
|
} else if (ParsePrefix(m_receive_packet, "threads:read::")) {
|
||||||
if (!this->qXferThreadsRead()) {
|
if (!this->qXferThreadsRead()) {
|
||||||
m_killed = true;
|
m_killed = true;
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to read threads\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
} else if (ParsePrefix(m_receive_packet, "libraries:read::")) {
|
} else if (ParsePrefix(m_receive_packet, "libraries:read::")) {
|
||||||
|
@ -2178,7 +2217,7 @@ namespace ams::dmnt {
|
||||||
} else if (ParsePrefix(m_receive_packet, "exec-file:read:")) {
|
} else if (ParsePrefix(m_receive_packet, "exec-file:read:")) {
|
||||||
AppendReplyFormat(m_reply_cur, m_reply_end, "l%s", m_debug_process.GetProcessName());
|
AppendReplyFormat(m_reply_cur, m_reply_end, "l%s", m_debug_process.GetProcessName());
|
||||||
} else {
|
} else {
|
||||||
AMS_DMNT2_GDB_LOG_DEBUG("Not Implemented qxfer: %s\n", m_receive_packet);
|
AMS_DMNT2_GDB_LOG_ERROR("Not Implemented qxfer: %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2229,7 +2268,7 @@ namespace ams::dmnt {
|
||||||
m_reply_cur[length] = 0;
|
m_reply_cur[length] = 0;
|
||||||
m_reply_cur += std::strlen(m_reply_cur);
|
m_reply_cur += std::strlen(m_reply_cur);
|
||||||
} else {
|
} else {
|
||||||
AMS_DMNT2_GDB_LOG_DEBUG("Not Implemented qxfer:features:read: %s\n", m_receive_packet);
|
AMS_DMNT2_GDB_LOG_ERROR("Not Implemented qXfer:features:read: %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2330,7 +2369,7 @@ namespace ams::dmnt {
|
||||||
/* Copy out the process list. */
|
/* Copy out the process list. */
|
||||||
GetAnnexBufferContents(m_reply_cur, offset, length);
|
GetAnnexBufferContents(m_reply_cur, offset, length);
|
||||||
} else {
|
} else {
|
||||||
AMS_DMNT2_GDB_LOG_DEBUG("Not Implemented qxfer:osdata:read: %s\n", m_receive_packet);
|
AMS_DMNT2_GDB_LOG_ERROR("Not Implemented qXfer:osdata:read: %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2426,6 +2465,7 @@ namespace ams::dmnt {
|
||||||
|
|
||||||
/* Decode the type. */
|
/* Decode the type. */
|
||||||
if (!('0' <= m_receive_packet[0] && m_receive_packet[0] <= '4') || m_receive_packet[1] != ',') {
|
if (!('0' <= m_receive_packet[0] && m_receive_packet[0] <= '4') || m_receive_packet[1] != ',') {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("'Z' command formatted incorrectly (not starting with pattern '[0-4],'): %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2436,6 +2476,7 @@ namespace ams::dmnt {
|
||||||
/* Decode the address/length. */
|
/* Decode the address/length. */
|
||||||
const char *comma = std::strchr(m_receive_packet, ',');
|
const char *comma = std::strchr(m_receive_packet, ',');
|
||||||
if (comma == nullptr) {
|
if (comma == nullptr) {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("'Z' command formatted incorrectly (no ','): %s\n", m_receive_packet);
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2450,6 +2491,7 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.ClearBreakPoint(address, length))) {
|
if (R_SUCCEEDED(m_debug_process.ClearBreakPoint(address, length))) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to clear software breakpoint\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2459,6 +2501,7 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.ClearHardwareBreakPoint(address, length))) {
|
if (R_SUCCEEDED(m_debug_process.ClearHardwareBreakPoint(address, length))) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to clear hardware breakpoint\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2470,6 +2513,7 @@ namespace ams::dmnt {
|
||||||
if (R_SUCCEEDED(m_debug_process.ClearWatchPoint(address, length))) {
|
if (R_SUCCEEDED(m_debug_process.ClearWatchPoint(address, length))) {
|
||||||
AppendReplyOk(m_reply_cur, m_reply_end);
|
AppendReplyOk(m_reply_cur, m_reply_end);
|
||||||
} else {
|
} else {
|
||||||
|
AMS_DMNT2_GDB_LOG_ERROR("Failed to clear watchpoint\n");
|
||||||
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
AppendReplyError(m_reply_cur, m_reply_end, "E01");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,11 @@ namespace ams::ldr {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ScopedCodeMount functionality. */
|
/* ScopedCodeMount functionality. */
|
||||||
ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc, PlatformId platform) : m_lk(g_scoped_code_mount_lock), m_has_status(false), m_mounted_ams(false), m_mounted_sd_or_code(false), m_mounted_code(false) {
|
ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform) : m_lk(g_scoped_code_mount_lock), m_has_status(false), m_mounted_ams(false), m_mounted_sd_or_code(false), m_mounted_code(false) {
|
||||||
m_result = this->Initialize(loc, platform);
|
m_result = this->Initialize(loc, platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &o, PlatformId platform) : m_lk(g_scoped_code_mount_lock), m_override_status(o), m_has_status(true), m_mounted_ams(false), m_mounted_sd_or_code(false), m_mounted_code(false) {
|
ScopedCodeMount::ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &o, ncm::ContentMetaPlatform platform) : m_lk(g_scoped_code_mount_lock), m_override_status(o), m_has_status(true), m_mounted_ams(false), m_mounted_sd_or_code(false), m_mounted_code(false) {
|
||||||
m_result = this->Initialize(loc, platform);
|
m_result = this->Initialize(loc, platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ namespace ams::ldr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ScopedCodeMount::Initialize(const ncm::ProgramLocation &loc, PlatformId platform) {
|
Result ScopedCodeMount::Initialize(const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform) {
|
||||||
/* Capture override status, if necessary. */
|
/* Capture override status, if necessary. */
|
||||||
this->EnsureOverrideStatus(loc);
|
this->EnsureOverrideStatus(loc);
|
||||||
AMS_ABORT_UNLESS(m_has_status);
|
AMS_ABORT_UNLESS(m_has_status);
|
||||||
|
@ -83,7 +83,7 @@ namespace ams::ldr {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Redirection API. */
|
/* Redirection API. */
|
||||||
Result GetProgramPath(char *out_path, size_t out_size, const ncm::ProgramLocation &loc, PlatformId platform) {
|
Result GetProgramPath(char *out_path, size_t out_size, const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform) {
|
||||||
/* Check for storage id none. */
|
/* Check for storage id none. */
|
||||||
if (static_cast<ncm::StorageId>(loc.storage_id) == ncm::StorageId::None) {
|
if (static_cast<ncm::StorageId>(loc.storage_id) == ncm::StorageId::None) {
|
||||||
std::memset(out_path, 0, out_size);
|
std::memset(out_path, 0, out_size);
|
||||||
|
@ -166,9 +166,9 @@ namespace ams::ldr {
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::ContentAttributes GetPlatformContentAttributes(PlatformId platform) {
|
fs::ContentAttributes GetPlatformContentAttributes(ncm::ContentMetaPlatform platform) {
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case PlatformId_Nx:
|
case ncm::ContentMetaPlatform::Nx:
|
||||||
return fs::ContentAttributes_None;
|
return fs::ContentAttributes_None;
|
||||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,8 @@ namespace ams::ldr {
|
||||||
bool m_mounted_sd_or_code;
|
bool m_mounted_sd_or_code;
|
||||||
bool m_mounted_code;
|
bool m_mounted_code;
|
||||||
public:
|
public:
|
||||||
ScopedCodeMount(const ncm::ProgramLocation &loc, PlatformId platform);
|
ScopedCodeMount(const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform);
|
||||||
ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, PlatformId platform);
|
ScopedCodeMount(const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, ncm::ContentMetaPlatform platform);
|
||||||
~ScopedCodeMount();
|
~ScopedCodeMount();
|
||||||
|
|
||||||
Result GetResult() const {
|
Result GetResult() const {
|
||||||
|
@ -59,7 +59,7 @@ namespace ams::ldr {
|
||||||
return m_base_code_verification_data;
|
return m_base_code_verification_data;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Result Initialize(const ncm::ProgramLocation &loc, PlatformId platform);
|
Result Initialize(const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform);
|
||||||
void EnsureOverrideStatus(const ncm::ProgramLocation &loc);
|
void EnsureOverrideStatus(const ncm::ProgramLocation &loc);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -76,10 +76,10 @@ namespace ams::ldr {
|
||||||
#define ENCODE_CMPT_PATH(relative) "cmpt:" relative
|
#define ENCODE_CMPT_PATH(relative) "cmpt:" relative
|
||||||
|
|
||||||
/* Redirection API. */
|
/* Redirection API. */
|
||||||
Result GetProgramPath(char *out_path, size_t out_size, const ncm::ProgramLocation &loc, PlatformId platform);
|
Result GetProgramPath(char *out_path, size_t out_size, const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform);
|
||||||
Result RedirectProgramPath(const char *path, size_t size, const ncm::ProgramLocation &loc);
|
Result RedirectProgramPath(const char *path, size_t size, const ncm::ProgramLocation &loc);
|
||||||
Result RedirectHtmlDocumentPathForHbl(const ncm::ProgramLocation &loc);
|
Result RedirectHtmlDocumentPathForHbl(const ncm::ProgramLocation &loc);
|
||||||
|
|
||||||
fs::ContentAttributes GetPlatformContentAttributes(PlatformId platform);
|
fs::ContentAttributes GetPlatformContentAttributes(ncm::ContentMetaPlatform platform);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,11 @@ namespace ams::ldr {
|
||||||
|
|
||||||
constinit ArgumentStore g_argument_store;
|
constinit ArgumentStore g_argument_store;
|
||||||
|
|
||||||
bool IsValidPlatform(PlatformId platform) {
|
bool IsValidPlatform(ncm::ContentMetaPlatform platform) {
|
||||||
return platform == PlatformId_Nx;
|
return platform == ncm::ContentMetaPlatform::Nx;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result CreateProcessByPlatform(os::NativeHandle *out, PinId pin_id, u32 flags, os::NativeHandle resource_limit, PlatformId platform) {
|
Result CreateProcessByPlatform(os::NativeHandle *out, PinId pin_id, u32 flags, os::NativeHandle resource_limit, ncm::ContentMetaPlatform platform) {
|
||||||
/* Check that the platform is valid. */
|
/* Check that the platform is valid. */
|
||||||
R_UNLESS(IsValidPlatform(platform), ldr::ResultInvalidPlatformId());
|
R_UNLESS(IsValidPlatform(platform), ldr::ResultInvalidPlatformId());
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ namespace ams::ldr {
|
||||||
R_RETURN(ldr::CreateProcess(out, pin_id, loc, override_status, path, g_argument_store.Get(loc.program_id), flags, resource_limit, platform));
|
R_RETURN(ldr::CreateProcess(out, pin_id, loc, override_status, path, g_argument_store.Get(loc.program_id), flags, resource_limit, platform));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result GetProgramInfoByPlatform(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, PlatformId platform) {
|
Result GetProgramInfoByPlatform(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, ncm::ContentMetaPlatform platform) {
|
||||||
/* Check that the platform is valid. */
|
/* Check that the platform is valid. */
|
||||||
R_UNLESS(IsValidPlatform(platform), ldr::ResultInvalidPlatformId());
|
R_UNLESS(IsValidPlatform(platform), ldr::ResultInvalidPlatformId());
|
||||||
|
|
||||||
|
@ -88,11 +88,11 @@ namespace ams::ldr {
|
||||||
|
|
||||||
|
|
||||||
Result LoaderService::CreateProcess(os::NativeHandle *out, PinId pin_id, u32 flags, os::NativeHandle resource_limit) {
|
Result LoaderService::CreateProcess(os::NativeHandle *out, PinId pin_id, u32 flags, os::NativeHandle resource_limit) {
|
||||||
R_RETURN(CreateProcessByPlatform(out, pin_id, flags, resource_limit, PlatformId_Nx));
|
R_RETURN(CreateProcessByPlatform(out, pin_id, flags, resource_limit, ncm::ContentMetaPlatform::Nx));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result LoaderService::GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) {
|
Result LoaderService::GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc) {
|
||||||
R_RETURN(GetProgramInfoByPlatform(out, out_status, loc, PlatformId_Nx));
|
R_RETURN(GetProgramInfoByPlatform(out, out_status, loc, ncm::ContentMetaPlatform::Nx));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result LoaderService::PinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) {
|
Result LoaderService::PinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status) {
|
||||||
|
|
|
@ -103,15 +103,15 @@ namespace ams::ldr {
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
const u8 *GetAcidSignatureModulus(PlatformId platform, u8 key_generation, bool unk_unused) {
|
const u8 *GetAcidSignatureModulus(ncm::ContentMetaPlatform platform, u8 key_generation, bool unk_unused) {
|
||||||
return fssystem::GetAcidSignatureKeyModulus(platform, !IsDevelopmentForAcidSignatureCheck(), key_generation, unk_unused);
|
return fssystem::GetAcidSignatureKeyModulus(platform, !IsDevelopmentForAcidSignatureCheck(), key_generation, unk_unused);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GetAcidSignatureModulusSize(PlatformId platform, bool unk_unused) {
|
size_t GetAcidSignatureModulusSize(ncm::ContentMetaPlatform platform, bool unk_unused) {
|
||||||
return fssystem::GetAcidSignatureKeyModulusSize(platform, unk_unused);
|
return fssystem::GetAcidSignatureKeyModulusSize(platform, unk_unused);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ValidateAcidSignature(Meta *meta, PlatformId platform, bool unk_unused) {
|
Result ValidateAcidSignature(Meta *meta, ncm::ContentMetaPlatform platform, bool unk_unused) {
|
||||||
/* Loader did not check signatures prior to 10.0.0. */
|
/* Loader did not check signatures prior to 10.0.0. */
|
||||||
if (hos::GetVersion() < hos::Version_10_0_0) {
|
if (hos::GetVersion() < hos::Version_10_0_0) {
|
||||||
meta->check_verification_data = false;
|
meta->check_verification_data = false;
|
||||||
|
@ -190,7 +190,7 @@ namespace ams::ldr {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* API. */
|
/* API. */
|
||||||
Result LoadMeta(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, PlatformId platform, bool unk_unused) {
|
Result LoadMeta(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, ncm::ContentMetaPlatform platform, bool unk_unused) {
|
||||||
/* Set the cached program id back to zero. */
|
/* Set the cached program id back to zero. */
|
||||||
g_cached_program_id = {};
|
g_cached_program_id = {};
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ namespace ams::ldr {
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result LoadMetaFromCache(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, PlatformId platform) {
|
Result LoadMetaFromCache(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, ncm::ContentMetaPlatform platform) {
|
||||||
if (g_cached_program_id != loc.program_id || g_cached_override_status != status) {
|
if (g_cached_program_id != loc.program_id || g_cached_override_status != status) {
|
||||||
R_RETURN(LoadMeta(out_meta, loc, status, platform, false));
|
R_RETURN(LoadMeta(out_meta, loc, status, platform, false));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@ namespace ams::ldr {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Meta API. */
|
/* Meta API. */
|
||||||
Result LoadMeta(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, PlatformId platform, bool unk_unused);
|
Result LoadMeta(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, ncm::ContentMetaPlatform platform, bool unk_unused);
|
||||||
Result LoadMetaFromCache(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, PlatformId platform);
|
Result LoadMetaFromCache(Meta *out_meta, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status, ncm::ContentMetaPlatform platform);
|
||||||
void InvalidateMetaCache();
|
void InvalidateMetaCache();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -664,7 +664,7 @@ namespace ams::ldr {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process Creation API. */
|
/* Process Creation API. */
|
||||||
Result CreateProcess(os::NativeHandle *out, PinId pin_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, const char *path, const ArgumentStore::Entry *argument, u32 flags, os::NativeHandle resource_limit, PlatformId platform) {
|
Result CreateProcess(os::NativeHandle *out, PinId pin_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, const char *path, const ArgumentStore::Entry *argument, u32 flags, os::NativeHandle resource_limit, ncm::ContentMetaPlatform platform) {
|
||||||
/* Mount code. */
|
/* Mount code. */
|
||||||
AMS_UNUSED(path);
|
AMS_UNUSED(path);
|
||||||
ScopedCodeMount mount(loc, override_status, platform);
|
ScopedCodeMount mount(loc, override_status, platform);
|
||||||
|
@ -720,7 +720,7 @@ namespace ams::ldr {
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, const char *path, PlatformId platform) {
|
Result GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, const char *path, ncm::ContentMetaPlatform platform) {
|
||||||
Meta meta;
|
Meta meta;
|
||||||
|
|
||||||
/* Load Meta. */
|
/* Load Meta. */
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
namespace ams::ldr {
|
namespace ams::ldr {
|
||||||
|
|
||||||
/* Process Creation API. */
|
/* Process Creation API. */
|
||||||
Result CreateProcess(os::NativeHandle *out, PinId pin_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, const char *path, const ArgumentStore::Entry *argument, u32 flags, os::NativeHandle resource_limit, PlatformId platform);
|
Result CreateProcess(os::NativeHandle *out, PinId pin_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status, const char *path, const ArgumentStore::Entry *argument, u32 flags, os::NativeHandle resource_limit, ncm::ContentMetaPlatform platform);
|
||||||
Result GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, const char *path, PlatformId platform);
|
Result GetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc, const char *path, ncm::ContentMetaPlatform platform);
|
||||||
|
|
||||||
Result PinProgram(PinId *out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status);
|
Result PinProgram(PinId *out_id, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &override_status);
|
||||||
Result UnpinProgram(PinId id);
|
Result UnpinProgram(PinId id);
|
||||||
|
|
Loading…
Add table
Reference in a new issue