| 64 | |
| 65 | |
| 66 | SectionsWidget::SectionsWidget(QWidget* parent, BinaryViewRef data) : QWidget(parent) |
| 67 | { |
| 68 | QGridLayout* layout = new QGridLayout(); |
| 69 | layout->setContentsMargins(0, 0, 0, 0); |
| 70 | layout->setVerticalSpacing(1); |
| 71 | layout->setHorizontalSpacing(UIContext::getScaledWindowSize(16, 16).width()); |
| 72 | |
| 73 | size_t maxNameLen = 0; |
| 74 | for (auto& section : data->GetSections()) |
| 75 | if (section->GetName().size() > maxNameLen) |
| 76 | maxNameLen = section->GetName().size(); |
| 77 | if (maxNameLen > 32) |
| 78 | maxNameLen = 32; |
| 79 | |
| 80 | for (auto& section : data->GetSections()) |
| 81 | if (section->GetSemantics() != ExternalSectionSemantics) |
| 82 | m_sections.push_back(section); |
| 83 | sort(m_sections.begin(), m_sections.end(), |
| 84 | [&](SectionRef a, SectionRef b) { return a->GetStart() < b->GetStart(); }); |
| 85 | |
| 86 | int row = 0; |
| 87 | for (auto& section : m_sections) |
| 88 | { |
| 89 | std::string name = section->GetName(); |
| 90 | if (name.size() > maxNameLen) |
| 91 | name = name.substr(0, maxNameLen - 1) + std::string("…"); |
| 92 | |
| 93 | QString begin = QString("0x") + QString::number(section->GetStart(), 16); |
| 94 | QString end = QString("0x") + QString::number(section->GetStart() + section->GetLength(), 16); |
| 95 | QString typeName = QString::fromStdString(section->GetType()); |
| 96 | |
| 97 | QString permissions; |
| 98 | if (data->IsOffsetReadable(section->GetStart())) |
| 99 | permissions += "r"; |
| 100 | else |
| 101 | permissions += "-"; |
| 102 | if (data->IsOffsetWritable(section->GetStart())) |
| 103 | permissions += "w"; |
| 104 | else |
| 105 | permissions += "-"; |
| 106 | if (data->IsOffsetExecutable(section->GetStart())) |
| 107 | permissions += "x"; |
| 108 | else |
| 109 | permissions += "-"; |
| 110 | |
| 111 | QString semantics; |
| 112 | if (section->GetSemantics() == ReadOnlyCodeSectionSemantics) |
| 113 | semantics = "Code"; |
| 114 | else if (section->GetSemantics() == ReadOnlyDataSectionSemantics) |
| 115 | semantics = "Read-only Data"; |
| 116 | else if (section->GetSemantics() == ReadWriteDataSectionSemantics) |
| 117 | semantics = "Writable Data"; |
| 118 | |
| 119 | QLabel* nameLabel = new QLabel(QString::fromStdString(name)); |
| 120 | nameLabel->setFont(getMonospaceFont(this)); |
| 121 | layout->addWidget(nameLabel, row, 0); |
| 122 | |
| 123 | QHBoxLayout* rangeLayout = new QHBoxLayout(); |
no test coverage detected