2018-09-07 16:00:13 +01:00
|
|
|
/*
|
2019-04-08 03:00:49 +01:00
|
|
|
* Copyright (c) 2018-2019 Atmosphère-NX
|
2018-09-07 16:00:13 +01:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2018-04-19 06:00:10 +01:00
|
|
|
#pragma once
|
|
|
|
#include <switch.h>
|
2018-06-19 19:07:31 +01:00
|
|
|
#include <array>
|
2018-04-19 06:00:10 +01:00
|
|
|
|
2018-04-27 03:27:52 +01:00
|
|
|
#include "ldr_map.hpp"
|
|
|
|
|
2018-04-19 06:00:10 +01:00
|
|
|
class Registration {
|
|
|
|
public:
|
2019-04-21 02:15:39 +01:00
|
|
|
static constexpr size_t MaxProcesses = 0x40;
|
|
|
|
static constexpr size_t MaxModuleInfos = 0x20;
|
|
|
|
public:
|
|
|
|
struct ModuleInfoHolder {
|
2018-04-19 23:14:48 +01:00
|
|
|
bool in_use;
|
2019-04-21 02:15:39 +01:00
|
|
|
LoaderModuleInfo info;
|
2018-04-19 23:14:48 +01:00
|
|
|
};
|
2019-04-21 17:08:08 +01:00
|
|
|
|
2018-04-19 06:00:10 +01:00
|
|
|
struct TidSid {
|
|
|
|
u64 title_id;
|
|
|
|
FsStorageId storage_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Process {
|
|
|
|
bool in_use;
|
2018-04-26 21:53:33 +01:00
|
|
|
bool is_64_bit_addspace;
|
2018-04-19 06:00:10 +01:00
|
|
|
u64 index;
|
|
|
|
u64 process_id;
|
2018-05-01 23:49:20 +01:00
|
|
|
u64 title_id;
|
2018-04-19 06:00:10 +01:00
|
|
|
Registration::TidSid tid_sid;
|
2019-04-21 02:15:39 +01:00
|
|
|
std::array<Registration::ModuleInfoHolder, MaxModuleInfos> module_infos;
|
2018-04-19 06:00:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct List {
|
2019-04-21 02:15:39 +01:00
|
|
|
std::array<Registration::Process, MaxProcesses> processes;
|
2018-04-19 06:00:10 +01:00
|
|
|
u64 num_processes;
|
|
|
|
};
|
|
|
|
|
2018-04-27 00:03:10 +01:00
|
|
|
static Registration::Process *GetFreeProcess();
|
|
|
|
static Registration::Process *GetProcess(u64 index);
|
|
|
|
static Registration::Process *GetProcessByProcessId(u64 pid);
|
|
|
|
static Result GetRegisteredTidSid(u64 index, Registration::TidSid *out);
|
|
|
|
static bool RegisterTidSid(const TidSid *tid_sid, u64 *out_index);
|
|
|
|
static bool UnregisterIndex(u64 index);
|
2018-05-01 23:49:20 +01:00
|
|
|
static void SetProcessIdTidAndIs64BitAddressSpace(u64 index, u64 process_id, u64 tid, bool is_64_bit_addspace);
|
2019-04-21 02:15:39 +01:00
|
|
|
static void AddModuleInfo(u64 index, u64 base_address, u64 size, const unsigned char *build_id);
|
|
|
|
static Result GetProcessModuleInfo(LoaderModuleInfo *out, u32 max_out, u64 process_id, u32 *num_written);
|
2018-06-15 00:50:01 +01:00
|
|
|
|
|
|
|
/* Atmosphere MitM Extension. */
|
|
|
|
static void AssociatePidTidForMitM(u64 index);
|
2018-04-19 06:00:10 +01:00
|
|
|
};
|