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)
|
if(hFile == INVALID_HANDLE_VALUE)
|
||||||
return false;
|
return false;
|
||||||
DWORD written = 0;
|
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]);
|
dprintf("Invalid expression: \"%s\"", argv[1]);
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
maxFindResults = num;
|
maxFindResults = int(num & 0x7FFFFFFF);
|
||||||
return STATUS_CONTINUE;
|
return STATUS_CONTINUE;
|
||||||
}
|
}
|
|
@ -499,14 +499,24 @@ bool MemFindInPage(SimplePage page, uint startoffset, const std::vector<PatternB
|
||||||
return true;
|
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)
|
for(const auto page : pages)
|
||||||
{
|
{
|
||||||
if(!MemFindInPage(page, 0, pattern, results, maxresults))
|
if(!MemFindInPage(page, 0, pattern, results, maxresults))
|
||||||
return false;
|
return false;
|
||||||
|
if (progress)
|
||||||
|
GuiReferenceSetProgress(int(floor((float(count) / float(total)) * 100.0f)));
|
||||||
if(results.size() >= maxresults)
|
if(results.size() >= maxresults)
|
||||||
break;
|
break;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
if (progress)
|
||||||
|
{
|
||||||
|
GuiReferenceSetProgress(100);
|
||||||
|
GuiReferenceReloadData();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
|
@ -36,4 +36,4 @@ bool MemGetPageRights(uint Address, char* Rights);
|
||||||
bool MemPageRightsToString(DWORD Protect, char* Rights);
|
bool MemPageRightsToString(DWORD Protect, char* Rights);
|
||||||
bool MemPageRightsFromString(DWORD* Protect, const 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 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 "PageMemoryRights.h"
|
||||||
#include "YaraRuleSelectionDialog.h"
|
#include "YaraRuleSelectionDialog.h"
|
||||||
#include "EntropyDialog.h"
|
#include "EntropyDialog.h"
|
||||||
|
#include "HexEditDialog.h"
|
||||||
|
|
||||||
MemoryMapView::MemoryMapView(StdTable* parent) : StdTable(parent)
|
MemoryMapView::MemoryMapView(StdTable* parent) : StdTable(parent)
|
||||||
{
|
{
|
||||||
|
@ -102,6 +103,12 @@ void MemoryMapView::setupContextMenu()
|
||||||
mEntropy = new QAction(QIcon(":/icons/images/entropy.png"), "Entropy...", this);
|
mEntropy = new QAction(QIcon(":/icons/images/entropy.png"), "Entropy...", this);
|
||||||
connect(mEntropy, SIGNAL(triggered()), this, SLOT(entropy()));
|
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();
|
refreshShortcutsSlot();
|
||||||
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot()));
|
connect(Config(), SIGNAL(shortcutsUpdated()), this, SLOT(refreshShortcutsSlot()));
|
||||||
}
|
}
|
||||||
|
@ -111,6 +118,7 @@ void MemoryMapView::refreshShortcutsSlot()
|
||||||
mMemoryExecuteSingleshoot->setShortcut(ConfigShortcut("ActionToggleBreakpoint"));
|
mMemoryExecuteSingleshoot->setShortcut(ConfigShortcut("ActionToggleBreakpoint"));
|
||||||
mMemoryRemove->setShortcut(ConfigShortcut("ActionToggleBreakpoint"));
|
mMemoryRemove->setShortcut(ConfigShortcut("ActionToggleBreakpoint"));
|
||||||
mMemoryExecuteSingleshootToggle->setShortcut(ConfigShortcut("ActionToggleBreakpoint"));
|
mMemoryExecuteSingleshootToggle->setShortcut(ConfigShortcut("ActionToggleBreakpoint"));
|
||||||
|
mFindPattern->setShortcut(ConfigShortcut("ActionFindPattern"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryMapView::contextMenuSlot(const QPoint & pos)
|
void MemoryMapView::contextMenuSlot(const QPoint & pos)
|
||||||
|
@ -122,6 +130,7 @@ void MemoryMapView::contextMenuSlot(const QPoint & pos)
|
||||||
wMenu->addAction(mFollowDump);
|
wMenu->addAction(mFollowDump);
|
||||||
wMenu->addAction(mYara);
|
wMenu->addAction(mYara);
|
||||||
wMenu->addAction(mEntropy);
|
wMenu->addAction(mEntropy);
|
||||||
|
wMenu->addAction(mFindPattern);
|
||||||
wMenu->addAction(mSwitchView);
|
wMenu->addAction(mSwitchView);
|
||||||
wMenu->addSeparator();
|
wMenu->addSeparator();
|
||||||
wMenu->addAction(mPageMemoryRights);
|
wMenu->addAction(mPageMemoryRights);
|
||||||
|
@ -422,3 +431,19 @@ void MemoryMapView::entropy()
|
||||||
|
|
||||||
delete[] data;
|
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 pageMemoryRights();
|
||||||
void refreshMap();
|
void refreshMap();
|
||||||
void entropy();
|
void entropy();
|
||||||
|
void findPatternSlot();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString getProtectionString(DWORD Protect);
|
QString getProtectionString(DWORD Protect);
|
||||||
|
@ -57,6 +58,7 @@ private:
|
||||||
QAction* mMemoryRemove;
|
QAction* mMemoryRemove;
|
||||||
QAction* mMemoryExecuteSingleshootToggle;
|
QAction* mMemoryExecuteSingleshootToggle;
|
||||||
QAction* mEntropy;
|
QAction* mEntropy;
|
||||||
|
QAction* mFindPattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MEMORYMAPVIEW_H
|
#endif // MEMORYMAPVIEW_H
|
||||||
|
|
Loading…
Reference in New Issue