@@ -1113,5 +1113,52 @@ private void checkBoxWriteProtect_CheckedChanged(object sender, EventArgs e)
1113
1113
{
1114
1114
Properties . Settings . Default . WriteCheck = checkBoxWriteProtect . Checked ;
1115
1115
}
1116
+
1117
+ private void buttonHardNested_Click ( object sender , EventArgs e )
1118
+ {
1119
+ if ( lprocess ) { MessageBox . Show ( "有任务运行中,不可执行。" , "设备忙" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ; return ; } Form1 . ActiveForm . Text = "MifareOne Tool - 运行中" ;
1120
+ FormHardNes fhn = new FormHardNes ( ) ;
1121
+ if ( fhn . ShowDialog ( ) == DialogResult . Yes )
1122
+ {
1123
+ string hardargs = fhn . GetArg ( ) ;
1124
+ BackgroundWorker bgw = new BackgroundWorker ( ) ;
1125
+ bgw . DoWork += new DoWorkEventHandler ( Hardnest ) ;
1126
+ bgw . WorkerReportsProgress = true ;
1127
+ bgw . ProgressChanged += new ProgressChangedEventHandler ( default_rpt ) ;
1128
+ bgw . RunWorkerAsync ( hardargs ) ;
1129
+ }
1130
+ else
1131
+ {
1132
+ Text = "MifareOne Tool - 已取消" ;
1133
+ }
1134
+ }
1135
+ void Hardnest ( object sender , DoWorkEventArgs e )
1136
+ {
1137
+ if ( lprocess ) { return ; }
1138
+ ProcessStartInfo psi = new ProcessStartInfo ( "nfc-bin/libnfc_hardnested.exe" ) ;
1139
+ psi . Arguments = ( string ) e . Argument ;
1140
+ psi . CreateNoWindow = true ;
1141
+ psi . UseShellExecute = false ;
1142
+ psi . RedirectStandardOutput = true ;
1143
+ psi . RedirectStandardError = true ;
1144
+ lprocess = true ;
1145
+ BackgroundWorker b = ( BackgroundWorker ) sender ;
1146
+ process = Process . Start ( psi ) ; running = true ;
1147
+ process . OutputDataReceived += ( s , _e ) => b . ReportProgress ( 0 , _e . Data ) ;
1148
+ process . ErrorDataReceived += ( s , _e ) => b . ReportProgress ( 0 , _e . Data ) ;
1149
+ //StreamReader stderr = process.StandardError;
1150
+ process . BeginOutputReadLine ( ) ;
1151
+ process . BeginErrorReadLine ( ) ;
1152
+ process . WaitForExit ( ) ;
1153
+ lprocess = false ; running = false ;
1154
+ if ( process . ExitCode == 0 )
1155
+ {
1156
+ b . ReportProgress ( 100 , "##运行完毕##" ) ;
1157
+ }
1158
+ else
1159
+ {
1160
+ b . ReportProgress ( 100 , "##运行出错##" ) ;
1161
+ }
1162
+ }
1116
1163
}
1117
1164
}
0 commit comments