DBG: fixed issue #112 (binary search in memory map over all pages)
This commit is contained in:
parent
e0085323f5
commit
0195c20936
|
@ -25,5 +25,5 @@ bool FileHelper::WriteAllText(const String & fileName, const String & content)
|
|||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
DWORD written = 0;
|
||||
return !!WriteFile(hFile, content.c_str(), content.length(), &written, nullptr);
|
||||
return !!WriteFile(hFile, content.c_str(), DWORD(content.length()), &written, nullptr);
|
||||
}
|
|
@ -2286,6 +2286,6 @@ CMDRESULT cbInstrSetMaxFindResult(int argc, char* argv[])
|
|||
dprintf("Invalid expression: \"%s\"", argv[1]);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
maxFindResults = num;
|
||||
maxFindResults = int(num & 0x7FFFFFFF);
|
||||
return STATUS_CONTINUE;
|
||||
}
|
|
@ -499,14 +499,24 @@ bool MemFindInPage(SimplePage page, uint startoffset, const std::vector<PatternB
|
|||
return true;
|
||||
}
|
||||
|
||||
bool MemFindInMap(const std::vector<SimplePage> & pages, const std::vector<PatternByte> & pattern, std::vector<uint> & results, uint maxresults)
|
||||
bool MemFindInMap(const std::vector<SimplePage> & pages, const std::vector<PatternByte> & pattern, std::vector<uint> & results, uint maxresults, bool progress)
|
||||
{
|
||||
uint count = 0;
|
||||
uint total = pages.size();
|
||||
for(const auto page : pages)
|
||||
{
|
||||
if(!MemFindInPage(page, 0, pattern, results, maxresults))
|
||||
return false;
|
||||
if (progress)
|
||||
GuiReferenceSetProgress(int(floor((float(count) / float(total)) * 100.0f)));
|
||||
if(results.size() >= maxresults)
|
||||
break;
|
||||
count++;
|
||||
}
|
||||
if (progress)
|
||||
{
|
||||
GuiReferenceSetProgress(100);
|
||||
GuiReferenceReloadData();
|
||||
}
|
||||
return true;
|
||||
}
|
|
@ -36,4 +36,4 @@ bool MemGetPageRights(uint Address, char* Rights);
|
|||
bool MemPageRightsToString(DWORD Protect, char* Rights);
|
||||
bool MemPageRightsFromString(DWORD* Protect, const char* Rights);
|
||||
bool MemFindInPage(SimplePage page, uint startoffset, const std::vector<PatternByte> & pattern, std::vector<uint> & results, uint maxresults);
|
||||
bool MemFindInMap(const std::vector<SimplePage> & pages, const std::vector<PatternByte> & pattern, std::vector<uint> & results, uint maxresults);
|
||||
bool MemFindInMap(const std::vector<SimplePage> & pages, const std::vector<PatternByte> & pattern, std::vector<uint> & results, uint maxresults, bool progress = true);
|
|
@ -4,6 +4,7 @@
|
|||
#include "PageMemoryRights.h"
|
||||
#include "YaraRuleSelectionDialog.h"
|
||||
#include "EntropyDialog.h"
|
||||
#include "HexEditDialog.h"
|
||||
|
||||
MemoryMapView::MemoryMapView(StdTable* parent) : StdTable(parent)
|
||||
{
|
||||
|
@ -102,6 +103,12 @@ void MemoryMapView::setupContextMenu()
|
|||
mEntropy = new QAction(QIcon(":/icons/images/entropy.png"), "Entropy...", this);
|
||||
connect(mEntropy, SIGNAL(triggered()), this, SLOT(entropy()));
|
||||
|
||||
//Find
|
||||
mFindPattern = new QAction(QIcon(":/icons/images/search-for.png"), "&Find Pattern...", this);
|
||||
this->addAction(mFindPattern);
|
||||
mFindPattern->setShortcutContext(Qt::WidgetShortcut);
|
||||
connect(mFindPattern, SIGNAL(triggered()), this, SLOT(findPatternSlot()));
|
||||
|
||||
refreshShortcutsSlot();
|
||||
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot()));
|
||||
}
|
||||
|
@ -111,6 +118,7 @@ void MemoryMapView::refreshShortcutsSlot()
|
|||
mMemoryExecuteSingleshoot->setShortcut(ConfigShortcut("ActionToggleBreakpoint"));
|
||||
mMemoryRemove->setShortcut(ConfigShortcut("ActionToggleBreakpoint"));
|
||||
mMemoryExecuteSingleshootToggle->setShortcut(ConfigShortcut("ActionToggleBreakpoint"));
|
||||
mFindPattern->setShortcut(ConfigShortcut("ActionFindPattern"));
|
||||
}
|
||||
|
||||
void MemoryMapView::contextMenuSlot(const QPoint & pos)
|
||||
|
@ -122,6 +130,7 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos)
|
|||
wMenu->addAction(mFollowDump);
|
||||
wMenu->addAction(mYara);
|
||||
wMenu->addAction(mEntropy);
|
||||
wMenu->addAction(mFindPattern);
|
||||
wMenu->addAction(mSwitchView);
|
||||
wMenu->addSeparator();
|
||||
wMenu->addAction(mPageMemoryRights);
|
||||
|
@ -422,3 +431,19 @@ void MemoryMapView::entropy()
|
|||
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
void MemoryMapView::findPatternSlot()
|
||||
{
|
||||
HexEditDialog hexEdit(this);
|
||||
hexEdit.showEntireBlock(true);
|
||||
hexEdit.mHexEdit->setOverwriteMode(false);
|
||||
hexEdit.setWindowTitle("Find Pattern...");
|
||||
if(hexEdit.exec() != QDialog::Accepted)
|
||||
return;
|
||||
uint_t addr = getCellContent(getInitialSelection(), 0).toULongLong(0, 16);
|
||||
if(hexEdit.entireBlock())
|
||||
addr = 0;
|
||||
QString addrText = QString("%1").arg(addr, sizeof(int_t) * 2, 16, QChar('0')).toUpper();
|
||||
DbgCmdExec(QString("findmemall " + addrText + ", \"" + hexEdit.mHexEdit->pattern() + "\", &data&").toUtf8().constData());
|
||||
emit showReferences();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ public slots:
|
|||
void pageMemoryRights();
|
||||
void refreshMap();
|
||||
void entropy();
|
||||
void findPatternSlot();
|
||||
|
||||
private:
|
||||
QString getProtectionString(DWORD Protect);
|
||||
|
@ -57,6 +58,7 @@ private:
|
|||
QAction* mMemoryRemove;
|
||||
QAction* mMemoryExecuteSingleshootToggle;
|
||||
QAction* mEntropy;
|
||||
QAction* mFindPattern;
|
||||
};
|
||||
|
||||
#endif // MEMORYMAPVIEW_H
|
||||
|
|
Loading…
Reference in New Issue