mirror of
https://github.com/Atmosphere-NX/Atmosphere-libs.git
synced 2025-06-28 22:12:40 +02:00
strat: automatic program id detection
This commit is contained in:
parent
57f439afe7
commit
28756234d9
@ -36,7 +36,7 @@ namespace ams::os {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IoRegion(size_t size, Handle handle, bool managed) {
|
IoRegion(size_t size, Handle handle, bool managed) {
|
||||||
this->Attach(size, handle, managed);
|
this->AttachHandle(size, handle, managed);
|
||||||
}
|
}
|
||||||
|
|
||||||
~IoRegion() {
|
~IoRegion() {
|
||||||
|
@ -16,13 +16,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stratosphere/os/os_managed_handle.hpp>
|
#include <stratosphere/os/os_managed_handle.hpp>
|
||||||
|
#include <stratosphere/ncm/ncm_program_id.hpp>
|
||||||
|
|
||||||
namespace ams::os {
|
namespace ams::os {
|
||||||
|
|
||||||
::Handle GetCurrentProcessHandle();
|
::Handle GetCurrentProcessHandle();
|
||||||
|
|
||||||
NX_INLINE ProcessId GetCurrentProcessId() {
|
ALWAYS_INLINE ProcessId GetCurrentProcessId() {
|
||||||
return GetProcessId(GetCurrentProcessHandle());
|
return GetProcessId(GetCurrentProcessHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: Another header? */
|
||||||
|
ncm::ProgramId GetCurrentProgramId();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,6 @@ namespace ams {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern ncm::ProgramId CurrentProgramId;
|
|
||||||
|
|
||||||
void InitializeForBoot() {
|
void InitializeForBoot() {
|
||||||
R_ABORT_UNLESS(amsBpcInitialize());
|
R_ABORT_UNLESS(amsBpcInitialize());
|
||||||
}
|
}
|
||||||
@ -56,7 +54,7 @@ namespace ams {
|
|||||||
{
|
{
|
||||||
ams_ctx.magic = FatalErrorContext::Magic;
|
ams_ctx.magic = FatalErrorContext::Magic;
|
||||||
ams_ctx.error_desc = ctx->error_desc;
|
ams_ctx.error_desc = ctx->error_desc;
|
||||||
ams_ctx.program_id = static_cast<u64>(CurrentProgramId);
|
ams_ctx.program_id = os::GetCurrentProgramId().value;
|
||||||
for (size_t i = 0; i < FatalErrorContext::NumGprs; i++) {
|
for (size_t i = 0; i < FatalErrorContext::NumGprs; i++) {
|
||||||
ams_ctx.gprs[i] = ctx->cpu_gprs[i].x;
|
ams_ctx.gprs[i] = ctx->cpu_gprs[i].x;
|
||||||
}
|
}
|
||||||
|
@ -15,12 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
#include <stratosphere.hpp>
|
#include <stratosphere.hpp>
|
||||||
|
|
||||||
namespace ams {
|
|
||||||
|
|
||||||
extern ncm::ProgramId CurrentProgramId;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ams::diag {
|
namespace ams::diag {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -69,7 +63,7 @@ namespace ams::diag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NORETURN WEAK_SYMBOL void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) {
|
NORETURN WEAK_SYMBOL void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) {
|
||||||
DebugLog("%016lx: Assertion Failure\n", static_cast<u64>(ams::CurrentProgramId));
|
DebugLog("%016lx: Assertion Failure\n", os::GetCurrentProgramId().value);
|
||||||
DebugLog(" Location: %s:%d\n", file, line);
|
DebugLog(" Location: %s:%d\n", file, line);
|
||||||
DebugLog(" Function: %s\n", func);
|
DebugLog(" Function: %s\n", func);
|
||||||
DebugLog(" Expression: %s\n", expr);
|
DebugLog(" Expression: %s\n", expr);
|
||||||
@ -89,7 +83,7 @@ namespace ams::diag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NORETURN WEAK_SYMBOL void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value) {
|
NORETURN WEAK_SYMBOL void AssertionFailureImpl(const char *file, int line, const char *func, const char *expr, u64 value) {
|
||||||
DebugLog("%016lx: Assertion Failure\n", static_cast<u64>(ams::CurrentProgramId));
|
DebugLog("%016lx: Assertion Failure\n", os::GetCurrentProgramId().value);
|
||||||
DebugLog(" Location: %s:%d\n", file, line);
|
DebugLog(" Location: %s:%d\n", file, line);
|
||||||
DebugLog(" Function: %s\n", func);
|
DebugLog(" Function: %s\n", func);
|
||||||
DebugLog(" Expression: %s\n", expr);
|
DebugLog(" Expression: %s\n", expr);
|
||||||
@ -101,7 +95,7 @@ namespace ams::diag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NORETURN WEAK_SYMBOL void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) {
|
NORETURN WEAK_SYMBOL void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value, const char *format, ...) {
|
||||||
DebugLog("%016lx: Abort Called\n", static_cast<u64>(ams::CurrentProgramId));
|
DebugLog("%016lx: Abort Called\n", os::GetCurrentProgramId().value);
|
||||||
DebugLog(" Location: %s:%d\n", file, line);
|
DebugLog(" Location: %s:%d\n", file, line);
|
||||||
DebugLog(" Function: %s\n", func);
|
DebugLog(" Function: %s\n", func);
|
||||||
DebugLog(" Expression: %s\n", expr);
|
DebugLog(" Expression: %s\n", expr);
|
||||||
@ -121,7 +115,7 @@ namespace ams::diag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NORETURN WEAK_SYMBOL void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value) {
|
NORETURN WEAK_SYMBOL void AbortImpl(const char *file, int line, const char *func, const char *expr, u64 value) {
|
||||||
DebugLog("%016lx: Abort Called\n", static_cast<u64>(ams::CurrentProgramId));
|
DebugLog("%016lx: Abort Called\n", os::GetCurrentProgramId().value);
|
||||||
DebugLog(" Location: %s:%d\n", file, line);
|
DebugLog(" Location: %s:%d\n", file, line);
|
||||||
DebugLog(" Function: %s\n", func);
|
DebugLog(" Function: %s\n", func);
|
||||||
DebugLog(" Expression: %s\n", expr);
|
DebugLog(" Expression: %s\n", expr);
|
||||||
|
23
libstratosphere/source/os/impl/os_program_id_impl.hpp
Normal file
23
libstratosphere/source/os/impl/os_program_id_impl.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2020 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 <stratosphere.hpp>
|
||||||
|
|
||||||
|
namespace ams::os::impl {
|
||||||
|
|
||||||
|
ncm::ProgramId GetCurrentProgramId();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2020 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/>.
|
||||||
|
*/
|
||||||
|
#include <stratosphere.hpp>
|
||||||
|
#include "os_program_id_impl.hpp"
|
||||||
|
|
||||||
|
namespace ams::os::impl {
|
||||||
|
|
||||||
|
ncm::ProgramId GetCurrentProgramId() {
|
||||||
|
u64 value;
|
||||||
|
R_ABORT_UNLESS(svc::GetInfo(std::addressof(value), svc::InfoType_ProgramId, svc::PseudoHandle::CurrentProcess, 0));
|
||||||
|
return {value};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
26
libstratosphere/source/os/os_program_id.cpp
Normal file
26
libstratosphere/source/os/os_program_id.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-2020 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/>.
|
||||||
|
*/
|
||||||
|
#include <stratosphere.hpp>
|
||||||
|
#include "impl/os_program_id_impl.hpp"
|
||||||
|
|
||||||
|
namespace ams::os {
|
||||||
|
|
||||||
|
ncm::ProgramId GetCurrentProgramId() {
|
||||||
|
return ::ams::os::impl::GetCurrentProgramId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user