mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-26 16:52:46 +01:00
dmnt_cheat_vm: Default initialize structure values
This commit is contained in:
parent
682174b112
commit
2bddc03468
3 changed files with 88 additions and 89 deletions
|
@ -278,8 +278,7 @@ std::optional<std::vector<Memory::CheatEntry>> ReadCheatFileFromFolder(
|
||||||
|
|
||||||
std::vector<Memory::CheatEntry> PatchManager::CreateCheatList(
|
std::vector<Memory::CheatEntry> PatchManager::CreateCheatList(
|
||||||
const Core::System& system, const std::array<u8, 32>& build_id_) const {
|
const Core::System& system, const std::array<u8, 32>& build_id_) const {
|
||||||
const auto load_dir =
|
const auto load_dir = system.GetFileSystemController().GetModificationLoadRoot(title_id);
|
||||||
Core::System::GetInstance().GetFileSystemController().GetModificationLoadRoot(title_id);
|
|
||||||
if (load_dir == nullptr) {
|
if (load_dir == nullptr) {
|
||||||
LOG_ERROR(Loader, "Cannot load mods for invalid title_id={:016X}", title_id);
|
LOG_ERROR(Loader, "Cannot load mods for invalid title_id={:016X}", title_id);
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -29,30 +29,30 @@
|
||||||
namespace Memory {
|
namespace Memory {
|
||||||
|
|
||||||
struct MemoryRegionExtents {
|
struct MemoryRegionExtents {
|
||||||
u64 base;
|
u64 base{};
|
||||||
u64 size;
|
u64 size{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CheatProcessMetadata {
|
struct CheatProcessMetadata {
|
||||||
u64 process_id;
|
u64 process_id{};
|
||||||
u64 title_id;
|
u64 title_id{};
|
||||||
MemoryRegionExtents main_nso_extents;
|
MemoryRegionExtents main_nso_extents{};
|
||||||
MemoryRegionExtents heap_extents;
|
MemoryRegionExtents heap_extents{};
|
||||||
MemoryRegionExtents alias_extents;
|
MemoryRegionExtents alias_extents{};
|
||||||
MemoryRegionExtents address_space_extents;
|
MemoryRegionExtents address_space_extents{};
|
||||||
std::array<u8, 0x20> main_nso_build_id;
|
std::array<u8, 0x20> main_nso_build_id{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CheatDefinition {
|
struct CheatDefinition {
|
||||||
std::array<char, 0x40> readable_name;
|
std::array<char, 0x40> readable_name{};
|
||||||
u32 num_opcodes;
|
u32 num_opcodes{};
|
||||||
std::array<u32, 0x100> opcodes;
|
std::array<u32, 0x100> opcodes{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CheatEntry {
|
struct CheatEntry {
|
||||||
bool enabled;
|
bool enabled{};
|
||||||
u32 cheat_id;
|
u32 cheat_id{};
|
||||||
CheatDefinition definition;
|
CheatDefinition definition{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Memory
|
} // namespace Memory
|
||||||
|
|
|
@ -136,131 +136,131 @@ union VmInt {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StoreStaticOpcode {
|
struct StoreStaticOpcode {
|
||||||
u32 bit_width;
|
u32 bit_width{};
|
||||||
MemoryAccessType mem_type;
|
MemoryAccessType mem_type{};
|
||||||
u32 offset_register;
|
u32 offset_register{};
|
||||||
u64 rel_address;
|
u64 rel_address{};
|
||||||
VmInt value;
|
VmInt value{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BeginConditionalOpcode {
|
struct BeginConditionalOpcode {
|
||||||
u32 bit_width;
|
u32 bit_width{};
|
||||||
MemoryAccessType mem_type;
|
MemoryAccessType mem_type{};
|
||||||
ConditionalComparisonType cond_type;
|
ConditionalComparisonType cond_type{};
|
||||||
u64 rel_address;
|
u64 rel_address{};
|
||||||
VmInt value;
|
VmInt value{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EndConditionalOpcode {};
|
struct EndConditionalOpcode {};
|
||||||
|
|
||||||
struct ControlLoopOpcode {
|
struct ControlLoopOpcode {
|
||||||
bool start_loop;
|
bool start_loop{};
|
||||||
u32 reg_index;
|
u32 reg_index{};
|
||||||
u32 num_iters;
|
u32 num_iters{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LoadRegisterStaticOpcode {
|
struct LoadRegisterStaticOpcode {
|
||||||
u32 reg_index;
|
u32 reg_index{};
|
||||||
u64 value;
|
u64 value{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LoadRegisterMemoryOpcode {
|
struct LoadRegisterMemoryOpcode {
|
||||||
u32 bit_width;
|
u32 bit_width{};
|
||||||
MemoryAccessType mem_type;
|
MemoryAccessType mem_type{};
|
||||||
u32 reg_index;
|
u32 reg_index{};
|
||||||
bool load_from_reg;
|
bool load_from_reg{};
|
||||||
u64 rel_address;
|
u64 rel_address{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StoreStaticToAddressOpcode {
|
struct StoreStaticToAddressOpcode {
|
||||||
u32 bit_width;
|
u32 bit_width{};
|
||||||
u32 reg_index;
|
u32 reg_index{};
|
||||||
bool increment_reg;
|
bool increment_reg{};
|
||||||
bool add_offset_reg;
|
bool add_offset_reg{};
|
||||||
u32 offset_reg_index;
|
u32 offset_reg_index{};
|
||||||
u64 value;
|
u64 value{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PerformArithmeticStaticOpcode {
|
struct PerformArithmeticStaticOpcode {
|
||||||
u32 bit_width;
|
u32 bit_width{};
|
||||||
u32 reg_index;
|
u32 reg_index{};
|
||||||
RegisterArithmeticType math_type;
|
RegisterArithmeticType math_type{};
|
||||||
u32 value;
|
u32 value{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BeginKeypressConditionalOpcode {
|
struct BeginKeypressConditionalOpcode {
|
||||||
u32 key_mask;
|
u32 key_mask{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PerformArithmeticRegisterOpcode {
|
struct PerformArithmeticRegisterOpcode {
|
||||||
u32 bit_width;
|
u32 bit_width{};
|
||||||
RegisterArithmeticType math_type;
|
RegisterArithmeticType math_type{};
|
||||||
u32 dst_reg_index;
|
u32 dst_reg_index{};
|
||||||
u32 src_reg_1_index;
|
u32 src_reg_1_index{};
|
||||||
u32 src_reg_2_index;
|
u32 src_reg_2_index{};
|
||||||
bool has_immediate;
|
bool has_immediate{};
|
||||||
VmInt value;
|
VmInt value{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct StoreRegisterToAddressOpcode {
|
struct StoreRegisterToAddressOpcode {
|
||||||
u32 bit_width;
|
u32 bit_width{};
|
||||||
u32 str_reg_index;
|
u32 str_reg_index{};
|
||||||
u32 addr_reg_index;
|
u32 addr_reg_index{};
|
||||||
bool increment_reg;
|
bool increment_reg{};
|
||||||
StoreRegisterOffsetType ofs_type;
|
StoreRegisterOffsetType ofs_type{};
|
||||||
MemoryAccessType mem_type;
|
MemoryAccessType mem_type{};
|
||||||
u32 ofs_reg_index;
|
u32 ofs_reg_index{};
|
||||||
u64 rel_address;
|
u64 rel_address{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BeginRegisterConditionalOpcode {
|
struct BeginRegisterConditionalOpcode {
|
||||||
u32 bit_width;
|
u32 bit_width{};
|
||||||
ConditionalComparisonType cond_type;
|
ConditionalComparisonType cond_type{};
|
||||||
u32 val_reg_index;
|
u32 val_reg_index{};
|
||||||
CompareRegisterValueType comp_type;
|
CompareRegisterValueType comp_type{};
|
||||||
MemoryAccessType mem_type;
|
MemoryAccessType mem_type{};
|
||||||
u32 addr_reg_index;
|
u32 addr_reg_index{};
|
||||||
u32 other_reg_index;
|
u32 other_reg_index{};
|
||||||
u32 ofs_reg_index;
|
u32 ofs_reg_index{};
|
||||||
u64 rel_address;
|
u64 rel_address{};
|
||||||
VmInt value;
|
VmInt value{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SaveRestoreRegisterOpcode {
|
struct SaveRestoreRegisterOpcode {
|
||||||
u32 dst_index;
|
u32 dst_index{};
|
||||||
u32 src_index;
|
u32 src_index{};
|
||||||
SaveRestoreRegisterOpType op_type;
|
SaveRestoreRegisterOpType op_type{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SaveRestoreRegisterMaskOpcode {
|
struct SaveRestoreRegisterMaskOpcode {
|
||||||
SaveRestoreRegisterOpType op_type;
|
SaveRestoreRegisterOpType op_type{};
|
||||||
std::array<bool, 0x10> should_operate;
|
std::array<bool, 0x10> should_operate{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DebugLogOpcode {
|
struct DebugLogOpcode {
|
||||||
u32 bit_width;
|
u32 bit_width{};
|
||||||
u32 log_id;
|
u32 log_id{};
|
||||||
DebugLogValueType val_type;
|
DebugLogValueType val_type{};
|
||||||
MemoryAccessType mem_type;
|
MemoryAccessType mem_type{};
|
||||||
u32 addr_reg_index;
|
u32 addr_reg_index{};
|
||||||
u32 val_reg_index;
|
u32 val_reg_index{};
|
||||||
u32 ofs_reg_index;
|
u32 ofs_reg_index{};
|
||||||
u64 rel_address;
|
u64 rel_address{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UnrecognizedInstruction {
|
struct UnrecognizedInstruction {
|
||||||
CheatVmOpcodeType opcode;
|
CheatVmOpcodeType opcode{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CheatVmOpcode {
|
struct CheatVmOpcode {
|
||||||
bool begin_conditional_block;
|
bool begin_conditional_block{};
|
||||||
std::variant<StoreStaticOpcode, BeginConditionalOpcode, EndConditionalOpcode, ControlLoopOpcode,
|
std::variant<StoreStaticOpcode, BeginConditionalOpcode, EndConditionalOpcode, ControlLoopOpcode,
|
||||||
LoadRegisterStaticOpcode, LoadRegisterMemoryOpcode, StoreStaticToAddressOpcode,
|
LoadRegisterStaticOpcode, LoadRegisterMemoryOpcode, StoreStaticToAddressOpcode,
|
||||||
PerformArithmeticStaticOpcode, BeginKeypressConditionalOpcode,
|
PerformArithmeticStaticOpcode, BeginKeypressConditionalOpcode,
|
||||||
PerformArithmeticRegisterOpcode, StoreRegisterToAddressOpcode,
|
PerformArithmeticRegisterOpcode, StoreRegisterToAddressOpcode,
|
||||||
BeginRegisterConditionalOpcode, SaveRestoreRegisterOpcode,
|
BeginRegisterConditionalOpcode, SaveRestoreRegisterOpcode,
|
||||||
SaveRestoreRegisterMaskOpcode, DebugLogOpcode, UnrecognizedInstruction>
|
SaveRestoreRegisterMaskOpcode, DebugLogOpcode, UnrecognizedInstruction>
|
||||||
opcode;
|
opcode{};
|
||||||
};
|
};
|
||||||
|
|
||||||
class DmntCheatVm {
|
class DmntCheatVm {
|
||||||
|
|
Loading…
Reference in a new issue