diff --git a/WPinternals/Models/UEFIApps/LumiaFlashAppModel.cs b/WPinternals/Models/UEFIApps/LumiaFlashAppModel.cs index 4e612a8..2c087e7 100644 --- a/WPinternals/Models/UEFIApps/LumiaFlashAppModel.cs +++ b/WPinternals/Models/UEFIApps/LumiaFlashAppModel.cs @@ -344,7 +344,8 @@ namespace WPinternals UInt16 Error = (UInt16)((Buffer[6] << 8) + Buffer[7]); if (Error > 0) { - throw new NotSupportedException("ReadGPT: Error 0x" + Error.ToString("X4")); + ThrowFlashError(Error); + //throw new NotSupportedException("ReadGPT: Error 0x" + Error.ToString("X4")); } System.Buffer.BlockCopy(Buffer, 8, GPTChunk, 0, 0x4400); diff --git a/WPinternals/Models/UEFIApps/NokiaFlashModel.cs b/WPinternals/Models/UEFIApps/NokiaFlashModel.cs index b1c0c3e..4906cc8 100644 --- a/WPinternals/Models/UEFIApps/NokiaFlashModel.cs +++ b/WPinternals/Models/UEFIApps/NokiaFlashModel.cs @@ -62,7 +62,7 @@ namespace WPinternals bool ModernFlashApp = info.VersionMajor >= 2; byte[] Request = new byte[7]; - ByteOperations.WriteAsciiString(Request, 0, SwitchModeSignature + "B"); + ByteOperations.WriteAsciiString(Request, 0, $"{SwitchModeSignature}B"); byte[] Response = ExecuteRawMethod(Request); if (ByteOperations.ReadAsciiString(Response, 0, 4) == "NOKU") { diff --git a/WPinternals/ViewModels/LumiaFlashRomViewModel.cs b/WPinternals/ViewModels/LumiaFlashRomViewModel.cs index 686b30e..d5ca718 100644 --- a/WPinternals/ViewModels/LumiaFlashRomViewModel.cs +++ b/WPinternals/ViewModels/LumiaFlashRomViewModel.cs @@ -501,7 +501,7 @@ namespace WPinternals internal void FlashFFUTask(string FFUPath) { - new Thread(() => + new Thread(async () => { bool Result = true; @@ -519,8 +519,35 @@ namespace WPinternals if (Info.FlashAppProtocolVersionMajor >= 2) { - byte[] GPTChunk = Phone.GetGptChunk(0x20000); // TODO: Get proper profile FFU and get ChunkSizeInBytes + Phone.SwitchToBootManagerContext(); + + if (PhoneNotifier.CurrentInterface != PhoneInterfaces.Lumia_Bootloader) + { + await PhoneNotifier.WaitForArrival(); + } + + if (PhoneNotifier.CurrentInterface != PhoneInterfaces.Lumia_Bootloader) + { + throw new WPinternalsException("Unexpected Mode"); + } + + byte[] GPTChunk = ((LumiaBootManagerAppModel)PhoneNotifier.CurrentModel).GetGptChunk(0x20000); // TODO: Get proper profile FFU and get ChunkSizeInBytes GPT GPT = new(GPTChunk); + + ((LumiaBootManagerAppModel)PhoneNotifier.CurrentModel).SwitchToFlashAppContext(); + + if (PhoneNotifier.CurrentInterface != PhoneInterfaces.Lumia_Flash) + { + await PhoneNotifier.WaitForArrival(); + } + + if (PhoneNotifier.CurrentInterface != PhoneInterfaces.Lumia_Flash) + { + throw new WPinternalsException("Unexpected Mode"); + } + + Phone = (LumiaFlashAppModel)PhoneNotifier.CurrentModel; + FlashPart Part; List FlashParts = new(); diff --git a/WPinternals/ViewModels/NokiaNormalViewModel.cs b/WPinternals/ViewModels/NokiaNormalViewModel.cs index 47c532f..a6e29bb 100644 --- a/WPinternals/ViewModels/NokiaNormalViewModel.cs +++ b/WPinternals/ViewModels/NokiaNormalViewModel.cs @@ -67,17 +67,35 @@ namespace WPinternals LogFile.Log("IMEI: " + IMEI); PublicID = CurrentModel.ExecuteJsonMethodAsBytes("ReadPublicId", "PublicId"); // 0x14 bytes: a5 e5 ... - LogFile.Log("Public ID: " + Converter.ConvertHexToString(PublicID, " ")); + if (PublicID != null) + { + LogFile.Log("Public ID: " + Converter.ConvertHexToString(PublicID, " ")); + } BluetoothMac = CurrentModel.ExecuteJsonMethodAsBytes("ReadBtId", "BtId"); // 6 bytes: bc c6 ... - LogFile.Log("Bluetooth MAC: " + Converter.ConvertHexToString(BluetoothMac, " ")); + if (BluetoothMac != null) + { + LogFile.Log("Bluetooth MAC: " + Converter.ConvertHexToString(BluetoothMac, " ")); + } WlanMac1 = CurrentModel.ExecuteJsonMethodAsBytes("ReadWlanMacAddress", "WlanMacAddress1"); // 6 bytes - LogFile.Log("WLAN MAC 1: " + Converter.ConvertHexToString(WlanMac1, " ")); + if (WlanMac1 != null) + { + LogFile.Log("WLAN MAC 1: " + Converter.ConvertHexToString(WlanMac1, " ")); + } WlanMac2 = CurrentModel.ExecuteJsonMethodAsBytes("ReadWlanMacAddress", "WlanMacAddress2"); // 6 bytes - LogFile.Log("WLAN MAC 2: " + Converter.ConvertHexToString(WlanMac2, " ")); + if (WlanMac2 != null) + { + LogFile.Log("WLAN MAC 2: " + Converter.ConvertHexToString(WlanMac2, " ")); + } WlanMac3 = CurrentModel.ExecuteJsonMethodAsBytes("ReadWlanMacAddress", "WlanMacAddress3"); // 6 bytes - LogFile.Log("WLAN MAC 3: " + Converter.ConvertHexToString(WlanMac3, " ")); + if (WlanMac3 != null) + { + LogFile.Log("WLAN MAC 3: " + Converter.ConvertHexToString(WlanMac3, " ")); + } WlanMac4 = CurrentModel.ExecuteJsonMethodAsBytes("ReadWlanMacAddress", "WlanMacAddress4"); // 6 bytes - LogFile.Log("WLAN MAC 4: " + Converter.ConvertHexToString(WlanMac4, " ")); + if (WlanMac4 != null) + { + LogFile.Log("WLAN MAC 4: " + Converter.ConvertHexToString(WlanMac4, " ")); + } bool? ProductionDone = CurrentModel.ExecuteJsonMethodAsBoolean("ReadProductionDoneState", "ProductionDone"); IsBootloaderSecurityEnabled = ProductionDone == null