workaround older phone fw issues when retrieving via json rpc and gpt get function failures

This commit is contained in:
Gustave Monce
2024-09-01 16:49:36 +02:00
parent 91961b0e7b
commit c6dee3fe33
4 changed files with 56 additions and 10 deletions
@@ -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);
@@ -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")
{
@@ -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<FlashPart> FlashParts = new();
@@ -67,17 +67,35 @@ namespace WPinternals
LogFile.Log("IMEI: " + IMEI);
PublicID = CurrentModel.ExecuteJsonMethodAsBytes("ReadPublicId", "PublicId"); // 0x14 bytes: a5 e5 ...
if (PublicID != null)
{
LogFile.Log("Public ID: " + Converter.ConvertHexToString(PublicID, " "));
}
BluetoothMac = CurrentModel.ExecuteJsonMethodAsBytes("ReadBtId", "BtId"); // 6 bytes: bc c6 ...
if (BluetoothMac != null)
{
LogFile.Log("Bluetooth MAC: " + Converter.ConvertHexToString(BluetoothMac, " "));
}
WlanMac1 = CurrentModel.ExecuteJsonMethodAsBytes("ReadWlanMacAddress", "WlanMacAddress1"); // 6 bytes
if (WlanMac1 != null)
{
LogFile.Log("WLAN MAC 1: " + Converter.ConvertHexToString(WlanMac1, " "));
}
WlanMac2 = CurrentModel.ExecuteJsonMethodAsBytes("ReadWlanMacAddress", "WlanMacAddress2"); // 6 bytes
if (WlanMac2 != null)
{
LogFile.Log("WLAN MAC 2: " + Converter.ConvertHexToString(WlanMac2, " "));
}
WlanMac3 = CurrentModel.ExecuteJsonMethodAsBytes("ReadWlanMacAddress", "WlanMacAddress3"); // 6 bytes
if (WlanMac3 != null)
{
LogFile.Log("WLAN MAC 3: " + Converter.ConvertHexToString(WlanMac3, " "));
}
WlanMac4 = CurrentModel.ExecuteJsonMethodAsBytes("ReadWlanMacAddress", "WlanMacAddress4"); // 6 bytes
if (WlanMac4 != null)
{
LogFile.Log("WLAN MAC 4: " + Converter.ConvertHexToString(WlanMac4, " "));
}
bool? ProductionDone = CurrentModel.ExecuteJsonMethodAsBoolean("ReadProductionDoneState", "ProductionDone");
IsBootloaderSecurityEnabled = ProductionDone == null