1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-23 10:52:13 +00:00
Atmosphere/stratosphere/ams_mitm_old/source/amsmitm_modules.cpp

62 lines
2.1 KiB
C++
Raw Normal View History

2019-01-29 10:29:29 +00:00
/*
2019-04-08 03:00:49 +01:00
* Copyright (c) 2018-2019 Atmosphère-NX
2019-01-29 10:29:29 +00: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/>.
*/
2019-06-20 12:04:33 +01:00
2019-01-29 10:29:29 +00:00
#include <switch.h>
#include <stratosphere.hpp>
#include <cstring>
#include "debug.hpp"
#include "amsmitm_modules.hpp"
#include "fs_mitm/fsmitm_main.hpp"
#include "set_mitm/setmitm_main.hpp"
#include "bpc_mitm/bpcmitm_main.hpp"
#include "ns_mitm/nsmitm_main.hpp"
#include "hid_mitm/hidmitm_main.hpp"
2019-01-29 10:29:29 +00:00
static ams::os::Thread g_module_threads[MitmModuleId_Count];
2019-01-29 10:29:29 +00:00
static const struct {
ThreadFunc main;
u32 priority;
u32 stack_size;
} g_module_definitions[MitmModuleId_Count] = {
{ &FsMitmMain, FsMitmPriority, FsMitmStackSize }, /* FsMitm */
{ &SetMitmMain, SetMitmPriority, SetMitmStackSize }, /* SetMitm */
{ &BpcMitmMain, BpcMitmPriority, BpcMitmStackSize }, /* BpcMitm */
{ &NsMitmMain, NsMitmPriority, NsMitmStackSize }, /* NsMitm */
{ &HidMitmMain, HidMitmPriority, HidMitmStackSize }, /* HidMitm */
2019-01-29 10:29:29 +00:00
};
void LaunchAllMitmModules() {
/* Create thread for each module. */
for (u32 i = 0; i < static_cast<u32>(MitmModuleId_Count); i++) {
const auto cur_module = &g_module_definitions[i];
2019-06-20 12:04:33 +01:00
R_ASSERT(g_module_threads[i].Initialize(cur_module->main, nullptr, cur_module->stack_size, cur_module->priority));
2019-01-29 10:29:29 +00:00
}
2019-06-20 12:04:33 +01:00
2019-01-29 10:29:29 +00:00
/* Start thread for each module. */
for (u32 i = 0; i < static_cast<u32>(MitmModuleId_Count); i++) {
2019-06-20 12:04:33 +01:00
R_ASSERT(g_module_threads[i].Start());
2019-01-29 10:29:29 +00:00
}
}
void WaitAllMitmModules() {
/* Wait on thread for each module. */
for (u32 i = 0; i < static_cast<u32>(MitmModuleId_Count); i++) {
g_module_threads[i].Join();
}
}