1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-27 12:46:03 +00:00

Merge branch 'master' into emunand_dev

This commit is contained in:
hexkyz 2019-06-03 20:14:22 +01:00
commit 4c328b6c50
10 changed files with 407 additions and 169 deletions

View file

@ -19,6 +19,16 @@ Atmosphère consists of multiple components, each of which replaces/modifies a d
* Stratosphère: Custom Sysmodule(s), both Rosalina style to extend the kernel/provide new features, and of the loader reimplementation style to hook important system actions
* Troposphère: Application-level Horizon OS patches, used to implement desirable CFW features
Licensing
=====
This software is licensed under the terms of the GPLv2, with exemptions for specific projects noted below.
You can find a copy of the license in the [LICENSE file](LICENSE).
Exemptions:
* The [yuzu emulator project](https://github.com/yuzu-emu/yuzu) is exempt from GPLv2 licensing and may (at its option) instead license any source code authored for the Atmosphère project as GPLv2 or later.
Credits
=====

View file

@ -17,9 +17,15 @@
#pragma once
#include <switch.h>
struct StackFrame {
u64 fp;
u64 lr;
union StackFrame {
struct {
u64 fp;
u64 lr;
} frame_64;
struct {
u32 fp;
u32 lr;
} frame_32;
};
struct AttachProcessInfo {

View file

@ -75,9 +75,11 @@ bool ThreadInfo::ReadFromProcess(std::map<u64, u64> &tls_map, Handle debug_handl
return false;
}
/* Don't try to parse stack frames if 32-bit. */
/* In AArch32 mode the LR, FP, and SP registers aren't set correctly in the ThreadContext by svcGetDebugThreadParam... */
if (!is_64_bit) {
return true;
this->context.fp = this->context.cpu_gprs[11].x;
this->context.sp = this->context.cpu_gprs[13].x;
this->context.lr = this->context.cpu_gprs[14].x;
}
/* Parse information from TLS if present. */
@ -104,21 +106,41 @@ bool ThreadInfo::ReadFromProcess(std::map<u64, u64> &tls_map, Handle debug_handl
TryGetStackInfo(debug_handle);
u64 cur_fp = this->context.fp;
for (unsigned int i = 0; i < sizeof(this->stack_trace)/sizeof(u64); i++) {
/* Validate the current frame. */
if (cur_fp == 0 || (cur_fp & 0xF)) {
break;
}
/* Read a new frame. */
StackFrame cur_frame;
if (R_FAILED(svcReadDebugProcessMemory(&cur_frame, debug_handle, cur_fp, sizeof(StackFrame)))) {
break;
}
if (is_64_bit) {
for (unsigned int i = 0; i < sizeof(this->stack_trace)/sizeof(u64); i++) {
/* Validate the current frame. */
if (cur_fp == 0 || (cur_fp & 0xF)) {
break;
}
/* Advance to the next frame. */
this->stack_trace[this->stack_trace_size++] = cur_frame.lr;
cur_fp = cur_frame.fp;
/* Read a new frame. */
StackFrame cur_frame;
if (R_FAILED(svcReadDebugProcessMemory(&cur_frame, debug_handle, cur_fp, sizeof(cur_frame.frame_64)))) {
break;
}
/* Advance to the next frame. */
this->stack_trace[this->stack_trace_size++] = cur_frame.frame_64.lr;
cur_fp = cur_frame.frame_64.fp;
}
} else {
for (unsigned int i = 0; i < sizeof(this->stack_trace)/sizeof(u64); i++) {
/* Validate the current frame. */
if (cur_fp == 0 || (cur_fp & 0x7)) {
break;
}
/* Read a new frame. */
StackFrame cur_frame;
if (R_FAILED(svcReadDebugProcessMemory(&cur_frame, debug_handle, cur_fp, sizeof(cur_frame.frame_32)))) {
break;
}
/* Advance to the next frame. */
this->stack_trace[this->stack_trace_size++] = cur_frame.frame_32.lr;
cur_fp = cur_frame.frame_32.fp;
}
}
return true;

View file

@ -13,13 +13,28 @@
* 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 <sys/stat.h>
#include <switch.h>
#include "dmnt_cheat_types.hpp"
#include "dmnt_cheat_vm.hpp"
#include "dmnt_cheat_manager.hpp"
#include "dmnt_hid.hpp"
void DmntCheatVm::DebugLog(u32 log_id, u64 value) {
/* Just unconditionally try to create the log folder. */
mkdir("/atmosphere/cheat_vm_logs", 0777);
FILE *f_log = NULL;
{
char log_path[FS_MAX_PATH];
snprintf(log_path, sizeof(log_path), "/atmosphere/cheat_vm_logs/%x.log", log_id);
f_log = fopen(log_path, "ab");
}
if (f_log != NULL) {
ON_SCOPE_EXIT { fclose(f_log); };
fprintf(f_log, "%016lx\n", value);
}
}
void DmntCheatVm::OpenDebugLogFile() {
#ifdef DMNT_CHEAT_VM_DEBUG_LOG
@ -152,55 +167,86 @@ void DmntCheatVm::LogOpcode(const CheatVmOpcode *opcode) {
break;
}
break;
case CheatVmOpcodeType_BeginRegisterConditionalBlock:
case CheatVmOpcodeType_BeginRegisterConditionalBlock:
this->LogToDebugFile("Opcode: Begin Register Conditional\n");
this->LogToDebugFile("Bit Width: %x\n", opcode->begin_reg_cond.bit_width);
this->LogToDebugFile("Cond Type: %x\n", opcode->begin_reg_cond.cond_type);
this->LogToDebugFile("V Reg Idx: %x\n", opcode->begin_reg_cond.val_reg_index);
switch (opcode->begin_reg_cond.comp_type) {
case CompareRegisterValueType_StaticValue:
this->LogToDebugFile("Comp Type: Static Value\n");
this->LogToDebugFile("Value: %lx\n", opcode->begin_reg_cond.value.bit64);
break;
case CompareRegisterValueType_OtherRegister:
this->LogToDebugFile("Comp Type: Other Register\n");
this->LogToDebugFile("X Reg Idx: %x\n", opcode->begin_reg_cond.other_reg_index);
break;
case CompareRegisterValueType_MemoryRelAddr:
this->LogToDebugFile("Comp Type: Memory Relative Address\n");
this->LogToDebugFile("Mem Type: %x\n", opcode->begin_reg_cond.mem_type);
this->LogToDebugFile("Rel Addr: %lx\n", opcode->begin_reg_cond.rel_address);
break;
case CompareRegisterValueType_MemoryOfsReg:
this->LogToDebugFile("Comp Type: Memory Offset Register\n");
this->LogToDebugFile("Mem Type: %x\n", opcode->begin_reg_cond.mem_type);
this->LogToDebugFile("O Reg Idx: %x\n", opcode->begin_reg_cond.ofs_reg_index);
break;
case CompareRegisterValueType_RegisterRelAddr:
this->LogToDebugFile("Comp Type: Register Relative Address\n");
this->LogToDebugFile("A Reg Idx: %x\n", opcode->begin_reg_cond.addr_reg_index);
this->LogToDebugFile("Rel Addr: %lx\n", opcode->begin_reg_cond.rel_address);
break;
case CompareRegisterValueType_RegisterOfsReg:
this->LogToDebugFile("Comp Type: Register Offset Register\n");
this->LogToDebugFile("A Reg Idx: %x\n", opcode->begin_reg_cond.addr_reg_index);
this->LogToDebugFile("O Reg Idx: %x\n", opcode->begin_reg_cond.ofs_reg_index);
break;
}
switch (opcode->begin_reg_cond.comp_type) {
case CompareRegisterValueType_StaticValue:
this->LogToDebugFile("Comp Type: Static Value\n");
this->LogToDebugFile("Value: %lx\n", opcode->begin_reg_cond.value.bit64);
break;
case CompareRegisterValueType_OtherRegister:
this->LogToDebugFile("Comp Type: Other Register\n");
this->LogToDebugFile("X Reg Idx: %x\n", opcode->begin_reg_cond.other_reg_index);
break;
case CompareRegisterValueType_MemoryRelAddr:
this->LogToDebugFile("Comp Type: Memory Relative Address\n");
this->LogToDebugFile("Mem Type: %x\n", opcode->begin_reg_cond.mem_type);
this->LogToDebugFile("Rel Addr: %lx\n", opcode->begin_reg_cond.rel_address);
break;
case CompareRegisterValueType_MemoryOfsReg:
this->LogToDebugFile("Comp Type: Memory Offset Register\n");
this->LogToDebugFile("Mem Type: %x\n", opcode->begin_reg_cond.mem_type);
this->LogToDebugFile("O Reg Idx: %x\n", opcode->begin_reg_cond.ofs_reg_index);
break;
case CompareRegisterValueType_RegisterRelAddr:
this->LogToDebugFile("Comp Type: Register Relative Address\n");
this->LogToDebugFile("A Reg Idx: %x\n", opcode->begin_reg_cond.addr_reg_index);
this->LogToDebugFile("Rel Addr: %lx\n", opcode->begin_reg_cond.rel_address);
break;
case CompareRegisterValueType_RegisterOfsReg:
this->LogToDebugFile("Comp Type: Register Offset Register\n");
this->LogToDebugFile("A Reg Idx: %x\n", opcode->begin_reg_cond.addr_reg_index);
this->LogToDebugFile("O Reg Idx: %x\n", opcode->begin_reg_cond.ofs_reg_index);
break;
}
break;
case CheatVmOpcodeType_SaveRestoreRegister:
case CheatVmOpcodeType_SaveRestoreRegister:
this->LogToDebugFile("Opcode: Save or Restore Register\n");
this->LogToDebugFile("Dst Idx: %x\n", opcode->save_restore_reg.dst_index);
this->LogToDebugFile("Src Idx: %x\n", opcode->save_restore_reg.src_index);
this->LogToDebugFile("Op Type: %d\n", opcode->save_restore_reg.op_type);
break;
case CheatVmOpcodeType_SaveRestoreRegisterMask:
case CheatVmOpcodeType_SaveRestoreRegisterMask:
this->LogToDebugFile("Opcode: Save or Restore Register Mask\n");
this->LogToDebugFile("Op Type: %d\n", opcode->save_restore_regmask.op_type);
for (size_t i = 0; i < NumRegisters; i++) {
this->LogToDebugFile("Act[%02x]: %d\n", i, opcode->save_restore_regmask.should_operate[i]);
}
break;
case CheatVmOpcodeType_DebugLog:
this->LogToDebugFile("Opcode: Debug Log\n");
this->LogToDebugFile("Bit Width: %x\n", opcode->debug_log.bit_width);
this->LogToDebugFile("Log ID: %x\n", opcode->debug_log.log_id);
this->LogToDebugFile("Val Type: %x\n", opcode->debug_log.val_type);
switch (opcode->debug_log.val_type) {
case DebugLogValueType_RegisterValue:
this->LogToDebugFile("Val Type: Register Value\n");
this->LogToDebugFile("X Reg Idx: %x\n", opcode->debug_log.val_reg_index);
break;
case DebugLogValueType_MemoryRelAddr:
this->LogToDebugFile("Val Type: Memory Relative Address\n");
this->LogToDebugFile("Mem Type: %x\n", opcode->debug_log.mem_type);
this->LogToDebugFile("Rel Addr: %lx\n", opcode->debug_log.rel_address);
break;
case DebugLogValueType_MemoryOfsReg:
this->LogToDebugFile("Val Type: Memory Offset Register\n");
this->LogToDebugFile("Mem Type: %x\n", opcode->debug_log.mem_type);
this->LogToDebugFile("O Reg Idx: %x\n", opcode->debug_log.ofs_reg_index);
break;
case DebugLogValueType_RegisterRelAddr:
this->LogToDebugFile("Val Type: Register Relative Address\n");
this->LogToDebugFile("A Reg Idx: %x\n", opcode->debug_log.addr_reg_index);
this->LogToDebugFile("Rel Addr: %lx\n", opcode->debug_log.rel_address);
break;
case DebugLogValueType_RegisterOfsReg:
this->LogToDebugFile("Val Type: Register Offset Register\n");
this->LogToDebugFile("A Reg Idx: %x\n", opcode->debug_log.addr_reg_index);
this->LogToDebugFile("O Reg Idx: %x\n", opcode->debug_log.ofs_reg_index);
break;
}
default:
this->LogToDebugFile("Unknown opcode: %x\n", opcode->opcode);
break;
@ -217,7 +263,7 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode *out) {
*out = opcode;
}
};
/* Helper function for getting instruction dwords. */
auto GetNextDword = [&]() {
if (this->instruction_ptr >= this->num_opcodes) {
@ -226,11 +272,11 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode *out) {
}
return this->program[this->instruction_ptr++];
};
/* Helper function for parsing a VmInt. */
auto GetNextVmInt = [&](const u32 bit_width) {
VmInt val = {0};
const u32 first_dword = GetNextDword();
switch (bit_width) {
case 1:
@ -246,21 +292,24 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode *out) {
val.bit64 = (((u64)first_dword) << 32ul) | ((u64)GetNextDword());
break;
}
return val;
};
/* Read opcode. */
const u32 first_dword = GetNextDword();
if (!valid) {
return valid;
}
opcode.opcode = (CheatVmOpcodeType)(((first_dword >> 28) & 0xF));
if (opcode.opcode >= CheatVmOpcodeType_ExtendedWidth) {
opcode.opcode = (CheatVmOpcodeType)((((u32)opcode.opcode) << 4) | ((first_dword >> 24) & 0xF));
}
if (opcode.opcode >= CheatVmOpcodeType_DoubleExtendedWidth) {
opcode.opcode = (CheatVmOpcodeType)((((u32)opcode.opcode) << 4) | ((first_dword >> 20) & 0xF));
}
/* detect condition start. */
switch (opcode.opcode) {
case CheatVmOpcodeType_BeginConditionalBlock:
@ -272,7 +321,7 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode *out) {
opcode.begin_conditional_block = false;
break;
}
switch (opcode.opcode) {
case CheatVmOpcodeType_StoreStatic:
{
@ -311,7 +360,7 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode *out) {
/* Parse register, whether loop start or loop end. */
opcode.ctrl_loop.start_loop = ((first_dword >> 24) & 0xF) == 0;
opcode.ctrl_loop.reg_index = ((first_dword >> 20) & 0xF);
/* Read number of iters if loop start. */
if (opcode.ctrl_loop.start_loop) {
opcode.ctrl_loop.num_iters = GetNextDword();
@ -448,7 +497,7 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode *out) {
opcode.begin_reg_cond.cond_type = (ConditionalComparisonType)((first_dword >> 16) & 0xF);
opcode.begin_reg_cond.val_reg_index = ((first_dword >> 12) & 0xF);
opcode.begin_reg_cond.comp_type = (CompareRegisterValueType)((first_dword >> 8) & 0xF);
switch (opcode.begin_reg_cond.comp_type) {
case CompareRegisterValueType_StaticValue:
opcode.begin_reg_cond.value = GetNextVmInt(opcode.begin_reg_cond.bit_width);
@ -500,13 +549,59 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode *out) {
}
}
break;
case CheatVmOpcodeType_DebugLog:
{
/* FFFTIX## */
/* FFFTI0Ma aaaaaaaa */
/* FFFTI1Mr */
/* FFFTI2Ra aaaaaaaa */
/* FFFTI3Rr */
/* FFFTI4X0 */
/* FFF = opcode 0xFFF */
/* T = bit width. */
/* I = log id. */
/* X = value operand type, 0 = main/heap with relative offset, 1 = main/heap with offset register, */
/* 2 = register with relative offset, 3 = register with offset register, 4 = register value. */
/* M = memory type. */
/* R = address register. */
/* a = relative address. */
/* r = offset register. */
/* X = value register. */
opcode.debug_log.bit_width = (first_dword >> 16) & 0xF;
opcode.debug_log.log_id = ((first_dword >> 12) & 0xF);
opcode.debug_log.val_type = (DebugLogValueType)((first_dword >> 8) & 0xF);
switch (opcode.debug_log.val_type) {
case DebugLogValueType_RegisterValue:
opcode.debug_log.val_reg_index = ((first_dword >> 4) & 0xF);
break;
case DebugLogValueType_MemoryRelAddr:
opcode.debug_log.mem_type = (MemoryAccessType)((first_dword >> 4) & 0xF);
opcode.debug_log.rel_address = (((u64)(first_dword & 0xF) << 32ul) | ((u64)GetNextDword()));
break;
case DebugLogValueType_MemoryOfsReg:
opcode.debug_log.mem_type = (MemoryAccessType)((first_dword >> 4) & 0xF);
opcode.debug_log.ofs_reg_index = (first_dword & 0xF);
break;
case DebugLogValueType_RegisterRelAddr:
opcode.debug_log.addr_reg_index = ((first_dword >> 4) & 0xF);
opcode.debug_log.rel_address = (((u64)(first_dword & 0xF) << 32ul) | ((u64)GetNextDword()));
break;
case DebugLogValueType_RegisterOfsReg:
opcode.debug_log.addr_reg_index = ((first_dword >> 4) & 0xF);
opcode.debug_log.ofs_reg_index = (first_dword & 0xF);
break;
}
}
break;
case CheatVmOpcodeType_ExtendedWidth:
case CheatVmOpcodeType_DoubleExtendedWidth:
default:
/* Unrecognized instruction cannot be decoded. */
valid = false;
break;
}
/* End decoding. */
return valid;
}
@ -515,7 +610,7 @@ void DmntCheatVm::SkipConditionalBlock() {
if (this->condition_depth > 0) {
/* We want to continue until we're out of the current block. */
const size_t desired_depth = this->condition_depth - 1;
CheatVmOpcode skip_opcode;
while (this->condition_depth > desired_depth && this->DecodeNextOpcode(&skip_opcode)) {
/* Decode instructions until we see end of the current conditional block. */
@ -523,7 +618,7 @@ void DmntCheatVm::SkipConditionalBlock() {
/* Gateway currently checks for "0x2" instead of "0x20000000" */
/* In addition, they do a linear scan instead of correctly decoding opcodes. */
/* This causes issues if "0x2" appears as an immediate in the conditional block... */
/* We also support nesting of conditional blocks, and Gateway does not. */
if (skip_opcode.begin_conditional_block) {
this->condition_depth++;
@ -581,7 +676,7 @@ void DmntCheatVm::ResetState() {
bool DmntCheatVm::LoadProgram(const CheatEntry *cheats, size_t num_cheats) {
/* Reset opcode count. */
this->num_opcodes = 0;
for (size_t i = 0; i < num_cheats; i++) {
if (cheats[i].enabled) {
/* Bounds check. */
@ -589,34 +684,34 @@ bool DmntCheatVm::LoadProgram(const CheatEntry *cheats, size_t num_cheats) {
this->num_opcodes = 0;
return false;
}
for (size_t n = 0; n < cheats[i].definition.num_opcodes; n++) {
this->program[this->num_opcodes++] = cheats[i].definition.opcodes[n];
}
}
}
return true;
}
void DmntCheatVm::Execute(const CheatProcessMetadata *metadata) {
CheatVmOpcode cur_opcode;
u64 kDown = 0;
/* Get Keys down. */
HidManagement::GetKeysDown(&kDown);
this->OpenDebugLogFile();
ON_SCOPE_EXIT { this->CloseDebugLogFile(); };
this->LogToDebugFile("Started VM execution.\n");
this->LogToDebugFile("Main NSO: %012lx\n", metadata->main_nso_extents.base);
this->LogToDebugFile("Heap: %012lx\n", metadata->main_nso_extents.base);
this->LogToDebugFile("Keys Down: %08x\n", (u32)(kDown & 0x0FFFFFFF));
/* Clear VM state. */
this->ResetState();
/* Loop until program finishes. */
while (this->DecodeNextOpcode(&cur_opcode)) {
this->LogToDebugFile("Instruction Ptr: %04x\n", (u32)this->instruction_ptr);
@ -629,12 +724,12 @@ void DmntCheatVm::Execute(const CheatProcessMetadata *metadata) {
this->LogToDebugFile("SavedRegs[%02x]: %016lx\n", i, this->saved_values[i]);
}
this->LogOpcode(&cur_opcode);
/* Increment conditional depth, if relevant. */
if (cur_opcode.begin_conditional_block) {
this->condition_depth++;
}
switch (cur_opcode.opcode) {
case CheatVmOpcodeType_StoreStatic:
{
@ -810,10 +905,10 @@ void DmntCheatVm::Execute(const CheatProcessMetadata *metadata) {
case CheatVmOpcodeType_PerformArithmeticRegister:
{
const u64 operand_1_value = this->registers[cur_opcode.perform_math_reg.src_reg_1_index];
const u64 operand_2_value = cur_opcode.perform_math_reg.has_immediate ?
const u64 operand_2_value = cur_opcode.perform_math_reg.has_immediate ?
GetVmInt(cur_opcode.perform_math_reg.value, cur_opcode.perform_math_reg.bit_width) :
this->registers[cur_opcode.perform_math_reg.src_reg_2_index];
u64 res_val = 0;
/* Do requested math. */
switch (cur_opcode.perform_math_reg.math_type) {
@ -848,8 +943,8 @@ void DmntCheatVm::Execute(const CheatProcessMetadata *metadata) {
res_val = operand_1_value;
break;
}
/* Apply bit width. */
switch (cur_opcode.perform_math_reg.bit_width) {
case 1:
@ -865,7 +960,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata *metadata) {
res_val = static_cast<u64>(res_val);
break;
}
/* Save to register. */
this->registers[cur_opcode.perform_math_reg.dst_reg_index] = res_val;
}
@ -895,7 +990,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata *metadata) {
dst_address = GetCheatProcessAddress(metadata, cur_opcode.str_register.mem_type, this->registers[cur_opcode.str_register.addr_reg_index] + cur_opcode.str_register.rel_address);
break;
}
/* Write value to memory. Write only on valid bitwidth. */
switch (cur_opcode.str_register.bit_width) {
case 1:
@ -905,7 +1000,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata *metadata) {
DmntCheatManager::WriteCheatProcessMemoryForVm(dst_address, &dst_value, cur_opcode.str_register.bit_width);
break;
}
/* Increment register if relevant. */
if (cur_opcode.str_register.increment_reg) {
this->registers[cur_opcode.str_register.addr_reg_index] += cur_opcode.str_register.bit_width;
@ -930,7 +1025,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata *metadata) {
src_value = static_cast<u64>(this->registers[cur_opcode.begin_reg_cond.val_reg_index] & 0xFFFFFFFFFFFFFFFFul);
break;
}
/* Read value from memory. */
u64 cond_value = 0;
if (cur_opcode.begin_reg_cond.comp_type == CompareRegisterValueType_StaticValue) {
@ -977,7 +1072,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata *metadata) {
break;
}
}
/* Check against condition. */
bool cond_met = false;
switch (cur_opcode.begin_reg_cond.cond_type) {
@ -1000,7 +1095,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata *metadata) {
cond_met = src_value != cond_value;
break;
}
/* Skip conditional block if condition not met. */
if (!cond_met) {
this->SkipConditionalBlock();
@ -1058,6 +1153,57 @@ void DmntCheatVm::Execute(const CheatProcessMetadata *metadata) {
}
}
break;
case CheatVmOpcodeType_DebugLog:
{
/* Read value from memory. */
u64 log_value = 0;
if (cur_opcode.debug_log.val_type == DebugLogValueType_RegisterValue) {
switch (cur_opcode.debug_log.bit_width) {
case 1:
log_value = static_cast<u8>(this->registers[cur_opcode.debug_log.val_reg_index] & 0xFFul);
break;
case 2:
log_value = static_cast<u16>(this->registers[cur_opcode.debug_log.val_reg_index] & 0xFFFFul);
break;
case 4:
log_value = static_cast<u32>(this->registers[cur_opcode.debug_log.val_reg_index] & 0xFFFFFFFFul);
break;
case 8:
log_value = static_cast<u64>(this->registers[cur_opcode.debug_log.val_reg_index] & 0xFFFFFFFFFFFFFFFFul);
break;
}
} else {
u64 val_address = 0;
switch (cur_opcode.debug_log.val_type) {
case DebugLogValueType_MemoryRelAddr:
val_address = GetCheatProcessAddress(metadata, cur_opcode.debug_log.mem_type, cur_opcode.debug_log.rel_address);
break;
case DebugLogValueType_MemoryOfsReg:
val_address = GetCheatProcessAddress(metadata, cur_opcode.debug_log.mem_type, this->registers[cur_opcode.debug_log.ofs_reg_index]);
break;
case DebugLogValueType_RegisterRelAddr:
val_address = this->registers[cur_opcode.debug_log.addr_reg_index] + cur_opcode.debug_log.rel_address;
break;
case DebugLogValueType_RegisterOfsReg:
val_address = this->registers[cur_opcode.debug_log.addr_reg_index] + this->registers[cur_opcode.debug_log.ofs_reg_index];
break;
default:
break;
}
switch (cur_opcode.debug_log.bit_width) {
case 1:
case 2:
case 4:
case 8:
DmntCheatManager::ReadCheatProcessMemoryForVm(val_address, &log_value, cur_opcode.debug_log.bit_width);
break;
}
}
/* Log value. */
this->DebugLog(cur_opcode.debug_log.log_id, log_value);
}
break;
default:
/* By default, we do a no-op. */
break;

View file

@ -45,6 +45,13 @@ enum CheatVmOpcodeType : u32 {
CheatVmOpcodeType_BeginRegisterConditionalBlock = 0xC0,
CheatVmOpcodeType_SaveRestoreRegister = 0xC1,
CheatVmOpcodeType_SaveRestoreRegisterMask = 0xC2,
/* This is a meta entry, and not a real opcode. */
/* This is to facilitate multi-nybble instruction decoding. */
CheatVmOpcodeType_DoubleExtendedWidth = 0xF0,
/* Double-extended width opcodes. */
CheatVmOpcodeType_DebugLog = 0xFFF,
};
enum MemoryAccessType : u32 {
@ -102,6 +109,14 @@ enum SaveRestoreRegisterOpType : u32 {
SaveRestoreRegisterOpType_ClearRegs = 3,
};
enum DebugLogValueType : u32 {
DebugLogValueType_MemoryRelAddr = 0,
DebugLogValueType_MemoryOfsReg = 1,
DebugLogValueType_RegisterRelAddr = 2,
DebugLogValueType_RegisterOfsReg = 3,
DebugLogValueType_RegisterValue = 4,
};
union VmInt {
u8 bit8;
u16 bit16;
@ -211,6 +226,17 @@ struct SaveRestoreRegisterMaskOpcode {
bool should_operate[0x10];
};
struct DebugLogOpcode {
u32 bit_width;
u32 log_id;
DebugLogValueType val_type;
MemoryAccessType mem_type;
u32 addr_reg_index;
u32 val_reg_index;
u32 ofs_reg_index;
u64 rel_address;
};
struct CheatVmOpcode {
CheatVmOpcodeType opcode;
bool begin_conditional_block;
@ -229,6 +255,7 @@ struct CheatVmOpcode {
BeginRegisterConditionalOpcode begin_reg_cond;
SaveRestoreRegisterOpcode save_restore_reg;
SaveRestoreRegisterMaskOpcode save_restore_regmask;
DebugLogOpcode debug_log;
};
};
@ -250,6 +277,9 @@ class DmntCheatVm {
void SkipConditionalBlock();
void ResetState();
/* For implementing the DebugLog opcode. */
void DebugLog(u32 log_id, u64 value);
/* For debugging. These will be IFDEF'd out normally. */
void OpenDebugLogFile();
void CloseDebugLogFile();

View file

@ -13,7 +13,7 @@
* 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 <switch.h>
#include <stratosphere.hpp>
#include "pm_process_track.hpp"
@ -23,9 +23,9 @@ void ProcessTracking::MainLoop(void *arg) {
/* Make a new waitable manager. */
auto process_waiter = new WaitableManager(1);
process_waiter->AddWaitable(Registration::GetProcessLaunchStartEvent());
/* Service processes. */
process_waiter->Process();
delete process_waiter;
}

View file

@ -35,6 +35,7 @@ static std::atomic<u64> g_debug_on_launch_tid(0);
static IEvent *g_process_event = nullptr;
static IEvent *g_debug_title_event = nullptr;
static IEvent *g_debug_application_event = nullptr;
static IEvent *g_boot_finished_event = nullptr;
static u8 g_ac_buf[4 * sizeof(LoaderProgramInfo)];
@ -46,10 +47,11 @@ void Registration::InitializeSystemResources() {
g_process_event = CreateWriteOnlySystemEvent();
g_debug_title_event = CreateWriteOnlySystemEvent();
g_debug_application_event = CreateWriteOnlySystemEvent();
g_boot_finished_event = CreateWriteOnlySystemEvent();
/* Auto-clear non-system event. */
g_process_launch_start_event = CreateHosEvent(&Registration::ProcessLaunchStartCallback);
ResourceLimitUtils::InitializeLimits();
}
@ -72,55 +74,55 @@ void Registration::HandleProcessLaunch() {
new_process.tid_sid = g_process_launch_state.tid_sid;
std::memset(g_ac_buf, 0xCC, sizeof(g_ac_buf));
u8 *acid_sac = g_ac_buf, *aci0_sac = acid_sac + sizeof(LoaderProgramInfo), *fac = aci0_sac + sizeof(LoaderProgramInfo), *fah = fac + sizeof(LoaderProgramInfo);
/* Check that this is a real program. */
if (R_FAILED((rc = ldrPmGetProgramInfo(new_process.tid_sid.title_id, new_process.tid_sid.storage_id, &program_info)))) {
goto HANDLE_PROCESS_LAUNCH_END;
}
/* Get the resource limit handle, ensure that we can launch the program. */
if ((program_info.application_type & 3) == 1 && HasApplicationProcess(NULL)) {
rc = ResultPmApplicationRunning;
goto HANDLE_PROCESS_LAUNCH_END;
}
/* Try to register the title for launch in loader... */
if (R_FAILED((rc = ldrPmRegisterTitle(new_process.tid_sid.title_id, new_process.tid_sid.storage_id, &new_process.ldr_queue_index)))) {
goto HANDLE_PROCESS_LAUNCH_END;
}
/* Make sure the previous application is cleaned up. */
if ((program_info.application_type & 3) == 1) {
ResourceLimitUtils::EnsureApplicationResourcesAvailable();
}
/* Try to create the process... */
if (R_FAILED((rc = ldrPmCreateProcess(LAUNCHFLAGS_ARGLOW(launch_flags) | LAUNCHFLAGS_ARGHIGH(launch_flags), new_process.ldr_queue_index, ResourceLimitUtils::GetResourceLimitHandle(program_info.application_type), &new_process.handle)))) {
goto PROCESS_CREATION_FAILED;
}
/* Get the new process's id. */
svcGetProcessId(&new_process.pid, new_process.handle);
/* Register with FS. */
memcpy(fac, program_info.ac_buffer + program_info.acid_sac_size + program_info.aci0_sac_size, program_info.acid_fac_size);
memcpy(fah, program_info.ac_buffer + program_info.acid_sac_size + program_info.aci0_sac_size + program_info.acid_fac_size, program_info.aci0_fah_size);
if (R_FAILED((rc = fsprRegisterProgram(new_process.pid, new_process.tid_sid.title_id, new_process.tid_sid.storage_id, fah, program_info.aci0_fah_size, fac, program_info.acid_fac_size)))) {
goto FS_REGISTRATION_FAILED;
}
/* Register with SM. */
memcpy(acid_sac, program_info.ac_buffer, program_info.acid_sac_size);
memcpy(aci0_sac, program_info.ac_buffer + program_info.acid_sac_size, program_info.aci0_sac_size);
if (R_FAILED((rc = smManagerRegisterProcess(new_process.pid, acid_sac, program_info.acid_sac_size, aci0_sac, program_info.aci0_sac_size)))) {
goto SM_REGISTRATION_FAILED;
}
/* Setup process flags. */
if (program_info.application_type & 1) {
new_process.flags |= PROCESSFLAGS_APPLICATION;
}
if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_200) && LAUNCHFLAGS_NOTIYDEBUGSPECIAL(launch_flags) && (program_info.application_type & 4)) {
if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_200) && LAUNCHFLAGS_NOTIYDEBUGSPECIAL(launch_flags) && (program_info.application_type & 4)) {
new_process.flags |= PROCESSFLAGS_NOTIFYDEBUGSPECIAL;
}
if (LAUNCHFLAGS_NOTIFYWHENEXITED(launch_flags)) {
@ -129,10 +131,10 @@ void Registration::HandleProcessLaunch() {
if (LAUNCHFLAGS_NOTIFYDEBUGEVENTS(launch_flags) && (GetRuntimeFirmwareVersion() < FirmwareVersion_200 || (program_info.application_type & 4))) {
new_process.flags |= PROCESSFLAGS_NOTIFYDEBUGEVENTS;
}
/* Add process to the list. */
Registration::AddProcessToList(std::make_shared<Registration::Process>(new_process));
/* Signal, if relevant. */
if (new_process.tid_sid.title_id == g_debug_on_launch_tid.load()) {
g_debug_title_event->Signal();
@ -146,39 +148,39 @@ void Registration::HandleProcessLaunch() {
rc = ResultSuccess;
} else {
rc = svcStartProcess(new_process.handle, program_info.main_thread_priority, program_info.default_cpu_id, program_info.main_thread_stack_size);
if (R_SUCCEEDED(rc)) {
SetProcessState(new_process.pid, ProcessState_Running);
}
}
if (R_FAILED(rc)) {
Registration::RemoveProcessFromList(new_process.pid);
smManagerUnregisterProcess(new_process.pid);
}
SM_REGISTRATION_FAILED:
if (R_FAILED(rc)) {
fsprUnregisterProgram(new_process.pid);
}
FS_REGISTRATION_FAILED:
if (R_FAILED(rc)) {
svcCloseHandle(new_process.handle);
new_process.handle = 0;
}
PROCESS_CREATION_FAILED:
if (R_FAILED(rc)) {
ldrPmUnregisterTitle(new_process.ldr_queue_index);
}
HANDLE_PROCESS_LAUNCH_END:
g_process_launch_state.result = rc;
if (R_SUCCEEDED(rc)) {
*out_pid = new_process.pid;
}
g_sema_finish_launch.Signal();
}
@ -187,25 +189,25 @@ Result Registration::LaunchDebugProcess(u64 pid) {
std::scoped_lock<ProcessList &> lk(GetProcessList());
LoaderProgramInfo program_info = {0};
Result rc;
std::shared_ptr<Registration::Process> proc = GetProcess(pid);
if (proc == NULL) {
return ResultPmProcessNotFound;
}
if (proc->state >= ProcessState_Running) {
return ResultPmAlreadyStarted;
}
/* Check that this is a real program. */
if (R_FAILED((rc = ldrPmGetProgramInfo(proc->tid_sid.title_id, proc->tid_sid.storage_id, &program_info)))) {
return rc;
}
if (R_SUCCEEDED((rc = svcStartProcess(proc->handle, program_info.main_thread_priority, program_info.default_cpu_id, program_info.main_thread_stack_size)))) {
proc->state = ProcessState_Running;
}
return rc;
}
@ -216,11 +218,11 @@ Result Registration::LaunchProcess(u64 title_id, FsStorageId storage_id, u64 lau
g_process_launch_state.tid_sid.storage_id = storage_id;
g_process_launch_state.launch_flags = launch_flags;
g_process_launch_state.out_pid = out_pid;
/* Start a launch, and wait for it to exit. */
g_process_launch_start_event->Signal();
g_sema_finish_launch.Wait();
return g_process_launch_state.result;
}
@ -230,15 +232,15 @@ Result Registration::LaunchProcessByTidSid(TidSid tid_sid, u64 launch_flags, u64
Result Registration::HandleSignaledProcess(std::shared_ptr<Registration::Process> process) {
u64 tmp;
/* Reset the signal. */
svcResetSignal(process->handle);
ProcessState old_state;
old_state = process->state;
svcGetProcessInfo(&tmp, process->handle, ProcessInfoType_ProcessState);
process->state = (ProcessState)tmp;
if (old_state == ProcessState_Crashed && process->state != ProcessState_Crashed) {
process->flags &= ~PROCESSFLAGS_CRASH_DEBUG;
}
@ -307,18 +309,18 @@ void Registration::FinalizeExitedProcess(std::shared_ptr<Registration::Process>
if (R_FAILED(ldrPmUnregisterTitle(process->ldr_queue_index))) {
std::abort();
}
/* Close the process's handle. */
svcCloseHandle(process->handle);
process->handle = 0;
/* Insert into dead process list, if relevant. */
if (signal_debug_process_5x) {
std::scoped_lock<ProcessList &> dead_lk(g_dead_process_list);
g_dead_process_list.processes.push_back(process);
}
/* Remove NOTE: This probably frees process. */
RemoveProcessFromList(process->pid);
}
@ -337,7 +339,7 @@ void Registration::AddProcessToList(std::shared_ptr<Registration::Process> proce
void Registration::RemoveProcessFromList(u64 pid) {
std::scoped_lock<ProcessList &> lk(GetProcessList());
/* Remove process from list. */
for (unsigned int i = 0; i < g_process_list.processes.size(); i++) {
std::shared_ptr<Registration::Process> process = g_process_list.processes[i];
@ -352,10 +354,10 @@ void Registration::RemoveProcessFromList(u64 pid) {
void Registration::SetProcessState(u64 pid, ProcessState new_state) {
std::scoped_lock<ProcessList &> lk(GetProcessList());
/* Set process state. */
for (auto &process : g_process_list.processes) {
if (process->pid == pid) {
if (process->pid == pid) {
process->state = new_state;
break;
}
@ -364,7 +366,7 @@ void Registration::SetProcessState(u64 pid, ProcessState new_state) {
bool Registration::HasApplicationProcess(std::shared_ptr<Registration::Process> *out) {
std::scoped_lock<ProcessList &> lk(GetProcessList());
for (auto &process : g_process_list.processes) {
if (process->flags & PROCESSFLAGS_APPLICATION) {
if (out != nullptr) {
@ -373,31 +375,31 @@ bool Registration::HasApplicationProcess(std::shared_ptr<Registration::Process>
return true;
}
}
return false;
}
std::shared_ptr<Registration::Process> Registration::GetProcess(u64 pid) {
std::scoped_lock<ProcessList &> lk(GetProcessList());
for (auto &process : g_process_list.processes) {
if (process->pid == pid) {
return process;
}
}
return nullptr;
}
std::shared_ptr<Registration::Process> Registration::GetProcessByTitleId(u64 tid) {
std::scoped_lock<ProcessList &> lk(GetProcessList());
for (auto &process : g_process_list.processes) {
if (process->tid_sid.title_id == tid) {
return process;
}
}
return nullptr;
}
@ -405,14 +407,14 @@ std::shared_ptr<Registration::Process> Registration::GetProcessByTitleId(u64 tid
Result Registration::GetDebugProcessIds(u64 *out_pids, u32 max_out, u32 *num_out) {
std::scoped_lock<ProcessList &> lk(GetProcessList());
u32 num = 0;
for (auto &process : g_process_list.processes) {
if (process->flags & PROCESSFLAGS_CRASH_DEBUG && num < max_out) {
out_pids[num++] = process->pid;
}
}
*num_out = num;
return ResultSuccess;
}
@ -425,7 +427,7 @@ void Registration::GetProcessEventType(u64 *out_pid, u64 *out_type) {
/* Scope to manage process list lock. */
{
std::scoped_lock<ProcessList &> lk(GetProcessList());
for (auto &p : g_process_list.processes) {
if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_200) && p->state >= ProcessState_Running && p->flags & PROCESSFLAGS_DEBUGDETACHED) {
p->flags &= ~PROCESSFLAGS_DEBUGDETACHED;
@ -461,7 +463,7 @@ void Registration::GetProcessEventType(u64 *out_pid, u64 *out_type) {
*out_pid = 0;
*out_type = 0;
}
if ((GetRuntimeFirmwareVersion() >= FirmwareVersion_500)) {
std::scoped_lock<ProcessList &> dead_lk(g_dead_process_list);
@ -501,3 +503,19 @@ Result Registration::DisableDebug(u32 which) {
}
return ResultSuccess;
}
Handle Registration::GetDebugTitleEventHandle() {
return g_debug_title_event->GetHandle();
}
Handle Registration::GetDebugApplicationEventHandle() {
return g_debug_application_event->GetHandle();
}
Handle Registration::GetBootFinishedEventHandle() {
return g_boot_finished_event->GetHandle();
}
void Registration::SignalBootFinished() {
g_boot_finished_event->Signal();
}

View file

@ -13,7 +13,7 @@
* 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>
#include <stratosphere.hpp>
@ -98,7 +98,7 @@ enum {
- and PROCESSFLAGS_NOTIFYDEBUGEVENTS is set
*/
PROCESSFLAGS_DEBUGSUSPENDED = 0x020,
/*
set in HandleProcessLaunch when
- program_info.application_type & 1
@ -148,7 +148,7 @@ enum {
PROCESSEVENTTYPE_500_RUNNING = 4, // debug detached or running
PROCESSEVENTTYPE_500_SUSPENDED = 5, // debug suspended
};
class Registration {
public:
struct TidSid {
@ -163,7 +163,7 @@ class Registration {
ProcessState state;
u32 flags;
};
struct ProcessLaunchState {
TidSid tid_sid;
u64 launch_flags;
@ -175,14 +175,14 @@ class Registration {
static IWaitable *GetProcessLaunchStartEvent();
static ProcessList &GetProcessList();
static Result ProcessLaunchStartCallback(u64 timeout);
static Result HandleSignaledProcess(std::shared_ptr<Process> process);
static void FinalizeExitedProcess(std::shared_ptr<Process> process);
static void AddProcessToList(std::shared_ptr<Process> process);
static void RemoveProcessFromList(u64 pid);
static void SetProcessState(u64 pid, ProcessState new_state);
static std::shared_ptr<Registration::Process> GetProcess(u64 pid);
static std::shared_ptr<Registration::Process> GetProcessByTitleId(u64 tid);
static Result GetDebugProcessIds(u64 *out_pids, u32 max_out, u32 *num_out);
@ -193,13 +193,16 @@ class Registration {
static Result DisableDebug(u32 which);
static Handle GetDebugTitleEventHandle();
static Handle GetDebugApplicationEventHandle();
static Handle GetBootFinishedEventHandle();
static void HandleProcessLaunch();
static Result LaunchDebugProcess(u64 pid);
static void SignalFinishLaunchProcess();
static Result LaunchProcess(u64 title_id, FsStorageId storage_id, u64 launch_flags, u64 *out_pid);
static Result LaunchProcessByTidSid(TidSid tid_sid, u64 launch_flags, u64 *out_pid);
static void SignalBootFinished();
static bool HasApplicationProcess(std::shared_ptr<Process> *out);
};

View file

@ -13,7 +13,7 @@
* 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 <switch.h>
#include <stratosphere.hpp>
#include "pm_registration.hpp"
@ -29,7 +29,7 @@ Result ShellService::LaunchProcess(Out<u64> pid, Registration::TidSid tid_sid, u
Result ShellService::TerminateProcessId(u64 pid) {
std::scoped_lock<ProcessList &> lk(Registration::GetProcessList());
auto proc = Registration::GetProcess(pid);
if (proc != nullptr) {
return svcTerminateProcess(proc->handle);
@ -40,7 +40,7 @@ Result ShellService::TerminateProcessId(u64 pid) {
Result ShellService::TerminateTitleId(u64 tid) {
std::scoped_lock<ProcessList &> lk(Registration::GetProcessList());
auto proc = Registration::GetProcessByTitleId(tid);
if (proc != NULL) {
return svcTerminateProcess(proc->handle);
@ -59,7 +59,7 @@ void ShellService::GetProcessEventType(Out<u64> type, Out<u64> pid) {
Result ShellService::FinalizeExitedProcess(u64 pid) {
std::scoped_lock<ProcessList &> lk(Registration::GetProcessList());
auto proc = Registration::GetProcess(pid);
if (proc == NULL) {
return ResultPmProcessNotFound;
@ -73,7 +73,7 @@ Result ShellService::FinalizeExitedProcess(u64 pid) {
Result ShellService::ClearProcessNotificationFlag(u64 pid) {
std::scoped_lock<ProcessList &> lk(Registration::GetProcessList());
auto proc = Registration::GetProcess(pid);
if (proc != NULL) {
proc->flags &= ~PROCESSFLAGS_CRASHED;
@ -86,13 +86,14 @@ Result ShellService::ClearProcessNotificationFlag(u64 pid) {
void ShellService::NotifyBootFinished() {
if (!g_has_boot_finished) {
g_has_boot_finished = true;
Registration::SignalBootFinished();
EmbeddedBoot2::Main();
}
}
Result ShellService::GetApplicationProcessId(Out<u64> pid) {
std::scoped_lock<ProcessList &> lk(Registration::GetProcessList());
std::shared_ptr<Registration::Process> app_proc;
if (Registration::HasApplicationProcess(&app_proc)) {
pid.SetValue(app_proc->pid);
@ -113,13 +114,15 @@ Result ShellService::BoostSystemThreadsResourceLimit() {
}
Result ShellService::GetUnimplementedEventHandle(Out<CopiedHandle> event) {
/* In 8.0.0, Nintendo added this command which should return an event handle. */
/* In addition, they also added code to create a new event in the global PM constructor. */
/* However, nothing signals this event, and this command currently does std::abort();. */
/* We will oblige. */
std::abort();
/* TODO: Return an event handle, once N makes this command a real thing in the future. */
/* TODO: return ResultSuccess; */
void ShellService::GetBootFinishedEvent(Out<CopiedHandle> event) {
/* In 8.0.0, Nintendo added this command, which signals that the boot sysmodule has finished. */
/* Nintendo only signals it in safe mode FIRM, and this function aborts on normal FIRM. */
/* We will signal it always, but only allow this function to succeed on safe mode. */
{
u64 is_recovery_boot = 0;
if (R_FAILED(SmcGetConfig(SplConfigItem_IsRecoveryBoot, &is_recovery_boot)) || !is_recovery_boot) {
std::abort();
}
}
event.SetValue(Registration::GetBootFinishedEventHandle());
}

View file

@ -13,7 +13,7 @@
* 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>
#include <stratosphere.hpp>
@ -42,12 +42,12 @@ enum ShellCmd_5X {
Shell_Cmd_5X_NotifyBootFinished = 5,
Shell_Cmd_5X_GetApplicationProcessId = 6,
Shell_Cmd_5X_BoostSystemMemoryResourceLimit = 7,
Shell_Cmd_BoostSystemThreadsResourceLimit = 8,
Shell_Cmd_GetUnimplementedEventHandle = 9 /* TODO: Rename when Nintendo implements this. */
Shell_Cmd_GetBootFinishedEvent = 9,
};
class ShellService final : public IServiceObject {
class ShellService final : public IServiceObject {
private:
/* Actual commands. */
Result LaunchProcess(Out<u64> pid, Registration::TidSid tid_sid, u32 launch_flags);
@ -61,7 +61,7 @@ class ShellService final : public IServiceObject {
Result GetApplicationProcessId(Out<u64> pid);
Result BoostSystemMemoryResourceLimit(u64 sysmem_size);
Result BoostSystemThreadsResourceLimit();
Result GetUnimplementedEventHandle(Out<CopiedHandle> event);
void GetBootFinishedEvent(Out<CopiedHandle> event);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
/* 1.0.0-4.0.0 */
@ -74,10 +74,10 @@ class ShellService final : public IServiceObject {
MakeServiceCommandMeta<Shell_Cmd_ClearProcessNotificationFlag, &ShellService::ClearProcessNotificationFlag, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Shell_Cmd_NotifyBootFinished, &ShellService::NotifyBootFinished, FirmwareVersion_Min, FirmwareVersion_400>(),
MakeServiceCommandMeta<Shell_Cmd_GetApplicationProcessId, &ShellService::GetApplicationProcessId, FirmwareVersion_Min, FirmwareVersion_400>(),
/* 4.0.0-4.0.0 */
MakeServiceCommandMeta<Shell_Cmd_BoostSystemMemoryResourceLimit, &ShellService::BoostSystemMemoryResourceLimit, FirmwareVersion_400, FirmwareVersion_400>(),
/* 5.0.0-* */
MakeServiceCommandMeta<Shell_Cmd_5X_LaunchProcess, &ShellService::LaunchProcess, FirmwareVersion_500>(),
MakeServiceCommandMeta<Shell_Cmd_5X_TerminateProcessId, &ShellService::TerminateProcessId, FirmwareVersion_500>(),
@ -87,11 +87,11 @@ class ShellService final : public IServiceObject {
MakeServiceCommandMeta<Shell_Cmd_5X_NotifyBootFinished, &ShellService::NotifyBootFinished, FirmwareVersion_500>(),
MakeServiceCommandMeta<Shell_Cmd_5X_GetApplicationProcessId, &ShellService::GetApplicationProcessId, FirmwareVersion_500>(),
MakeServiceCommandMeta<Shell_Cmd_5X_BoostSystemMemoryResourceLimit, &ShellService::BoostSystemMemoryResourceLimit, FirmwareVersion_500>(),
/* 7.0.0-* */
MakeServiceCommandMeta<Shell_Cmd_BoostSystemThreadsResourceLimit, &ShellService::BoostSystemThreadsResourceLimit, FirmwareVersion_700>(),
/* 8.0.0-* */
MakeServiceCommandMeta<Shell_Cmd_GetUnimplementedEventHandle, &ShellService::GetUnimplementedEventHandle, FirmwareVersion_800>(),
MakeServiceCommandMeta<Shell_Cmd_GetBootFinishedEvent, &ShellService::GetBootFinishedEvent, FirmwareVersion_800>(),
};
};