Fix invalid memory access on start, remove combo box code from symbol map

This commit is contained in:
Kingcom 2013-11-28 10:49:02 +01:00
parent 577a46be09
commit cca750aab5
4 changed files with 1 additions and 69 deletions

View File

@ -153,7 +153,7 @@ void DisassemblyManager::analyze(u32 address, u32 size = 1024)
u32 next = symbolMap.GetNextSymbolAddress(address,ST_ALL);
if (next % 4)
if ((next % 4) && next != -1)
{
u32 alignedNext = next & ~3;

View File

@ -663,67 +663,4 @@ void SymbolMap::FillSymbolListBox(HWND listbox,SymbolType symType) const
RedrawWindow(listbox, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
}
void SymbolMap::FillSymbolComboBox(HWND comboxBox, SymbolType symType) const
{
wchar_t temp[256];
lock_guard guard(lock_);
SendMessage(comboxBox, WM_SETREDRAW, FALSE, 0);
ComboBox_ResetContent(comboxBox);
switch (symType)
{
case ST_FUNCTION:
{
SendMessage(comboxBox, CB_INITSTORAGE, (WPARAM)functions.size(), (LPARAM)functions.size() * 30);
for (auto it = functions.begin(), end = functions.end(); it != end; ++it)
{
const FunctionEntry& entry = it->second;
const char* name = GetLabelName(it->first);
if (name != NULL)
wsprintf(temp, L"%S", name);
else
wsprintf(temp, L"0x%08X", it->first);
int index = ComboBox_AddString(comboxBox,temp);
ComboBox_SetItemData(comboxBox,index,it->first);
}
}
break;
case ST_DATA:
{
int count = ARRAYSIZE(defaultSymbols)+(int)data.size();
SendMessage(comboxBox, CB_INITSTORAGE, (WPARAM)count, (LPARAM)count * 30);
for (int i = 0; i < ARRAYSIZE(defaultSymbols); i++)
{
wsprintf(temp, L"0x%08X (%S)", defaultSymbols[i].address, defaultSymbols[i].name);
int index = ComboBox_AddString(comboxBox,temp);
ComboBox_SetItemData(comboxBox,index,defaultSymbols[i].address);
}
for (auto it = data.begin(), end = data.end(); it != end; ++it)
{
const DataEntry& entry = it->second;
const char* name = GetLabelName(it->first);
if (name != NULL)
wsprintf(temp, L"%S", name);
else
wsprintf(temp, L"0x%08X", it->first);
int index = ComboBox_AddString(comboxBox,temp);
ComboBox_SetItemData(comboxBox,index,it->first);
}
}
break;
}
SendMessage(comboxBox, WM_SETREDRAW, TRUE, 0);
RedrawWindow(comboxBox, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
}
#endif

View File

@ -68,7 +68,6 @@ public:
#ifdef _WIN32
void FillSymbolListBox(HWND listbox, SymbolType symType) const;
void FillSymbolComboBox(HWND listbox,SymbolType symType) const;
#endif
void AddFunction(const char* name, u32 address, u32 size);

View File

@ -101,8 +101,6 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di
CtrlRegisterList *rl = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST));
rl->setCPU(cpu);
symbolMap.FillSymbolComboBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION);
leftTabs = new TabControl(GetDlgItem(m_hDlg,IDC_LEFTTABS));
leftTabs->SetIgnoreBottomMargin(true);
@ -531,7 +529,6 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam)
case IDC_ALLFUNCTIONS:
{
symbolMap.FillSymbolListBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION);
symbolMap.FillSymbolComboBox(GetDlgItem(m_hDlg, IDC_GOTOINT),ST_FUNCTION);
break;
}
default:
@ -780,7 +777,6 @@ void CDisasm::SetDebugMode(bool _bDebug, bool switchPC)
void CDisasm::NotifyMapLoaded()
{
symbolMap.FillSymbolListBox(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST),ST_FUNCTION);
symbolMap.FillSymbolComboBox(GetDlgItem(m_hDlg, IDC_GOTOINT),ST_FUNCTION);
CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW));
ptr->clearFunctions();
ptr->redraw();