Skip to content

Commit

Permalink
FIX V29F
Browse files Browse the repository at this point in the history
  • Loading branch information
werasik2aa authored Jan 15, 2024
1 parent 767e2f5 commit 025a6dc
Show file tree
Hide file tree
Showing 25 changed files with 1,019 additions and 1,027 deletions.
3 changes: 2 additions & 1 deletion HuaweiUnlock/DIAGNOS/Bootloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ private bool Validate()
return true;
}

using (var stream = File.OpenRead(Path)) {
using (var stream = File.OpenRead(Path))
{
using (var sha1 = SHA1.Create())
{
stream.Position = 0;
Expand Down
6 changes: 2 additions & 4 deletions HuaweiUnlock/DIAGNOS/CRC.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.Text;
using System.Globalization;
using System.Linq;
using System.Security.Cryptography;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Globalization;
using System.Text;

namespace HuaweiUnlocker.DIAGNOS
{
Expand Down
3 changes: 0 additions & 3 deletions HuaweiUnlock/DIAGNOS/LibCrypt.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using Base62;
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Windows.Input;
using static HuaweiUnlocker.LangProc;
namespace HuaweiUnlocker.DIAGNOS
{
Expand Down
8 changes: 3 additions & 5 deletions HuaweiUnlock/DIAGNOS/OemInfoTool.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using Microsoft.VisualBasic.Logging;
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using static HuaweiUnlocker.LangProc;
namespace HuaweiUnlocker.DIAGNOS
{
Expand All @@ -28,7 +25,8 @@ public static void Decompile(string path, string Header = "4F454D5F494E464F06")
for (var i = 0; i < Offsets.Count; i++)
data.Add("OEM_INFO_" + Offsets[i] + ".header");
File.WriteAllBytes("UnlockFiles/OemInfoData/OEM_INFO_" + 0 + ".header", FileAll.Take(Offsets[0]).ToArray());
for (int i = 0; i < Offsets.Count; i++) {
for (int i = 0; i < Offsets.Count; i++)
{
int curof = Offsets[i];
LOG(0, "Writting: OEM_INFO_" + curof + ".header");
if (Offsets.Count > i + 1)
Expand Down
8 changes: 2 additions & 6 deletions HuaweiUnlock/FlashTool/FlashToolQClegacy.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
using System;
using static HuaweiUnlocker.LangProc;
using System.Collections.Generic;
using HuaweiUnlocker.DIAGNOS;
using System.IO;
using System.Collections.Concurrent;
using System.Threading.Tasks;
using System.Security.Cryptography.Xml;
using System.Threading;
using System.Linq;
using System.Threading.Tasks;
using static HuaweiUnlocker.LangProc;

namespace HuaweiUnlocker.FlashTool
{
Expand Down
4 changes: 1 addition & 3 deletions HuaweiUnlock/FlashTool/MTKFlash.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using HuaweiUnlocker.DIAGNOS;
using System;
using static HuaweiUnlocker.LangProc;
using static HuaweiUnlocker.LangProc;
namespace HuaweiUnlocker.FlashTool
{
public class MTKFlash
Expand Down
42 changes: 19 additions & 23 deletions HuaweiUnlock/LangProc.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
using System;
using HuaweiUnlocker.DIAGNOS;
using HuaweiUnlocker.FlashTool;
using HuaweiUnlocker.UI;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using System.IO;
using System.Management;
using HuaweiUnlocker.UI;
using HuaweiUnlocker.FlashTool;
using System.Linq;
using System.Threading;
using HuaweiUnlocker.DIAGNOS;
using System.Globalization;
using System.Management;
using System.Reflection;
using System.Text;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Base62;
using System.Runtime.CompilerServices;
using System.Reflection;
using System.Windows.Forms;

namespace HuaweiUnlocker
{
Expand Down Expand Up @@ -317,15 +313,15 @@ public static Dictionary<string, Partition> GET_GPT_FROM_FILE(string GPT_File, i
if (!string.IsNullOrEmpty(bsa) && !string.IsNullOrEmpty(bea))
{
uint blocks_count = Convert.ToUInt32(bea, 16) - Convert.ToUInt32(bsa, 16) + 1;
if(!GPT.ContainsKey(bn.ToString()) & !bn.ToString().Contains("userdata") & !string.IsNullOrEmpty(bn.ToString()))
GPT.Add(bn.ToString().Replace(".img", ""), new Partition()
{
BlockStart = Convert.ToInt32(bsa, 16).ToString(),
BlockEnd = Convert.ToInt32(bea, 16).ToString(),
BlockBytes = (blocks_count * block_size).ToString(),
BlockNumSectors = blocks_count.ToString(),
BlockLength = (blocks_count / 2).ToString(),
});
if (!GPT.ContainsKey(bn.ToString()) & !bn.ToString().Contains("userdata") & !string.IsNullOrEmpty(bn.ToString()))
GPT.Add(bn.ToString().Replace(".img", ""), new Partition()
{
BlockStart = Convert.ToInt32(bsa, 16).ToString(),
BlockEnd = Convert.ToInt32(bea, 16).ToString(),
BlockBytes = (blocks_count * block_size).ToString(),
BlockNumSectors = blocks_count.ToString(),
BlockLength = (blocks_count / 2).ToString(),
});
}
}
return GPT;
Expand Down Expand Up @@ -399,7 +395,7 @@ public static bool WriteGPT_TO_XML(string papthto, Dictionary<string, Partition>
writer.Dispose();
return partbI.Count > 0;
}
public static void Progress(int v, int max=100)
public static void Progress(int v, int max = 100)
{
action = () => { PRG.Value = v; PRG.ValueMaximum = max; };
if (PRG.InvokeRequired)
Expand All @@ -410,7 +406,7 @@ public static void Progress(int v, int max=100)
}
public static string GuessMbn()
{
if(!string.IsNullOrEmpty(wndw.LoaderBox.Text))
if (!string.IsNullOrEmpty(wndw.LoaderBox.Text))
return PickLoader(wndw.LoaderBox.Text);
if (wndw.AutoLdr.Checked & DeviceInfo.HWID.Contains("NaN"))
return LOG(0, "NoDEVICEAnsw").ToString();
Expand Down
1 change: 0 additions & 1 deletion HuaweiUnlock/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Diagnostics;
using System.Windows.Forms;
using static HuaweiUnlocker.LangProc;

namespace HuaweiUnlocker
{
Expand Down
9 changes: 3 additions & 6 deletions HuaweiUnlock/TOOLS/Fastboot.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using LibUsbDotNet;
using LibUsbDotNet.Main;
using System;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using LibUsbDotNet;
using LibUsbDotNet.Main;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using static HuaweiUnlocker.LangProc;
namespace HuaweiUnlocker.TOOLS
{
Expand Down
12 changes: 5 additions & 7 deletions HuaweiUnlock/TOOLS/HISI.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using HuaweiUnlocker.DIAGNOS;
using Microsoft.VisualBasic.Logging;
using System;
using System.Collections.Generic;
using System.Runtime.Remoting.Messaging;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using static HuaweiUnlocker.LangProc;
namespace HuaweiUnlocker.TOOLS
{
Expand Down Expand Up @@ -53,7 +50,8 @@ public static void FlashBootloader(Bootloader bootloader, string port)

LOG(0, "EwPS", image.Role);

flasher.Write(image.Path, (int)image.Address, x => {
flasher.Write(image.Path, (int)image.Address, x =>
{
Progress(dsize, asize);
});

Expand Down Expand Up @@ -145,7 +143,7 @@ public static void SetNVMEProp(string prop, byte[] value)

var res = fb.Command(cmd.ToArray());

LOG(0, "", res.Payload) ;
LOG(0, "", res.Payload);

if (!res.Payload.Contains("set nv ok"))
{
Expand All @@ -155,7 +153,7 @@ public static void SetNVMEProp(string prop, byte[] value)

public static byte[] GetSHA256(string str)
{
return SHA256.Create().ComputeHash(Encoding.ASCII.GetBytes(str));
return SHA256.Create().ComputeHash(Encoding.ASCII.GetBytes(str));
}

public static void SetHWDogState(byte state)
Expand Down Expand Up @@ -312,7 +310,7 @@ public static void StartUnlockPRCS(bool frp, bool rb, string key, Bootloader d,
LOG(1, "Unlocker", "(KIRIN FRP)");
UnlockFRP();
}
if(rb) Reboot();
if (rb) Reboot();
fb.Disconnect();
}
else LOG(1, "NoDEVICEAnsw", " [HISI] Maybe hisi Loaders Wont boot");
Expand Down
7 changes: 3 additions & 4 deletions HuaweiUnlock/TOOLS/UpdateApp.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using HuaweiUnlocker.Core;
using HuaweiUnlocker.FlashTool;
using HuaweiUnlocker.UI;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using static HuaweiUnlocker.LangProc;

namespace HuaweiUnlocker.TOOLS
Expand Down Expand Up @@ -44,7 +42,7 @@ public static async void Unpack(string path, int state)
}
//Set 0
unpacked = true;
if(state != 3)
if (state != 3)
CreateRWProgram0xml();
else
ReadFilesInDirAsPartitions();
Expand Down Expand Up @@ -108,7 +106,8 @@ public static void ReadFilesInDirAsPartitions()
DirectoryInfo hdDirectoryInWhichToSearch = new DirectoryInfo("UnlockFiles/UpdateAPP/");
FileInfo[] filesInDir = hdDirectoryInWhichToSearch.GetFiles();
foreach (var a in filesInDir)
gpttable.Add(a.FullName.Split('\\').Last(),new Partition() {
gpttable.Add(a.FullName.Split('\\').Last(), new Partition()
{
BlockLength = new FileInfo(a.FullName).Length.ToString(),
});
DeviceInfo.Partitions = gpttable;
Expand Down
2 changes: 1 addition & 1 deletion HuaweiUnlock/TOOLS/UpdateUtil/EventStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class ReadEventArgs : EventArgs
/// <summary>
/// Read buffer
/// </summary>
public byte []Buffer;
public byte[] Buffer;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion HuaweiUnlock/TOOLS/UpdateUtil/FileHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal struct FileHeader
public UInt16 HeaderChecksum;
public UInt16 BlockSize;
public UInt16 Blank2;
public static readonly int Size = Marshal.SizeOf(typeof (FileHeader));
public static readonly int Size = Marshal.SizeOf(typeof(FileHeader));
public static FileHeader Create()
{
var result = new FileHeader
Expand Down
10 changes: 5 additions & 5 deletions HuaweiUnlock/TOOLS/UpdateUtil/PartialStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public class PartialStream : Stream
{
private readonly Stream _baseStream;
private readonly long _basePosition;
private readonly long _size;
private readonly long _size;

/// <summary>
/// Wrapper around <see cref="Stream"/> to work with a part of a stream
/// </summary>
Expand All @@ -36,8 +36,8 @@ public class PartialStream : Stream
public PartialStream(Stream baseStream, long size)
{
_baseStream = baseStream;
_basePosition = baseStream.Position;
_basePosition = baseStream.Position;

if (_basePosition + _size > _baseStream.Length)
throw new ArgumentOutOfRangeException("size", _basePosition + _size, "Invalid size");
_size = size;
Expand Down Expand Up @@ -109,7 +109,7 @@ public override int Read(byte[] buffer, int offset, int count)
if (currentPosition + count > _size)
{
var rc = _size - currentPosition;
count = (rc > int.MaxValue) ? int.MaxValue : (int) rc;
count = (rc > int.MaxValue) ? int.MaxValue : (int)rc;
}

return _baseStream.Read(buffer, offset, count);
Expand Down
6 changes: 3 additions & 3 deletions HuaweiUnlock/TOOLS/UpdateUtil/UpdateEntry.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using HuaweiUnlocker.Streams;
using System.IO;
using HuaweiUnlocker.DIAGNOS;
using HuaweiUnlocker.Streams;
using System;
using HuaweiUnlocker.DIAGNOS;
using System.IO;

namespace HuaweiUnlocker.Core
{
Expand Down
6 changes: 3 additions & 3 deletions HuaweiUnlock/TOOLS/UpdateUtil/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace HuaweiUnlocker.Core
{
internal static class Utilities
{
public const Int32 UintSize = sizeof (UInt32);
public const Int32 UshortSize = sizeof (ushort);
public const Int32 UintSize = sizeof(UInt32);
public const Int32 UshortSize = sizeof(ushort);

public static bool ByteToType<T>(BinaryReader reader, out T result)
{
Expand Down Expand Up @@ -64,7 +64,7 @@ public static void SetCharArray(string source, byte[] destination)
public static string GetString(byte[] source)
{
var index = Array.FindIndex(source, b => b == 0);
if (index == -1)
if (index == -1)
index = source.Length;
return Encoding.ASCII.GetString(source, 0, index);
}
Expand Down
10 changes: 5 additions & 5 deletions HuaweiUnlock/UI/Animation/Animation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ private float Step()
float basicStep = Math.Abs(Volume) / StepDivider; // Math.Abs - превращает числа 0< в >0
float resultStep = 0;

if(Reverse == false)
if (Reverse == false)
{
if(Value <= p15 || Value >= p85)
if (Value <= p15 || Value >= p85)
{
resultStep = basicStep / 3.5f;
}
else if (Value <= p30 || Value >= p70)
{
resultStep = basicStep / 2f;
}
else if(Value > p30 && Value < p70)
else if (Value > p30 && Value < p70)
{
resultStep = basicStep;
}
Expand Down Expand Up @@ -94,11 +94,11 @@ public void UpdateFrame()

if (Reverse == false)
{
if(Value <= targetValue)
if (Value <= targetValue)
{
Value += Step();

if(Value >= targetValue)
if (Value >= targetValue)
{
Value = targetValue;
Status = AnimationStatus.Completed;
Expand Down
Loading

0 comments on commit 025a6dc

Please sign in to comment.