fix: Log all silent exceptions

This commit is contained in:
Gustave Monce
2024-08-30 21:43:30 +02:00
parent 350b6e8f1e
commit c21692491d
20 changed files with 224 additions and 51 deletions
+4 -1
View File
@@ -318,7 +318,10 @@ namespace WPinternals
s = new FileStream(args[3], FileMode.Open, FileAccess.Read);
Archive = new ZipArchive(s);
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
if (Archive == null)
{
+8 -2
View File
@@ -316,13 +316,19 @@ namespace WPinternals
{
filename = System.IO.Path.GetFileName(Text);
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
string directory = "";
try
{
directory = System.IO.Path.GetDirectoryName(Text);
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
FormattedText formatted;
bool widthOK = false;
bool changedWidth = false;
+12 -3
View File
@@ -275,7 +275,10 @@ namespace WPinternals
{
StreamLengthInSectors = (ulong)DecompressedStream.Length / 0x200;
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
if (NewPartition.LastSector == 0)
@@ -471,7 +474,10 @@ namespace WPinternals
{
StreamLengthInSectors = (ulong)DecompressedStream.Length / 0x200;
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
DecompressedStream.Close();
UInt64 MaxPartitionSizeInSectors = OldPartition.SizeInSectors;
@@ -521,7 +527,10 @@ namespace WPinternals
{
StreamLengthInSectors = (ulong)DecompressedStream.Length / 0x200;
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
DecompressedStream.Close();
if (NewPartition.SizeInSectors != StreamLengthInSectors)
{
+8 -2
View File
@@ -73,7 +73,10 @@ namespace WPinternals
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
internal void AttachQualcommSerial(string DevicePath)
@@ -119,7 +122,10 @@ namespace WPinternals
SerialDevice.Close();
SerialDevice.Dispose();
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
protected override void Dispose(bool disposing)
+55 -9
View File
@@ -808,7 +808,10 @@ namespace WPinternals
{
InputStreamLength = (UInt64)InputStream.Length;
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
if ((InputStreamLength != null) && ((UInt64)InputStream.Length > PartitionSize))
{
@@ -1008,16 +1011,34 @@ namespace WPinternals
try
{
SwitchToPhoneInfoAppContext(); // May throw NotSupportedException
if (Result.BootManagerProtocolVersionMajor >= 2)
{
SwitchToPhoneInfoAppContext(); // May throw NotSupportedException
Result.Type = ReadPhoneInfoVariable("TYPE");
Result.ProductCode = ReadPhoneInfoVariable("CTR");
Result.Imei = ReadPhoneInfoVariable("IMEI");
Result.Type = ReadPhoneInfoVariable("TYPE");
Result.ProductCode = ReadPhoneInfoVariable("CTR");
Result.Imei = ReadPhoneInfoVariable("IMEI");
SwitchToFlashAppContext();
DisableRebootTimeOut();
SwitchToFlashAppContext();
DisableRebootTimeOut();
}
else if (OriginalType == FlashAppType.PhoneInfoApp)
{
Result.Type = ReadPhoneInfoVariable("TYPE");
Result.ProductCode = ReadPhoneInfoVariable("CTR");
Result.Imei = ReadPhoneInfoVariable("IMEI");
}
else
{
//SwitchToPhoneInfoAppContextLegacy();
//SwitchAwayToPhoneInfoAppContextLegacy();
}
}
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
catch { }
if (Result.App == FlashAppType.FlashApp)
{
@@ -1032,7 +1053,10 @@ namespace WPinternals
SwitchToBootManagerContext();
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
Result.State = PhoneInfoState.Extended;
}
@@ -1122,6 +1146,28 @@ namespace WPinternals
InterfaceChanged(PhoneInterfaces.Lumia_Flash);
}
internal void SwitchToPhoneInfoAppContextLegacy()
{
byte[] Request = new byte[4];
ByteOperations.WriteAsciiString(Request, 0, "NOKP");
ExecuteRawVoidMethod(Request);
//DisableRebootTimeOut();
Info.App = FlashAppType.PhoneInfoApp;
InterfaceChanged(PhoneInterfaces.Lumia_Bootloader);
}
internal void SwitchAwayToPhoneInfoAppContextLegacy()
{
byte[] Request = new byte[4];
ByteOperations.WriteAsciiString(Request, 0, "NOKA");
ExecuteRawVoidMethod(Request);
//DisableRebootTimeOut();
//Info.App = FlashAppType.FlashApp;
//InterfaceChanged(PhoneInterfaces.Lumia_Flash);
}
internal void SwitchToFlashAppContext()
{
// SwitchToFlashAppContext() should only be used with BootMgr v2
+12 -3
View File
@@ -40,7 +40,10 @@ namespace WPinternals
{
Device = new USBDevice(DevicePath);
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
private JsonElement? ExecuteJsonMethodAsJsonToken(string JsonMethod, Dictionary<string, object> Params, string ResultElement)
@@ -335,7 +338,10 @@ namespace WPinternals
Result = new byte[OutputLength];
System.Buffer.BlockCopy(Buffer, 0, Result, 0, OutputLength);
}
catch { } // Reboot command looses connection
catch (Exception ex) // Reboot command looses connection
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
return Result;
}
@@ -363,7 +369,10 @@ namespace WPinternals
pipe.Reset();
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
/// <summary>
+5 -1
View File
@@ -18,6 +18,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using System.IO;
using System.Linq;
@@ -100,7 +101,10 @@ namespace WPinternals
LogFile.Log("Programmer failed to authenticate Digital Signature", LogType.FileOnly);
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
while (!HandshakeCompleted && (HelloSendCount < 6));
+12 -3
View File
@@ -69,10 +69,16 @@ namespace WPinternals
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
return Result;
}
@@ -121,7 +127,10 @@ namespace WPinternals
Result = new byte[BufferSize];
System.Buffer.BlockCopy(Buffer, 0, Result, 0, BufferSize);
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
return Result;
}
+8 -2
View File
@@ -58,7 +58,10 @@ namespace WPinternals
{
this.USBDevice = new USBDevice(DevicePath);
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
}
@@ -146,7 +149,10 @@ namespace WPinternals
{
IsIncomplete = true;
}
catch { } // Will be rethrown as BadConnectionException
catch (Exception ex) // Will be rethrown as BadConnectionException
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
while (IsIncomplete);
+4 -1
View File
@@ -45,7 +45,10 @@ namespace WPinternals
Binary = FFUFile.GetPartition("SBL3");
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
// If not succeeded, then try to parse it as raw image
if (Binary == null)
+8 -2
View File
@@ -360,7 +360,10 @@ namespace WPinternals
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
finally
{
Phone.CloseVolume();
@@ -463,7 +466,10 @@ namespace WPinternals
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
finally
{
Phone.CloseVolume();
+12 -3
View File
@@ -194,7 +194,10 @@ namespace WPinternals
EmergencyURLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType);
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
UIContext.Post(s =>
{
@@ -256,7 +259,10 @@ namespace WPinternals
EmergencyURLs = LumiaDownloadModel.SearchEmergencyFiles(ProductType);
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
UIContext.Post(s =>
{
@@ -369,7 +375,10 @@ namespace WPinternals
{
Directory.CreateDirectory(_DownloadFolder);
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
if (!Directory.Exists(_DownloadFolder))
{
_DownloadFolder = @"C:\ProgramData\WPinternals\Repository";
@@ -256,7 +256,10 @@ namespace WPinternals
{
EvaluateViewState();
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}).Start();
}
@@ -343,7 +343,10 @@ namespace WPinternals
{
StreamLengthInSectors = (ulong)DecompressedStream.Length / 0x200;
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
TotalSizeSectors += StreamLengthInSectors;
PartitionCount++;
@@ -438,7 +441,10 @@ namespace WPinternals
{
StreamLengthInSectors = (ulong)DecompressedStream.Length / 0x200;
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
if (StreamLengthInSectors <= Partition.SizeInSectors)
{
@@ -642,7 +642,10 @@ namespace WPinternals
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
try
{
@@ -658,7 +661,10 @@ namespace WPinternals
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
List<FFUEntry> FFUs = App.Config.FFURepository.Where(e => PlatformID.StartsWith(e.PlatformID, StringComparison.OrdinalIgnoreCase) && e.Exists()).ToList();
if (FFUs.Count > 0)
@@ -688,7 +694,10 @@ namespace WPinternals
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
try
{
@@ -703,7 +712,10 @@ namespace WPinternals
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
TempEDEPath = LumiaV2UnlockBootViewModel.GetProgrammerPath(RootKeyHash, ProductType);
if (TempEDEPath != null)
@@ -753,7 +765,10 @@ namespace WPinternals
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
try
{
@@ -770,7 +785,10 @@ namespace WPinternals
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
List<FFUEntry> FFUs = App.Config.FFURepository.Where(e => App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V1.1-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)).ToList();
if (FFUs.Count > 0)
@@ -815,7 +833,10 @@ namespace WPinternals
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
try
{
@@ -832,7 +853,10 @@ namespace WPinternals
}
}
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
List<FFUEntry> FFUs = App.Config.FFURepository.Where(e => App.PatchEngine.PatchDefinitions.First(p => p.Name == "SecureBootHack-V2-EFIESP").TargetVersions.Any(v => v.Description == e.OSVersion)).ToList();
if (FFUs.Count > 0)
@@ -82,7 +82,10 @@ namespace WPinternals
Result = true;
LogFile.Log("Loader sent successfully");
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
if (Result)
{
@@ -2049,7 +2049,10 @@ namespace WPinternals
{
StreamLengthInSectors = (ulong)DecompressedStream.Length / 0x200;
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
TotalSizeSectors += StreamLengthInSectors;
PartitionCount++;
@@ -105,7 +105,10 @@ namespace WPinternals
this.Pk = Pk;
LogFile.Log("PK: " + Pk);
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
private string _ProductCode = null;
@@ -115,7 +115,10 @@ namespace WPinternals
LogWatcher.Enabled = true;
App.IsPnPEventLogMissing = false;
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
private void PnPEventWritten(Object obj, EventRecordWrittenEventArgs arg)
+16 -4
View File
@@ -101,7 +101,10 @@ namespace WPinternals
PhoneNotifier.CurrentInterface = PhoneInterfaces.Lumia_Flash;
PhoneNotifier.NotifyArrival();
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
}
@@ -472,7 +475,10 @@ namespace WPinternals
CurrentMode = PhoneInterfaces.Lumia_Flash;
PhoneNotifier.NotifyArrival();
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
if (CurrentMode == TargetMode)
@@ -556,7 +562,10 @@ namespace WPinternals
{
FlashModel.SwitchToFlashAppContext();
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
PhoneInfo Info = FlashModel.ReadPhoneInfo(ExtendedInfo: true);
@@ -641,7 +650,10 @@ namespace WPinternals
{
FlashModel.SwitchToFlashAppContext();
}
catch { }
catch (Exception ex)
{
LogFile.LogException(ex, LogType.FileOnly);
}
}
PhoneInfo Info = FlashModel.ReadPhoneInfo(ExtendedInfo: false);