diff options
| author | 2019-03-05 10:09:27 -0500 | |
|---|---|---|
| committer | 2019-03-05 10:09:36 -0500 | |
| commit | 52ac6419dafb84b10369226d3746b3b5b761d33b (patch) | |
| tree | 008c14ba2e019b86128e6168ad49a3a1eafa6ba8 /src | |
| parent | core: Add support for registering and controlling ownership of CheatEngine (diff) | |
| download | yuzu-52ac6419dafb84b10369226d3746b3b5b761d33b.tar.gz yuzu-52ac6419dafb84b10369226d3746b3b5b761d33b.tar.xz yuzu-52ac6419dafb84b10369226d3746b3b5b761d33b.zip | |
vm_manager: Remove cheat-specific ranges from VMManager
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 6 | ||||
| -rw-r--r-- | src/core/core.h | 4 | ||||
| -rw-r--r-- | src/core/file_sys/cheat_engine.cpp | 70 | ||||
| -rw-r--r-- | src/core/file_sys/cheat_engine.h | 11 | ||||
| -rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 17 | ||||
| -rw-r--r-- | src/core/hle/kernel/vm_manager.h | 8 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.h | 2 | ||||
| -rw-r--r-- | src/core/loader/deconstructed_rom_directory.cpp | 4 | ||||
| -rw-r--r-- | src/core/loader/nso.cpp | 10 | ||||
| -rw-r--r-- | src/core/loader/nso.h | 1 |
10 files changed, 56 insertions, 77 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index ce53ef758..32c5b112d 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -450,8 +450,10 @@ Tegra::DebugContext* System::GetGPUDebugContext() const { | |||
| 450 | } | 450 | } |
| 451 | 451 | ||
| 452 | void System::RegisterCheatList(const std::vector<FileSys::CheatList>& list, | 452 | void System::RegisterCheatList(const std::vector<FileSys::CheatList>& list, |
| 453 | const std::string& build_id) { | 453 | const std::string& build_id, VAddr code_region_start, |
| 454 | impl->cheat_engine = std::make_unique<FileSys::CheatEngine>(list, build_id); | 454 | VAddr code_region_end) { |
| 455 | impl->cheat_engine = | ||
| 456 | std::make_unique<FileSys::CheatEngine>(list, build_id, code_region_start, code_region_end); | ||
| 455 | } | 457 | } |
| 456 | 458 | ||
| 457 | void System::SetFilesystem(std::shared_ptr<FileSys::VfsFilesystem> vfs) { | 459 | void System::SetFilesystem(std::shared_ptr<FileSys::VfsFilesystem> vfs) { |
diff --git a/src/core/core.h b/src/core/core.h index bfb75631e..a6cfda405 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -254,8 +254,8 @@ public: | |||
| 254 | 254 | ||
| 255 | std::shared_ptr<FileSys::VfsFilesystem> GetFilesystem() const; | 255 | std::shared_ptr<FileSys::VfsFilesystem> GetFilesystem() const; |
| 256 | 256 | ||
| 257 | void RegisterCheatList(const std::vector<FileSys::CheatList>& list, | 257 | void RegisterCheatList(const std::vector<FileSys::CheatList>& list, const std::string& build_id, |
| 258 | const std::string& build_id); | 258 | VAddr code_region_start, VAddr code_region_end); |
| 259 | 259 | ||
| 260 | void SetProfileSelector(std::unique_ptr<Frontend::ProfileSelectApplet> applet); | 260 | void SetProfileSelector(std::unique_ptr<Frontend::ProfileSelectApplet> applet); |
| 261 | 261 | ||
diff --git a/src/core/file_sys/cheat_engine.cpp b/src/core/file_sys/cheat_engine.cpp index e4383d8c1..09ca9d705 100644 --- a/src/core/file_sys/cheat_engine.cpp +++ b/src/core/file_sys/cheat_engine.cpp | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | 18 | ||
| 19 | namespace FileSys { | 19 | namespace FileSys { |
| 20 | 20 | ||
| 21 | constexpr u64 CHEAT_ENGINE_TICKS = CoreTiming::BASE_CLOCK_RATE / 60; | 21 | constexpr u64 CHEAT_ENGINE_TICKS = Core::Timing::BASE_CLOCK_RATE / 60; |
| 22 | constexpr u32 KEYPAD_BITMASK = 0x3FFFFFF; | 22 | constexpr u32 KEYPAD_BITMASK = 0x3FFFFFF; |
| 23 | 23 | ||
| 24 | u64 Cheat::Address() const { | 24 | u64 Cheat::Address() const { |
| @@ -82,7 +82,7 @@ CheatList::CheatList(ProgramSegment master, ProgramSegment standard) | |||
| 82 | 82 | ||
| 83 | bool CheatList::EvaluateConditional(const Cheat& cheat) const { | 83 | bool CheatList::EvaluateConditional(const Cheat& cheat) const { |
| 84 | using ComparisonFunction = bool (*)(u64, u64); | 84 | using ComparisonFunction = bool (*)(u64, u64); |
| 85 | constexpr ComparisonFunction comparison_functions[] = { | 85 | constexpr std::array<ComparisonFunction, 6> comparison_functions{ |
| 86 | [](u64 a, u64 b) { return a > b; }, [](u64 a, u64 b) { return a >= b; }, | 86 | [](u64 a, u64 b) { return a > b; }, [](u64 a, u64 b) { return a >= b; }, |
| 87 | [](u64 a, u64 b) { return a < b; }, [](u64 a, u64 b) { return a <= b; }, | 87 | [](u64 a, u64 b) { return a < b; }, [](u64 a, u64 b) { return a <= b; }, |
| 88 | [](u64 a, u64 b) { return a == b; }, [](u64 a, u64 b) { return a != b; }, | 88 | [](u64 a, u64 b) { return a == b; }, [](u64 a, u64 b) { return a != b; }, |
| @@ -103,7 +103,7 @@ bool CheatList::EvaluateConditional(const Cheat& cheat) const { | |||
| 103 | const auto press_state = | 103 | const auto press_state = |
| 104 | applet_resource | 104 | applet_resource |
| 105 | ->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad) | 105 | ->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad) |
| 106 | .GetPressState(); | 106 | .GetAndResetPressState(); |
| 107 | return ((press_state & cheat.KeypadValue()) & KEYPAD_BITMASK) != 0; | 107 | return ((press_state & cheat.KeypadValue()) & KEYPAD_BITMASK) != 0; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| @@ -112,7 +112,7 @@ bool CheatList::EvaluateConditional(const Cheat& cheat) const { | |||
| 112 | const auto offset = | 112 | const auto offset = |
| 113 | cheat.memory_type == MemoryType::MainNSO ? main_region_begin : heap_region_begin; | 113 | cheat.memory_type == MemoryType::MainNSO ? main_region_begin : heap_region_begin; |
| 114 | ASSERT(static_cast<u8>(cheat.comparison_op.Value()) < 6); | 114 | ASSERT(static_cast<u8>(cheat.comparison_op.Value()) < 6); |
| 115 | const auto* function = comparison_functions[static_cast<u8>(cheat.comparison_op.Value())]; | 115 | auto* function = comparison_functions[static_cast<u8>(cheat.comparison_op.Value())]; |
| 116 | const auto addr = cheat.Address() + offset; | 116 | const auto addr = cheat.Address() + offset; |
| 117 | 117 | ||
| 118 | return function(reader(cheat.width, SanitizeAddress(addr)), cheat.ValueWidth(8)); | 118 | return function(reader(cheat.width, SanitizeAddress(addr)), cheat.ValueWidth(8)); |
| @@ -157,7 +157,7 @@ void CheatList::ProcessBlockPairs(const Block& block) { | |||
| 157 | void CheatList::WriteImmediate(const Cheat& cheat) { | 157 | void CheatList::WriteImmediate(const Cheat& cheat) { |
| 158 | const auto offset = | 158 | const auto offset = |
| 159 | cheat.memory_type == MemoryType::MainNSO ? main_region_begin : heap_region_begin; | 159 | cheat.memory_type == MemoryType::MainNSO ? main_region_begin : heap_region_begin; |
| 160 | auto& register_3 = scratch.at(cheat.register_3); | 160 | const auto& register_3 = scratch.at(cheat.register_3); |
| 161 | 161 | ||
| 162 | const auto addr = cheat.Address() + offset + register_3; | 162 | const auto addr = cheat.Address() + offset + register_3; |
| 163 | LOG_DEBUG(Common_Filesystem, "writing value={:016X} to addr={:016X}", addr, | 163 | LOG_DEBUG(Common_Filesystem, "writing value={:016X} to addr={:016X}", addr, |
| @@ -166,11 +166,13 @@ void CheatList::WriteImmediate(const Cheat& cheat) { | |||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | void CheatList::BeginConditional(const Cheat& cheat) { | 168 | void CheatList::BeginConditional(const Cheat& cheat) { |
| 169 | if (!EvaluateConditional(cheat)) { | 169 | if (EvaluateConditional(cheat)) { |
| 170 | const auto iter = block_pairs.find(current_index); | 170 | return; |
| 171 | ASSERT(iter != block_pairs.end()); | ||
| 172 | current_index = iter->second - 1; | ||
| 173 | } | 171 | } |
| 172 | |||
| 173 | const auto iter = block_pairs.find(current_index); | ||
| 174 | ASSERT(iter != block_pairs.end()); | ||
| 175 | current_index = iter->second - 1; | ||
| 174 | } | 176 | } |
| 175 | 177 | ||
| 176 | void CheatList::EndConditional(const Cheat& cheat) { | 178 | void CheatList::EndConditional(const Cheat& cheat) { |
| @@ -218,7 +220,7 @@ void CheatList::LoadIndexed(const Cheat& cheat) { | |||
| 218 | } | 220 | } |
| 219 | 221 | ||
| 220 | void CheatList::StoreIndexed(const Cheat& cheat) { | 222 | void CheatList::StoreIndexed(const Cheat& cheat) { |
| 221 | auto& register_3 = scratch.at(cheat.register_3); | 223 | const auto& register_3 = scratch.at(cheat.register_3); |
| 222 | 224 | ||
| 223 | const auto addr = | 225 | const auto addr = |
| 224 | register_3 + (cheat.add_additional_register.Value() ? scratch.at(cheat.register_6) : 0); | 226 | register_3 + (cheat.add_additional_register.Value() ? scratch.at(cheat.register_6) : 0); |
| @@ -229,14 +231,14 @@ void CheatList::StoreIndexed(const Cheat& cheat) { | |||
| 229 | 231 | ||
| 230 | void CheatList::RegisterArithmetic(const Cheat& cheat) { | 232 | void CheatList::RegisterArithmetic(const Cheat& cheat) { |
| 231 | using ArithmeticFunction = u64 (*)(u64, u64); | 233 | using ArithmeticFunction = u64 (*)(u64, u64); |
| 232 | constexpr ArithmeticFunction arithmetic_functions[] = { | 234 | constexpr std::array<ArithmeticFunction, 5> arithmetic_functions{ |
| 233 | [](u64 a, u64 b) { return a + b; }, [](u64 a, u64 b) { return a - b; }, | 235 | [](u64 a, u64 b) { return a + b; }, [](u64 a, u64 b) { return a - b; }, |
| 234 | [](u64 a, u64 b) { return a * b; }, [](u64 a, u64 b) { return a << b; }, | 236 | [](u64 a, u64 b) { return a * b; }, [](u64 a, u64 b) { return a << b; }, |
| 235 | [](u64 a, u64 b) { return a >> b; }, | 237 | [](u64 a, u64 b) { return a >> b; }, |
| 236 | }; | 238 | }; |
| 237 | 239 | ||
| 238 | using ArithmeticOverflowCheck = bool (*)(u64, u64); | 240 | using ArithmeticOverflowCheck = bool (*)(u64, u64); |
| 239 | constexpr ArithmeticOverflowCheck arithmetic_overflow_checks[] = { | 241 | constexpr std::array<ArithmeticOverflowCheck, 5> arithmetic_overflow_checks{ |
| 240 | [](u64 a, u64 b) { return a > (std::numeric_limits<u64>::max() - b); }, // a + b | 242 | [](u64 a, u64 b) { return a > (std::numeric_limits<u64>::max() - b); }, // a + b |
| 241 | [](u64 a, u64 b) { return a > (std::numeric_limits<u64>::max() + b); }, // a - b | 243 | [](u64 a, u64 b) { return a > (std::numeric_limits<u64>::max() + b); }, // a - b |
| 242 | [](u64 a, u64 b) { return a > (std::numeric_limits<u64>::max() / b); }, // a * b | 244 | [](u64 a, u64 b) { return a > (std::numeric_limits<u64>::max() / b); }, // a * b |
| @@ -250,8 +252,8 @@ void CheatList::RegisterArithmetic(const Cheat& cheat) { | |||
| 250 | auto& register_3 = scratch.at(cheat.register_3); | 252 | auto& register_3 = scratch.at(cheat.register_3); |
| 251 | 253 | ||
| 252 | ASSERT(static_cast<u8>(cheat.arithmetic_op.Value()) < 5); | 254 | ASSERT(static_cast<u8>(cheat.arithmetic_op.Value()) < 5); |
| 253 | const auto* function = arithmetic_functions[static_cast<u8>(cheat.arithmetic_op.Value())]; | 255 | auto* function = arithmetic_functions[static_cast<u8>(cheat.arithmetic_op.Value())]; |
| 254 | const auto* overflow_function = | 256 | auto* overflow_function = |
| 255 | arithmetic_overflow_checks[static_cast<u8>(cheat.arithmetic_op.Value())]; | 257 | arithmetic_overflow_checks[static_cast<u8>(cheat.arithmetic_op.Value())]; |
| 256 | LOG_DEBUG(Common_Filesystem, "performing arithmetic with register={:01X}, value={:016X}", | 258 | LOG_DEBUG(Common_Filesystem, "performing arithmetic with register={:01X}, value={:016X}", |
| 257 | cheat.register_3, cheat.ValueWidth(4)); | 259 | cheat.register_3, cheat.ValueWidth(4)); |
| @@ -267,11 +269,12 @@ void CheatList::RegisterArithmetic(const Cheat& cheat) { | |||
| 267 | } | 269 | } |
| 268 | 270 | ||
| 269 | void CheatList::BeginConditionalInput(const Cheat& cheat) { | 271 | void CheatList::BeginConditionalInput(const Cheat& cheat) { |
| 270 | if (!EvaluateConditional(cheat)) { | 272 | if (EvaluateConditional(cheat)) |
| 271 | const auto iter = block_pairs.find(current_index); | 273 | return; |
| 272 | ASSERT(iter != block_pairs.end()); | 274 | |
| 273 | current_index = iter->second - 1; | 275 | const auto iter = block_pairs.find(current_index); |
| 274 | } | 276 | ASSERT(iter != block_pairs.end()); |
| 277 | current_index = iter->second - 1; | ||
| 275 | } | 278 | } |
| 276 | 279 | ||
| 277 | VAddr CheatList::SanitizeAddress(VAddr in) const { | 280 | VAddr CheatList::SanitizeAddress(VAddr in) const { |
| @@ -290,7 +293,7 @@ VAddr CheatList::SanitizeAddress(VAddr in) const { | |||
| 290 | 293 | ||
| 291 | void CheatList::ExecuteSingleCheat(const Cheat& cheat) { | 294 | void CheatList::ExecuteSingleCheat(const Cheat& cheat) { |
| 292 | using CheatOperationFunction = void (CheatList::*)(const Cheat&); | 295 | using CheatOperationFunction = void (CheatList::*)(const Cheat&); |
| 293 | constexpr CheatOperationFunction cheat_operation_functions[] = { | 296 | constexpr std::array<CheatOperationFunction, 9> cheat_operation_functions{ |
| 294 | &CheatList::WriteImmediate, &CheatList::BeginConditional, | 297 | &CheatList::WriteImmediate, &CheatList::BeginConditional, |
| 295 | &CheatList::EndConditional, &CheatList::Loop, | 298 | &CheatList::EndConditional, &CheatList::Loop, |
| 296 | &CheatList::LoadImmediate, &CheatList::LoadIndexed, | 299 | &CheatList::LoadImmediate, &CheatList::LoadIndexed, |
| @@ -346,7 +349,7 @@ CheatList TextCheatParser::Parse(const std::vector<u8>& data) const { | |||
| 346 | if (!line.empty() && (line[0] == '[' || line[0] == '{')) { | 349 | if (!line.empty() && (line[0] == '[' || line[0] == '{')) { |
| 347 | const auto master = line[0] == '{'; | 350 | const auto master = line[0] == '{'; |
| 348 | const auto begin = master ? line.find('{') : line.find('['); | 351 | const auto begin = master ? line.find('{') : line.find('['); |
| 349 | const auto end = master ? line.find_last_of('}') : line.find_last_of(']'); | 352 | const auto end = master ? line.rfind('}') : line.rfind(']'); |
| 350 | 353 | ||
| 351 | ASSERT(begin != std::string::npos && end != std::string::npos); | 354 | ASSERT(begin != std::string::npos && end != std::string::npos); |
| 352 | 355 | ||
| @@ -422,7 +425,7 @@ std::array<u8, 16> TextCheatParser::ParseSingleLineCheat(const std::string& line | |||
| 422 | return out; | 425 | return out; |
| 423 | } | 426 | } |
| 424 | 427 | ||
| 425 | u64 MemoryReadImpl(u8 width, VAddr addr) { | 428 | u64 MemoryReadImpl(u32 width, VAddr addr) { |
| 426 | switch (width) { | 429 | switch (width) { |
| 427 | case 1: | 430 | case 1: |
| 428 | return Memory::Read8(addr); | 431 | return Memory::Read8(addr); |
| @@ -438,7 +441,7 @@ u64 MemoryReadImpl(u8 width, VAddr addr) { | |||
| 438 | } | 441 | } |
| 439 | } | 442 | } |
| 440 | 443 | ||
| 441 | void MemoryWriteImpl(u8 width, VAddr addr, u64 value) { | 444 | void MemoryWriteImpl(u32 width, VAddr addr, u64 value) { |
| 442 | switch (width) { | 445 | switch (width) { |
| 443 | case 1: | 446 | case 1: |
| 444 | Memory::Write8(addr, static_cast<u8>(value)); | 447 | Memory::Write8(addr, static_cast<u8>(value)); |
| @@ -457,31 +460,34 @@ void MemoryWriteImpl(u8 width, VAddr addr, u64 value) { | |||
| 457 | } | 460 | } |
| 458 | } | 461 | } |
| 459 | 462 | ||
| 460 | CheatEngine::CheatEngine(std::vector<CheatList> cheats, const std::string& build_id) | 463 | CheatEngine::CheatEngine(std::vector<CheatList> cheats, const std::string& build_id, |
| 464 | VAddr code_region_start, VAddr code_region_end) | ||
| 461 | : cheats(std::move(cheats)) { | 465 | : cheats(std::move(cheats)) { |
| 462 | event = CoreTiming::RegisterEvent( | 466 | auto& core_timing{Core::System::GetInstance().CoreTiming()}; |
| 467 | event = core_timing.RegisterEvent( | ||
| 463 | "CheatEngine::FrameCallback::" + build_id, | 468 | "CheatEngine::FrameCallback::" + build_id, |
| 464 | [this](u64 userdata, s64 cycles_late) { FrameCallback(userdata, cycles_late); }); | 469 | [this](u64 userdata, s64 cycles_late) { FrameCallback(userdata, cycles_late); }); |
| 465 | CoreTiming::ScheduleEvent(CHEAT_ENGINE_TICKS, event); | 470 | core_timing.ScheduleEvent(CHEAT_ENGINE_TICKS, event); |
| 466 | 471 | ||
| 467 | const auto& vm_manager = Core::System::GetInstance().CurrentProcess()->VMManager(); | 472 | const auto& vm_manager = Core::System::GetInstance().CurrentProcess()->VMManager(); |
| 468 | for (auto& list : this->cheats) { | 473 | for (auto& list : this->cheats) { |
| 469 | list.SetMemoryParameters( | 474 | list.SetMemoryParameters(code_region_start, vm_manager.GetHeapRegionBaseAddress(), |
| 470 | vm_manager.GetMainCodeRegionBaseAddress(), vm_manager.GetHeapRegionBaseAddress(), | 475 | code_region_end, vm_manager.GetHeapRegionEndAddress(), |
| 471 | vm_manager.GetMainCodeRegionEndAddress(), vm_manager.GetHeapRegionEndAddress(), | 476 | &MemoryWriteImpl, &MemoryReadImpl); |
| 472 | &MemoryWriteImpl, &MemoryReadImpl); | ||
| 473 | } | 477 | } |
| 474 | } | 478 | } |
| 475 | 479 | ||
| 476 | CheatEngine::~CheatEngine() { | 480 | CheatEngine::~CheatEngine() { |
| 477 | CoreTiming::UnscheduleEvent(event, 0); | 481 | auto& core_timing{Core::System::GetInstance().CoreTiming()}; |
| 482 | core_timing.UnscheduleEvent(event, 0); | ||
| 478 | } | 483 | } |
| 479 | 484 | ||
| 480 | void CheatEngine::FrameCallback(u64 userdata, int cycles_late) { | 485 | void CheatEngine::FrameCallback(u64 userdata, int cycles_late) { |
| 481 | for (auto& list : cheats) | 486 | for (auto& list : cheats) |
| 482 | list.Execute(); | 487 | list.Execute(); |
| 483 | 488 | ||
| 484 | CoreTiming::ScheduleEvent(CHEAT_ENGINE_TICKS - cycles_late, event); | 489 | auto& core_timing{Core::System::GetInstance().CoreTiming()}; |
| 490 | core_timing.ScheduleEvent(CHEAT_ENGINE_TICKS - cycles_late, event); | ||
| 485 | } | 491 | } |
| 486 | 492 | ||
| 487 | } // namespace FileSys | 493 | } // namespace FileSys |
diff --git a/src/core/file_sys/cheat_engine.h b/src/core/file_sys/cheat_engine.h index d7a8654b7..7ed69a2c8 100644 --- a/src/core/file_sys/cheat_engine.h +++ b/src/core/file_sys/cheat_engine.h | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #include "common/bit_field.h" | 11 | #include "common/bit_field.h" |
| 12 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | 13 | ||
| 14 | namespace CoreTiming { | 14 | namespace Core::Timing { |
| 15 | struct EventType; | 15 | struct EventType; |
| 16 | } | 16 | } |
| 17 | 17 | ||
| @@ -123,9 +123,9 @@ public: | |||
| 123 | using ProgramSegment = std::vector<std::pair<std::string, Block>>; | 123 | using ProgramSegment = std::vector<std::pair<std::string, Block>>; |
| 124 | 124 | ||
| 125 | // (width in bytes, address, value) | 125 | // (width in bytes, address, value) |
| 126 | using MemoryWriter = void (*)(u8, VAddr, u64); | 126 | using MemoryWriter = void (*)(u32, VAddr, u64); |
| 127 | // (width in bytes, address) -> value | 127 | // (width in bytes, address) -> value |
| 128 | using MemoryReader = u64 (*)(u8, VAddr); | 128 | using MemoryReader = u64 (*)(u32, VAddr); |
| 129 | 129 | ||
| 130 | void SetMemoryParameters(VAddr main_begin, VAddr heap_begin, VAddr main_end, VAddr heap_end, | 130 | void SetMemoryParameters(VAddr main_begin, VAddr heap_begin, VAddr main_end, VAddr heap_end, |
| 131 | MemoryWriter writer, MemoryReader reader); | 131 | MemoryWriter writer, MemoryReader reader); |
| @@ -212,13 +212,14 @@ private: | |||
| 212 | // Class that encapsulates a CheatList and manages its interaction with memory and CoreTiming | 212 | // Class that encapsulates a CheatList and manages its interaction with memory and CoreTiming |
| 213 | class CheatEngine final { | 213 | class CheatEngine final { |
| 214 | public: | 214 | public: |
| 215 | CheatEngine(std::vector<CheatList> cheats, const std::string& build_id); | 215 | CheatEngine(std::vector<CheatList> cheats, const std::string& build_id, VAddr code_region_start, |
| 216 | VAddr code_region_end); | ||
| 216 | ~CheatEngine(); | 217 | ~CheatEngine(); |
| 217 | 218 | ||
| 218 | private: | 219 | private: |
| 219 | void FrameCallback(u64 userdata, int cycles_late); | 220 | void FrameCallback(u64 userdata, int cycles_late); |
| 220 | 221 | ||
| 221 | CoreTiming::EventType* event; | 222 | Core::Timing::EventType* event; |
| 222 | 223 | ||
| 223 | std::vector<CheatList> cheats; | 224 | std::vector<CheatList> cheats; |
| 224 | }; | 225 | }; |
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 161a83660..10ad94aa6 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp | |||
| @@ -786,23 +786,6 @@ u64 VMManager::GetNewMapRegionSize() const { | |||
| 786 | return new_map_region_end - new_map_region_base; | 786 | return new_map_region_end - new_map_region_base; |
| 787 | } | 787 | } |
| 788 | 788 | ||
| 789 | void VMManager::SetMainCodeRegion(VAddr begin, VAddr end) { | ||
| 790 | main_code_region_base = begin; | ||
| 791 | main_code_region_end = end; | ||
| 792 | } | ||
| 793 | |||
| 794 | VAddr VMManager::GetMainCodeRegionBaseAddress() const { | ||
| 795 | return main_code_region_base; | ||
| 796 | } | ||
| 797 | |||
| 798 | VAddr VMManager::GetMainCodeRegionEndAddress() const { | ||
| 799 | return main_code_region_end; | ||
| 800 | } | ||
| 801 | |||
| 802 | u64 VMManager::GetMainCodeRegionSize() const { | ||
| 803 | return main_code_region_end - main_code_region_base; | ||
| 804 | } | ||
| 805 | |||
| 806 | VAddr VMManager::GetTLSIORegionBaseAddress() const { | 789 | VAddr VMManager::GetTLSIORegionBaseAddress() const { |
| 807 | return tls_io_region_base; | 790 | return tls_io_region_base; |
| 808 | } | 791 | } |
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 728318f4b..d83a63e07 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h | |||
| @@ -480,14 +480,6 @@ public: | |||
| 480 | /// Gets the total size of the new map region in bytes. | 480 | /// Gets the total size of the new map region in bytes. |
| 481 | u64 GetNewMapRegionSize() const; | 481 | u64 GetNewMapRegionSize() const; |
| 482 | 482 | ||
| 483 | void SetMainCodeRegion(VAddr begin, VAddr end); | ||
| 484 | |||
| 485 | VAddr GetMainCodeRegionBaseAddress() const; | ||
| 486 | |||
| 487 | VAddr GetMainCodeRegionEndAddress() const; | ||
| 488 | |||
| 489 | u64 GetMainCodeRegionSize() const; | ||
| 490 | |||
| 491 | /// Gets the base address of the TLS IO region. | 483 | /// Gets the base address of the TLS IO region. |
| 492 | VAddr GetTLSIORegionBaseAddress() const; | 484 | VAddr GetTLSIORegionBaseAddress() const; |
| 493 | 485 | ||
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index e39cd6b51..498602de5 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | |||
| 7 | #include "core/hle/service/hid/controllers/controller_base.h" | ||
| 6 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 7 | 9 | ||
| 8 | #include "controllers/controller_base.h" | 10 | #include "controllers/controller_base.h" |
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index ef9a577e3..07aa7a1cd 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp | |||
| @@ -147,10 +147,8 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process) | |||
| 147 | 147 | ||
| 148 | const VAddr load_addr = next_load_addr; | 148 | const VAddr load_addr = next_load_addr; |
| 149 | const bool should_pass_arguments = std::strcmp(module, "rtld") == 0; | 149 | const bool should_pass_arguments = std::strcmp(module, "rtld") == 0; |
| 150 | const bool should_register_data_segment = std::strcmp(module, "main") == 0; | ||
| 151 | const auto tentative_next_load_addr = | 150 | const auto tentative_next_load_addr = |
| 152 | AppLoader_NSO::LoadModule(process, *module_file, load_addr, should_pass_arguments, | 151 | AppLoader_NSO::LoadModule(process, *module_file, load_addr, should_pass_arguments, pm); |
| 153 | should_register_data_segment, pm); | ||
| 154 | if (!tentative_next_load_addr) { | 152 | if (!tentative_next_load_addr) { |
| 155 | return ResultStatus::ErrorLoadingNSO; | 153 | return ResultStatus::ErrorLoadingNSO; |
| 156 | } | 154 | } |
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 2721d85b1..5f6a6c0cf 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -97,7 +97,6 @@ static constexpr u32 PageAlignSize(u32 size) { | |||
| 97 | std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, | 97 | std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, |
| 98 | const FileSys::VfsFile& file, VAddr load_base, | 98 | const FileSys::VfsFile& file, VAddr load_base, |
| 99 | bool should_pass_arguments, | 99 | bool should_pass_arguments, |
| 100 | bool should_register_data_region, | ||
| 101 | std::optional<FileSys::PatchManager> pm) { | 100 | std::optional<FileSys::PatchManager> pm) { |
| 102 | if (file.GetSize() < sizeof(NsoHeader)) | 101 | if (file.GetSize() < sizeof(NsoHeader)) |
| 103 | return {}; | 102 | return {}; |
| @@ -156,10 +155,6 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, | |||
| 156 | const u32 image_size{PageAlignSize(static_cast<u32>(program_image.size()) + bss_size)}; | 155 | const u32 image_size{PageAlignSize(static_cast<u32>(program_image.size()) + bss_size)}; |
| 157 | program_image.resize(image_size); | 156 | program_image.resize(image_size); |
| 158 | 157 | ||
| 159 | if (should_register_data_region) { | ||
| 160 | process.VMManager().SetMainCodeRegion(load_base, load_base + program_image.size()); | ||
| 161 | } | ||
| 162 | |||
| 163 | // Apply patches if necessary | 158 | // Apply patches if necessary |
| 164 | if (pm && (pm->HasNSOPatch(nso_header.build_id) || Settings::values.dump_nso)) { | 159 | if (pm && (pm->HasNSOPatch(nso_header.build_id) || Settings::values.dump_nso)) { |
| 165 | std::vector<u8> pi_header(program_image.size() + 0x100); | 160 | std::vector<u8> pi_header(program_image.size() + 0x100); |
| @@ -176,7 +171,8 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process, | |||
| 176 | const auto cheats = pm->CreateCheatList(nso_header.build_id); | 171 | const auto cheats = pm->CreateCheatList(nso_header.build_id); |
| 177 | if (!cheats.empty()) { | 172 | if (!cheats.empty()) { |
| 178 | Core::System::GetInstance().RegisterCheatList( | 173 | Core::System::GetInstance().RegisterCheatList( |
| 179 | cheats, Common::HexArrayToString(nso_header.build_id)); | 174 | cheats, Common::HexArrayToString(nso_header.build_id), load_base, |
| 175 | load_base + program_image.size()); | ||
| 180 | } | 176 | } |
| 181 | } | 177 | } |
| 182 | 178 | ||
| @@ -197,7 +193,7 @@ ResultStatus AppLoader_NSO::Load(Kernel::Process& process) { | |||
| 197 | 193 | ||
| 198 | // Load module | 194 | // Load module |
| 199 | const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); | 195 | const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); |
| 200 | if (!LoadModule(process, *file, base_address, true, true)) { | 196 | if (!LoadModule(process, *file, base_address, true)) { |
| 201 | return ResultStatus::ErrorLoadingNSO; | 197 | return ResultStatus::ErrorLoadingNSO; |
| 202 | } | 198 | } |
| 203 | LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address); | 199 | LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address); |
diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h index 858e346c6..135b6ea5a 100644 --- a/src/core/loader/nso.h +++ b/src/core/loader/nso.h | |||
| @@ -43,7 +43,6 @@ public: | |||
| 43 | 43 | ||
| 44 | static std::optional<VAddr> LoadModule(Kernel::Process& process, const FileSys::VfsFile& file, | 44 | static std::optional<VAddr> LoadModule(Kernel::Process& process, const FileSys::VfsFile& file, |
| 45 | VAddr load_base, bool should_pass_arguments, | 45 | VAddr load_base, bool should_pass_arguments, |
| 46 | bool should_register_data_segment, | ||
| 47 | std::optional<FileSys::PatchManager> pm = {}); | 46 | std::optional<FileSys::PatchManager> pm = {}); |
| 48 | 47 | ||
| 49 | ResultStatus Load(Kernel::Process& process) override; | 48 | ResultStatus Load(Kernel::Process& process) override; |