diff --git a/.idea/editor.xml b/.idea/editor.xml index 25c6c37..5b0c0e7 100644 --- a/.idea/editor.xml +++ b/.idea/editor.xml @@ -1,6 +1,10 @@ + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f75854..0b287ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,11 +31,11 @@ if(ANDROID) ) else() add_executable(USB_Config_Vendor + WIN32 main.cpp widget.cpp widget.h widget.ui - ) endif() diff --git a/widget.cpp b/widget.cpp index 5276665..535ba29 100644 --- a/widget.cpp +++ b/widget.cpp @@ -21,7 +21,7 @@ Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget){ } }); connect(ui->SettingBtn, &QPushButton::clicked, this,&Widget::writeClick); -} +} // AA-20260203-20260505 XunBangBS Widget::~Widget(){ loop_running = false; @@ -52,6 +52,8 @@ bool Widget::readInit() { const CTL::String VID = CTL::String::format("%04X", key.vendor_id); ui->R_PID->setText(PID.c_str()); ui->R_VID->setText(VID.c_str()); + ui->S_PID->setText(PID.c_str()); + ui->S_VID->setText(VID.c_str()); ui->R_PIN->clear(); ui->R_PIN->setText((char*)key.PIN); }); @@ -60,6 +62,8 @@ bool Widget::readInit() { void Widget::readClick() { CCUniqueLock lock(loop_mutex); + uint8_t data[1024] = {0}; + readData(data, 60); PrintInfo("正在读取加密狗配置信息..."); AES_USB::PID_Key key; const int ret = AES_USB::readID_Pin(&key); @@ -77,6 +81,8 @@ void Widget::readClick() { const CTL::String VID = CTL::String::format("%04X", key.vendor_id); ui->R_PID->setText(PID.c_str()); ui->R_VID->setText(VID.c_str()); + ui->S_PID->setText(PID.c_str()); + ui->S_VID->setText(VID.c_str()); ui->R_PIN->clear(); ui->R_PIN->setText((char*)key.PIN); }); @@ -174,7 +180,7 @@ bool Widget::writeInit() { if (ui->B_PIN->isChecked() && !ui->S_PIN->text().isEmpty() && !ui->S_PID->text().isEmpty() && !ui->S_VID->text().isEmpty()) { - AES_USB::PID_Key key; + AES_USB::PID_Key key = { 0 }; key.product_id = hexStringToUint16(ui->S_PID->text().toStdString()); key.vendor_id = hexStringToUint16(ui->S_VID->text().toStdString()); const auto pin = ui->S_PIN->text().toStdString(); @@ -200,3 +206,23 @@ uint16_t Widget::hexStringToUint16(const std::string &hexStr) { return static_cast(std::stoi(hexStr, nullptr, 16)); } +bool Widget::readData(uint8_t *data, int length) { + if (ui->R_PID->text().isEmpty() || ui->R_VID->text().isEmpty()) { + return false; + } + uint16_t PID = hexStringToUint16(ui->R_PID->text().toStdString()); + uint16_t VID = hexStringToUint16(ui->R_VID->text().toStdString()); + int ret = aes_usb.open(VID, PID); + aes_usb.setUserPIN(ui->R_PIN->text().toStdString()); + if (ret != 1) { + return false; + } + ret = aes_usb.read(data, length); + aes_usb.close(); + if (ret > 0) { + CTL::System::Println("Data: {}",(char*)data); + return true; + } + return false; +} + diff --git a/widget.h b/widget.h index e988139..c91158d 100644 --- a/widget.h +++ b/widget.h @@ -25,6 +25,7 @@ public: bool writeInit(); void writeClick(); static uint16_t hexStringToUint16(const std::string& hexStr); + bool readData(uint8_t* data, int length); private: Ui::Widget *ui;