This commit is contained in:
Gustave Monce
2024-10-12 13:40:24 +02:00
parent 2d5b0fd3db
commit 00407d6f24
27 changed files with 99 additions and 90 deletions
+2 -2
View File
@@ -47,7 +47,7 @@ namespace SevenZip.CommandLineParser
{ {
public bool ThereIs; public bool ThereIs;
public bool WithMinus; public bool WithMinus;
public ArrayList PostStrings = new(); public ArrayList PostStrings = [];
public int PostCharIndex; public int PostCharIndex;
public SwitchResult() public SwitchResult()
{ {
@@ -57,7 +57,7 @@ namespace SevenZip.CommandLineParser
public class Parser public class Parser
{ {
public ArrayList NonSwitchStrings = new(); public ArrayList NonSwitchStrings = [];
private readonly SwitchResult[] _switches; private readonly SwitchResult[] _switches;
public Parser(int numSwitches) public Parser(int numSwitches)
@@ -61,7 +61,7 @@ namespace DiscUtils.Internal
/// <returns>The resultant array.</returns> /// <returns>The resultant array.</returns>
public static U[] Map<T, U>(IEnumerable<T> source, Func<T, U> func) public static U[] Map<T, U>(IEnumerable<T> source, Func<T, U> func)
{ {
List<U> result = new(); List<U> result = [];
foreach (T sVal in source) foreach (T sVal in source)
{ {
@@ -48,15 +48,7 @@ namespace DiscUtils.Fat
_fat = fileSystem.Fat; _fat = fileSystem.Fat;
_length = length; _length = length;
_knownClusters = new List<uint>(); _knownClusters = [firstCluster != 0 ? firstCluster : FatBuffer.EndOfChain];
if (firstCluster != 0)
{
_knownClusters.Add(firstCluster);
}
else
{
_knownClusters.Add(FatBuffer.EndOfChain);
}
if (_length == uint.MaxValue) if (_length == uint.MaxValue)
{ {
@@ -64,7 +64,7 @@ namespace DiscUtils.Fat
{ {
_type = type; _type = type;
_buffer = buffer; _buffer = buffer;
_dirtySectors = new Dictionary<uint, uint>(); _dirtySectors = [];
} }
internal int NumEntries internal int NumEntries
@@ -220,7 +220,7 @@ namespace DiscUtils.Fat
internal List<uint> GetChain(uint head) internal List<uint> GetChain(uint head)
{ {
List<uint> result = new(); List<uint> result = [];
if (head != 0) if (head != 0)
{ {
@@ -452,8 +452,8 @@ namespace DiscUtils.Fat
private void LoadEntries() private void LoadEntries()
{ {
_entries = new Dictionary<long, DirectoryEntry>(); _entries = [];
_freeEntries = new List<long>(); _freeEntries = [];
_selfEntryLocation = -1; _selfEntryLocation = -1;
_parentEntryLocation = -1; _parentEntryLocation = -1;
@@ -94,7 +94,7 @@ namespace DiscUtils.Fat
public FatFileSystem(Stream data) public FatFileSystem(Stream data)
: base(new FatFileSystemOptions()) : base(new FatFileSystemOptions())
{ {
_dirCache = new Dictionary<uint, Directory>(); _dirCache = [];
_timeConverter = DefaultTimeConverter; _timeConverter = DefaultTimeConverter;
Initialize(data); Initialize(data);
} }
@@ -111,7 +111,7 @@ namespace DiscUtils.Fat
public FatFileSystem(Stream data, Ownership ownsData) public FatFileSystem(Stream data, Ownership ownsData)
: base(new FatFileSystemOptions()) : base(new FatFileSystemOptions())
{ {
_dirCache = new Dictionary<uint, Directory>(); _dirCache = [];
_timeConverter = DefaultTimeConverter; _timeConverter = DefaultTimeConverter;
Initialize(data); Initialize(data);
_ownsData = ownsData; _ownsData = ownsData;
@@ -125,7 +125,7 @@ namespace DiscUtils.Fat
public FatFileSystem(Stream data, TimeConverter timeConverter) public FatFileSystem(Stream data, TimeConverter timeConverter)
: base(new FatFileSystemOptions()) : base(new FatFileSystemOptions())
{ {
_dirCache = new Dictionary<uint, Directory>(); _dirCache = [];
_timeConverter = timeConverter; _timeConverter = timeConverter;
Initialize(data); Initialize(data);
} }
@@ -140,7 +140,7 @@ namespace DiscUtils.Fat
public FatFileSystem(Stream data, Ownership ownsData, TimeConverter timeConverter) public FatFileSystem(Stream data, Ownership ownsData, TimeConverter timeConverter)
: base(new FatFileSystemOptions()) : base(new FatFileSystemOptions())
{ {
_dirCache = new Dictionary<uint, Directory>(); _dirCache = [];
_timeConverter = timeConverter; _timeConverter = timeConverter;
Initialize(data); Initialize(data);
_ownsData = ownsData; _ownsData = ownsData;
@@ -156,7 +156,7 @@ namespace DiscUtils.Fat
public FatFileSystem(Stream data, Ownership ownsData, FileSystemParameters parameters) public FatFileSystem(Stream data, Ownership ownsData, FileSystemParameters parameters)
: base(new FatFileSystemOptions(parameters)) : base(new FatFileSystemOptions(parameters))
{ {
_dirCache = new Dictionary<uint, Directory>(); _dirCache = [];
if (parameters?.TimeConverter != null) if (parameters?.TimeConverter != null)
{ {
@@ -1273,7 +1273,7 @@ namespace DiscUtils.Fat
{ {
Regex re = Utilities.ConvertWildcardsToRegEx(searchPattern); Regex re = Utilities.ConvertWildcardsToRegEx(searchPattern);
List<string> dirs = new(); List<string> dirs = [];
DoSearch(dirs, path, re, searchOption == SearchOption.AllDirectories, true, false); DoSearch(dirs, path, re, searchOption == SearchOption.AllDirectories, true, false);
return [.. dirs]; return [.. dirs];
} }
@@ -1309,7 +1309,7 @@ namespace DiscUtils.Fat
{ {
Regex re = Utilities.ConvertWildcardsToRegEx(searchPattern); Regex re = Utilities.ConvertWildcardsToRegEx(searchPattern);
List<string> results = new(); List<string> results = [];
DoSearch(results, path, re, searchOption == SearchOption.AllDirectories, false, true); DoSearch(results, path, re, searchOption == SearchOption.AllDirectories, false, true);
return [.. results]; return [.. results];
} }
+4 -4
View File
@@ -279,7 +279,7 @@ namespace WPinternals
{ {
public CollapsibleSection() public CollapsibleSection()
{ {
CollapsibleBlocks = new List<Block>(); CollapsibleBlocks = [];
} }
protected override void OnInitialized(EventArgs e) protected override void OnInitialized(EventArgs e)
@@ -915,7 +915,7 @@ namespace WPinternals
{ {
public static void AddWeakReferenceHandler(ref List<WeakReference> handlers, EventHandler handler, int defaultListSize) public static void AddWeakReferenceHandler(ref List<WeakReference> handlers, EventHandler handler, int defaultListSize)
{ {
(handlers ??= (defaultListSize > 0) ? new List<WeakReference>(defaultListSize) : new List<WeakReference>()).Add(new WeakReference(handler)); (handlers ??= (defaultListSize > 0) ? new List<WeakReference>(defaultListSize) : []).Add(new WeakReference(handler));
} }
private static void CallHandler(object sender, EventHandler eventHandler) private static void CallHandler(object sender, EventHandler eventHandler)
@@ -1925,7 +1925,7 @@ namespace WPinternals
#if PREVIEW #if PREVIEW
internal static class Uploader internal static class Uploader
{ {
internal static List<Task> Uploads = new List<Task>(); internal static List<Task> Uploads = [];
internal static void Upload(string FileName, string Text) internal static void Upload(string FileName, string Text)
{ {
@@ -1949,7 +1949,7 @@ namespace WPinternals
{ {
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls; System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient(); System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient();
System.Net.Http.MultipartFormDataContent form = new System.Net.Http.MultipartFormDataContent(); System.Net.Http.MultipartFormDataContent form = [];
System.Net.Http.StreamContent Content = new System.Net.Http.StreamContent(FileStream); System.Net.Http.StreamContent Content = new System.Net.Http.StreamContent(FileStream);
Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/plain"); Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("text/plain");
form.Add(Content, InputName, FileName); form.Add(Content, InputName, FileName);
+2 -2
View File
@@ -42,7 +42,7 @@ namespace WPinternals
internal bool HasChanged = false; internal bool HasChanged = false;
[XmlElement("Partition")] [XmlElement("Partition")]
public List<Partition> Partitions = new(); public List<Partition> Partitions = [];
public GPT() // Only for serialization public GPT() // Only for serialization
{ {
@@ -334,7 +334,7 @@ namespace WPinternals
} }
} }
List<Partition> DynamicPartitions = new(); List<Partition> DynamicPartitions = [];
if (Archive != null) if (Archive != null)
{ {
// Partitions which are present in the archive, and which have no start-sector in the new GPT data (dynamic relocation), // Partitions which are present in the archive, and which have no start-sector in the new GPT data (dynamic relocation),
+4 -4
View File
@@ -327,7 +327,7 @@ namespace WPinternals
ProductType = "RM-1113"; ProductType = "RM-1113";
} }
List<string> Result = new(); List<string> Result = [];
WebClient Client = new(); WebClient Client = new();
string Src; string Src;
@@ -488,7 +488,7 @@ namespace WPinternals
{ {
this.apiVersion = "1"; this.apiVersion = "1";
this.query = new DiscoveryQueryParameters(); this.query = new DiscoveryQueryParameters();
this.condition = new List<string>(); this.condition = [];
if (Condition == DiscoveryCondition.All) if (Condition == DiscoveryCondition.All)
{ {
this.condition.Add("all"); this.condition.Add("all");
@@ -517,14 +517,14 @@ namespace WPinternals
public ExtendedAttributes() public ExtendedAttributes()
{ {
this.Dictionary = new Dictionary<string, string>(); this.Dictionary = [];
} }
protected ExtendedAttributes(SerializationInfo info, StreamingContext context) protected ExtendedAttributes(SerializationInfo info, StreamingContext context)
{ {
if (info != null) if (info != null)
{ {
this.Dictionary = new Dictionary<string, string>(); this.Dictionary = [];
SerializationInfoEnumerator Enumerator = info.GetEnumerator(); SerializationInfoEnumerator Enumerator = info.GetEnumerator();
while (Enumerator.MoveNext()) while (Enumerator.MoveNext())
{ {
+3 -3
View File
@@ -56,7 +56,7 @@ namespace WPinternals
const string jsonrpc = "2.0"; const string jsonrpc = "2.0";
int id = MessageId++; int id = MessageId++;
string method = JsonMethod; string method = JsonMethod;
Dictionary<string, object> @params = new(); Dictionary<string, object> @params = [];
if (Params != null) if (Params != null)
{ {
foreach (KeyValuePair<string, object> Param in Params) foreach (KeyValuePair<string, object> Param in Params)
@@ -191,7 +191,7 @@ namespace WPinternals
const string jsonrpc = "2.0"; const string jsonrpc = "2.0";
int id = MessageId++; int id = MessageId++;
string method = JsonMethod; string method = JsonMethod;
Dictionary<string, object> @params = new(); Dictionary<string, object> @params = [];
if (Params != null) if (Params != null)
{ {
foreach (KeyValuePair<string, object> Param in Params) foreach (KeyValuePair<string, object> Param in Params)
@@ -279,7 +279,7 @@ namespace WPinternals
const string jsonrpc = "2.0"; const string jsonrpc = "2.0";
int id = MessageId++; int id = MessageId++;
string method = JsonMethod; string method = JsonMethod;
Dictionary<string, object> @params = new(); Dictionary<string, object> @params = [];
if (Params != null) if (Params != null)
{ {
foreach (KeyValuePair<string, object> Param in Params) foreach (KeyValuePair<string, object> Param in Params)
+8 -8
View File
@@ -33,8 +33,8 @@ namespace WPinternals
{ {
internal class PatchEngine internal class PatchEngine
{ {
internal List<PatchDefinition> PatchDefinitions = new(); internal List<PatchDefinition> PatchDefinitions = [];
internal readonly List<TargetRedirection> TargetRedirections = new(); internal readonly List<TargetRedirection> TargetRedirections = [];
internal PatchEngine() { } internal PatchEngine() { }
@@ -115,7 +115,7 @@ namespace WPinternals
internal bool Patch(string PatchDefinition) internal bool Patch(string PatchDefinition)
{ {
bool Result = false; bool Result = false;
List<FilePatcher> LoadedFiles = new(); List<FilePatcher> LoadedFiles = [];
LogFile.Log("Attempt patch: " + PatchDefinition); LogFile.Log("Attempt patch: " + PatchDefinition);
@@ -237,7 +237,7 @@ namespace WPinternals
internal void Restore(string PatchDefinition) internal void Restore(string PatchDefinition)
{ {
List<FilePatcher> LoadedFiles = new(); List<FilePatcher> LoadedFiles = [];
try try
{ {
@@ -492,7 +492,7 @@ namespace WPinternals
[XmlAttribute] [XmlAttribute]
public string Name; public string Name;
public List<TargetVersion> TargetVersions = new(); public List<TargetVersion> TargetVersions = [];
} }
public class TargetVersion // Must be public to be serializable public class TargetVersion // Must be public to be serializable
@@ -500,7 +500,7 @@ namespace WPinternals
[XmlAttribute] [XmlAttribute]
public string Description; public string Description;
public List<TargetFile> TargetFiles = new(); public List<TargetFile> TargetFiles = [];
} }
public class TargetFile // Must be public to be serializable public class TargetFile // Must be public to be serializable
@@ -549,8 +549,8 @@ namespace WPinternals
} }
} }
public List<Patch> Patches = new(); public List<Patch> Patches = [];
public List<TargetFile> Obsolete = new(); public List<TargetFile> Obsolete = [];
} }
public class Patch // Must be public to be serializable public class Patch // Must be public to be serializable
+2 -2
View File
@@ -35,8 +35,8 @@ namespace WPinternals
{ {
#region Private static members #region Private static members
private static readonly LocalDataStoreSlot tlsSlot = Thread.AllocateDataSlot(); private static readonly LocalDataStoreSlot tlsSlot = Thread.AllocateDataSlot();
private static readonly HybridDictionary privileges = new(); private static readonly HybridDictionary privileges = [];
private static readonly HybridDictionary luids = new(); private static readonly HybridDictionary luids = [];
private static readonly ReaderWriterLock privilegeLock = new(); private static readonly ReaderWriterLock privilegeLock = new();
#endregion #endregion
+1 -1
View File
@@ -29,7 +29,7 @@ namespace WPinternals
{ {
internal static List<QualcommPartition> GetPossibleLoadersForRootKeyHash(string Path, byte[] RootKeyHash) internal static List<QualcommPartition> GetPossibleLoadersForRootKeyHash(string Path, byte[] RootKeyHash)
{ {
List<QualcommPartition> Result = new(); List<QualcommPartition> Result = [];
try try
{ {
+1 -1
View File
@@ -117,7 +117,7 @@ namespace WPinternals
byte[] Response = Serial.GetResponse(null, Length: (int)RKHLength); byte[] Response = Serial.GetResponse(null, Length: (int)RKHLength);
List<byte[]> RootKeyHashes = new(); List<byte[]> RootKeyHashes = [];
for (int i = 0; i < RKHLength / 0x20; i++) for (int i = 0; i < RKHLength / 0x20; i++)
{ {
RootKeyHashes.Add(Response[(i * 0x20)..((i + 1) * 0x20)]); RootKeyHashes.Add(Response[(i * 0x20)..((i + 1) * 0x20)]);
+1 -1
View File
@@ -39,7 +39,7 @@ namespace WPinternals
{ {
internal byte[] Binary; internal byte[] Binary;
private byte[] DecompressedImage; private byte[] DecompressedImage;
internal List<EFI> EFIs = new(); internal List<EFI> EFIs = [];
private readonly byte PaddingByteValue = 0xFF; private readonly byte PaddingByteValue = 0xFF;
private readonly UInt32 DecompressedVolumeSectionHeaderOffset; private readonly UInt32 DecompressedVolumeSectionHeaderOffset;
private readonly UInt32 DecompressedVolumeHeaderOffset; private readonly UInt32 DecompressedVolumeHeaderOffset;
+1 -1
View File
@@ -61,7 +61,7 @@ namespace WPinternals
internal class TerminalResponse internal class TerminalResponse
{ {
public Dictionary<int, byte[]> RawEntries = new(); public Dictionary<int, byte[]> RawEntries = [];
public byte[] PublicId = null; public byte[] PublicId = null;
public byte[] RootKeyHash = null; public byte[] RootKeyHash = null;
} }
+2 -2
View File
@@ -382,8 +382,8 @@ namespace WPinternals
App.Config.AddSecWimToRepository(Files[0], (string)State); App.Config.AddSecWimToRepository(Files[0], (string)State);
} }
public ObservableCollection<DownloadEntry> DownloadList { get; } = new(); public ObservableCollection<DownloadEntry> DownloadList { get; } = [];
public ObservableCollection<SearchResult> SearchResultList { get; } = new(); public ObservableCollection<SearchResult> SearchResultList { get; } = [];
private DelegateCommand _DownloadSelectedCommand = null; private DelegateCommand _DownloadSelectedCommand = null;
public DelegateCommand DownloadSelectedCommand public DelegateCommand DownloadSelectedCommand
@@ -549,7 +549,7 @@ namespace WPinternals
Phone = (LumiaFlashAppModel)PhoneNotifier.CurrentModel; Phone = (LumiaFlashAppModel)PhoneNotifier.CurrentModel;
FlashPart Part; FlashPart Part;
List<FlashPart> FlashParts = new(); List<FlashPart> FlashParts = [];
Partition NvBackupPartition = GPT.GetPartition("BACKUP_BS_NV"); Partition NvBackupPartition = GPT.GetPartition("BACKUP_BS_NV");
if (NvBackupPartition != null) if (NvBackupPartition != null)
@@ -1683,7 +1683,7 @@ namespace WPinternals
((LumiaBootManagerAppModel)Notifier.CurrentModel).SwitchToFlashAppContext(); ((LumiaBootManagerAppModel)Notifier.CurrentModel).SwitchToFlashAppContext();
List<FlashPart> FlashParts = new(); List<FlashPart> FlashParts = [];
if (UndoEFIESPPadding) if (UndoEFIESPPadding)
{ {
@@ -1928,7 +1928,7 @@ namespace WPinternals
LogFile.Log("Enabling Test Signing", LogType.FileAndConsole); LogFile.Log("Enabling Test Signing", LogType.FileAndConsole);
SetWorkingStatus("Enabling Test Signing", null, null); SetWorkingStatus("Enabling Test Signing", null, null);
List<FlashPart> Parts = new(); List<FlashPart> Parts = [];
FlashPart Part; FlashPart Part;
// Now add NV partition // Now add NV partition
@@ -2020,7 +2020,7 @@ namespace WPinternals
ShouldApplyOldEFIESPMethod = false; ShouldApplyOldEFIESPMethod = false;
} }
Parts = ShouldApplyOldEFIESPMethod ? new List<FlashPart>() : LumiaGenerateEFIESPFlashPayload(UnlockedEFIESP, GPT, ProfileFFU, IsSpecB); Parts = ShouldApplyOldEFIESPMethod ? [] : LumiaGenerateEFIESPFlashPayload(UnlockedEFIESP, GPT, ProfileFFU, IsSpecB);
Part = null; Part = null;
UInt32 OriginalEfiespSizeInSectors = (UInt32)GPT.GetPartition("EFIESP").SizeInSectors; UInt32 OriginalEfiespSizeInSectors = (UInt32)GPT.GetPartition("EFIESP").SizeInSectors;
@@ -2214,7 +2214,7 @@ namespace WPinternals
SetWorkingStatus("Problem detected, rolling back...", ErrorMessage); SetWorkingStatus("Problem detected, rolling back...", ErrorMessage);
await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash); await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
Parts = new List<FlashPart>(); Parts = [];
// Restore original GPT, which will also reference the original NV. // Restore original GPT, which will also reference the original NV.
Part = new FlashPart Part = new FlashPart
@@ -2390,7 +2390,7 @@ namespace WPinternals
GPT.Partitions.Add(IsUnlockedFlag); GPT.Partitions.Add(IsUnlockedFlag);
} }
Parts = new List<FlashPart>(); Parts = [];
GPT.Rebuild(); GPT.Rebuild();
Part = new FlashPart Part = new FlashPart
{ {
@@ -2528,7 +2528,7 @@ namespace WPinternals
byte[] SecondEFIESP = NewEFIESP.Skip((int)SectorSize * ReservedOGSectors).Take((int)(NewEFIESP.Length - (ReservedSectors * SectorSize))).ToArray(); byte[] SecondEFIESP = NewEFIESP.Skip((int)SectorSize * ReservedOGSectors).Take((int)(NewEFIESP.Length - (ReservedSectors * SectorSize))).ToArray();
List<FlashPart> Parts = new(); List<FlashPart> Parts = [];
FlashPart Part = new(); FlashPart Part = new();
Part.StartSector = (uint)EFIESP.FirstSector; Part.StartSector = (uint)EFIESP.FirstSector;
@@ -2559,7 +2559,7 @@ namespace WPinternals
byte[] FirstSector = DeviceFFU.GetPartition("EFIESP").Take(EFIESPFirstPartSize).ToArray(); byte[] FirstSector = DeviceFFU.GetPartition("EFIESP").Take(EFIESPFirstPartSize).ToArray();
List<FlashPart> Parts = new(); List<FlashPart> Parts = [];
FlashPart Part = new(); FlashPart Part = new();
Part.StartSector = (uint)EFIESP.FirstSector; Part.StartSector = (uint)EFIESP.FirstSector;
@@ -127,7 +127,7 @@ namespace WPinternals
UIContext.Send(s => Notifier.Start(), null); UIContext.Send(s => Notifier.Start(), null);
LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash); LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
List<FlashPart> Parts = new(); List<FlashPart> Parts = [];
FlashPart Part; FlashPart Part;
// Use GetGptChunk() here instead of ReadGPT(), because ReadGPT() skips the first sector. // Use GetGptChunk() here instead of ReadGPT(), because ReadGPT() skips the first sector.
@@ -261,7 +261,7 @@ namespace WPinternals
PhoneNotifierViewModel Notifier = new(); PhoneNotifierViewModel Notifier = new();
UIContext.Send(s => Notifier.Start(), null); UIContext.Send(s => Notifier.Start(), null);
LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash); LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
List<FlashPart> Parts = new(); List<FlashPart> Parts = [];
// Use GetGptChunk() here instead of ReadGPT(), because ReadGPT() skips the first sector. // Use GetGptChunk() here instead of ReadGPT(), because ReadGPT() skips the first sector.
// We need the fist sector if we want to write back the GPT. // We need the fist sector if we want to write back the GPT.
@@ -355,7 +355,7 @@ namespace WPinternals
bool IsUnlocked = false; bool IsUnlocked = false;
bool GPTChanged = false; bool GPTChanged = false;
List<FlashPart> Parts = new(); List<FlashPart> Parts = [];
FlashPart Part; FlashPart Part;
if (string.Equals(PartitionName, "EFIESP", StringComparison.CurrentCultureIgnoreCase)) if (string.Equals(PartitionName, "EFIESP", StringComparison.CurrentCultureIgnoreCase))
{ {
@@ -468,16 +468,14 @@ namespace WPinternals
{ {
using MemoryStream Stream = new(Data); using MemoryStream Stream = new(Data);
FlashPart Part = new() { StartSector = StartSector, Stream = Stream }; FlashPart Part = new() { StartSector = StartSector, Stream = Stream };
List<FlashPart> Parts = new(); List<FlashPart> Parts = [Part];
Parts.Add(Part);
await LumiaV2CustomFlash(Notifier, FFUPath, PerformFullFlashFirst, SkipWrite, Parts, DoResetFirst, ClearFlashingStatusAtEnd, CheckSectorAlignment, ShowProgress, Experimental); await LumiaV2CustomFlash(Notifier, FFUPath, PerformFullFlashFirst, SkipWrite, Parts, DoResetFirst, ClearFlashingStatusAtEnd, CheckSectorAlignment, ShowProgress, Experimental);
} }
internal async static Task LumiaV2CustomFlash(PhoneNotifierViewModel Notifier, string FFUPath, bool PerformFullFlashFirst, bool SkipWrite, UInt32 StartSector, Stream Data, bool DoResetFirst = true, bool ClearFlashingStatusAtEnd = true, bool CheckSectorAlignment = true, bool ShowProgress = true, bool Experimental = false) //, string LoaderPath = null) internal async static Task LumiaV2CustomFlash(PhoneNotifierViewModel Notifier, string FFUPath, bool PerformFullFlashFirst, bool SkipWrite, UInt32 StartSector, Stream Data, bool DoResetFirst = true, bool ClearFlashingStatusAtEnd = true, bool CheckSectorAlignment = true, bool ShowProgress = true, bool Experimental = false) //, string LoaderPath = null)
{ {
FlashPart Part = new() { StartSector = StartSector, Stream = Data }; FlashPart Part = new() { StartSector = StartSector, Stream = Data };
List<FlashPart> Parts = new(); List<FlashPart> Parts = [Part];
Parts.Add(Part);
await LumiaV2CustomFlash(Notifier, FFUPath, PerformFullFlashFirst, SkipWrite, Parts, DoResetFirst, ClearFlashingStatusAtEnd, CheckSectorAlignment, ShowProgress, Experimental); await LumiaV2CustomFlash(Notifier, FFUPath, PerformFullFlashFirst, SkipWrite, Parts, DoResetFirst, ClearFlashingStatusAtEnd, CheckSectorAlignment, ShowProgress, Experimental);
} }
@@ -1880,7 +1878,7 @@ namespace WPinternals
SetWorkingStatus("Hashing resources...", "Initializing flash...", (UInt64)TotalProcess1, Status: WPinternalsStatus.Initializing); SetWorkingStatus("Hashing resources...", "Initializing flash...", (UInt64)TotalProcess1, Status: WPinternalsStatus.Initializing);
var crypto = System.Security.Cryptography.SHA256.Create(); var crypto = System.Security.Cryptography.SHA256.Create();
List<FlashingPayload> flashingPayloads = new(); List<FlashingPayload> flashingPayloads = [];
if (flashParts == null) if (flashParts == null)
{ {
return [.. flashingPayloads]; return [.. flashingPayloads];
@@ -1911,7 +1909,7 @@ namespace WPinternals
// //
internal static FlashingPayload[] GetOptimizedPayloads(List<FlashPart> flashParts, Int32 chunkSize, UInt32 MaximumChunkCount, SetWorkingStatus SetWorkingStatus = null, UpdateWorkingStatus UpdateWorkingStatus = null) internal static FlashingPayload[] GetOptimizedPayloads(List<FlashPart> flashParts, Int32 chunkSize, UInt32 MaximumChunkCount, SetWorkingStatus SetWorkingStatus = null, UpdateWorkingStatus UpdateWorkingStatus = null)
{ {
List<FlashingPayload> flashingPayloads = new(); List<FlashingPayload> flashingPayloads = [];
if (flashParts == null) if (flashParts == null)
{ {
return [.. flashingPayloads]; return [.. flashingPayloads];
@@ -2013,7 +2011,7 @@ namespace WPinternals
Partition Target; Partition Target;
FlashPart Part; FlashPart Part;
List<FlashPart> Parts = new(); List<FlashPart> Parts = [];
ulong MainOSOldSectorCount = 0; ulong MainOSOldSectorCount = 0;
ulong MainOSNewSectorCount = 0; ulong MainOSNewSectorCount = 0;
ulong DataOldSectorCount = 0; ulong DataOldSectorCount = 0;
@@ -2406,7 +2404,7 @@ namespace WPinternals
Partition Target; Partition Target;
FlashPart Part; FlashPart Part;
List<FlashPart> Parts = new(); List<FlashPart> Parts = [];
ulong MainOSOldSectorCount = 0; ulong MainOSOldSectorCount = 0;
ulong MainOSNewSectorCount = 0; ulong MainOSNewSectorCount = 0;
ulong DataOldSectorCount = 0; ulong DataOldSectorCount = 0;
@@ -2712,8 +2710,8 @@ namespace WPinternals
private static UInt32 CurrentBufferSize = 0; private static UInt32 CurrentBufferSize = 0;
public static byte[] Buffer; public static byte[] Buffer;
private static readonly List<Allocation> Allocations = new(); private static readonly List<Allocation> Allocations = [];
private static readonly List<FreeMemRange> FreeMemRanges = new(); private static readonly List<FreeMemRange> FreeMemRanges = [];
public static UInt32 RoundUpToPages(UInt32 Size) public static UInt32 RoundUpToPages(UInt32 Size)
{ {
+15 -4
View File
@@ -74,10 +74,21 @@ namespace WPinternals
byte[] AsskMask = [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]; byte[] Challenge = new byte[0x88];
Dictionary<string, object> Params = new(); Dictionary<string, object> Params = new()
Params.Add("AsskMask", AsskMask); {
Params.Add("Challenge", Challenge); {
Params.Add("AsicIndex", 0); "AsskMask",
AsskMask
},
{
"Challenge",
Challenge
},
{
"AsicIndex",
0
}
};
byte[] TerminalResponseBytes = CurrentModel.ExecuteJsonMethodAsBytes("TerminalChallenge", Params, "TerminalResponse"); byte[] TerminalResponseBytes = CurrentModel.ExecuteJsonMethodAsBytes("TerminalChallenge", Params, "TerminalResponse");
if (TerminalResponseBytes != null) if (TerminalResponseBytes != null)
{ {
+13 -5
View File
@@ -289,9 +289,17 @@ namespace WPinternals
return; return;
} }
Dictionary<string, object> Params = new(); Dictionary<string, object> Params = new()
Params.Add("DeviceMode", DeviceMode); {
Params.Add("ResetMethod", "HwReset"); {
"DeviceMode",
DeviceMode
},
{
"ResetMethod",
"HwReset"
}
};
try try
{ {
((NokiaPhoneModel)PhoneNotifier.CurrentModel).ExecuteJsonMethodAsync("SetDeviceMode", Params); ((NokiaPhoneModel)PhoneNotifier.CurrentModel).ExecuteJsonMethodAsync("SetDeviceMode", Params);
@@ -1077,7 +1085,7 @@ namespace WPinternals
// We've been reading the GPT, so we let the phone reset once more to be sure that memory maps are the same // We've been reading the GPT, so we let the phone reset once more to be sure that memory maps are the same
WPinternalsStatus LastStatus = WPinternalsStatus.Undefined; WPinternalsStatus LastStatus = WPinternalsStatus.Undefined;
List<FlashPart> Parts = new(); List<FlashPart> Parts = [];
FlashPart Part = new(); FlashPart Part = new();
Part.StartSector = (uint)Target.FirstSector; Part.StartSector = (uint)Target.FirstSector;
Part.Stream = SB; Part.Stream = SB;
@@ -1286,7 +1294,7 @@ namespace WPinternals
// We've been reading the GPT, so we let the phone reset once more to be sure that memory maps are the same // We've been reading the GPT, so we let the phone reset once more to be sure that memory maps are the same
WPinternalsStatus LastStatus = WPinternalsStatus.Undefined; WPinternalsStatus LastStatus = WPinternalsStatus.Undefined;
List<FlashPart> Parts = new(); List<FlashPart> Parts = [];
FlashPart Part = new(); FlashPart Part = new();
Part.StartSector = (uint)Target.FirstSector; Part.StartSector = (uint)Target.FirstSector;
Part.Stream = SB; Part.Stream = SB;
+4 -4
View File
@@ -151,7 +151,7 @@ namespace WPinternals
return FlashProfiles.Find(p => string.Equals(p.PlatformID, PlatformID, StringComparison.CurrentCultureIgnoreCase) && string.Equals(p.PhoneFirmware, PhoneFirmware, StringComparison.CurrentCultureIgnoreCase) && ((FfuFirmware == null) || string.Equals(p.FfuFirmware, FfuFirmware, StringComparison.CurrentCultureIgnoreCase))); return FlashProfiles.Find(p => string.Equals(p.PlatformID, PlatformID, StringComparison.CurrentCultureIgnoreCase) && string.Equals(p.PhoneFirmware, PhoneFirmware, StringComparison.CurrentCultureIgnoreCase) && ((FfuFirmware == null) || string.Equals(p.FfuFirmware, FfuFirmware, StringComparison.CurrentCultureIgnoreCase)));
} }
public List<FlashProfile> FlashProfiles = new(); public List<FlashProfile> FlashProfiles = [];
internal void AddFfuToRepository(string FFUPath) internal void AddFfuToRepository(string FFUPath)
{ {
@@ -218,7 +218,7 @@ namespace WPinternals
} }
} }
public List<FFUEntry> FFURepository = new(); public List<FFUEntry> FFURepository = [];
internal void AddSecWimToRepository(string SecWimPath, string FirmwareVersion) internal void AddSecWimToRepository(string SecWimPath, string FirmwareVersion)
{ {
@@ -264,9 +264,9 @@ namespace WPinternals
} }
} }
public List<SecWimEntry> SecWimRepository = new(); public List<SecWimEntry> SecWimRepository = [];
public List<EmergencyFileEntry> EmergencyRepository = new(); public List<EmergencyFileEntry> EmergencyRepository = [];
internal void AddEmergencyToRepository(string Type, string ProgrammerPath, string PayloadPath) internal void AddEmergencyToRepository(string Type, string ProgrammerPath, string PayloadPath)
{ {
@@ -206,7 +206,7 @@ namespace MadWizard.WinUSBNet.API
public static DeviceDetails[] FindDevicesFromGuid(Guid guid) public static DeviceDetails[] FindDevicesFromGuid(Guid guid)
{ {
IntPtr deviceInfoSet = IntPtr.Zero; IntPtr deviceInfoSet = IntPtr.Zero;
List<DeviceDetails> deviceList = new(); List<DeviceDetails> deviceList = [];
try try
{ {
deviceInfoSet = SetupDiGetClassDevs(ref guid, IntPtr.Zero, IntPtr.Zero, deviceInfoSet = SetupDiGetClassDevs(ref guid, IntPtr.Zero, IntPtr.Zero,
+1 -1
View File
@@ -260,7 +260,7 @@ namespace MadWizard.WinUSBNet.API
throw APIException.Win32("Failed to initialize WinUSB handle. Device might not be connected."); throw APIException.Win32("Failed to initialize WinUSB handle. Device might not be connected.");
} }
List<IntPtr> interfaces = new(); List<IntPtr> interfaces = [];
byte numAddInterfaces = 0; byte numAddInterfaces = 0;
byte idx = 0; byte idx = 0;
+1 -1
View File
@@ -147,7 +147,7 @@ namespace MadWizard.WinUSBNet
{ {
int numInterfaces = InternalDevice.InterfaceCount; int numInterfaces = InternalDevice.InterfaceCount;
List<USBPipe> allPipes = new(); List<USBPipe> allPipes = [];
InputPipe = null; InputPipe = null;
OutputPipe = null; OutputPipe = null;
@@ -107,7 +107,7 @@ namespace MadWizard.WinUSBNet
/// array if no interface matches.</returns> /// array if no interface matches.</returns>
public USBInterface[] FindAll(USBBaseClass interfaceClass) public USBInterface[] FindAll(USBBaseClass interfaceClass)
{ {
List<USBInterface> matchingInterfaces = new(); List<USBInterface> matchingInterfaces = [];
for (int i = 0; i < _interfaces.Length; i++) for (int i = 0; i < _interfaces.Length; i++)
{ {
USBInterface iface = _interfaces[i]; USBInterface iface = _interfaces[i];