From a4f271a1ea4fb4a171f77d381dc9252301a1d6bd Mon Sep 17 00:00:00 2001 From: XAS-712 Date: Fri, 18 Jan 2019 22:51:34 +0800 Subject: [PATCH] Update Form1.cs --- MifareOneTool/Form1.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/MifareOneTool/Form1.cs b/MifareOneTool/Form1.cs index 7f1b7f9..8c81f5c 100644 --- a/MifareOneTool/Form1.cs +++ b/MifareOneTool/Form1.cs @@ -237,6 +237,28 @@ namespace MifareOneTool } } + bool writecheck(string file) + { + S50 card = new S50(); + try + { + card.LoadFromMfd(file); + } + catch (IOException ioe) + { + MessageBox.Show(ioe.Message, "打开出错", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + if (card.Verify()[16] == 0x00) + { + return true; + } + else + { + return false; + } + } + private void buttonMfWrite_Click(object sender, EventArgs e) { if (lprocess) { MessageBox.Show("有任务运行中,不可执行。", "设备忙", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Form1.ActiveForm.Text = "MifareOne Tool - 运行中"; @@ -254,6 +276,7 @@ namespace MifareOneTool { return; } + if (!writecheck(rmfd)) { MessageBox.Show("将要写入的文件存在错误,请用高级模式中的Hex工具打开查看。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string kt = "a"; string nn = ""; switch (MessageBox.Show("使用KeyA(是)或KeyB(否),还是不使用(用于全新白卡)(取消)?", "KeyA/B/N", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information)) @@ -649,6 +672,7 @@ namespace MifareOneTool { return; } + if (!writecheck(rmfd)) { MessageBox.Show("将要写入的文件存在错误,请用高级模式中的Hex工具打开查看。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string kt = "a"; string nn = ""; switch (MessageBox.Show("使用KeyA(是)或KeyB(否),还是不使用(用于全新白卡)(取消)?", "KeyA/B/N", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information))