Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support flash extracted payload.bin #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions App.config
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Expand Down
19 changes: 15 additions & 4 deletions FastbootEnhance.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<RootNamespace>FastbootEnhance</RootNamespace>
<AssemblyName>FastbootEnhance</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -90,18 +90,24 @@
<Reference Include="Google.Protobuf, Version=3.17.3.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
<HintPath>packages\Google.Protobuf.3.17.3\lib\net45\Google.Protobuf.dll</HintPath>
</Reference>
<Reference Include="Ookii.Dialogs.Wpf, Version=5.0.0.0, Culture=neutral, PublicKeyToken=66aa232afad40158, processorArchitecture=MSIL">
<HintPath>packages\Ookii.Dialogs.Wpf.5.0.1\lib\net462\Ookii.Dialogs.Wpf.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.5.1\lib\netstandard1.1\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Memory.4.5.4\lib\netstandard1.1\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Security" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -138,7 +144,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.ja-JP.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Resources.ko-KR.Designer.cs">
<Compile Include="Properties\Resources.ko-KR.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.ko-KR.resx</DependentUpon>
Expand All @@ -149,6 +155,7 @@
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="UpdateMetadata.cs" />
<Compile Include="Var.cs" />
<Page Include="FastbootActionWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -190,18 +197,22 @@
<EmbeddedResource Include="Properties\Resources.ja-JP.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.ja-JP.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.ko-KR.resx">
<EmbeddedResource Include="Properties\Resources.ko-KR.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.ko-KR.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.zh-CN.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.zh-CN.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
Expand Down Expand Up @@ -232,4 +243,4 @@
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
125 changes: 93 additions & 32 deletions FastbootUI.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -13,6 +18,7 @@ class FastbootUI
static List<fastboot_devices_row> devices;
static string cur_serial;
static FastbootData fastbootData;
public Var var1;

static Logger logger;
static void appendLog(string logs)
Expand Down Expand Up @@ -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 = "";
Expand All @@ -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);
}));
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
<Button x:Name="fastboot_ab_switch" Margin="5,5,5,5" Content="切换分区" Grid.Column="1"/>
<Button x:Name="fastboot_flash_payload" Margin="5,5,5,5" Content="{x:Static props:Resources.fastboot_flash_payload}" Grid.Column="2"/>
<Button x:Name="fastboot_cancel_update" Margin="5,5,5,5" Content="{x:Static props:Resources.fastboot_cancel_update}" Grid.Column="3"/>

</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
Expand All @@ -144,9 +144,10 @@
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label VerticalAlignment="Center" x:Name="fastboot_cur_device" Content="{x:Static props:Resources.fastboot_current_device}" Grid.Column="0"/>
<Button x:Name="fastboot_remove" Margin="5 5 5 5" Content="{x:Static props:Resources.fastboot_remove_device}" Grid.Column="1"/>
<Button x:Name="fastboot_reboot_system" Margin="5 5 5 5" Content="{x:Static props:Resources.fastboot_reboot_system}" Grid.Column="2"/>
<Button x:Name="fastboot_remove" Margin="4,5,72,5" Content="{x:Static props:Resources.fastboot_remove_device}" Grid.Column="2"/>
<Button x:Name="fastboot_reboot_system" Margin="76,5,143,5" Content="{x:Static props:Resources.fastboot_reboot_system}" Grid.Column="2" Grid.ColumnSpan="2"/>
<Button x:Name="fastboot_reboot_recovery" Margin="5 5 5 5" Content="{x:Static props:Resources.fastboot_reboot_recovery}" Grid.Column="3"/>
<CheckBox Grid.Column="1" Content="已解压payload" HorizontalAlignment="Left" Margin="31,0,0,0" VerticalAlignment="Center" x:Name="payload_extracted_new" Checked="payload_extracted_Checked" Unchecked="payload_extracted_UnChecked"/>
</Grid>
</Grid>
</Grid>
Expand Down
12 changes: 12 additions & 0 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace FastbootEnhance
public partial class MainWindow : Window
{
public static MainWindow THIS;
public bool payloadextracted = false;
const string version = "1.4.0";
public MainWindow()
{
Expand Down Expand Up @@ -75,5 +76,16 @@ private void OSS_Click(object sender, RoutedEventArgs e)
{
Process.Start("https://github.com/libxzr/FastbootEnhance");
}

private void payload_extracted_Checked(object sender, RoutedEventArgs e)
{
Var.payload_extracted_newvar = true;
MessageBox.Show(Var.payload_extracted_newvar.ToString());
}
private void payload_extracted_UnChecked(object sender, RoutedEventArgs e)
{
Var.payload_extracted_newvar = false;
MessageBox.Show(Var.payload_extracted_newvar.ToString());
}
}
}
1 change: 0 additions & 1 deletion Properties/Resources.ko-KR.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Var.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FastbootEnhance
{
internal class Var
{
public static bool payload_extracted_newvar = false;
public static string pe_path;
}
}
7 changes: 4 additions & 3 deletions packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
<packages>
<package id="DotNetZip" version="1.15.0" targetFramework="net45" />
<package id="Google.Protobuf" version="3.17.3" targetFramework="net45" />
<package id="System.Buffers" version="4.5.1" targetFramework="net45" />
<package id="System.Memory" version="4.5.4" targetFramework="net45" />
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net45" />
<package id="Ookii.Dialogs.Wpf" version="5.0.1" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net45" requireReinstallation="true" />
<package id="System.Memory" version="4.5.4" targetFramework="net45" requireReinstallation="true" />
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net45" requireReinstallation="true" />
<package id="XZ.NET" version="2.0.0" targetFramework="net45" />
</packages>