1
0
Fork 0

GUI: do not automatically update dump if the memory and view didn't change

This commit is contained in:
Duncan Ogilvie 2019-09-07 17:29:41 +02:00
parent 362b2d7260
commit 14201568cf
2 changed files with 44 additions and 0 deletions

View File

@ -36,6 +36,10 @@ HexDump::HexDump(QWidget* parent)
mNonprintReplace = QChar('.'); //QChar(0x25CA);
mNullReplace = QChar('.'); //QChar(0x2022);
const auto updateCacheDataSize = 0x1000;
mUpdateCacheData.resize(updateCacheDataSize);
mUpdateCacheTemp.resize(updateCacheDataSize);
// Slots
connect(Bridge::getBridge(), SIGNAL(updateDump()), this, SLOT(updateDumpSlot()));
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), this, SLOT(debugStateChanged(DBGSTATE)));
@ -110,6 +114,31 @@ void HexDump::updateDumpSlot()
printDumpAt(syncAddr, false, false, true);
}
}
UpdateCache cur;
cur.memBase = mMemPage->getBase();
cur.memSize = mMemPage->getSize();
if(cur.memBase)
{
cur.rva = getTableOffsetRva();
cur.size = getBytePerRowCount() * getViewableRowsCount();
if(cur.size < mUpdateCacheData.size())
{
if(mMemPage->read(mUpdateCacheTemp.data(), cur.rva, cur.size))
{
if(mUpdateCache == cur && memcmp(mUpdateCacheData.data(), mUpdateCacheTemp.data(), cur.size) == 0)
{
// same view and same data, do not reload
return;
}
else
{
mUpdateCache = cur;
mUpdateCacheData.swap(mUpdateCacheTemp);
OutputDebugStringA(QString("[x64dbg] %1[%2] %3[%4]").arg(ToPtrString(mUpdateCache.memBase)).arg(ToHexString(mUpdateCache.memSize)).arg(ToPtrString(mUpdateCache.rva)).arg(ToHexString(mUpdateCache.size)).toUtf8().constData());
}
}
}
}
reloadData();
}

View File

@ -193,6 +193,21 @@ private:
QColor mUnknownCodePointerHighlightColor;
QColor mUnknownDataPointerHighlightColor;
struct UpdateCache
{
duint memBase = 0;
duint memSize = 0;
duint rva = 0;
duint size = 0;
bool operator==(const UpdateCache & o) const
{
return std::tie(memBase, memSize, rva, size) == std::tie(o.memBase, o.memSize, o.rva, o.size);
}
} mUpdateCache;
std::vector<uint8_t> mUpdateCacheData;
std::vector<uint8_t> mUpdateCacheTemp;
protected:
MemoryPage* mMemPage;
int mByteOffset;