1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-23 03:02:53 +01:00

Add a memory ASCII string search

This commit is contained in:
darkf 2014-12-24 20:39:57 -08:00
parent 31aef6460d
commit a94a7d4495
6 changed files with 109 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "Gui/KernelExplorer.h"
#include "Gui/MemoryViewer.h"
#include "Gui/RSXDebugger.h"
#include "Gui/MemoryStringSearcher.h"
#include "Gui/LLEModulesManager.h"
#include <wx/dynlib.h>
@ -51,6 +52,7 @@ enum IDs
id_tools_kernel_explorer,
id_tools_memory_viewer,
id_tools_rsx_debugger,
id_tools_string_search,
id_help_about,
id_update_dbg,
};
@ -112,6 +114,7 @@ MainFrame::MainFrame()
menu_tools->Append(id_tools_kernel_explorer, "&Kernel Explorer")->Enable(false);
menu_tools->Append(id_tools_memory_viewer, "&Memory Viewer")->Enable(false);
menu_tools->Append(id_tools_rsx_debugger, "&RSX Debugger")->Enable(false);
menu_tools->Append(id_tools_string_search, "&String Search")->Enable(false);
wxMenu* menu_help = new wxMenu();
menubar->Append(menu_help, "&Help");
@ -151,6 +154,7 @@ MainFrame::MainFrame()
Bind(wxEVT_MENU, &MainFrame::OpenKernelExplorer, this, id_tools_kernel_explorer);
Bind(wxEVT_MENU, &MainFrame::OpenMemoryViewer, this, id_tools_memory_viewer);
Bind(wxEVT_MENU, &MainFrame::OpenRSXDebugger, this, id_tools_rsx_debugger);
Bind(wxEVT_MENU, &MainFrame::OpenStringSearch, this, id_tools_string_search);
Bind(wxEVT_MENU, &MainFrame::AboutDialogHandler, this, id_help_about);
@ -720,6 +724,10 @@ void MainFrame::OpenRSXDebugger(wxCommandEvent& WXUNUSED(event))
(new RSXDebugger(this)) -> Show();
}
void MainFrame::OpenStringSearch(wxCommandEvent& WXUNUSED(event))
{
(new MemoryStringSearcher(this)) -> Show();
}
void MainFrame::AboutDialogHandler(wxCommandEvent& WXUNUSED(event))
{
@ -818,9 +826,12 @@ void MainFrame::UpdateUI(wxCommandEvent& event)
wxMenuItem& kernel_explorer = *menubar.FindItem(id_tools_kernel_explorer);
wxMenuItem& memory_viewer = *menubar.FindItem(id_tools_memory_viewer);
wxMenuItem& rsx_debugger = *menubar.FindItem(id_tools_rsx_debugger);
wxMenuItem& string_search = *menubar.FindItem(id_tools_string_search);
kernel_explorer.Enable(!is_stopped);
memory_viewer.Enable(!is_stopped);
rsx_debugger.Enable(!is_stopped);
string_search.Enable(!is_stopped);
//m_aui_mgr.Update();

View File

@ -45,6 +45,7 @@ private:
void OpenKernelExplorer(wxCommandEvent& evt);
void OpenMemoryViewer(wxCommandEvent& evt);
void OpenRSXDebugger(wxCommandEvent& evt);
void OpenStringSearch(wxCommandEvent& evt);
void OpenFnIdGenerator(wxCommandEvent& evt);
void AboutDialogHandler(wxCommandEvent& event);
void UpdateUI(wxCommandEvent& event);

View File

@ -0,0 +1,74 @@
#include "stdafx_gui.h"
#include "rpcs3/Ini.h"
#include "Utilities/rPlatform.h"
#include "Utilities/Log.h"
#include "Emu/Memory/Memory.h"
#include "Emu/System.h"
#include "MemoryStringSearcher.h"
#include "Emu/RSX/sysutil_video.h"
#include "Emu/RSX/GSManager.h"
//#include "Emu/RSX/GCM.h"
#include <wx/notebook.h>
MemoryStringSearcher::MemoryStringSearcher(wxWindow* parent)
: wxFrame(parent, wxID_ANY, "String Searcher", wxDefaultPosition, wxSize(545, 64))
, exit(false)
{
this->SetBackgroundColour(wxColour(240,240,240));
//wxBoxSizer* s_panel = new wxBoxSizer(wxHORIZONTAL);
//Tools
//wxBoxSizer* s_tools = new wxBoxSizer(wxVERTICAL);
//Tabs
//wxNotebook* nb_rsx = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxSize(482,475));
s_panel = new wxBoxSizer(wxHORIZONTAL);
t_addr = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(482, -1));
b_search = new wxButton(this, wxID_ANY, "Search", wxPoint(482, 0), wxSize(40, -1));
b_search->Bind(wxEVT_BUTTON, &MemoryStringSearcher::Search, this);
s_panel->Add(t_addr);
s_panel->Add(b_search);
};
void MemoryStringSearcher::Search(wxCommandEvent& event)
{
const wxString wstr = t_addr->GetValue();
const char *str = wstr.c_str();
const u32 len = wstr.length();
LOG_NOTICE(GENERAL, "Searching for string %s", str);
// Search the address space for the string
u32 strIndex = 0;
u32 numFound = 0;
for (u32 addr = Memory.MainMem.GetStartAddr(); addr < Memory.MainMem.GetEndAddr(); addr++) {
if (!Memory.IsGoodAddr(addr)) {
strIndex = 0;
continue;
}
u8 byte = vm::read8(addr);
if (byte == str[strIndex]) {
if (strIndex == len) {
// Found it
LOG_NOTICE(GENERAL, "Found @ %04x", addr - len);
numFound++;
strIndex = 0;
continue;
}
strIndex++;
}
else
strIndex = 0;
if (addr % (1024 * 1024 * 64) == 0) { // Log every 64mb
LOG_NOTICE(GENERAL, "Searching %04x ...", addr);
}
}
LOG_NOTICE(GENERAL, "Search completed (found %d matches)", numFound);
}

View File

@ -0,0 +1,19 @@
#pragma once
#include <wx/listctrl.h>
class MemoryStringSearcher : public wxFrame
{
wxTextCtrl* t_addr;
wxBoxSizer* s_panel;
wxButton* b_search;
public:
bool exit;
MemoryStringSearcher(wxWindow* parent);
~MemoryStringSearcher()
{
exit = true;
}
void MemoryStringSearcher::Search(wxCommandEvent& event);
};

View File

@ -175,6 +175,7 @@
<ClCompile Include="Gui\KernelExplorer.cpp" />
<ClCompile Include="Gui\LLEModulesManager.cpp" />
<ClCompile Include="Gui\MainFrame.cpp" />
<ClCompile Include="Gui\MemoryStringSearcher.cpp" />
<ClCompile Include="Gui\MemoryViewer.cpp" />
<ClCompile Include="Gui\MsgDialog.cpp" />
<ClCompile Include="Gui\PADManager.cpp" />

View File

@ -93,6 +93,9 @@
<ClCompile Include="Gui\LLEModulesManager.cpp">
<Filter>Gui</Filter>
</ClCompile>
<ClCompile Include="Gui\MemoryStringSearcher.cpp">
<Filter>Gui</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="rpcs3.rc" />