diff --git a/App.config b/App.config index 36d14a7..319ab1a 100644 --- a/App.config +++ b/App.config @@ -1,17 +1,17 @@ - + - + - - + + - - + + diff --git a/FastbootEnhance.csproj b/FastbootEnhance.csproj index 1cc772c..93e42d0 100644 --- a/FastbootEnhance.csproj +++ b/FastbootEnhance.csproj @@ -8,7 +8,7 @@ WinExe FastbootEnhance FastbootEnhance - v4.5.2 + v4.7.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 @@ -90,11 +90,16 @@ packages\Google.Protobuf.3.17.3\lib\net45\Google.Protobuf.dll + + packages\Ookii.Dialogs.Wpf.5.0.1\lib\net462\Ookii.Dialogs.Wpf.dll + packages\System.Buffers.4.5.1\lib\netstandard1.1\System.Buffers.dll + + packages\System.Memory.4.5.4\lib\netstandard1.1\System.Memory.dll @@ -102,6 +107,7 @@ packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll + @@ -138,7 +144,7 @@ True Resources.ja-JP.resx - + True True Resources.ko-KR.resx @@ -149,6 +155,7 @@ True + Designer MSBuild:Compile @@ -190,18 +197,22 @@ PublicResXFileCodeGenerator Resources.ja-JP.Designer.cs + Designer - + PublicResXFileCodeGenerator Resources.ko-KR.Designer.cs + Designer PublicResXFileCodeGenerator Resources.zh-CN.Designer.cs + Designer PublicResXFileCodeGenerator Resources.Designer.cs + Designer @@ -232,4 +243,4 @@ - + \ No newline at end of file diff --git a/FastbootUI.cs b/FastbootUI.cs index 8047097..226da4e 100644 --- a/FastbootUI.cs +++ b/FastbootUI.cs @@ -1,9 +1,14 @@ using ChromeosUpdateEngine; using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; +using System.Security.Cryptography.X509Certificates; using System.Threading; using System.Windows; +using Ookii.Dialogs.Wpf; +using System.Windows.Forms; +using MessageBox = System.Windows.MessageBox; namespace FastbootEnhance { @@ -13,6 +18,7 @@ class FastbootUI static List devices; static string cur_serial; static FastbootData fastbootData; + public Var var1; static Logger logger; static void appendLog(string logs) @@ -715,6 +721,31 @@ public static void init() MessageBox.Show(Properties.Resources.payload_unsupported_format + "\n" + exc.Message); return; } + string partition_list = ""; + foreach (PartitionUpdate partitionUpdate in payload.manifest.Partitions) + { + partition_list += partitionUpdate.PartitionName + " "; + } + MessageBox.Show(partition_list); + MessageBox.Show(Var.payload_extracted_newvar.ToString()); + if (Var.payload_extracted_newvar == true) + { + System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); + dialog.Description = "请选择一个目录作为路径:"; + dialog.ShowNewFolderButton = true; + dialog.RootFolder = Environment.SpecialFolder.MyComputer; + System.Windows.Forms.DialogResult result = dialog.ShowDialog(); + Var.pe_path=dialog.SelectedPath; + + /*Ookii.Dialogs.Wpf.VistaFolderBrowserDialog folderBrowser = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog(); + folderBrowser.Description = "请选择img所在的目录"; + Var.pe_path = folderBrowser.SelectedPath;*/ + MessageBox.Show(Var.pe_path); + + } + + //Process.GetCurrentProcess().Kill(); + //Ensure that all partitions are there string unknown_partition_list = ""; @@ -739,58 +770,88 @@ public static void init() } Directory.CreateDirectory(PAYLOAD_TMP); + MessageBox.Show(PAYLOAD_TMP); + action_lock(); new Thread(new ThreadStart(delegate { int count_full = payload.manifest.Partitions.Count * 2; int count = 0; - foreach (PartitionUpdate partitionUpdate in payload.manifest.Partitions) + if (Var.payload_extracted_newvar == false) { - appendLog("Extracting " + partitionUpdate.PartitionName); - Payload.PayloadExtractionException e = payload.extract(partitionUpdate.PartitionName, - PAYLOAD_TMP, false, false); - - if (e != null) + Process.GetCurrentProcess().Kill(); + foreach (PartitionUpdate partitionUpdate in payload.manifest.Partitions) { - MessageBox.Show(e.Message); - MainWindow.THIS.Dispatcher.Invoke(new Action(delegate + appendLog("Extracting " + partitionUpdate.PartitionName); + Payload.PayloadExtractionException e = payload.extract(partitionUpdate.PartitionName, + PAYLOAD_TMP, false, false); + + if (e != null) + { + MessageBox.Show(e.Message); + MainWindow.THIS.Dispatcher.Invoke(new Action(delegate + { + action_unlock(); + })); + payload.Dispose(); + return; + } + + appendLog("Extracted " + partitionUpdate.PartitionName); + + MainWindow.THIS.Dispatcher.BeginInvoke(new Action(delegate { - action_unlock(); + MainWindow.THIS.fastboot_progress_bar.Value = 100 * ++count / count_full; + Helper.TaskbarItemHelper.update(100 * count / count_full); })); - payload.Dispose(); - return; } + foreach (PartitionUpdate partitionUpdate in payload.manifest.Partitions) + { + using (Fastboot fastboot = new Fastboot + (cur_serial, "flash \"" + partitionUpdate.PartitionName + "\" \"" + PAYLOAD_TMP + "\\" + partitionUpdate.PartitionName + ".img\"")) + { + while (true) + { + string err = fastboot.stderr.ReadLine(); - appendLog("Extracted " + partitionUpdate.PartitionName); + if (err == null) + break; - MainWindow.THIS.Dispatcher.BeginInvoke(new Action(delegate - { - MainWindow.THIS.fastboot_progress_bar.Value = 100 * ++count / count_full; - Helper.TaskbarItemHelper.update(100 * count / count_full); - })); - } + appendLog(err); + } - foreach (PartitionUpdate partitionUpdate in payload.manifest.Partitions) + MainWindow.THIS.Dispatcher.BeginInvoke(new Action(delegate + { + MainWindow.THIS.fastboot_progress_bar.Value = 100 * ++count / count_full; + Helper.TaskbarItemHelper.update(100 * count / count_full); + })); + } + } + } + else { - using (Fastboot fastboot = new Fastboot - (cur_serial, "flash \"" + partitionUpdate.PartitionName + "\" \"" + PAYLOAD_TMP + "\\" + partitionUpdate.PartitionName + ".img\"")) + foreach (PartitionUpdate partitionUpdate in payload.manifest.Partitions) { - while (true) + using (Fastboot fastboot = new Fastboot + (cur_serial, "flash \"" + partitionUpdate.PartitionName + "\" \"" + Var.pe_path + "\\" + partitionUpdate.PartitionName + ".img\"")) { - string err = fastboot.stderr.ReadLine(); + while (true) + { + string err = fastboot.stderr.ReadLine(); - if (err == null) - break; + if (err == null) + break; - appendLog(err); - } + appendLog(err); + } - MainWindow.THIS.Dispatcher.BeginInvoke(new Action(delegate - { - MainWindow.THIS.fastboot_progress_bar.Value = 100 * ++count / count_full; - Helper.TaskbarItemHelper.update(100 * count / count_full); - })); + MainWindow.THIS.Dispatcher.BeginInvoke(new Action(delegate + { + MainWindow.THIS.fastboot_progress_bar.Value = 100 * ++count / count_full; + Helper.TaskbarItemHelper.update(100 * count / count_full); + })); + } } } diff --git a/MainWindow.xaml b/MainWindow.xaml index 1137e88..b7030ef 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -134,7 +134,7 @@