2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:43:35 +00:00
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:30:24 +00:00
|
|
|
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2008-12-08 05:30:24 +00:00
|
|
|
#include <wx/button.h>
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/listbox.h>
|
|
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <wx/panel.h>
|
|
|
|
#include <wx/sizer.h>
|
2015-08-03 08:39:06 +00:00
|
|
|
#include <wx/srchctrl.h>
|
2014-02-19 01:56:29 +00:00
|
|
|
#include <wx/textctrl.h>
|
2013-02-28 04:37:38 +00:00
|
|
|
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/FileUtil.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "Common/IniFile.h"
|
|
|
|
#include "Common/StringUtil.h"
|
|
|
|
#include "Common/SymbolDB.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/Debugger/PPCDebugInterface.h"
|
|
|
|
#include "Core/HW/DSP.h"
|
|
|
|
#include "Core/HW/Memmap.h"
|
|
|
|
#include "Core/PowerPC/PowerPC.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "DolphinWX/Debugger/MemoryView.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/Debugger/MemoryWindow.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/Globals.h"
|
|
|
|
#include "DolphinWX/WxUtils.h"
|
2008-12-08 05:30:24 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
IDM_MEM_ADDRBOX,
|
|
|
|
IDM_SYMBOLLIST,
|
|
|
|
IDM_SETVALBUTTON,
|
|
|
|
IDM_DUMP_MEMORY,
|
|
|
|
IDM_DUMP_MEM2,
|
|
|
|
IDM_DUMP_FAKEVMEM,
|
|
|
|
IDM_VALBOX,
|
|
|
|
IDM_U8,
|
|
|
|
IDM_U16,
|
|
|
|
IDM_U32,
|
|
|
|
IDM_SEARCH,
|
|
|
|
IDM_ASCII,
|
|
|
|
IDM_HEX
|
2008-12-08 05:30:24 +00:00
|
|
|
};
|
|
|
|
|
2009-09-07 20:51:02 +00:00
|
|
|
BEGIN_EVENT_TABLE(CMemoryWindow, wxPanel)
|
2016-06-24 08:43:46 +00:00
|
|
|
EVT_LISTBOX(IDM_SYMBOLLIST, CMemoryWindow::OnSymbolListChange)
|
|
|
|
EVT_HOST_COMMAND(wxID_ANY, CMemoryWindow::OnHostMessage)
|
|
|
|
EVT_BUTTON(IDM_SETVALBUTTON, CMemoryWindow::SetMemoryValue)
|
|
|
|
EVT_BUTTON(IDM_DUMP_MEMORY, CMemoryWindow::OnDumpMemory)
|
|
|
|
EVT_BUTTON(IDM_DUMP_MEM2, CMemoryWindow::OnDumpMem2)
|
|
|
|
EVT_BUTTON(IDM_DUMP_FAKEVMEM, CMemoryWindow::OnDumpFakeVMEM)
|
|
|
|
EVT_CHECKBOX(IDM_U8, CMemoryWindow::U8)
|
|
|
|
EVT_CHECKBOX(IDM_U16, CMemoryWindow::U16)
|
|
|
|
EVT_CHECKBOX(IDM_U32, CMemoryWindow::U32)
|
|
|
|
EVT_BUTTON(IDM_SEARCH, CMemoryWindow::onSearch)
|
|
|
|
EVT_CHECKBOX(IDM_ASCII, CMemoryWindow::onAscii)
|
|
|
|
EVT_CHECKBOX(IDM_HEX, CMemoryWindow::onHex)
|
2008-12-08 05:30:24 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos,
|
|
|
|
const wxSize& size, long style, const wxString& name)
|
|
|
|
: wxPanel(parent, id, pos, size, style, name)
|
2010-07-24 02:36:22 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
DebugInterface* di = &PowerPC::debug_interface;
|
|
|
|
|
|
|
|
memview = new CMemoryView(di, this);
|
|
|
|
|
|
|
|
addrbox = new wxSearchCtrl(this, IDM_MEM_ADDRBOX);
|
|
|
|
addrbox->Bind(wxEVT_TEXT, &CMemoryWindow::OnAddrBoxChange, this);
|
|
|
|
addrbox->SetDescriptiveText(_("Search Address"));
|
|
|
|
|
|
|
|
valbox =
|
|
|
|
new wxTextCtrl(this, IDM_VALBOX, "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
|
|
|
|
valbox->Bind(wxEVT_TEXT_ENTER, &CMemoryWindow::SetMemoryValueFromValBox, this);
|
|
|
|
|
|
|
|
wxGridSizer* const search_sizer = new wxGridSizer(1);
|
|
|
|
search_sizer->Add(addrbox);
|
|
|
|
search_sizer->Add(valbox, 0, wxEXPAND);
|
|
|
|
search_sizer->Add(new wxButton(this, IDM_SETVALBUTTON, _("Set Value")));
|
|
|
|
|
|
|
|
wxGridSizer* const dump_sizer = new wxGridSizer(1);
|
|
|
|
dump_sizer->Add(new wxButton(this, IDM_DUMP_MEMORY, _("Dump MRAM")), 0, wxEXPAND);
|
|
|
|
dump_sizer->Add(new wxButton(this, IDM_DUMP_MEM2, _("Dump EXRAM")), 0, wxEXPAND);
|
|
|
|
if (!SConfig::GetInstance().bMMU)
|
|
|
|
dump_sizer->Add(new wxButton(this, IDM_DUMP_FAKEVMEM, _("Dump FakeVMEM")), 0, wxEXPAND);
|
|
|
|
|
|
|
|
wxStaticBoxSizer* const sizerSearchType = new wxStaticBoxSizer(wxVERTICAL, this, _("Search"));
|
|
|
|
sizerSearchType->Add(btnSearch = new wxButton(this, IDM_SEARCH, _("Search")));
|
|
|
|
sizerSearchType->Add(chkAscii = new wxCheckBox(this, IDM_ASCII, "Ascii "));
|
|
|
|
sizerSearchType->Add(chkHex = new wxCheckBox(this, IDM_HEX, _("Hex")));
|
|
|
|
|
|
|
|
wxStaticBoxSizer* const sizerDataTypes = new wxStaticBoxSizer(wxVERTICAL, this, _("Data Type"));
|
|
|
|
sizerDataTypes->SetMinSize(74, 40);
|
|
|
|
sizerDataTypes->Add(chk8 = new wxCheckBox(this, IDM_U8, "U8"));
|
|
|
|
sizerDataTypes->Add(chk16 = new wxCheckBox(this, IDM_U16, "U16"));
|
|
|
|
sizerDataTypes->Add(chk32 = new wxCheckBox(this, IDM_U32, "U32"));
|
|
|
|
|
|
|
|
wxBoxSizer* const sizerRight = new wxBoxSizer(wxVERTICAL);
|
|
|
|
sizerRight->Add(search_sizer);
|
|
|
|
sizerRight->AddSpacer(5);
|
|
|
|
sizerRight->Add(dump_sizer);
|
|
|
|
sizerRight->Add(sizerSearchType);
|
|
|
|
sizerRight->Add(sizerDataTypes);
|
|
|
|
|
|
|
|
wxBoxSizer* const sizerBig = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
sizerBig->Add(memview, 20, wxEXPAND);
|
|
|
|
sizerBig->Add(sizerRight, 0, wxEXPAND | wxALL, 3);
|
|
|
|
|
|
|
|
SetSizer(sizerBig);
|
|
|
|
chkHex->SetValue(1); // Set defaults
|
|
|
|
chk8->SetValue(1);
|
|
|
|
|
|
|
|
sizerRight->Fit(this);
|
|
|
|
sizerBig->Fit(this);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2014-06-16 05:12:43 +00:00
|
|
|
void CMemoryWindow::Save(IniFile& ini) const
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
// Prevent these bad values that can happen after a crash or hanging
|
|
|
|
if (GetPosition().x != -32000 && GetPosition().y != -32000)
|
|
|
|
{
|
|
|
|
IniFile::Section* mem_window = ini.GetOrCreateSection("MemoryWindow");
|
|
|
|
mem_window->Set("x", GetPosition().x);
|
|
|
|
mem_window->Set("y", GetPosition().y);
|
|
|
|
mem_window->Set("w", GetSize().GetWidth());
|
|
|
|
mem_window->Set("h", GetSize().GetHeight());
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2014-06-16 05:12:43 +00:00
|
|
|
void CMemoryWindow::Load(IniFile& ini)
|
2008-12-08 05:30:24 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
int x, y, w, h;
|
2014-06-16 05:12:43 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
IniFile::Section* mem_window = ini.GetOrCreateSection("MemoryWindow");
|
|
|
|
mem_window->Get("x", &x, GetPosition().x);
|
|
|
|
mem_window->Get("y", &y, GetPosition().y);
|
|
|
|
mem_window->Get("w", &w, GetSize().GetWidth());
|
|
|
|
mem_window->Get("h", &h, GetSize().GetHeight());
|
2014-06-16 05:12:43 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
SetSize(x, y, w, h);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryWindow::JumpToAddress(u32 _Address)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
memview->Center(_Address);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2015-04-25 02:19:21 +00:00
|
|
|
void CMemoryWindow::SetMemoryValueFromValBox(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
SetMemoryValue(event);
|
|
|
|
valbox->SetFocus();
|
2015-04-25 02:19:21 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void CMemoryWindow::SetMemoryValue(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
if (!Memory::IsInitialized())
|
|
|
|
{
|
|
|
|
WxUtils::ShowErrorDialog(_("Cannot set uninitialized memory."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string str_addr = WxStrToStr(addrbox->GetValue());
|
|
|
|
std::string str_val = WxStrToStr(valbox->GetValue());
|
|
|
|
u32 addr;
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
if (!TryParse(std::string("0x") + str_addr, &addr))
|
|
|
|
{
|
|
|
|
WxUtils::ShowErrorDialog(wxString::Format(_("Invalid address: %s"), str_addr.c_str()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!TryParse(std::string("0x") + str_val, &val))
|
|
|
|
{
|
|
|
|
WxUtils::ShowErrorDialog(wxString::Format(_("Invalid value: %s"), str_val.c_str()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PowerPC::HostWrite_U32(val, addr);
|
|
|
|
memview->Refresh();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2009-06-17 19:50:59 +00:00
|
|
|
|
2008-12-08 05:30:24 +00:00
|
|
|
void CMemoryWindow::OnAddrBoxChange(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
wxString txt = addrbox->GetValue();
|
|
|
|
if (txt.size())
|
|
|
|
{
|
|
|
|
u32 addr;
|
|
|
|
sscanf(WxStrToStr(txt).c_str(), "%08x", &addr);
|
|
|
|
memview->Center(addr & ~3);
|
|
|
|
}
|
|
|
|
|
|
|
|
event.Skip();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryWindow::Update()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
memview->Refresh();
|
|
|
|
memview->Center(PC);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryWindow::NotifyMapLoaded()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
symbols->Show(false); // hide it for faster filling
|
|
|
|
symbols->Clear();
|
2010-07-24 02:36:22 +00:00
|
|
|
#if 0
|
2016-06-24 08:43:46 +00:00
|
|
|
#ifdef _WIN32
|
2008-12-08 05:30:24 +00:00
|
|
|
const FunctionDB::XFuncMap &syms = g_symbolDB.Symbols();
|
|
|
|
for (FuntionDB::XFuncMap::iterator iter = syms.begin(); iter != syms.end(); ++iter)
|
|
|
|
{
|
2010-01-16 19:01:00 +00:00
|
|
|
int idx = symbols->Append(iter->second.name.c_str());
|
|
|
|
symbols->SetClientData(idx, (void*)&iter->second);
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
2010-07-24 02:36:22 +00:00
|
|
|
#endif
|
2016-06-24 08:43:46 +00:00
|
|
|
#endif
|
|
|
|
symbols->Show(true);
|
|
|
|
Update();
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryWindow::OnSymbolListChange(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
int index = symbols->GetSelection();
|
|
|
|
if (index >= 0)
|
|
|
|
{
|
|
|
|
Symbol* pSymbol = static_cast<Symbol*>(symbols->GetClientData(index));
|
|
|
|
if (pSymbol != nullptr)
|
|
|
|
{
|
|
|
|
memview->Center(pSymbol->address);
|
|
|
|
}
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryWindow::OnHostMessage(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
switch (event.GetId())
|
|
|
|
{
|
|
|
|
case IDM_NOTIFY_MAP_LOADED:
|
|
|
|
NotifyMapLoaded();
|
|
|
|
break;
|
|
|
|
}
|
2008-12-08 05:30:24 +00:00
|
|
|
}
|
|
|
|
|
2014-07-08 12:29:26 +00:00
|
|
|
static void DumpArray(const std::string& filename, const u8* data, size_t length)
|
2009-01-21 17:02:01 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
if (data)
|
|
|
|
{
|
|
|
|
File::IOFile f(filename, "wb");
|
|
|
|
f.WriteBytes(data, length);
|
|
|
|
}
|
2010-10-14 04:07:04 +00:00
|
|
|
}
|
|
|
|
|
2011-03-11 10:21:46 +00:00
|
|
|
// Write mram to file
|
2016-06-24 08:43:46 +00:00
|
|
|
void CMemoryWindow::OnDumpMemory(wxCommandEvent& event)
|
2011-03-11 10:21:46 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
DumpArray(File::GetUserPath(F_RAMDUMP_IDX), Memory::m_pRAM, Memory::REALRAM_SIZE);
|
2011-03-11 10:21:46 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 04:07:04 +00:00
|
|
|
// Write exram (aram or mem2) to file
|
2016-06-24 08:43:46 +00:00
|
|
|
void CMemoryWindow::OnDumpMem2(wxCommandEvent& event)
|
2013-10-29 05:23:17 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
if (SConfig::GetInstance().bWii)
|
|
|
|
{
|
|
|
|
DumpArray(File::GetUserPath(F_ARAMDUMP_IDX), Memory::m_pEXRAM, Memory::EXRAM_SIZE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DumpArray(File::GetUserPath(F_ARAMDUMP_IDX), DSP::GetARAMPtr(), DSP::ARAM_SIZE);
|
|
|
|
}
|
2009-06-30 21:11:39 +00:00
|
|
|
}
|
2009-11-25 10:07:56 +00:00
|
|
|
|
2012-06-19 11:51:29 +00:00
|
|
|
// Write fake vmem to file
|
2016-06-24 08:43:46 +00:00
|
|
|
void CMemoryWindow::OnDumpFakeVMEM(wxCommandEvent& event)
|
2012-06-19 11:51:29 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
DumpArray(File::GetUserPath(F_FAKEVMEMDUMP_IDX), Memory::m_pFakeVMEM, Memory::FAKEVMEM_SIZE);
|
2012-06-19 11:51:29 +00:00
|
|
|
}
|
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
void CMemoryWindow::U8(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
chk16->SetValue(0);
|
|
|
|
chk32->SetValue(0);
|
|
|
|
memview->SetDataType(MemoryDataType::U8);
|
2009-11-25 10:07:56 +00:00
|
|
|
}
|
2010-07-24 02:36:22 +00:00
|
|
|
|
|
|
|
void CMemoryWindow::U16(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
chk8->SetValue(0);
|
|
|
|
chk32->SetValue(0);
|
|
|
|
memview->SetDataType(MemoryDataType::U16);
|
2009-11-25 10:07:56 +00:00
|
|
|
}
|
2010-07-24 02:36:22 +00:00
|
|
|
|
|
|
|
void CMemoryWindow::U32(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
chk16->SetValue(0);
|
|
|
|
chk8->SetValue(0);
|
|
|
|
memview->SetDataType(MemoryDataType::U32);
|
2009-11-25 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
void CMemoryWindow::onSearch(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
u8* TheRAM = nullptr;
|
|
|
|
u32 szRAM = 0;
|
|
|
|
switch (memview->GetMemoryType())
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
if (Memory::m_pRAM)
|
|
|
|
{
|
|
|
|
TheRAM = Memory::m_pRAM;
|
|
|
|
szRAM = Memory::REALRAM_SIZE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
u8* aram = DSP::GetARAMPtr();
|
|
|
|
if (aram)
|
|
|
|
{
|
|
|
|
TheRAM = aram;
|
|
|
|
szRAM = DSP::ARAM_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Now we have memory to look in
|
|
|
|
// Are we looking for ASCII string, or hex?
|
|
|
|
// memview->cu
|
|
|
|
wxString rawData = valbox->GetValue();
|
|
|
|
std::vector<u8> Dest; // May need a better name
|
|
|
|
u32 size = 0;
|
|
|
|
int pad = rawData.size() % 2; // If it's uneven
|
|
|
|
unsigned int i = 0;
|
|
|
|
long count = 0;
|
|
|
|
char copy[3] = {0};
|
|
|
|
long newsize = 0;
|
|
|
|
unsigned char* tmp2 = nullptr;
|
|
|
|
char* tmpstr = nullptr;
|
|
|
|
|
|
|
|
if (chkHex->GetValue())
|
|
|
|
{
|
|
|
|
// We are looking for hex
|
|
|
|
// If it's uneven
|
|
|
|
size = (rawData.size() / 2) + pad;
|
|
|
|
Dest.resize(size + 32);
|
|
|
|
newsize = rawData.size();
|
|
|
|
|
|
|
|
if (pad)
|
|
|
|
{
|
|
|
|
tmpstr = new char[newsize + 2];
|
|
|
|
memset(tmpstr, 0, newsize + 2);
|
|
|
|
tmpstr[0] = '0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmpstr = new char[newsize + 1];
|
|
|
|
memset(tmpstr, 0, newsize + 1);
|
|
|
|
}
|
|
|
|
strcat(tmpstr, WxStrToStr(rawData).c_str());
|
|
|
|
tmp2 = &Dest.front();
|
|
|
|
count = 0;
|
|
|
|
for (i = 0; i < strlen(tmpstr); i++)
|
|
|
|
{
|
|
|
|
copy[0] = tmpstr[i];
|
|
|
|
copy[1] = tmpstr[i + 1];
|
|
|
|
copy[2] = 0;
|
|
|
|
int tmpint;
|
|
|
|
sscanf(copy, "%02x", &tmpint);
|
|
|
|
tmp2[count++] = tmpint;
|
|
|
|
// Dest[count] should now be the hex of what the two chars were!
|
|
|
|
// Also should add a check to make sure it's A-F only
|
|
|
|
// sscanf(copy, "%02x", &tmp2[count++]);
|
|
|
|
i += 1;
|
|
|
|
}
|
|
|
|
delete[] tmpstr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Looking for an ascii string
|
|
|
|
size = rawData.size();
|
|
|
|
Dest.resize(size + 1);
|
|
|
|
tmpstr = new char[size + 1];
|
|
|
|
|
|
|
|
tmp2 = &Dest.front();
|
|
|
|
sprintf(tmpstr, "%s", WxStrToStr(rawData).c_str());
|
|
|
|
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
tmp2[i] = tmpstr[i];
|
|
|
|
|
|
|
|
delete[] tmpstr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size)
|
|
|
|
{
|
|
|
|
unsigned char* pnt = &Dest.front();
|
|
|
|
unsigned int k = 0;
|
|
|
|
// grab
|
|
|
|
wxString txt = addrbox->GetValue();
|
|
|
|
u32 addr = 0;
|
|
|
|
if (txt.size())
|
|
|
|
{
|
|
|
|
sscanf(WxStrToStr(txt).c_str(), "%08x", &addr);
|
|
|
|
}
|
|
|
|
i = addr + 4;
|
|
|
|
for (; i < szRAM; ++i)
|
|
|
|
{
|
|
|
|
for (k = 0; k < size; ++k)
|
|
|
|
{
|
|
|
|
if (i + k > szRAM)
|
|
|
|
break;
|
|
|
|
if (k > size)
|
|
|
|
break;
|
|
|
|
if (pnt[k] != TheRAM[i + k])
|
|
|
|
{
|
|
|
|
k = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (k == size)
|
|
|
|
{
|
|
|
|
// Match was found
|
|
|
|
wxMessageBox(_("A match was found. Placing viewer at the offset."));
|
|
|
|
addrbox->SetValue(wxString::Format("%08x", i));
|
|
|
|
// memview->curAddress = i;
|
|
|
|
// memview->Refresh();
|
|
|
|
OnAddrBoxChange(event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wxMessageBox(_("No match was found."));
|
|
|
|
}
|
2009-11-25 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
void CMemoryWindow::onAscii(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
chkHex->SetValue(0);
|
2009-11-25 10:07:56 +00:00
|
|
|
}
|
|
|
|
|
2010-07-24 02:36:22 +00:00
|
|
|
void CMemoryWindow::onHex(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
chkAscii->SetValue(0);
|
2009-12-15 14:40:03 +00:00
|
|
|
}
|