Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
horsicq committed Feb 7, 2020
1 parent 51be4de commit 9c4529b
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 16 deletions.
2 changes: 1 addition & 1 deletion PE/pe_defs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ const FormatWidget::HEADER_RECORD records[]=
{NumberOfRelocations, "NumberOfRelocations", offsetof(XPE_DEF::IMAGE_SECTION_HEADER,NumberOfRelocations), 2, "WORD", FormatWidget::VAL_TYPE_DATA},
{NumberOfLinenumbers, "NumberOfLinenumbers", offsetof(XPE_DEF::IMAGE_SECTION_HEADER,NumberOfLinenumbers), 2, "WORD", FormatWidget::VAL_TYPE_DATA},
{Characteristics, "Characteristics", offsetof(XPE_DEF::IMAGE_SECTION_HEADER,Characteristics), 4, "DWORD", FormatWidget::VAL_TYPE_FLAGS},
{Characteristics, "", offsetof(XPE_DEF::IMAGE_SECTION_HEADER,Characteristics), 0, "", FormatWidget::VAL_TYPE_UNKNOWN}
{Characteristics, "", -1, 0, "", FormatWidget::VAL_TYPE_UNKNOWN}
};
}

Expand Down
3 changes: 2 additions & 1 deletion PE/pewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,8 @@ void PEWidget::editSectionHeader()
if(nRow!=-1)
{
SectionHeaderWidget *pSectionHeaderWidget=new SectionHeaderWidget(this);
DialogSectionHeader dsh(pSectionHeaderWidget,this);
DialogSectionHeader dsh(this);
dsh.setWidget(pSectionHeaderWidget);
dsh.setData(getDevice(),getOptions(),(quint32)nRow,"Section");
dsh.setEdited(isEdited());

Expand Down
2 changes: 1 addition & 1 deletion PE/pewidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
</widget>
<widget class="QStackedWidget" name="stackedWidgetInfo">
<property name="currentIndex">
<number>19</number>
<number>1</number>
</property>
<widget class="QWidget" name="page_HEX">
<layout class="QVBoxLayout" name="verticalLayout_13">
Expand Down
24 changes: 22 additions & 2 deletions PE/sectionheaderwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ void SectionHeaderWidget::clear()
memset(lineEdit_IMAGE_SECTION_HEADER,0,sizeof lineEdit_IMAGE_SECTION_HEADER);
memset(comboBox,0,sizeof comboBox);

pSubDevice=nullptr;

ui->checkBoxReadonly->setChecked(true);
}

Expand Down Expand Up @@ -98,7 +100,9 @@ bool SectionHeaderWidget::_setValue(QVariant vValue, int nStype, int nNdata, int
case N_IMAGE_SECTION_HEADER::Characteristics: pe.setSection_Characteristics((quint32)nPosition,(quint32)nValue); break;
}

break;
ui->widgetHex_IMAGE_SECTION_HEADER->reload();

break;
}

bResult=true;
Expand Down Expand Up @@ -131,7 +135,7 @@ void SectionHeaderWidget::adjustHeaderTable(int type, QTableWidget *pTableWidget
switch(type)
{
case SPE::TYPE_IMAGE_SECTION_HEADER:
pTableWidget->setColumnWidth(HEADER_COLUMN_NAME,nSymbolWidth*12);
pTableWidget->setColumnWidth(HEADER_COLUMN_NAME,nSymbolWidth*16);
pTableWidget->setColumnWidth(HEADER_COLUMN_VALUE,nSymbolWidth*8);
pTableWidget->setColumnWidth(HEADER_COLUMN_INFO,nSymbolWidth*16);
break;
Expand Down Expand Up @@ -179,6 +183,12 @@ void SectionHeaderWidget::reloadData()
comboBox[CB_CHARACTERISTICS]->setValue(ish.Characteristics);
comboBox[CB_ALIGH]->setValue(ish.Characteristics);

qint64 nOffset=pe.getSectionHeaderOffset(getNumber());
qint64 nSize=pe.getSectionHeaderSize();
qint64 nAddress=pe.offsetToRelAddress(nOffset);

loadHexSubdevice(nOffset,nSize,nAddress,&pSubDevice,ui->widgetHex_IMAGE_SECTION_HEADER);

blockSignals(false);

setReadonly(ui->checkBoxReadonly->isChecked());
Expand Down Expand Up @@ -210,3 +220,13 @@ void SectionHeaderWidget::widgetValueChanged(quint64 nValue)
break;
}
}

void SectionHeaderWidget::on_tableWidget_IMAGE_SECTION_HEADER_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
{
Q_UNUSED(currentRow)
Q_UNUSED(currentColumn)
Q_UNUSED(previousRow)
Q_UNUSED(previousColumn)

setHeaderTableSelection(ui->widgetHex_IMAGE_SECTION_HEADER,ui->tableWidget_IMAGE_SECTION_HEADER);
}
3 changes: 3 additions & 0 deletions PE/sectionheaderwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ private slots:
void reloadData();
void widgetValueChanged(quint64 nValue);

void on_tableWidget_IMAGE_SECTION_HEADER_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);

private:
Ui::SectionHeaderWidget *ui;
XLineEditHEX *lineEdit_IMAGE_SECTION_HEADER[N_IMAGE_SECTION_HEADER::__data_size+1];
XComboBoxEx *comboBox[__CB_size];
bool bInit;
SubDevice *pSubDevice;
};

#endif // SECTIONHEADERWIDGET_H
18 changes: 18 additions & 0 deletions PE/sectionheaderwidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,26 @@
</attribute>
</widget>
</item>
<item>
<widget class="ToolsWidget" name="widgetHex_IMAGE_SECTION_HEADER" native="true">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>200</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ToolsWidget</class>
<extends>QWidget</extends>
<header>toolswidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
17 changes: 10 additions & 7 deletions dialogsectionheader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@
#include "dialogsectionheader.h"
#include "ui_dialogsectionheader.h"

DialogSectionHeader::DialogSectionHeader(FormatWidget *pWidget,QWidget *parent) :
DialogSectionHeader::DialogSectionHeader(QWidget *parent) :
QDialog(parent),
ui(new Ui::DialogSectionHeader)
{
ui->setupUi(this);

this->pWidget=pWidget;

ui->WidgetLayout->addWidget(pWidget);

connect(pWidget,SIGNAL(editState(bool)),this,SIGNAL(editState(bool)));

setWindowFlags(Qt::Window);
}

Expand All @@ -41,6 +35,15 @@ DialogSectionHeader::~DialogSectionHeader()
delete ui;
}

void DialogSectionHeader::setWidget(FormatWidget *pWidget)
{
this->pWidget=pWidget;

ui->WidgetLayout->addWidget(pWidget);

connect(pWidget,SIGNAL(editState(bool)),this,SIGNAL(editState(bool)));
}

void DialogSectionHeader::setData(QIODevice *pDevice, FW_DEF::OPTIONS *pOptions, quint32 nNumber, QString sTitle)
{
setWindowTitle(sTitle);
Expand Down
3 changes: 2 additions & 1 deletion dialogsectionheader.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ class DialogSectionHeader : public QDialog
Q_OBJECT

public:
explicit DialogSectionHeader(FormatWidget *pWidget,QWidget *parent);
explicit DialogSectionHeader(QWidget *parent);
~DialogSectionHeader();
void setWidget(FormatWidget *pWidget);
void setData(QIODevice *pDevice, FW_DEF::OPTIONS *pOptions, quint32 nNumber,QString sTitle);
void setEdited(bool bState);

Expand Down
16 changes: 13 additions & 3 deletions formatwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,15 @@ void FormatWidget::setHeaderTableSelection(ToolsWidget *pToolWidget, QTableWidge

if(nCurrentRow!=-1)
{
qint64 nAddress=pToolWidget->getBaseAddress()+pTableWidget->item(nCurrentRow,0)->data(Qt::UserRole+HEADER_DATA_OFFSET).toInt();
qint32 nOffset=pTableWidget->item(nCurrentRow,0)->data(Qt::UserRole+HEADER_DATA_OFFSET).toInt();
qint64 nSize=pTableWidget->item(nCurrentRow,0)->data(Qt::UserRole+HEADER_DATA_SIZE).toInt();

pToolWidget->setSelection(nAddress,nSize);
if(nOffset!=-1)
{
qint64 nAddress=pToolWidget->getBaseAddress()+nOffset;

pToolWidget->setSelection(nAddress,nSize);
}
}
}

Expand Down Expand Up @@ -253,7 +258,12 @@ bool FormatWidget::createHeaderTable(int type, QTableWidget *pTableWidget, const
pTableWidget->setItem(i,HEADER_COLUMN_NAME,newItemName);

QTableWidgetItem *newItemOffset=new QTableWidgetItem;
newItemOffset->setText(XBinary::valueToHex((quint16)pRecords[i].nOffset));

if(pRecords[i].nOffset!=-1)
{
newItemOffset->setText(XBinary::valueToHex((quint16)pRecords[i].nOffset));
}

pTableWidget->setItem(i,HEADER_COLUMN_OFFSET,newItemOffset);

QTableWidgetItem *newItemType=new QTableWidgetItem;
Expand Down

0 comments on commit 9c4529b

Please sign in to comment.