mirror of
https://github.com/ReneLergner/WPinternals.git
synced 2026-06-19 13:50:11 +10:00
Enhancements
- Improved error messages - Added shutdown functionality from mass stoage - Fixed an issue where 9006 would incorrectly be used for rebooting from mass storage - Added support for gathering security information from older flash apps - Added a new indicator in the empty view when a phone in bootloader mode is detected - Fixed an issue where interrupting the bootloader may fail - Added more checks to some functions - Started to work on a bootloader view - Fixed an issue where x50 phones in label mode would not get detected once being disconnected - Added logging for Qualcomm Emergency Charging mode - General bug fixes
This commit is contained in:
+14
-14
@@ -53,7 +53,7 @@ namespace WPinternals
|
||||
this.GPTBuffer = GPTBuffer;
|
||||
UInt32? TempHeaderOffset = ByteOperations.FindAscii(GPTBuffer, "EFI PART");
|
||||
if (TempHeaderOffset == null)
|
||||
throw new WPinternalsException("Bad GPT");
|
||||
throw new WPinternalsException("Bad GPT", "The GPT read isn't valid. Couldn't find the text \"EFI PART\".");
|
||||
HeaderOffset = (UInt32)TempHeaderOffset;
|
||||
HeaderSize = ByteOperations.ReadUInt32(GPTBuffer, HeaderOffset + 0x0C);
|
||||
TableOffset = HeaderOffset + 0x200;
|
||||
@@ -63,7 +63,7 @@ namespace WPinternals
|
||||
PartitionEntrySize = ByteOperations.ReadUInt32(GPTBuffer, HeaderOffset + 0x54);
|
||||
TableSize = MaxPartitions * PartitionEntrySize;
|
||||
if ((TableOffset + TableSize) > GPTBuffer.Length)
|
||||
throw new WPinternalsException("Bad GPT");
|
||||
throw new WPinternalsException("Bad GPT", "The GPT read isn't valid. The sizes defined in the GPT header exceed the provided GPT size.");
|
||||
|
||||
UInt32 PartitionOffset = TableOffset;
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace WPinternals
|
||||
Partition SBL2 = Partitions.Where(p => (p.Name == "SBL2")).FirstOrDefault();
|
||||
|
||||
if ((SBL1 == null) || (SBL2 == null))
|
||||
throw new WPinternalsException("Bad GPT");
|
||||
throw new WPinternalsException("Bad GPT", "Can't patch GPT for the Secure Boot hack for Spec A devices. The provided GPT does not include a SBL1 and/or SBL2 partition.");
|
||||
|
||||
if (HackPartition == null)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ namespace WPinternals
|
||||
Partition SBL2 = Partitions.Where(p => (p.Name == "SBL2")).FirstOrDefault();
|
||||
|
||||
if ((SBL1 == null) || (SBL2 == null))
|
||||
throw new WPinternalsException("Bad GPT");
|
||||
throw new WPinternalsException("Bad GPT", "Can't un-patch GPT for the Secure Boot hack for Spec A devices. The provided GPT does not include a SBL1 and/or SBL2 partition.");
|
||||
|
||||
if (HackPartition != null)
|
||||
{
|
||||
@@ -224,7 +224,7 @@ namespace WPinternals
|
||||
|
||||
if (NewPartition.LastSector == 0)
|
||||
{
|
||||
throw new WPinternalsException("Unknown length for partition \"" + NewPartition.Name + "\"");
|
||||
throw new WPinternalsException("Unknown length for partition \"" + NewPartition.Name + "\". The last sector property is set to 0 and the partition doesn't exist on the device currently.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -234,9 +234,9 @@ namespace WPinternals
|
||||
// If the location of the new partition is specified, it must be the same as the current partition.
|
||||
|
||||
if ((NewPartition.FirstSector != 0) && (NewPartition.FirstSector != OldPartition.FirstSector))
|
||||
throw new WPinternalsException("Incorrect location for partition \"" + NewPartition.Name + "\"");
|
||||
throw new WPinternalsException("Incorrect location for partition \"" + NewPartition.Name + "\". A partition defined in the xml file got its boundaries updated, but as the partition isn't provided in the archive, it is not possible to relocate it.");
|
||||
if ((NewPartition.LastSector != 0) && (NewPartition.LastSector != OldPartition.LastSector))
|
||||
throw new WPinternalsException("Incorrect length for partition \"" + NewPartition.Name + "\"");
|
||||
throw new WPinternalsException("Incorrect length for partition \"" + NewPartition.Name + "\". A partition defined in the xml file got its boundaries updated, but as the partition isn't provided in the archive, it is not possible to relocate it.");
|
||||
|
||||
NewPartition.FirstSector = OldPartition.FirstSector;
|
||||
NewPartition.LastSector = OldPartition.LastSector;
|
||||
@@ -264,7 +264,7 @@ namespace WPinternals
|
||||
else
|
||||
{
|
||||
if (NewPartition.SizeInSectors != StreamLengthInSectors)
|
||||
throw new WPinternalsException("Inconsistent length specified for partition \"" + NewPartition.Name + "\"");
|
||||
throw new WPinternalsException("Inconsistent length specified for partition \"" + NewPartition.Name + "\". The provided partition in the archive does not match the length specified in the xml file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ namespace WPinternals
|
||||
|
||||
if (NewPartition.LastSector == 0)
|
||||
{
|
||||
throw new WPinternalsException("Unknown length for partition \"" + NewPartition.Name + "\"");
|
||||
throw new WPinternalsException("Unknown length for partition \"" + NewPartition.Name + "\". The last sector property is set to 0 and the partition doesn't exist on the device currently.");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -293,9 +293,9 @@ namespace WPinternals
|
||||
// If the location of the new partition is specified, it must be the same as the current partition.
|
||||
|
||||
if ((NewPartition.FirstSector != 0) && (NewPartition.FirstSector != OldPartition.FirstSector))
|
||||
throw new WPinternalsException("Incorrect location for partition \"" + NewPartition.Name + "\"");
|
||||
throw new WPinternalsException("Incorrect location for partition \"" + NewPartition.Name + "\". A partition defined in the xml file got its boundaries updated, but as the partition isn't provided in the archive, it is not possible to relocate it.");
|
||||
if ((NewPartition.LastSector != 0) && (NewPartition.LastSector != OldPartition.LastSector))
|
||||
throw new WPinternalsException("Incorrect length for partition \"" + NewPartition.Name + "\"");
|
||||
throw new WPinternalsException("Incorrect length for partition \"" + NewPartition.Name + "\". A partition defined in the xml file got its boundaries updated, but as the partition isn't provided in the archive, it is not possible to relocate it.");
|
||||
|
||||
NewPartition.FirstSector = OldPartition.FirstSector;
|
||||
NewPartition.LastSector = OldPartition.LastSector;
|
||||
@@ -348,7 +348,7 @@ namespace WPinternals
|
||||
|
||||
// Sanity check
|
||||
if (NewPartition.FirstSector < LowestSector)
|
||||
throw new WPinternalsException("Bad sector alignment for partition: " + NewPartition.Name);
|
||||
throw new WPinternalsException("Bad sector alignment for partition: " + NewPartition.Name + ". The partition is located before DPP.");
|
||||
|
||||
Partition CurrentPartition = this.GetPartition(NewPartition.Name);
|
||||
if (CurrentPartition == null)
|
||||
@@ -426,7 +426,7 @@ namespace WPinternals
|
||||
MaxPartitionSizeInSectors = NextPartition.FirstSector - OldPartition.FirstSector;
|
||||
if (StreamLengthInSectors > MaxPartitionSizeInSectors)
|
||||
{
|
||||
throw new WPinternalsException("Incorrect length for partition \"" + OldPartition.Name + "\"");
|
||||
throw new WPinternalsException("Incorrect length for partition \"" + OldPartition.Name + "\". The provided partition in the archive does not match the length specified in the xml file.");
|
||||
}
|
||||
|
||||
if (OldPartition.SizeInSectors != StreamLengthInSectors)
|
||||
@@ -528,7 +528,7 @@ namespace WPinternals
|
||||
}
|
||||
|
||||
if (RevisePartition.LastSector >= 0xF400)
|
||||
throw new WPinternalsException("Unsupported partition layout!");
|
||||
throw new WPinternalsException("Unsupported partition layout!", "The last sector of one of the BACKUP partitions defined in GPT exceeds the maximum threshold expected in order to restore BACKUP partitions to the device.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace WPinternals
|
||||
}
|
||||
|
||||
if (Package == null)
|
||||
throw new WPinternalsException("FFU not found");
|
||||
throw new WPinternalsException("FFU not found", "No FFU has been found in the remote software repository for the requested model.");
|
||||
|
||||
FoundProductType = Package.manufacturerHardwareModel[0];
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace WPinternals
|
||||
}
|
||||
|
||||
if (Package == null)
|
||||
throw new WPinternalsException("ENOSW package not found");
|
||||
throw new WPinternalsException("ENOSW package not found", "No ENOSW package has been found in the remote software repository for the requested model.");
|
||||
|
||||
SoftwareFile FileInfo = Package.files.Where(f => f.fileName.EndsWith(".secwim", StringComparison.OrdinalIgnoreCase)).First();
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace WPinternals
|
||||
}
|
||||
|
||||
if (DPLUrl == "")
|
||||
throw new WPinternalsException("DPL not found");
|
||||
throw new WPinternalsException("DPL not found", "No DPL has been found in the remote software repository for the requested model.");
|
||||
|
||||
Task<string> GetDPLStrTask = HttpClient.GetStringAsync(DPLUrl);
|
||||
GetDPLStrTask.Wait();
|
||||
|
||||
+19
-6
@@ -35,7 +35,7 @@ namespace WPinternals
|
||||
internal IntPtr hDrive = (IntPtr)(-1);
|
||||
private bool OpenWithWriteAccess;
|
||||
|
||||
private QualcommSerial Serial;
|
||||
private string Serial;
|
||||
|
||||
internal MassStorage(string DevicePath) : base(DevicePath)
|
||||
{
|
||||
@@ -77,10 +77,16 @@ namespace WPinternals
|
||||
{
|
||||
try
|
||||
{
|
||||
Serial = new QualcommSerial(DevicePath);
|
||||
Serial.EncodeCommands = false;
|
||||
QualcommSerial SerialDevice = new QualcommSerial(DevicePath);
|
||||
SerialDevice.Close();
|
||||
SerialDevice.Dispose();
|
||||
|
||||
Serial = DevicePath;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogFile.Log(ex.Message);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
internal bool DoesDeviceSupportReboot()
|
||||
@@ -95,11 +101,18 @@ namespace WPinternals
|
||||
|
||||
try
|
||||
{
|
||||
QualcommSerial SerialDevice = new QualcommSerial(Serial);
|
||||
|
||||
SerialDevice.EncodeCommands = false;
|
||||
|
||||
// This will succeed on new models
|
||||
Serial.SendData(new byte[] { 0x7, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0 });
|
||||
SerialDevice.SendData(new byte[] { 0x7, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0 });
|
||||
|
||||
// This will succeed on old models
|
||||
Serial.SendData(new byte[] { 0x7E, 0xA, 0x0, 0x0, 0xB6, 0xB5, 0x7E });
|
||||
SerialDevice.SendData(new byte[] { 0x7E, 0xA, 0x0, 0x0, 0xB6, 0xB5, 0x7E });
|
||||
|
||||
SerialDevice.Close();
|
||||
SerialDevice.Dispose();
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace WPinternals
|
||||
if (Response == null)
|
||||
throw new BadConnectionException();
|
||||
if (Response.Length == 4)
|
||||
throw new WPinternalsException("Flash protocol v2 not supported");
|
||||
throw new WPinternalsException("Flash protocol v2 not supported", "The device reported that the Flash protocol v2 was not supported while sending the FFU header.");
|
||||
int ResultCode = (Response[6] << 8) + Response[7];
|
||||
if (ResultCode != 0)
|
||||
ThrowFlashError(ResultCode);
|
||||
@@ -345,7 +345,7 @@ namespace WPinternals
|
||||
ThrowFlashError(ResultCode);
|
||||
}
|
||||
else
|
||||
throw new WPinternalsException("Specified partition cannot be backupped to RAM");
|
||||
throw new WPinternalsException("Specified partition cannot be backupped to RAM", "Partition name: \"" + PartitionName + "\".");
|
||||
}
|
||||
|
||||
public void LoadMmosBinary(UInt32 TotalLength, UInt32 Offset, bool SkipMmosSupportCheck, byte[] MmosPart)
|
||||
@@ -450,7 +450,7 @@ namespace WPinternals
|
||||
|
||||
PhoneInfo Info = ReadPhoneInfo();
|
||||
if ((Info.SecureFfuSupportedProtocolMask & ((ushort)FfuProtocol.ProtocolSyncV1 | (ushort)FfuProtocol.ProtocolSyncV2)) == 0)
|
||||
throw new WPinternalsException("Flash failed!", "Protocols not supported");
|
||||
throw new WPinternalsException("Flash failed!", "Protocols not supported. The device reports that both Protocol Sync v1 and Protocol Sync v2 are not supported for FFU flashing. Is this an old device?");
|
||||
|
||||
UInt64 CombinedFFUHeaderSize = FFU.HeaderSize;
|
||||
byte[] FfuHeader = new byte[CombinedFFUHeaderSize];
|
||||
@@ -518,7 +518,7 @@ namespace WPinternals
|
||||
|
||||
PhoneInfo Info = ReadPhoneInfo();
|
||||
if (!Info.MmosOverUsbSupported)
|
||||
throw new WPinternalsException("Flash failed!", "Protocols not supported");
|
||||
throw new WPinternalsException("Flash failed!", "Protocols not supported. The device reports that loading Microsoft Manufacturing Operating System over USB is not supported.");
|
||||
|
||||
FileInfo info = new FileInfo(MMOSPath);
|
||||
uint length = uint.Parse(info.Length.ToString());
|
||||
@@ -986,7 +986,7 @@ namespace WPinternals
|
||||
if (Response == null)
|
||||
throw new BadConnectionException();
|
||||
if (ByteOperations.ReadAsciiString(Response, 0, 4) != "NOKI")
|
||||
throw new WPinternalsException("Bad response from phone!");
|
||||
throw new WPinternalsException("Bad response from phone!", "The phone did not answer properly to the Hello message sent.");
|
||||
}
|
||||
|
||||
internal UInt16 ReadSecureFfuSupportedProtocolMask()
|
||||
@@ -1199,7 +1199,7 @@ namespace WPinternals
|
||||
LogFile.Log("Product code: " + ProductCode, Type);
|
||||
if (RKH != null)
|
||||
LogFile.Log("Root key hash: " + Converter.ConvertHexToString(RKH, ""), Type);
|
||||
if (Firmware.Length > 0)
|
||||
if (Firmware != null && Firmware.Length > 0)
|
||||
LogFile.Log("Firmware version: " + Firmware, Type);
|
||||
if (!(Type == LogType.ConsoleOnly) && (Imei != null))
|
||||
LogFile.Log("IMEI: " + Imei, LogType.FileOnly);
|
||||
|
||||
@@ -399,7 +399,7 @@ namespace WPinternals
|
||||
internal FilePatcher(string FilePath, Stream FileStream)
|
||||
{
|
||||
if (!FileStream.CanSeek || !FileStream.CanWrite)
|
||||
throw new WPinternalsException("Incorrect filestream");
|
||||
throw new WPinternalsException("Incorrect filestream", "The provided file stream for patching does not support seeking and/or writing.");
|
||||
|
||||
this.FilePath = FilePath;
|
||||
this.Stream = FileStream;
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace WPinternals
|
||||
HeaderOffset = ImageOffset + 8;
|
||||
}
|
||||
else
|
||||
throw new WPinternalsException("Invalid programmer");
|
||||
throw new WPinternalsException("Invalid programmer", "The type of elf image could not be determined from the provided programmer.");
|
||||
}
|
||||
else if (ByteOperations.FindPattern(Binary, Offset, (uint)LongHeaderPattern.Length, LongHeaderPattern, LongHeaderMask, null) == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user