From 2390be427866c44c24ac5e266e979c07a981447a Mon Sep 17 00:00:00 2001 From: Vincent Bousquet Date: Tue, 23 Feb 2021 23:28:02 +0100 Subject: [PATCH] Ignore all DLL unblock failure to avoid crashes --- FlexDMDUI/MainWindow.xaml.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/FlexDMDUI/MainWindow.xaml.cs b/FlexDMDUI/MainWindow.xaml.cs index e741c18..649a2cf 100644 --- a/FlexDMDUI/MainWindow.xaml.cs +++ b/FlexDMDUI/MainWindow.xaml.cs @@ -317,15 +317,21 @@ private bool CheckRegisteredVersion(string clsid, string version) private bool IsDLLBlocked(string path) { - FileInfo file = new FileInfo(path); - if (file.AlternateDataStreamExists("Zone.Identifier")) + try { - AlternateDataStreamInfo s = file.GetAlternateDataStream("Zone.Identifier", FileMode.Open); - using (TextReader reader = s.OpenText()) + FileInfo file = new FileInfo(path); + if (file.AlternateDataStreamExists("Zone.Identifier")) { - var zoneId = reader.ReadToEnd().ToUpperInvariant(); - return zoneId.Contains("ZONEID=3") || zoneId.Contains("ZONEID=4"); + AlternateDataStreamInfo s = file.GetAlternateDataStream("Zone.Identifier", FileMode.Open); + using (TextReader reader = s.OpenText()) + { + var zoneId = reader.ReadToEnd().ToUpperInvariant(); + return zoneId.Contains("ZONEID=3") || zoneId.Contains("ZONEID=4"); + } } + } catch (Exception) + { + // FIXME this is an horrible exception swallowing when DLL blocking check fails. This should be properly reported (at leats in a log file) } return false; }