V0.1
This commit is contained in:
parent
28e0cec76f
commit
6e2a0e6e3c
@ -1,6 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="BackendCodeEditorSettings">
|
||||
<option name="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=Component_0020Designer_0020generated_0020code/@EntryIndexedValue" value="Component Designer generated code" type="string" />
|
||||
<option name="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=Designer_0020generated_0020code/@EntryIndexedValue" value="Designer generated code" type="string" />
|
||||
<option name="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=Web_0020Form_0020Designer_0020generated_0020code/@EntryIndexedValue" value="Web Form Designer generated code" type="string" />
|
||||
<option name="/Default/CodeInspection/GeneratedCode/GeneratedCodeRegions/=Windows_0020Form_0020Designer_0020generated_0020code/@EntryIndexedValue" value="Windows Form Designer generated code" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CDeclarationWithImplicitIntType/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CommentTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
|
||||
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConstevalIfIsAlwaysConstant/@EntryIndexedValue" value="WARNING" type="string" />
|
||||
|
||||
@ -4,4 +4,5 @@
|
||||
<option name="pythonIntegrationState" value="YES" />
|
||||
</component>
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
<component name="WestSettings"><![CDATA[{}]]></component>
|
||||
</project>
|
||||
@ -31,11 +31,11 @@ if(ANDROID)
|
||||
)
|
||||
else()
|
||||
add_executable(USB_Config_Vendor
|
||||
WIN32
|
||||
main.cpp
|
||||
widget.cpp
|
||||
widget.h
|
||||
widget.ui
|
||||
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
30
widget.cpp
30
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<uint16_t>(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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user