results: Add unofficial atmosphere results header

This commit is contained in:
Michael Scire 2019-03-28 20:19:01 -07:00
parent 27164564a1
commit 8d15f82a9b
5 changed files with 41 additions and 7 deletions

View File

@ -22,9 +22,6 @@
#include "../results.hpp" #include "../results.hpp"
#include "mitm_query_service.hpp" #include "mitm_query_service.hpp"
/* TODO: Change this. */
#define RESULT_FORWARD_TO_SESSION 0xCAFEFC
class MitmSession final : public ServiceSession { class MitmSession final : public ServiceSession {
private: private:
/* This will be for the actual session. */ /* This will be for the actual session. */
@ -157,7 +154,7 @@ class MitmSession final : public ServiceSession {
} }
} }
if (!found_entry || rc == RESULT_FORWARD_TO_SESSION) { if (!found_entry || rc == ResultAtmosphereMitmShouldForwardToSession) {
memcpy(armGetTls(), this->backup_tls, sizeof(this->backup_tls)); memcpy(armGetTls(), this->backup_tls, sizeof(this->backup_tls));
rc = ForwardRequest(ctx); rc = ForwardRequest(ctx);
} }

View File

@ -16,6 +16,7 @@
#pragma once #pragma once
/* Official. */
#include "results/creport_results.hpp" #include "results/creport_results.hpp"
#include "results/debug_results.hpp" #include "results/debug_results.hpp"
#include "results/dmnt_results.hpp" #include "results/dmnt_results.hpp"
@ -28,4 +29,7 @@
#include "results/sf_results.hpp" #include "results/sf_results.hpp"
#include "results/sm_results.hpp" #include "results/sm_results.hpp"
/* Unofficial. */
#include "results/ams_results.hpp"
static constexpr Result ResultSuccess = 0; static constexpr Result ResultSuccess = 0;

View File

@ -0,0 +1,31 @@
/*
* Copyright (c) 2018 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 <switch.h>
/* Please note: These results are all custom, and not official. */
static constexpr u32 Module_Atmosphere = 444;
/* Result 1-1000 reserved for Atmosphere. */
static constexpr Result ResultAtmosphereExosphereNotPresent = MAKERESULT(Module_Atmosphere, 1);
static constexpr Result ResultAtmosphereVersionMismatch = MAKERESULT(Module_Atmosphere, 2);
/* Results 1000-2000 reserved for Atmosphere Mitm. */
static constexpr Result ResultAtmosphereMitmShouldForwardToSession = MAKERESULT(Module_Atmosphere, 1000);
static constexpr Result ResultAtmosphereMitmProcessNotAssociated = MAKERESULT(Module_Atmosphere, 1100);

View File

@ -17,11 +17,13 @@
#pragma once #pragma once
#include <switch.h> #include <switch.h>
#include "results.hpp"
static inline void GetAtmosphereApiVersion(u32 *major, u32 *minor, u32 *micro, u32 *target_fw, u32 *mkey_rev) { static inline void GetAtmosphereApiVersion(u32 *major, u32 *minor, u32 *micro, u32 *target_fw, u32 *mkey_rev) {
/* Check for exosphere API compatibility. */ /* Check for exosphere API compatibility. */
u64 exosphere_cfg; u64 exosphere_cfg;
if (R_FAILED(SmcGetConfig((SplConfigItem)65000, &exosphere_cfg))) { if (R_FAILED(SmcGetConfig((SplConfigItem)65000, &exosphere_cfg))) {
fatalSimple(0xCAFE << 4 | 0xE); fatalSimple(ResultAtmosphereExosphereNotPresent);
} }
if (mkey_rev) { if (mkey_rev) {
@ -54,7 +56,7 @@ static inline void CheckAtmosphereVersion(u32 expected_major, u32 expected_minor
GetAtmosphereApiVersion(&major, &minor, &micro, nullptr, nullptr); GetAtmosphereApiVersion(&major, &minor, &micro, nullptr, nullptr);
if (MakeAtmosphereVersion(major, minor, micro) < MakeAtmosphereVersion(expected_major, expected_minor, expected_micro)) { if (MakeAtmosphereVersion(major, minor, micro) < MakeAtmosphereVersion(expected_major, expected_minor, expected_micro)) {
fatalSimple(0xCAFE << 4 | 0xF); fatalSimple(ResultAtmosphereVersionMismatch);
} }
} }

View File

@ -23,7 +23,7 @@ static std::vector<u64> g_known_tids;
static HosMutex g_pid_tid_mutex; static HosMutex g_pid_tid_mutex;
Result MitmQueryUtils::GetAssociatedTidForPid(u64 pid, u64 *tid) { Result MitmQueryUtils::GetAssociatedTidForPid(u64 pid, u64 *tid) {
Result rc = 0xCAFE; Result rc = ResultAtmosphereMitmProcessNotAssociated;
std::scoped_lock lk{g_pid_tid_mutex}; std::scoped_lock lk{g_pid_tid_mutex};
for (unsigned int i = 0; i < g_known_pids.size(); i++) { for (unsigned int i = 0; i < g_known_pids.size(); i++) {
if (g_known_pids[i] == pid) { if (g_known_pids[i] == pid) {