diff --git a/rpcs3/rpcs3qt/memory_string_searcher.cpp b/rpcs3/rpcs3qt/memory_string_searcher.cpp index 48fb3436c8..fc56509a12 100644 --- a/rpcs3/rpcs3qt/memory_string_searcher.cpp +++ b/rpcs3/rpcs3qt/memory_string_searcher.cpp @@ -12,6 +12,7 @@ #include #include +#include #include "util/logs.hpp" #include "util/sysinfo.hpp" @@ -40,7 +41,9 @@ void fmt_class_string::format(std::string& out, u64 arg) case as_f64: return "Double"; case as_f32: return "Float"; case as_inst: return "Instruction"; + case as_regex_inst: return "Regex-Instruction"; case as_fake_spu_inst: return "SPU Instruction"; + case as_regex_fake_spu_inst: return "SPU Regex-Instruction"; default: return ""; } }(); @@ -82,7 +85,9 @@ u64 memory_viewer_panel::OnSearch(std::string wstr, u32 mode) { case as_inst: case as_string: + case as_regex_inst: case as_fake_spu_inst: + case as_regex_fake_spu_inst: { case_insensitive = m_chkbox_case_insensitive->isChecked(); @@ -105,7 +110,7 @@ u64 memory_viewer_panel::OnSearch(std::string wstr, u32 mode) { if (part.size() % 2) { - gui_log.warning("Padding string part with '0' at front due to odd hexadeciaml characters count."); + gui_log.warning("Padding string part with '0' at front due to odd hexadecimal characters count."); part.insert(part.begin(), '0'); } } @@ -187,7 +192,7 @@ u64 memory_viewer_panel::OnSearch(std::string wstr, u32 mode) const named_thread_group workers("Memory Searcher "sv, max_threads, [&]() { - if (mode == as_inst || mode == as_fake_spu_inst) + if (mode == as_inst || mode == as_fake_spu_inst || mode == as_regex_inst || mode == as_regex_fake_spu_inst) { auto disasm = m_disasm->copy_type_erased(); disasm->change_mode(cpu_disasm_mode::normal); @@ -260,7 +265,9 @@ u64 memory_viewer_panel::OnSearch(std::string wstr, u32 mode) std::transform(last.begin(), last.end(), last.begin(), ::tolower); } - if (last.find(wstr) != umax) + std::smatch sm; + + if (mode & (as_regex_inst | as_regex_fake_spu_inst) ? std::regex_search(last, sm, std::regex(wstr)) : last.find(wstr) != umax) { gui_log.success("Found instruction at 0x%08x: '%s'", addr + i, last); found++; diff --git a/rpcs3/rpcs3qt/memory_viewer_panel.cpp b/rpcs3/rpcs3qt/memory_viewer_panel.cpp index cd0f178813..07a7ff9bd2 100644 --- a/rpcs3/rpcs3qt/memory_viewer_panel.cpp +++ b/rpcs3/rpcs3qt/memory_viewer_panel.cpp @@ -304,16 +304,19 @@ memory_viewer_panel::memory_viewer_panel(QWidget* parent, std::shared_ptraddItem(tr("Double"), QVariant::fromValue(+as_f64)); m_cbox_input_mode->addItem(tr("Float"), QVariant::fromValue(+as_f32)); m_cbox_input_mode->addItem(tr("Instruction"), QVariant::fromValue(+as_inst)); + m_cbox_input_mode->addItem(tr("RegEx Instruction"), QVariant::fromValue(+as_regex_inst)); QString tooltip = tr("String: search the memory for the specified string." "\nHEX bytes/integer: search the memory for hexadecimal values. Spaces, commas, \"0x\", \"0X\", \"\\x\", \"h\", \"H\" ensure separation of bytes but they are not mandatory." "\nDouble: reinterpret the string as 64-bit precision floating point value. Values are searched for exact representation, meaning -0 != 0." "\nFloat: reinterpret the string as 32-bit precision floating point value. Values are searched for exact representation, meaning -0 != 0." - "\nInstruction: search an instruction contains the text of the string."); + "\nInstruction: search an instruction contains the text of the string." + "\nRegEx: search an instruction containing text that matches the regular expression input."); if (m_size != 0x40000/*SPU_LS_SIZE*/) { m_cbox_input_mode->addItem("SPU Instruction", QVariant::fromValue(+as_fake_spu_inst)); + m_cbox_input_mode->addItem(tr("SPU RegEx-Instruction"), QVariant::fromValue(+as_regex_fake_spu_inst)); tooltip.append(tr("\nSPU Instruction: Search an SPU instruction contains the text of the string. For searching instructions within embedded SPU images.\nTip: SPU floats are commented along forming instructions.")); } diff --git a/rpcs3/rpcs3qt/memory_viewer_panel.h b/rpcs3/rpcs3qt/memory_viewer_panel.h index 4398c77dc9..4462875868 100644 --- a/rpcs3/rpcs3qt/memory_viewer_panel.h +++ b/rpcs3/rpcs3qt/memory_viewer_panel.h @@ -40,8 +40,10 @@ enum search_mode : unsigned as_f64 = 16, as_f32 = 32, as_inst = 64, - as_fake_spu_inst = 128, - search_mode_last = 256, + as_regex_inst = 128, + as_fake_spu_inst = 256, + as_regex_fake_spu_inst = 512, + search_mode_last = 1024, }; class memory_viewer_panel final : public QDialog