From 96c42a29b5904a63a19bcff2b87394a76df42fcb Mon Sep 17 00:00:00 2001 From: Gustave Monce Date: Sun, 26 Nov 2023 14:03:46 +0100 Subject: [PATCH] Adopt new C# syntax for array init --- WPinternals/7zip/Compress/LZMA/LzmaEncoder.cs | 4 +-- WPinternals/CommandLine.cs | 2 +- .../DiscUtils/DiscUtils.Fat/FileName.cs | 8 ++--- .../DiscUtils.Fat/FileSystemFactory.cs | 2 +- .../DiscUtils.Fat/Modified/Directory.cs | 32 +++++++++---------- WPinternals/HelperClasses.cs | 6 ++-- WPinternals/Models/ByteOperations.cs | 4 +-- WPinternals/Models/FFU.cs | 6 ++-- WPinternals/Models/GPT.cs | 2 +- WPinternals/Models/LZMA.cs | 6 ++-- WPinternals/Models/MassStorage.cs | 4 +-- WPinternals/Models/NokiaFlashModel.cs | 8 ++--- WPinternals/Models/PatchEngine.cs | 8 ++--- WPinternals/Models/QualcommDownload.cs | 14 ++++---- WPinternals/Models/QualcommFlasher.cs | 24 ++++++-------- WPinternals/Models/QualcommPartition.cs | 6 ++-- WPinternals/Models/QualcommSahara.cs | 30 ++++++++--------- WPinternals/Models/QualcommSerial.cs | 6 ++-- WPinternals/Models/SBL1.cs | 28 ++++++++-------- WPinternals/Models/SBL2.cs | 8 ++--- WPinternals/Models/SBL3.cs | 6 ++-- WPinternals/Models/UEFI.cs | 14 ++++---- .../LumiaUnlockBootloaderViewModel.cs | 2 +- .../ViewModels/LumiaV2UnlockBootViewModel.cs | 4 +-- .../ViewModels/LumiaV3FlashRomViewModel.cs | 4 +-- WPinternals/ViewModels/NokiaLabelViewModel.cs | 2 +- WPinternals/ViewModels/SwitchModeViewModel.cs | 22 ++++++------- 27 files changed, 129 insertions(+), 133 deletions(-) diff --git a/WPinternals/7zip/Compress/LZMA/LzmaEncoder.cs b/WPinternals/7zip/Compress/LZMA/LzmaEncoder.cs index 7d1dac9..7638ec5 100644 --- a/WPinternals/7zip/Compress/LZMA/LzmaEncoder.cs +++ b/WPinternals/7zip/Compress/LZMA/LzmaEncoder.cs @@ -1518,10 +1518,10 @@ namespace SevenZip.Compression.LZMA } private static readonly string[] kMatchFinderIDs = - { + [ "BT2", "BT4", - }; + ]; private static int FindMatchFinder(string s) { diff --git a/WPinternals/CommandLine.cs b/WPinternals/CommandLine.cs index 7d1ddf9..a19f21e 100644 --- a/WPinternals/CommandLine.cs +++ b/WPinternals/CommandLine.cs @@ -114,7 +114,7 @@ namespace WPinternals return; } - switch (args[1].ToLower().TrimStart(new char[] { '-', '/' })) + switch (args[1].ToLower().TrimStart(['-', '/'])) { #if DEBUG case "test": diff --git a/WPinternals/DiscUtils/DiscUtils.Fat/FileName.cs b/WPinternals/DiscUtils/DiscUtils.Fat/FileName.cs index c1cd0c2..7546af7 100644 --- a/WPinternals/DiscUtils/DiscUtils.Fat/FileName.cs +++ b/WPinternals/DiscUtils/DiscUtils.Fat/FileName.cs @@ -31,15 +31,15 @@ namespace DiscUtils.Fat private const byte SpaceByte = 0x20; public static readonly FileName SelfEntryName = - new(new byte[] { 0x2E, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }, 0); + new([0x2E, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20], 0); public static readonly FileName ParentEntryName = - new(new byte[] { 0x2E, 0x2E, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }, 0); + new([0x2E, 0x2E, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20], 0); public static readonly FileName Null = - new(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0); + new([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], 0); - private static readonly byte[] InvalidBytes = { 0x22, 0x2A, 0x2B, 0x2C, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x5B, 0x5C, 0x5D, 0x7C }; + private static readonly byte[] InvalidBytes = [0x22, 0x2A, 0x2B, 0x2C, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x5B, 0x5C, 0x5D, 0x7C]; private readonly byte[] _raw; diff --git a/WPinternals/DiscUtils/DiscUtils.Fat/FileSystemFactory.cs b/WPinternals/DiscUtils/DiscUtils.Fat/FileSystemFactory.cs index 8228f88..3c91f87 100644 --- a/WPinternals/DiscUtils/DiscUtils.Fat/FileSystemFactory.cs +++ b/WPinternals/DiscUtils/DiscUtils.Fat/FileSystemFactory.cs @@ -33,7 +33,7 @@ namespace DiscUtils.Fat { if (FatFileSystem.Detect(stream)) { - return new FileSystemInfo[] { new VfsFileSystemInfo("FAT", "Microsoft FAT", Open) }; + return [new VfsFileSystemInfo("FAT", "Microsoft FAT", Open)]; } return System.Array.Empty(); diff --git a/WPinternals/DiscUtils/DiscUtils.Fat/Modified/Directory.cs b/WPinternals/DiscUtils/DiscUtils.Fat/Modified/Directory.cs index c1f2247..1726e2e 100644 --- a/WPinternals/DiscUtils/DiscUtils.Fat/Modified/Directory.cs +++ b/WPinternals/DiscUtils/DiscUtils.Fat/Modified/Directory.cs @@ -80,22 +80,22 @@ namespace DiscUtils.Fat { // see http://home.teleport.com/~brainy/lfn.htm // NOTE: we assume ordinals are ok here. - char[] chars = new char[13]; - chars[0] = (char)((256 * buffer[2]) + buffer[1]); - chars[1] = (char)((256 * buffer[4]) + buffer[3]); - chars[2] = (char)((256 * buffer[6]) + buffer[5]); - chars[3] = (char)((256 * buffer[8]) + buffer[7]); - chars[4] = (char)((256 * buffer[10]) + buffer[9]); - - chars[5] = (char)((256 * buffer[15]) + buffer[14]); - chars[6] = (char)((256 * buffer[17]) + buffer[16]); - chars[7] = (char)((256 * buffer[19]) + buffer[18]); - chars[8] = (char)((256 * buffer[21]) + buffer[20]); - chars[9] = (char)((256 * buffer[23]) + buffer[22]); - chars[10] = (char)((256 * buffer[25]) + buffer[24]); - - chars[11] = (char)((256 * buffer[29]) + buffer[28]); - chars[12] = (char)((256 * buffer[31]) + buffer[30]); + char[] chars = + [ + (char)((256 * buffer[2]) + buffer[1]), + (char)((256 * buffer[4]) + buffer[3]), + (char)((256 * buffer[6]) + buffer[5]), + (char)((256 * buffer[8]) + buffer[7]), + (char)((256 * buffer[10]) + buffer[9]), + (char)((256 * buffer[15]) + buffer[14]), + (char)((256 * buffer[17]) + buffer[16]), + (char)((256 * buffer[19]) + buffer[18]), + (char)((256 * buffer[21]) + buffer[20]), + (char)((256 * buffer[23]) + buffer[22]), + (char)((256 * buffer[25]) + buffer[24]), + (char)((256 * buffer[29]) + buffer[28]), + (char)((256 * buffer[31]) + buffer[30]), + ]; string chunk = new(chars); int zero = chunk.IndexOf('\0'); return zero >= 0 ? chunk.Substring(0, zero) : chunk; diff --git a/WPinternals/HelperClasses.cs b/WPinternals/HelperClasses.cs index fcb6cdc..0ad5acc 100644 --- a/WPinternals/HelperClasses.cs +++ b/WPinternals/HelperClasses.cs @@ -924,7 +924,7 @@ namespace WPinternals { if (proxy?.CheckAccess() == false) { - proxy.BeginInvoke(new Action(CallHandler), new object[] { sender, eventHandler }); + proxy.BeginInvoke(new Action(CallHandler), [sender, eventHandler]); } else { @@ -1890,7 +1890,7 @@ namespace WPinternals internal static Version GetFileVersion(byte[] PEfile) { - byte[] version = GetResource(PEfile, new int[] { (int)ResourceType.RT_VERSION, 1, 1033 }); + byte[] version = GetResource(PEfile, [(int)ResourceType.RT_VERSION, 1, 1033]); // RT_VERSION format: // https://msdn.microsoft.com/en-us/library/windows/desktop/ms647001(v=vs.85).aspx @@ -1906,7 +1906,7 @@ namespace WPinternals internal static Version GetProductVersion(byte[] PEfile) { - byte[] version = GetResource(PEfile, new int[] { (int)ResourceType.RT_VERSION, 1, 1033 }); + byte[] version = GetResource(PEfile, [(int)ResourceType.RT_VERSION, 1, 1033]); // RT_VERSION format: // https://msdn.microsoft.com/en-us/library/windows/desktop/ms647001(v=vs.85).aspx diff --git a/WPinternals/Models/ByteOperations.cs b/WPinternals/Models/ByteOperations.cs index a59a295..cbe5898 100644 --- a/WPinternals/Models/ByteOperations.cs +++ b/WPinternals/Models/ByteOperations.cs @@ -332,7 +332,7 @@ namespace WPinternals return (UInt16)(0x10000 - Checksum); } - private static readonly UInt32[] CRC32Table = new UInt32[] { + private static readonly UInt32[] CRC32Table = [ 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, @@ -376,7 +376,7 @@ namespace WPinternals 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D - }; + ]; internal static UInt32 CRC32(byte[] Input, UInt32 Offset, UInt32 Length) { diff --git a/WPinternals/Models/FFU.cs b/WPinternals/Models/FFU.cs index a8103f9..a9da55a 100644 --- a/WPinternals/Models/FFU.cs +++ b/WPinternals/Models/FFU.cs @@ -84,7 +84,7 @@ namespace WPinternals // Read Store Header byte[] ShortStoreHeader = new byte[248]; FFUFile.Read(ShortStoreHeader, 0, 248); - PlatformID = ByteOperations.ReadAsciiString(ShortStoreHeader, 0x0C, 192).TrimEnd(new char[] { (char)0, ' ' }); + PlatformID = ByteOperations.ReadAsciiString(ShortStoreHeader, 0x0C, 192).TrimEnd([(char)0, ' ']); int WriteDescriptorCount = ByteOperations.ReadInt32(ShortStoreHeader, 208); UInt32 WriteDescriptorLength = ByteOperations.ReadUInt32(ShortStoreHeader, 212); UInt32 ValidateDescriptorLength = ByteOperations.ReadUInt32(ShortStoreHeader, 220); @@ -455,8 +455,8 @@ namespace WPinternals if (Offset != null) { uint Start = (uint)Offset + 10; - uint Length = (uint)ByteOperations.FindPattern(Data, Start, 0x100, new byte[] { 0x00 }, null, null) - Start; - uint? Offset0D = ByteOperations.FindPattern(Data, Start, 0x100, new byte[] { 0x0D }, null, null); + uint Length = (uint)ByteOperations.FindPattern(Data, Start, 0x100, [0x00], null, null) - Start; + uint? Offset0D = ByteOperations.FindPattern(Data, Start, 0x100, [0x0D], null, null); if ((Offset0D != null) && (Offset0D < (Start + Length))) { Length = (uint)Offset0D - Start; diff --git a/WPinternals/Models/GPT.cs b/WPinternals/Models/GPT.cs index 81c83bd..0d5a743 100644 --- a/WPinternals/Models/GPT.cs +++ b/WPinternals/Models/GPT.cs @@ -74,7 +74,7 @@ namespace WPinternals while (PartitionOffset < (TableOffset + TableSize)) { - string Name = ByteOperations.ReadUnicodeString(GPTBuffer, PartitionOffset + 0x38, 0x48).TrimEnd(new char[] { (char)0, ' ' }); + string Name = ByteOperations.ReadUnicodeString(GPTBuffer, PartitionOffset + 0x38, 0x48).TrimEnd([(char)0, ' ']); if (Name.Length == 0) { break; diff --git a/WPinternals/Models/LZMA.cs b/WPinternals/Models/LZMA.cs index 3c79335..25f973a 100644 --- a/WPinternals/Models/LZMA.cs +++ b/WPinternals/Models/LZMA.cs @@ -110,9 +110,9 @@ namespace WPinternals if (DictionarySize != 0) { Encoder.SetCoderProperties( - new CoderPropID[8] {CoderPropID.DictionarySize, CoderPropID.PosStateBits, CoderPropID.LitContextBits, - CoderPropID.LitPosBits, CoderPropID.Algorithm, CoderPropID.NumFastBytes, CoderPropID.MatchFinder, CoderPropID.EndMarker}, - new object[8] { DictionarySize, PosStateBits, LitContextBits, LitPosBits, Algorithm, NumFastBytes, MatchFinder, EndMarker }); + [CoderPropID.DictionarySize, CoderPropID.PosStateBits, CoderPropID.LitContextBits, + CoderPropID.LitPosBits, CoderPropID.Algorithm, CoderPropID.NumFastBytes, CoderPropID.MatchFinder, CoderPropID.EndMarker], + [DictionarySize, PosStateBits, LitContextBits, LitPosBits, Algorithm, NumFastBytes, MatchFinder, EndMarker]); } Encoder.WriteCoderProperties(stream); diff --git a/WPinternals/Models/MassStorage.cs b/WPinternals/Models/MassStorage.cs index f49c51c..4dadc1c 100644 --- a/WPinternals/Models/MassStorage.cs +++ b/WPinternals/Models/MassStorage.cs @@ -111,10 +111,10 @@ namespace WPinternals SerialDevice.EncodeCommands = false; // This will succeed on new models - SerialDevice.SendData(new byte[] { 0x7, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0 }); + SerialDevice.SendData([0x7, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0]); // This will succeed on old models - SerialDevice.SendData(new byte[] { 0x7E, 0xA, 0x0, 0x0, 0xB6, 0xB5, 0x7E }); + SerialDevice.SendData([0x7E, 0xA, 0x0, 0x0, 0xB6, 0xB5, 0x7E]); SerialDevice.Close(); SerialDevice.Dispose(); diff --git a/WPinternals/Models/NokiaFlashModel.cs b/WPinternals/Models/NokiaFlashModel.cs index 7f14ed0..c497513 100644 --- a/WPinternals/Models/NokiaFlashModel.cs +++ b/WPinternals/Models/NokiaFlashModel.cs @@ -80,7 +80,7 @@ namespace WPinternals return null; } - return System.Text.Encoding.ASCII.GetString(Bytes).Trim(new char[] { '\0' }); + return System.Text.Encoding.ASCII.GetString(Bytes).Trim(['\0']); } [Flags] @@ -193,7 +193,7 @@ namespace WPinternals public TerminalResponse GetTerminalResponse() { - byte[] AsskMask = new byte[0x10] { 1, 0, 16, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64 }; + byte[] AsskMask = [1, 0, 16, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64]; byte[] Request = new byte[0xAC]; const string Header = "NOKXFT"; Buffer.BlockCopy(System.Text.Encoding.ASCII.GetBytes(Header), 0, Request, 0, Header.Length); @@ -972,7 +972,7 @@ namespace WPinternals Result.EmmcSizeInSectors = BigEndian.ToUInt32(Response, SubblockPayloadOffset); break; case 0x05: - Result.PlatformID = ByteOperations.ReadAsciiString(Response, (uint)SubblockPayloadOffset, SubblockLength).Trim(new char[] { ' ', '\0' }); + Result.PlatformID = ByteOperations.ReadAsciiString(Response, (uint)SubblockPayloadOffset, SubblockLength).Trim([' ', '\0']); break; case 0x0D: Result.AsyncSupport = Response[SubblockPayloadOffset + 1] == 1; @@ -1215,7 +1215,7 @@ namespace WPinternals ByteOperations.WriteAsciiString(Request, 0, "NOKXPH" + VariableName + "\0"); // BTR or CTR, CTR is public ProductCode byte[] Response = ExecuteRawMethod(Request); UInt16 Length = BigEndian.ToUInt16(Response, 6); - return ByteOperations.ReadAsciiString(Response, 8, Length).Trim(new char[] { ' ', '\0' }); + return ByteOperations.ReadAsciiString(Response, 8, Length).Trim([' ', '\0']); } internal string ReadProductCode() diff --git a/WPinternals/Models/PatchEngine.cs b/WPinternals/Models/PatchEngine.cs index 3fe56a0..1502895 100644 --- a/WPinternals/Models/PatchEngine.cs +++ b/WPinternals/Models/PatchEngine.cs @@ -94,7 +94,7 @@ namespace WPinternals } set { - _TargetPath = value.TrimEnd(new char[] { '\\' }); + _TargetPath = value.TrimEnd(['\\']); } } @@ -365,7 +365,7 @@ namespace WPinternals } set { - _RelativePath = value.TrimStart(new char[] { '\\' }).TrimEnd(new char[] { '\\' }); + _RelativePath = value.TrimStart(['\\']).TrimEnd(['\\']); } } @@ -377,7 +377,7 @@ namespace WPinternals } set { - _TargetPath = value.TrimEnd(new char[] { '\\' }); + _TargetPath = value.TrimEnd(['\\']); } } } @@ -515,7 +515,7 @@ namespace WPinternals } set { - _Path = value.TrimStart(new char[] { '\\' }); + _Path = value.TrimStart(['\\']); } } diff --git a/WPinternals/Models/QualcommDownload.cs b/WPinternals/Models/QualcommDownload.cs index 078a06c..4984bf6 100644 --- a/WPinternals/Models/QualcommDownload.cs +++ b/WPinternals/Models/QualcommDownload.cs @@ -37,7 +37,7 @@ namespace WPinternals { try { - Serial.SendCommand(new byte[] { 0x06 }, new byte[] { 0x02 }); + Serial.SendCommand([0x06], [0x02]); return true; } catch @@ -61,7 +61,7 @@ namespace WPinternals CurrentLength = Remaining >= 0x100 ? 0x100 : (UInt32)Remaining; CurrentLength = (UInt32)Data.Read(Buffer, 7, (int)CurrentLength); - Serial.SendCommand(Buffer, new byte[] { 0x02 }); + Serial.SendCommand(Buffer, [0x02]); CurrentAddress += CurrentLength; Remaining -= CurrentLength; @@ -100,7 +100,7 @@ namespace WPinternals System.Buffer.BlockCopy(BitConverter.GetBytes((UInt16)CurrentLength).Reverse().ToArray(), 0, CurrentBytes, 5, 2); // Length is in Big Endian System.Buffer.BlockCopy(Data, (int)CurrentOffset, CurrentBytes, 7, (int)CurrentLength); - Serial.SendCommand(CurrentBytes, new byte[] { 0x02 }); + Serial.SendCommand(CurrentBytes, [0x02]); CurrentAddress += CurrentLength; CurrentOffset += CurrentLength; @@ -113,25 +113,25 @@ namespace WPinternals byte[] Buffer = new byte[5]; Buffer[0] = 0x05; System.Buffer.BlockCopy(BitConverter.GetBytes(Address).Reverse().ToArray(), 0, Buffer, 1, 4); // Address is in Big Endian - Serial.SendCommand(Buffer, new byte[] { 0x02 }); + Serial.SendCommand(Buffer, [0x02]); } // Reset interface. Interface becomes unresponsive. public void Reset() { - Serial.SendCommand(new byte[] { 0x0A }, new byte[] { 0x02 }); + Serial.SendCommand([0x0A], [0x02]); } // This also resets interface. This does not actually reboot the phone. The interface becomes unresponsive. public void Shutdown() { - Serial.SendCommand(new byte[] { 0x0E }, new byte[] { 0x02 }); + Serial.SendCommand([0x0E], [0x02]); } // This command only works on 9008 interface. public byte[] GetRKH() { - byte[] Response = Serial.SendCommand(new byte[] { 0x18 }, new byte[] { 0x18, 0x01, 0x00 }); + byte[] Response = Serial.SendCommand([0x18], [0x18, 0x01, 0x00]); byte[] Result = new byte[0x20]; Buffer.BlockCopy(Response, 3, Result, 0, 0x20); return Result; diff --git a/WPinternals/Models/QualcommFlasher.cs b/WPinternals/Models/QualcommFlasher.cs index b687ec6..5324cec 100644 --- a/WPinternals/Models/QualcommFlasher.cs +++ b/WPinternals/Models/QualcommFlasher.cs @@ -45,41 +45,37 @@ namespace WPinternals public void Hello() { - byte[] Command = new byte[] - { + byte[] Command = + [ 0x01, // Hello command 0x51, 0x43, 0x4F, 0x4D, 0x20, 0x66, 0x61, 0x73, 0x74, 0x20, 0x64, 0x6F, 0x77, 0x6E, 0x6C, 0x6F, // "QCOM fast download protocol host" 0x61, 0x64, 0x20, 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x63, 0x6F, 0x6C, 0x20, 0x68, 0x6F, 0x73, 0x74, 0x02, 0x02, // Protocol version - Must be at least 0x02 0x01 - }; + ]; - Serial.SendCommand(Command, new byte[] { 0x02 }); + Serial.SendCommand(Command, [0x02]); } public void SetSecurityMode(byte Mode) { - byte[] Command = new byte[2]; - Command[0] = 0x17; - Command[1] = Mode; + byte[] Command = [0x17, Mode]; - Serial.SendCommand(Command, new byte[] { 0x18 }); + Serial.SendCommand(Command, [0x18]); } // Use PartitionID 0x21 public void OpenPartition(byte PartitionID) { - byte[] Command = new byte[2]; - Command[0] = 0x1B; - Command[1] = PartitionID; + byte[] Command = [0x1B, PartitionID]; - Serial.SendCommand(Command, new byte[] { 0x1C }); + Serial.SendCommand(Command, [0x1C]); } public void ClosePartition() { - Serial.SendCommand(new byte[] { 0x15 }, new byte[] { 0x16 }); + Serial.SendCommand([0x15], [0x16]); } public void Flash(UInt32 StartInBytes, Stream Data, UInt32 LengthInBytes = UInt32.MaxValue) @@ -222,7 +218,7 @@ namespace WPinternals public void Reboot() { - Serial.SendCommand(new byte[] { 0x0B }, new byte[] { 0x0C }); + Serial.SendCommand([0x0B], [0x0C]); } } } diff --git a/WPinternals/Models/QualcommPartition.cs b/WPinternals/Models/QualcommPartition.cs index 561c2ce..0f8b83b 100644 --- a/WPinternals/Models/QualcommPartition.cs +++ b/WPinternals/Models/QualcommPartition.cs @@ -57,10 +57,10 @@ namespace WPinternals this.Binary = Binary; - byte[] LongHeaderPattern = new byte[] { 0xD1, 0xDC, 0x4B, 0x84, 0x34, 0x10, 0xD7, 0x73, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - byte[] LongHeaderMask = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + byte[] LongHeaderPattern = [0xD1, 0xDC, 0x4B, 0x84, 0x34, 0x10, 0xD7, 0x73, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]; + byte[] LongHeaderMask = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; - if (ByteOperations.FindPattern(Binary, Offset, 4, new byte[] { 0x7F, 0x45, 0x4C, 0x46 }, new byte[] { 0x00, 0x00, 0x00, 0x00 }, null) == 0) + if (ByteOperations.FindPattern(Binary, Offset, 4, [0x7F, 0x45, 0x4C, 0x46], [0x00, 0x00, 0x00, 0x00], null) == 0) { // This is an ELF image // First program header is a reference to the elf-header diff --git a/WPinternals/Models/QualcommSahara.cs b/WPinternals/Models/QualcommSahara.cs index bfbefff..053533e 100644 --- a/WPinternals/Models/QualcommSahara.cs +++ b/WPinternals/Models/QualcommSahara.cs @@ -63,7 +63,7 @@ namespace WPinternals try { Step = 1; - byte[] Hello = Serial.GetResponse(new byte[] { 0x01, 0x00, 0x00, 0x00 }); + byte[] Hello = Serial.GetResponse([0x01, 0x00, 0x00, 0x00]); // Incoming Hello packet: // 00000001 = Hello command id @@ -87,11 +87,11 @@ namespace WPinternals // 00000000 = Mode // rest is reserved space Step = 2; - byte[] HelloResponse = new byte[] { + byte[] HelloResponse = [ 0x02, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + ]; Serial.SendData(HelloResponse); Step = 3; @@ -151,7 +151,7 @@ namespace WPinternals try { - byte[] Hello = Serial.GetResponse(new byte[] { 0x01, 0x00, 0x00, 0x00 }); + byte[] Hello = Serial.GetResponse([0x01, 0x00, 0x00, 0x00]); // Incoming Hello packet: // 00000001 = Hello command id @@ -166,13 +166,13 @@ namespace WPinternals LogFile.Log("MaxLength: 0x" + ByteOperations.ReadUInt32(Hello, 0x10).ToString("X8"), LogType.FileOnly); LogFile.Log("Mode: 0x" + ByteOperations.ReadUInt32(Hello, 0x14).ToString("X8"), LogType.FileOnly); - byte[] HelloResponse = new byte[] { + byte[] HelloResponse = [ 0x02, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + ]; - byte[] Ready = Serial.SendCommand(HelloResponse, new byte[] { 0x03, 0x00, 0x00, 0x00 }); + byte[] Ready = Serial.SendCommand(HelloResponse, [0x03, 0x00, 0x00, 0x00]); } catch { @@ -184,7 +184,7 @@ namespace WPinternals public void ResetSahara() { - Serial.SendCommand(new byte[] { 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00 }, new byte[] { 0x08, 0x00, 0x00, 0x00 }); + Serial.SendCommand([0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00], [0x08, 0x00, 0x00, 0x00]); } public bool ConnectToProgrammer(byte[] PacketFromPcToProgrammer) @@ -319,19 +319,19 @@ namespace WPinternals public void SwitchMode(SaharaMode Mode) { - byte[] SwitchModeCommand = new byte[] { 0x0C, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + byte[] SwitchModeCommand = [0x0C, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]; ByteOperations.WriteUInt32(SwitchModeCommand, 8, (UInt32)Mode); byte[] ResponsePattern = null; switch (Mode) { case SaharaMode.ImageTransferPending: - ResponsePattern = new byte[] { 0x04, 0x00, 0x00, 0x00 }; + ResponsePattern = [0x04, 0x00, 0x00, 0x00]; break; case SaharaMode.MemoryDebug: - ResponsePattern = new byte[] { 0x09, 0x00, 0x00, 0x00 }; + ResponsePattern = [0x09, 0x00, 0x00, 0x00]; break; case SaharaMode.Command: - ResponsePattern = new byte[] { 0x0B, 0x00, 0x00, 0x00 }; + ResponsePattern = [0x0B, 0x00, 0x00, 0x00]; break; } Serial.SendCommand(SwitchModeCommand, ResponsePattern); @@ -340,7 +340,7 @@ namespace WPinternals public void StartProgrammer() { LogFile.Log("Starting programmer", LogType.FileAndConsole); - byte[] DoneCommand = new byte[] { 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00 }; + byte[] DoneCommand = [0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00]; bool Started = false; int count = 0; do @@ -348,7 +348,7 @@ namespace WPinternals count++; try { - byte[] DoneResponse = Serial.SendCommand(DoneCommand, new byte[] { 0x06, 0x00, 0x00, 0x00 }); + byte[] DoneResponse = Serial.SendCommand(DoneCommand, [0x06, 0x00, 0x00, 0x00]); Started = true; } catch (BadConnectionException) @@ -369,7 +369,7 @@ namespace WPinternals // First, let's read the Emergency Download payload header and verify its validity FileStream PayloadStream = File.OpenRead(PayloadPath); - byte[] ValidReferencePayloadHeader = new byte[] { 0x45, 0x6D, 0x65, 0x72, 0x67, 0x65, 0x6E, 0x63, 0x79, 0x20, 0x50, 0x61, 0x79, 0x6C, 0x6F, 0x61, 0x64 }; + byte[] ValidReferencePayloadHeader = [0x45, 0x6D, 0x65, 0x72, 0x67, 0x65, 0x6E, 0x63, 0x79, 0x20, 0x50, 0x61, 0x79, 0x6C, 0x6F, 0x61, 0x64]; byte[] PayloadHeader = new byte[17]; PayloadStream.Read(PayloadHeader, 0, 17); diff --git a/WPinternals/Models/QualcommSerial.cs b/WPinternals/Models/QualcommSerial.cs index 3b9e2e4..ce2b028 100644 --- a/WPinternals/Models/QualcommSerial.cs +++ b/WPinternals/Models/QualcommSerial.cs @@ -38,7 +38,7 @@ namespace WPinternals { CRC16 = new CRC16(0x1189, 0xFFFF, 0xFFFF); - string[] DevicePathElements = DevicePath.Split(new char[] { '#' }); + string[] DevicePathElements = DevicePath.Split(['#']); if (string.Equals(DevicePathElements[3], "{86E0D1E0-8089-11D0-9CE4-08003E301F73}", StringComparison.CurrentCultureIgnoreCase)) { string PortName = (string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\" + DevicePathElements[1] + @"\" + DevicePathElements[2] + @"\Device Parameters", "PortName", null); @@ -323,7 +323,7 @@ namespace WPinternals public class CRC16 { private readonly UInt16[] ChecksumTable = - new UInt16[] { + [ 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, @@ -356,7 +356,7 @@ namespace WPinternals 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 - }; + ]; private readonly UInt16 Seed, FinalXor; diff --git a/WPinternals/Models/SBL1.cs b/WPinternals/Models/SBL1.cs index 345f1be..f33fb1e 100644 --- a/WPinternals/Models/SBL1.cs +++ b/WPinternals/Models/SBL1.cs @@ -29,11 +29,11 @@ namespace WPinternals internal byte[] GenerateExtraSector(byte[] PartitionHeader) { UInt32? Offset = ByteOperations.FindPattern(Binary, - new byte[] { + [ 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, null, null); + ], null, null); if (Offset == null) { throw new BadImageFormatException(); @@ -43,12 +43,12 @@ namespace WPinternals byte[] FoundPattern = new byte[0x10]; Offset = ByteOperations.FindPattern(Binary, - new byte[] { + [ 0x04, 0x00, 0x9F, 0xE5, 0x28, 0x00, 0xD0, 0xE5, 0x1E, 0xFF, 0x2F, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF - }, - new byte[] { + ], + [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF - }, + ], FoundPattern); if (Offset == null) { @@ -59,14 +59,14 @@ namespace WPinternals UInt32 GlobalIsSecurityEnabledAddress = SharedMemoryAddress + 0x28; Offset = ByteOperations.FindPattern(Binary, - new byte[] { + [ 0x01, 0xFF, 0xA0, 0xE3, 0xFF, 0xFF, 0xA0, 0xE1, 0x1C, 0xD0, 0x8D, 0xE2, 0xF0, 0x4F, 0xBD, 0xE8, 0x1E, 0xFF, 0x2F, 0xE1 - }, - new byte[] { + ], + [ 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, + ], null); if (Offset == null) { @@ -78,7 +78,7 @@ namespace WPinternals byte[] Sector = new byte[0x200]; Array.Clear(Sector, 0, 0x200); - byte[] Content = new byte[] { + byte[] Content = [ 0x16, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x28, 0xBD, 0x02, 0x00, 0xD8, 0x01, 0x00, 0x00, 0xD8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xE3, 0x3C, 0x10, 0x9F, 0xE5, @@ -88,11 +88,11 @@ namespace WPinternals 0x04, 0x10, 0x81, 0xE2, 0x03, 0x00, 0x50, 0xE1, 0xF9, 0xFF, 0xFF, 0xBA, 0x14, 0xF0, 0x9F, 0xE5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0x90, 0xBF, 0x02, 0x00, 0xD0, 0xBF, 0x02, 0x00, 0xA0, 0xBD, 0x02, 0x00, 0xA0, 0xBE, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00 - }; + ]; - byte[] PartitionTypeGuid = new byte[] { + byte[] PartitionTypeGuid = [ 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74 - }; + ]; Buffer.BlockCopy(Content, 0, Sector, 0, Content.Length); diff --git a/WPinternals/Models/SBL2.cs b/WPinternals/Models/SBL2.cs index 90973f6..e87276c 100644 --- a/WPinternals/Models/SBL2.cs +++ b/WPinternals/Models/SBL2.cs @@ -35,12 +35,12 @@ namespace WPinternals internal byte[] Patch() { UInt32? PatchOffset = ByteOperations.FindPattern(Binary, - new byte[] { + [ 0xFF, 0xFF, 0xFF, 0xE3, 0x01, 0x0E, 0x42, 0xE3, 0x28, 0x00, 0xD0, 0xE5, 0x1E, 0xFF, 0x2F, 0xE1 - }, - new byte[] { + ], + [ 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }, + ], null); if (PatchOffset == null) diff --git a/WPinternals/Models/SBL3.cs b/WPinternals/Models/SBL3.cs index ebe7477..bc4f397 100644 --- a/WPinternals/Models/SBL3.cs +++ b/WPinternals/Models/SBL3.cs @@ -50,8 +50,8 @@ namespace WPinternals // If not succeeded, then try to parse it as raw image if (Binary == null) { - byte[] SBL3Pattern = new byte[] { 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF }; - byte[] SBL3Mask = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF }; + byte[] SBL3Pattern = [0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF]; + byte[] SBL3Mask = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF]; UInt32? Offset = ByteOperations.FindPatternInFile(FileName, SBL3Pattern, SBL3Mask, out byte[] SBL3Header); @@ -72,7 +72,7 @@ namespace WPinternals internal byte[] Patch() { UInt32? PatchOffset = ByteOperations.FindPattern(Binary, - new byte[] { 0x04, 0x00, 0x9F, 0xE5, 0x28, 0x00, 0xD0, 0xE5, 0x1E, 0xFF, 0x2F, 0xE1 }, + [0x04, 0x00, 0x9F, 0xE5, 0x28, 0x00, 0xD0, 0xE5, 0x1E, 0xFF, 0x2F, 0xE1], null, null); if (PatchOffset == null) diff --git a/WPinternals/Models/UEFI.cs b/WPinternals/Models/UEFI.cs index 54794f6..0140200 100644 --- a/WPinternals/Models/UEFI.cs +++ b/WPinternals/Models/UEFI.cs @@ -256,7 +256,7 @@ namespace WPinternals // but the sections that are used in Windows Phone EFI's all have a header of 4 bytes. if (SectionType == 0x15) { - CurrentEFI.Name = ByteOperations.ReadUnicodeString(DecompressedImage, DecompressedSectionHeaderOffset + 0x04, SectionSize - 0x04).TrimEnd(new char[] { (char)0, ' ' }); + CurrentEFI.Name = ByteOperations.ReadUnicodeString(DecompressedImage, DecompressedSectionHeaderOffset + 0x04, SectionSize - 0x04).TrimEnd([(char)0, ' ']); } else if ((SectionType == 0x10) || (SectionType == 0x19)) { @@ -599,8 +599,8 @@ namespace WPinternals ClearEfiChecksum(SecurityDxe); UInt32? PatchOffset = ByteOperations.FindPattern(SecurityDxe, - new byte[] { 0xF0, 0x41, 0x2D, 0xE9, 0xFF, 0xFF, 0xB0, 0xE1, 0x28, 0xD0, 0x4D, 0xE2, 0xFF, 0xFF, 0xA0, 0xE1, 0x00, 0x00, 0xFF, 0x13, 0x20, 0xFF, 0xA0, 0xE3 }, - new byte[] { 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00 }, + [0xF0, 0x41, 0x2D, 0xE9, 0xFF, 0xFF, 0xB0, 0xE1, 0x28, 0xD0, 0x4D, 0xE2, 0xFF, 0xFF, 0xA0, 0xE1, 0x00, 0x00, 0xFF, 0x13, 0x20, 0xFF, 0xA0, 0xE3], + [0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00], null); if (PatchOffset == null) @@ -616,8 +616,8 @@ namespace WPinternals ClearEfiChecksum(SecurityServicesDxe); PatchOffset = ByteOperations.FindPattern(SecurityServicesDxe, - new byte[] { 0x10, 0xFF, 0xFF, 0xE5, 0x80, 0xFF, 0x10, 0xE3, 0xFF, 0xFF, 0xFF, 0x0A }, - new byte[] { 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00 }, + [0x10, 0xFF, 0xFF, 0xE5, 0x80, 0xFF, 0x10, 0xE3, 0xFF, 0xFF, 0xFF, 0x0A], + [0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00], null); if (PatchOffset == null) @@ -628,8 +628,8 @@ namespace WPinternals ByteOperations.WriteUInt8(SecurityServicesDxe, (UInt32)PatchOffset + 0x0B, 0xEA); PatchOffset = ByteOperations.FindPattern(SecurityServicesDxe, - new byte[] { 0x11, 0xFF, 0xFF, 0xE5, 0x40, 0xFF, 0x10, 0xE3, 0xFF, 0xFF, 0xFF, 0x0A }, - new byte[] { 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00 }, + [0x11, 0xFF, 0xFF, 0xE5, 0x40, 0xFF, 0x10, 0xE3, 0xFF, 0xFF, 0xFF, 0x0A], + [0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00], null); if (PatchOffset == null) diff --git a/WPinternals/ViewModels/LumiaUnlockBootloaderViewModel.cs b/WPinternals/ViewModels/LumiaUnlockBootloaderViewModel.cs index 045a53b..8537074 100644 --- a/WPinternals/ViewModels/LumiaUnlockBootloaderViewModel.cs +++ b/WPinternals/ViewModels/LumiaUnlockBootloaderViewModel.cs @@ -51,7 +51,7 @@ namespace WPinternals FlashModel.SendFfuPayloadV1(EmptyChunk); // Reboot to Qualcomm Emergency mode - byte[] RebootCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x52 }; // NOKR + byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52]; // NOKR FlashModel.ExecuteRawVoidMethod(RebootCommand); } diff --git a/WPinternals/ViewModels/LumiaV2UnlockBootViewModel.cs b/WPinternals/ViewModels/LumiaV2UnlockBootViewModel.cs index 476054d..e2783e2 100644 --- a/WPinternals/ViewModels/LumiaV2UnlockBootViewModel.cs +++ b/WPinternals/ViewModels/LumiaV2UnlockBootViewModel.cs @@ -1848,7 +1848,7 @@ namespace WPinternals byte[] buffer = new byte[chunkSize]; Int64 position = flashPart.Stream.Position; flashPart.Stream.Read(buffer, 0, chunkSize); - flashingPayloads.Add(new FlashingPayload(1, new byte[][] { crypto.ComputeHash(buffer) }, new UInt32[] { (flashPart.StartSector * 0x200 / (UInt32)chunkSize) + i }, new UInt32[] { j }, new Int64[] { position })); + flashingPayloads.Add(new FlashingPayload(1, [crypto.ComputeHash(buffer)], [(flashPart.StartSector * 0x200 / (UInt32)chunkSize) + i], [j], [position])); CurrentProcess1++; } } @@ -1902,7 +1902,7 @@ namespace WPinternals } else { - flashingPayloads.Add(new FlashingPayload(1, new byte[][] { hash }, new UInt32[] { (flashPart.StartSector * 0x200 / (UInt32)chunkSize) + i }, new UInt32[] { j }, new Int64[] { position })); + flashingPayloads.Add(new FlashingPayload(1, [hash], [(flashPart.StartSector * 0x200 / (UInt32)chunkSize) + i], [j], [position])); } CurrentProcess1++; diff --git a/WPinternals/ViewModels/LumiaV3FlashRomViewModel.cs b/WPinternals/ViewModels/LumiaV3FlashRomViewModel.cs index aea3e4f..a5ce823 100644 --- a/WPinternals/ViewModels/LumiaV3FlashRomViewModel.cs +++ b/WPinternals/ViewModels/LumiaV3FlashRomViewModel.cs @@ -123,8 +123,8 @@ namespace WPinternals // private static byte[] GenerateCatalogFile(byte[] hashData) { - byte[] catalog_first_part = new byte[] { 0x30, 0x82, 0x01, 0x44, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02, 0xA0, 0x82, 0x01, 0x35, 0x30, 0x82, 0x01, 0x31, 0x02, 0x01, 0x01, 0x31, 0x00, 0x30, 0x82, 0x01, 0x26, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0A, 0x01, 0xA0, 0x82, 0x01, 0x17, 0x30, 0x82, 0x01, 0x13, 0x30, 0x0C, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0C, 0x01, 0x01, 0x04, 0x10, 0xA8, 0xCA, 0xD9, 0x7D, 0xBF, 0x6D, 0x67, 0x4D, 0xB1, 0x4D, 0x62, 0xFB, 0xE6, 0x26, 0x22, 0xD4, 0x17, 0x0D, 0x32, 0x30, 0x30, 0x31, 0x31, 0x30, 0x31, 0x32, 0x31, 0x32, 0x32, 0x37, 0x5A, 0x30, 0x0E, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0C, 0x01, 0x02, 0x05, 0x00, 0x30, 0x81, 0xD1, 0x30, 0x81, 0xCE, 0x04, 0x1E, 0x48, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x54, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x2E, 0x00, 0x62, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x62, 0x00, 0x00, 0x00, 0x31, 0x81, 0xAB, 0x30, 0x45, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x01, 0x04, 0x31, 0x37, 0x30, 0x35, 0x30, 0x10, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x01, 0x19, 0xA2, 0x02, 0x80, 0x00, 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14 }; - byte[] catalog_second_part = new byte[] { 0x30, 0x62, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0C, 0x02, 0x02, 0x31, 0x54, 0x30, 0x52, 0x1E, 0x4C, 0x00, 0x7B, 0x00, 0x44, 0x00, 0x45, 0x00, 0x33, 0x00, 0x35, 0x00, 0x31, 0x00, 0x41, 0x00, 0x34, 0x00, 0x32, 0x00, 0x2D, 0x00, 0x38, 0x00, 0x45, 0x00, 0x35, 0x00, 0x39, 0x00, 0x2D, 0x00, 0x31, 0x00, 0x31, 0x00, 0x44, 0x00, 0x30, 0x00, 0x2D, 0x00, 0x38, 0x00, 0x43, 0x00, 0x34, 0x00, 0x37, 0x00, 0x2D, 0x00, 0x30, 0x00, 0x30, 0x00, 0x43, 0x00, 0x30, 0x00, 0x34, 0x00, 0x46, 0x00, 0x43, 0x00, 0x32, 0x00, 0x39, 0x00, 0x35, 0x00, 0x45, 0x00, 0x45, 0x00, 0x7D, 0x02, 0x02, 0x02, 0x00, 0x31, 0x00 }; + byte[] catalog_first_part = [0x30, 0x82, 0x01, 0x44, 0x06, 0x09, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x07, 0x02, 0xA0, 0x82, 0x01, 0x35, 0x30, 0x82, 0x01, 0x31, 0x02, 0x01, 0x01, 0x31, 0x00, 0x30, 0x82, 0x01, 0x26, 0x06, 0x09, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0A, 0x01, 0xA0, 0x82, 0x01, 0x17, 0x30, 0x82, 0x01, 0x13, 0x30, 0x0C, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0C, 0x01, 0x01, 0x04, 0x10, 0xA8, 0xCA, 0xD9, 0x7D, 0xBF, 0x6D, 0x67, 0x4D, 0xB1, 0x4D, 0x62, 0xFB, 0xE6, 0x26, 0x22, 0xD4, 0x17, 0x0D, 0x32, 0x30, 0x30, 0x31, 0x31, 0x30, 0x31, 0x32, 0x31, 0x32, 0x32, 0x37, 0x5A, 0x30, 0x0E, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0C, 0x01, 0x02, 0x05, 0x00, 0x30, 0x81, 0xD1, 0x30, 0x81, 0xCE, 0x04, 0x1E, 0x48, 0x00, 0x61, 0x00, 0x73, 0x00, 0x68, 0x00, 0x54, 0x00, 0x61, 0x00, 0x62, 0x00, 0x6C, 0x00, 0x65, 0x00, 0x2E, 0x00, 0x62, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x62, 0x00, 0x00, 0x00, 0x31, 0x81, 0xAB, 0x30, 0x45, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x01, 0x04, 0x31, 0x37, 0x30, 0x35, 0x30, 0x10, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x02, 0x01, 0x19, 0xA2, 0x02, 0x80, 0x00, 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14]; + byte[] catalog_second_part = [0x30, 0x62, 0x06, 0x0A, 0x2B, 0x06, 0x01, 0x04, 0x01, 0x82, 0x37, 0x0C, 0x02, 0x02, 0x31, 0x54, 0x30, 0x52, 0x1E, 0x4C, 0x00, 0x7B, 0x00, 0x44, 0x00, 0x45, 0x00, 0x33, 0x00, 0x35, 0x00, 0x31, 0x00, 0x41, 0x00, 0x34, 0x00, 0x32, 0x00, 0x2D, 0x00, 0x38, 0x00, 0x45, 0x00, 0x35, 0x00, 0x39, 0x00, 0x2D, 0x00, 0x31, 0x00, 0x31, 0x00, 0x44, 0x00, 0x30, 0x00, 0x2D, 0x00, 0x38, 0x00, 0x43, 0x00, 0x34, 0x00, 0x37, 0x00, 0x2D, 0x00, 0x30, 0x00, 0x30, 0x00, 0x43, 0x00, 0x30, 0x00, 0x34, 0x00, 0x46, 0x00, 0x43, 0x00, 0x32, 0x00, 0x39, 0x00, 0x35, 0x00, 0x45, 0x00, 0x45, 0x00, 0x7D, 0x02, 0x02, 0x02, 0x00, 0x31, 0x00]; byte[] hash = new SHA1Managed().ComputeHash(hashData); diff --git a/WPinternals/ViewModels/NokiaLabelViewModel.cs b/WPinternals/ViewModels/NokiaLabelViewModel.cs index 4c136b4..1a8a457 100644 --- a/WPinternals/ViewModels/NokiaLabelViewModel.cs +++ b/WPinternals/ViewModels/NokiaLabelViewModel.cs @@ -72,7 +72,7 @@ namespace WPinternals //byte[] Meid = CurrentModel.ExecuteJsonMethodAsBytes("ReadMeid", "Meid"); // error //string Test = CurrentModel.ExecuteJsonMethodAsString("ReadManufacturingData", ""); -> This method is only possible in Label-mode. - byte[] AsskMask = new byte[0x10] { 1, 0, 16, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64 }; + byte[] AsskMask = [1, 0, 16, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64]; byte[] Challenge = new byte[0x88]; Dictionary Params = new(); Params.Add("AsskMask", AsskMask); diff --git a/WPinternals/ViewModels/SwitchModeViewModel.cs b/WPinternals/ViewModels/SwitchModeViewModel.cs index 871f464..e5b6642 100644 --- a/WPinternals/ViewModels/SwitchModeViewModel.cs +++ b/WPinternals/ViewModels/SwitchModeViewModel.cs @@ -296,8 +296,8 @@ namespace WPinternals break; case PhoneInterfaces.Lumia_Flash: case PhoneInterfaces.Lumia_Bootloader: - byte[] BootModeFlagCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x58, 0x46, 0x57, 0x00, 0x55, 0x42, 0x46, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 }; // NOKFW UBF - byte[] RebootCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x52 }; // NOKR + byte[] BootModeFlagCommand = [0x4E, 0x4F, 0x4B, 0x58, 0x46, 0x57, 0x00, 0x55, 0x42, 0x46, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00]; // NOKFW UBF + byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52]; // NOKR byte[] RebootCommandResult; IsSwitchingInterface = true; switch (TargetMode) @@ -328,7 +328,7 @@ namespace WPinternals SwitchFromFlashToLabelMode(); break; case PhoneInterfaces.Lumia_Flash: // attempt to boot from limited flash to full flash - byte[] RebootToFlashCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x53 }; // NOKS + byte[] RebootToFlashCommand = [0x4E, 0x4F, 0x4B, 0x53]; // NOKS ((NokiaPhoneModel)CurrentModel).ExecuteRawVoidMethod(RebootToFlashCommand); PhoneNotifier.NewDeviceArrived += NewDeviceArrived; ModeSwitchProgressWrapper("Rebooting phone to Flash mode...", null); @@ -338,7 +338,7 @@ namespace WPinternals SwitchFromFlashToMassStorageMode(); break; case PhoneInterfaces.Qualcomm_Download: - byte[] RebootToQualcommDownloadCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x58, 0x43, 0x42, 0x45 }; // NOKXCBE + byte[] RebootToQualcommDownloadCommand = [0x4E, 0x4F, 0x4B, 0x58, 0x43, 0x42, 0x45]; // NOKXCBE RebootCommandResult = ((NokiaPhoneModel)CurrentModel).ExecuteRawMethod(RebootToQualcommDownloadCommand); if (RebootCommandResult?.Length == 4) // This means fail: NOKU (unknow command) { @@ -504,8 +504,8 @@ namespace WPinternals } else if ((CurrentMode == PhoneInterfaces.Lumia_Flash) && (TargetMode == PhoneInterfaces.Qualcomm_Download)) { - byte[] RebootCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x52 }; - byte[] RebootToQualcommDownloadCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x58, 0x43, 0x42, 0x45 }; // NOKXCBE + byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52]; + byte[] RebootToQualcommDownloadCommand = [0x4E, 0x4F, 0x4B, 0x58, 0x43, 0x42, 0x45]; // NOKXCBE IsSwitchingInterface = true; LogFile.Log("Sending command for rebooting to Emergency Download mode"); byte[] RebootCommandResult = ((NokiaPhoneModel)CurrentModel).ExecuteRawMethod(RebootToQualcommDownloadCommand); @@ -619,8 +619,8 @@ namespace WPinternals } else { - byte[] BootModeFlagCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x58, 0x46, 0x57, 0x00, 0x55, 0x42, 0x46, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 }; // NOKFW UBF - byte[] RebootCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x52 }; // NOKR + byte[] BootModeFlagCommand = [0x4E, 0x4F, 0x4B, 0x58, 0x46, 0x57, 0x00, 0x55, 0x42, 0x46, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00]; // NOKFW UBF + byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52]; // NOKR BootModeFlagCommand[0x0F] = 0x59; ((NokiaPhoneModel)CurrentModel).ExecuteRawMethod(BootModeFlagCommand); @@ -671,9 +671,9 @@ namespace WPinternals if (IsOldLumia || IsOriginalEngineeringLumia) { - byte[] BootModeFlagCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x58, 0x46, 0x57, 0x00, 0x55, 0x42, 0x46, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 }; // NOKFW UBF - byte[] RebootCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x52 }; - byte[] RebootToMassStorageCommand = new byte[] { 0x4E, 0x4F, 0x4B, 0x4D }; // NOKM + byte[] BootModeFlagCommand = [0x4E, 0x4F, 0x4B, 0x58, 0x46, 0x57, 0x00, 0x55, 0x42, 0x46, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00]; // NOKFW UBF + byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52]; + byte[] RebootToMassStorageCommand = [0x4E, 0x4F, 0x4B, 0x4D]; // NOKM IsSwitchingInterface = true; byte[] RebootCommandResult = ((NokiaPhoneModel)CurrentModel).ExecuteRawMethod(RebootToMassStorageCommand); if (RebootCommandResult?.Length == 4) // This means fail: NOKU (unknown command)