Fix a small bug

pull/4/head
wh201906 4 years ago
parent 41bbcd2c4a
commit fbe8a5e51d

@ -12,7 +12,7 @@ A GUI for [Proxmark3](https://github.com/Proxmark/proxmark3) client
+ Have a friendly UI to test Mifare cards
+ Support different card size(MINI, 1K, 2K, 4K)
+ Easy to edit Mifare data files
+ Easy to read all blocks with well-designed read logic
+ Easy to read all/selected blocks with well-designed read logic
+ Support binary(.bin .dump) files and text(.eml) files
+ Analyze Access Bits
+ Support Chinese Magic Card

@ -833,21 +833,51 @@ void Mifare::data_syncWithKeyWidget(bool syncAll, int sector, KeyType keyType)
ui->MF_keyWidget->blockSignals(false);
}
void Mifare::data_clearData()
void Mifare::data_clearData(bool clearAll)
{
dataList->clear();
for(int i = 0; i < cardType.block_size; i++)
dataList->append("");
if(clearAll)
{
dataList->clear();
}
int delta = cardType.block_size - dataList->length() ;
if(delta >= 0)
{
for(int i = 0; i < delta; i++)
dataList->append("");
}
else if(delta < 0)
{
for(int i = 0; i < -delta; i++)
dataList->removeLast();
}
}
void Mifare::data_clearKey()
void Mifare::data_clearKey(bool clearAll)
{
keyAList->clear();
keyBList->clear();
for(int i = 0; i < cardType.sector_size; i++)
if(clearAll)
{
keyAList->append("");
keyBList->append("");
keyAList->clear();
keyBList->clear();
}
int delta = cardType.sector_size - keyAList->length() ;
if(delta >= 0)
{
for(int i = 0; i < delta; i++)
{
keyAList->append("");
keyBList->append("");
}
}
else if(delta < 0)
{
for(int i = 0; i < -delta; i++)
{
keyAList->removeLast();
keyBList->removeLast();
}
}
}
@ -912,8 +942,8 @@ void Mifare::setCardType(int type)
cardType = card_2k;
else if(type == 4)
cardType = card_4k;
data_clearKey();
data_clearData();
data_clearKey(false);
data_clearData(false);
}
}

@ -46,11 +46,11 @@ public:
struct CardType
{
int type;
int sector_size;
int block_size;
int blk[40];
int blks[40];
quint8 type;
quint8 sector_size;
quint16 block_size;
quint8 blk[40];
quint8 blks[40];
};
enum AccessType
@ -70,8 +70,8 @@ public:
static const AccessType trailerReadCondition[8][3];
static const AccessType trailerWriteCondition[8][3];
void data_clearData();
void data_clearKey();
void data_clearData(bool clearAll = true);
void data_clearKey(bool clearAll = true);
static bool data_isKeyValid(const QString& key);
static Mifare::DataType data_isDataValid(const QString& data);
void data_syncWithDataWidget(bool syncAll = true, int block = 0);

@ -181,7 +181,7 @@ void MainWindow::MF_onTypeChanged(int id, bool st)
int result;
if(id > typeBtnGroup->checkedId()) // id is specified in uiInit() with a proper order, so I can compare the size by id.
{
result = QMessageBox::question(this, tr("Info"), tr("When Changeing card type, the data and keys in this app will be cleard.") + "\n" + tr("Continue?"), QMessageBox::Yes | QMessageBox::No);
result = QMessageBox::question(this, tr("Info"), tr("Some of the data and key will be cleared.") + "\n" + tr("Continue?"), QMessageBox::Yes | QMessageBox::No);
}
else
{
@ -192,6 +192,8 @@ void MainWindow::MF_onTypeChanged(int id, bool st)
qDebug() << "Yes";
mifare->setCardType(typeBtnGroup->checkedId());
MF_widgetReset();
mifare->data_syncWithDataWidget();
mifare->data_syncWithKeyWidget();
}
else
{
@ -698,6 +700,7 @@ void MainWindow::MF_widgetReset()
ui->MF_dataWidget->setRowCount(blks);
ui->MF_dataWidget->blockSignals(true);
ui->MF_keyWidget->blockSignals(true);
ui->MF_selectAllBox->blockSignals(true);
for(int i = 0; i < blks; i++)
@ -720,6 +723,7 @@ void MainWindow::MF_widgetReset()
ui->MF_selectAllBox->setCheckState(Qt::Checked);
ui->MF_dataWidget->blockSignals(false);
ui->MF_keyWidget->blockSignals(false);
ui->MF_selectAllBox->blockSignals(false);
}
// ************************************************
@ -746,7 +750,7 @@ void MainWindow::uiInit()
ui->MF_dataWidget->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Blk")));
ui->MF_dataWidget->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Data")));
ui->MF_dataWidget->verticalHeader()->setVisible(false);
ui->MF_dataWidget->setColumnWidth(0, 45);
ui->MF_dataWidget->setColumnWidth(0, 55);
ui->MF_dataWidget->setColumnWidth(1, 55);
ui->MF_dataWidget->setColumnWidth(2, 430);

Loading…
Cancel
Save