Implement Qualcomm Sahara VIP and fix a few bugs

* Qualcomm Sahara VIP
* Project Cleanup
* Allow unlocking an already unlocked phone
This commit is contained in:
Gustave Monce
2021-08-11 14:33:49 +02:00
parent 9f4c92f437
commit c5fcb1ec8d
72 changed files with 987 additions and 861 deletions
+5 -1
View File
@@ -25,9 +25,13 @@ namespace MadWizard.WinUSBNet.API
{
}
public APIException() : base()
{
}
public static APIException Win32(string message)
{
return APIException.Win32(message, Marshal.GetLastWin32Error());
return Win32(message, Marshal.GetLastWin32Error());
// TEST!!
// int ErrorCode = Marshal.GetLastWin32Error();
+8 -17
View File
@@ -45,7 +45,7 @@ namespace MadWizard.WinUSBNet.API
// in the strucutre that are not part of dbch_name and dividing by 2 because there are
// 2 bytes per character.
stringSize = System.Convert.ToInt32((devBroadcastHeader.dbch_size - 32) / 2);
stringSize = Convert.ToInt32((devBroadcastHeader.dbch_size - 32) / 2);
// The dbcc_name parameter of devBroadcastDeviceInterface contains the device name.
// Trim dbcc_name to match the size of the String.
@@ -87,12 +87,9 @@ namespace MadWizard.WinUSBNet.API
private static byte[] GetProperty(IntPtr deviceInfoSet, SP_DEVINFO_DATA deviceInfoData, SPDRP property, out int regType)
{
if (!SetupDiGetDeviceRegistryProperty(deviceInfoSet, ref deviceInfoData, property, IntPtr.Zero, IntPtr.Zero, 0, out uint requiredSize))
if (!SetupDiGetDeviceRegistryProperty(deviceInfoSet, ref deviceInfoData, property, IntPtr.Zero, IntPtr.Zero, 0, out uint requiredSize) && Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER)
{
if (Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER)
{
throw APIException.Win32("Failed to get buffer size for device registry property.");
}
throw APIException.Win32("Failed to get buffer size for device registry property.");
}
byte[] buffer = new byte[requiredSize];
@@ -116,12 +113,9 @@ namespace MadWizard.WinUSBNet.API
// Heathcliff74
private static byte[] GetProperty(IntPtr deviceInfoSet, SP_DEVINFO_DATA deviceInfoData, DEVPROPKEY property, out uint propertyType)
{
if (!SetupDiGetDeviceProperty(deviceInfoSet, ref deviceInfoData, ref property, out propertyType, null, 0, out int requiredSize, 0))
if (!SetupDiGetDeviceProperty(deviceInfoSet, ref deviceInfoData, ref property, out propertyType, null, 0, out int requiredSize, 0) && Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER)
{
if (Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER)
{
throw APIException.Win32("Failed to get buffer size for device registry property.");
}
throw APIException.Win32("Failed to get buffer size for device registry property.");
}
byte[] buffer = new byte[requiredSize];
@@ -261,12 +255,9 @@ namespace MadWizard.WinUSBNet.API
ref bufferSize,
IntPtr.Zero);
if (!success)
if (!success && Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER)
{
if (Marshal.GetLastWin32Error() != ERROR_INSUFFICIENT_BUFFER)
{
throw APIException.Win32("Failed to get interface details buffer size.");
}
throw APIException.Win32("Failed to get interface details buffer size.");
}
IntPtr detailDataBuffer = IntPtr.Zero;
@@ -372,7 +363,7 @@ namespace MadWizard.WinUSBNet.API
public static void StopDeviceDeviceNotifications(IntPtr deviceNotificationHandle)
{
if (!DeviceManagement.UnregisterDeviceNotification(deviceNotificationHandle))
if (!UnregisterDeviceNotification(deviceNotificationHandle))
{
throw APIException.Win32("Failed to unregister device notification");
}
+1 -1
View File
@@ -177,7 +177,7 @@ namespace MadWizard.WinUSBNet
if (Application.Current != null)
{
if (Application.Current.Dispatcher.Thread.ManagedThreadId == System.Threading.Thread.CurrentThread.ManagedThreadId)
if (Application.Current.Dispatcher.Thread.ManagedThreadId == Environment.CurrentManagedThreadId)
{
RemoveHookAction();
}
+1 -1
View File
@@ -804,7 +804,7 @@ namespace MadWizard.WinUSBNet
/// no device with the given GUID could be found null is returned.</returns>
public static USBDevice GetSingleDevice(string guidString)
{
return USBDevice.GetSingleDevice(new Guid(guidString));
return GetSingleDevice(new Guid(guidString));
}
private static USBDeviceDescriptor GetDeviceDescriptor(string devicePath)
+4
View File
@@ -34,5 +34,9 @@ namespace MadWizard.WinUSBNet
: base(message, innerException)
{
}
public USBException() : base()
{
}
}
}
+2
View File
@@ -90,10 +90,12 @@ namespace MadWizard.WinUSBNet
get;
}
/// <summary>
/// Zero based interface index in WinUSB.
/// Note that this is not necessarily the same as the interface *number*
/// from the interface descriptor. There might be interfaces within the
/// USB device that do not use WinUSB, these are not counted for index.
/// </summary>
internal int InterfaceIndex
{
get;