2006-06-15 04:19:30 +00:00
|
|
|
#include <stdio.h>
|
2006-12-26 21:53:04 +00:00
|
|
|
#include <boost/bind.hpp>
|
2006-06-15 04:19:30 +00:00
|
|
|
#include "MemoryViewMIPS.h"
|
|
|
|
#include "win32/InputBox.h"
|
2013-02-05 03:40:59 +00:00
|
|
|
#include "lexical_cast_ex.h"
|
2010-10-22 01:46:24 +00:00
|
|
|
#include "DebugExpressionEvaluator.h"
|
|
|
|
#include "string_cast.h"
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2013-02-05 03:40:59 +00:00
|
|
|
#define ID_MEMORYVIEW_GOTOADDRESS 40001
|
|
|
|
#define ID_MEMORYVIEW_FOLLOWPOINTER 40002
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2012-05-13 20:34:06 +00:00
|
|
|
CMemoryViewMIPS::CMemoryViewMIPS(HWND hParent, RECT* pR, CVirtualMachine& virtualMachine, CMIPS* pCtx)
|
|
|
|
: CMemoryView(hParent, pR)
|
|
|
|
, m_virtualMachine(virtualMachine)
|
|
|
|
, m_pCtx(pCtx)
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
SetMemorySize(0x02004000);
|
|
|
|
|
2012-05-13 20:34:06 +00:00
|
|
|
m_virtualMachine.OnMachineStateChange.connect(boost::bind(&CMemoryViewMIPS::OnMachineStateChange, this));
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CMemoryViewMIPS::~CMemoryViewMIPS()
|
|
|
|
{
|
2006-12-26 21:53:04 +00:00
|
|
|
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
2006-07-09 00:45:09 +00:00
|
|
|
long CMemoryViewMIPS::OnRightButtonUp(int nX, int nY)
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
POINT pt;
|
|
|
|
pt.x = nX;
|
|
|
|
pt.y = nY;
|
|
|
|
ClientToScreen(m_hWnd, &pt);
|
|
|
|
|
2013-02-05 03:40:59 +00:00
|
|
|
HMENU hMenu = CreatePopupMenu();
|
2007-02-20 21:16:34 +00:00
|
|
|
InsertMenu(hMenu, 0, MF_BYPOSITION, ID_MEMORYVIEW_GOTOADDRESS, _T("Goto Address..."));
|
2013-02-05 03:40:59 +00:00
|
|
|
|
|
|
|
//Follow pointer
|
|
|
|
{
|
|
|
|
uint32 selection = GetSelection();
|
|
|
|
if((selection & 0x03) == 0)
|
|
|
|
{
|
|
|
|
uint32 valueAtSelection = m_pCtx->m_pMemoryMap->GetWord(GetSelection());
|
|
|
|
std::tstring followPointerText = _T("Follow Pointer (0x") + lexical_cast_hex<std::tstring>(valueAtSelection, 8) + _T(")");
|
|
|
|
InsertMenu(hMenu, 1, MF_BYPOSITION, ID_MEMORYVIEW_FOLLOWPOINTER, followPointerText.c_str());
|
|
|
|
}
|
|
|
|
}
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, m_hWnd, NULL);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
long CMemoryViewMIPS::OnCommand(unsigned short nID, unsigned short nCmd, HWND hSender)
|
|
|
|
{
|
|
|
|
switch(nID)
|
|
|
|
{
|
|
|
|
case ID_MEMORYVIEW_GOTOADDRESS:
|
|
|
|
GotoAddress();
|
|
|
|
break;
|
2013-02-05 03:40:59 +00:00
|
|
|
case ID_MEMORYVIEW_FOLLOWPOINTER:
|
|
|
|
FollowPointer();
|
|
|
|
break;
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
HFONT CMemoryViewMIPS::GetFont()
|
|
|
|
{
|
2007-02-20 21:16:34 +00:00
|
|
|
return CreateFont(-11, 0, 0, 0, 400, 0, 0, 0, 0, 1, 2, 1, 49, _T("Courier New"));
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8 CMemoryViewMIPS::GetByte(uint32 nAddress)
|
|
|
|
{
|
|
|
|
return m_pCtx->m_pMemoryMap->GetByte(nAddress);
|
|
|
|
}
|
|
|
|
|
2006-12-26 21:53:04 +00:00
|
|
|
void CMemoryViewMIPS::OnMachineStateChange()
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
Redraw();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMemoryViewMIPS::GotoAddress()
|
|
|
|
{
|
2012-05-13 20:34:06 +00:00
|
|
|
if(m_virtualMachine.GetStatus() == CVirtualMachine::RUNNING)
|
2006-06-15 04:19:30 +00:00
|
|
|
{
|
|
|
|
MessageBeep(-1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-05-13 20:34:06 +00:00
|
|
|
Framework::Win32::CInputBox i(_T("Goto Address"), _T("Enter new address:"), _T("00000000"));
|
2010-10-22 01:46:24 +00:00
|
|
|
const TCHAR* sValue = i.GetValue(m_hWnd);
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
if(sValue != NULL)
|
|
|
|
{
|
2010-10-22 01:46:24 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
uint32 nAddress = CDebugExpressionEvaluator::Evaluate(string_cast<std::string>(sValue).c_str(), m_pCtx);
|
|
|
|
ScrollToAddress(nAddress);
|
|
|
|
SetSelectionStart(nAddress);
|
|
|
|
}
|
|
|
|
catch(const std::exception& exception)
|
|
|
|
{
|
|
|
|
std::tstring message = std::tstring(_T("Error evaluating expression: ")) + string_cast<std::tstring>(exception.what());
|
|
|
|
MessageBox(m_hWnd, message.c_str(), NULL, 16);
|
|
|
|
}
|
2006-06-15 04:19:30 +00:00
|
|
|
}
|
|
|
|
}
|
2013-02-05 03:40:59 +00:00
|
|
|
|
|
|
|
void CMemoryViewMIPS::FollowPointer()
|
|
|
|
{
|
|
|
|
if(m_virtualMachine.GetStatus() == CVirtualMachine::RUNNING)
|
|
|
|
{
|
|
|
|
MessageBeep(-1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 valueAtSelection = m_pCtx->m_pMemoryMap->GetWord(GetSelection());
|
|
|
|
ScrollToAddress(valueAtSelection);
|
|
|
|
SetSelectionStart(valueAtSelection);
|
|
|
|
}
|