Fix Sections Size in Visualization

This commit is contained in:
Florian Märkl 2019-05-16 14:05:12 +02:00
parent a18265a022
commit 4f71526100
3 changed files with 12 additions and 12 deletions

View File

@ -47,7 +47,7 @@ inline QString RAddressString(RVA addr)
inline QString RSizeString(RVA size) inline QString RSizeString(RVA size)
{ {
return QString::asprintf("%lld", size); return QString::asprintf("%#llx", size);
} }
inline QString RHexString(RVA size) inline QString RHexString(RVA size)

View File

@ -57,7 +57,7 @@ QVariant SectionsModel::data(const QModelIndex &index, int role) const
case SectionsModel::NameColumn: case SectionsModel::NameColumn:
return section.name; return section.name;
case SectionsModel::SizeColumn: case SectionsModel::SizeColumn:
return section.vsize; return RSizeString(section.vsize);
case SectionsModel::AddressColumn: case SectionsModel::AddressColumn:
return RAddressString(section.vaddr); return RAddressString(section.vaddr);
case SectionsModel::EndAddressColumn: case SectionsModel::EndAddressColumn:
@ -367,24 +367,24 @@ void AbstractAddrDock::updateDock()
addrDockScene->seekAddrSizeMap[name] = desc.vsize; addrDockScene->seekAddrSizeMap[name] = desc.vsize;
RVA addr = getAddressOfSection(desc); RVA addr = getAddressOfSection(desc);
int size = getSizeOfSection(desc); RVA size = getSizeOfSection(desc);
addrDockScene->nameAddrMap[name] = addr; addrDockScene->nameAddrMap[name] = addr;
addrDockScene->nameAddrSizeMap[name] = size; addrDockScene->nameAddrSizeMap[name] = size;
size = getAdjustedSize(size, validMinSize); int drawSize = getAdjustedSize(size, validMinSize);
QGraphicsRectItem *rect = new QGraphicsRectItem(rectOffset, y, rectWidth, size); QGraphicsRectItem *rect = new QGraphicsRectItem(rectOffset, y, rectWidth, drawSize);
rect->setBrush(QBrush(idx.data(Qt::DecorationRole).value<QColor>())); rect->setBrush(QBrush(idx.data(Qt::DecorationRole).value<QColor>()));
addrDockScene->addItem(rect); addrDockScene->addItem(rect);
addTextItem(textColor, QPoint(0, y), QString("0x%1").arg(addr, 0, 16)); addTextItem(textColor, QPoint(0, y), RAddressString(addr));
addTextItem(textColor, QPoint(rectOffset, y), QString::number(size)); addTextItem(textColor, QPoint(rectOffset, y), RSizeString(size));
addTextItem(textColor, QPoint(rectOffset + rectWidth, y), name); addTextItem(textColor, QPoint(rectOffset + rectWidth, y), name);
addrDockScene->namePosYMap[name] = y; addrDockScene->namePosYMap[name] = y;
addrDockScene->nameHeightMap[name] = size; addrDockScene->nameHeightMap[name] = drawSize;
y += size; y += drawSize;
} }
graphicsView->setSceneRect(addrDockScene->itemsBoundingRect()); graphicsView->setSceneRect(addrDockScene->itemsBoundingRect());
@ -488,7 +488,7 @@ RVA AddrDockScene::getAddrFromPos(int posY, bool seek)
{ {
QHash<QString, int>::const_iterator it; QHash<QString, int>::const_iterator it;
QHash<QString, RVA> addrMap = seek ? seekAddrMap : nameAddrMap; QHash<QString, RVA> addrMap = seek ? seekAddrMap : nameAddrMap;
QHash<QString, int> addrSizeMap = seek ? seekAddrSizeMap : nameAddrSizeMap; QHash<QString, RVA> addrSizeMap = seek ? seekAddrSizeMap : nameAddrSizeMap;
for (it = namePosYMap.constBegin(); it != namePosYMap.constEnd(); ++it) { for (it = namePosYMap.constBegin(); it != namePosYMap.constEnd(); ++it) {
QString name = it.key(); QString name = it.key();
int y = it.value(); int y = it.value();

View File

@ -159,9 +159,9 @@ public:
bool disableCenterOn; bool disableCenterOn;
QHash<QString, RVA> nameAddrMap; QHash<QString, RVA> nameAddrMap;
QHash<QString, int> nameAddrSizeMap; QHash<QString, RVA> nameAddrSizeMap;
QHash<QString, RVA> seekAddrMap; QHash<QString, RVA> seekAddrMap;
QHash<QString, int> seekAddrSizeMap; QHash<QString, RVA> seekAddrSizeMap;
QHash<QString, int> namePosYMap; QHash<QString, int> namePosYMap;
QHash<QString, int> nameHeightMap; QHash<QString, int> nameHeightMap;