Skip to content

Commit 59ba14d

Browse files
committed
Attempt to catch IE process corrupted errors
1 parent 5f90c9e commit 59ba14d

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

BHOUserScript/Program.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System.Runtime.InteropServices.Expando;
1515
using System.Collections.Generic;
1616
using System.Linq;
17+
using System.Runtime.ExceptionServices;
1718
using System.Threading;
1819
using BHOUserScript.Properties;
1920

@@ -424,6 +425,7 @@ private void TryInjectCss(int i, IHTMLWindow2 window)
424425
/// Exposes the IExtension interface to the browser window.
425426
/// </summary>
426427
/// <param name="window"></param>
428+
[HandleProcessCorruptedStateExceptions]
427429
private void SetupWindow(IHTMLWindow2 window)
428430
{
429431
// Prevent multiple injections of API
@@ -447,6 +449,10 @@ private void SetupWindow(IHTMLWindow2 window)
447449
}
448450
catch (Exception ex)
449451
{
452+
if (ex is AccessViolationException) // Exception: "Attempted to read or write protected memory. _
453+
return; // This is often an indication that other memory is corrupt." _
454+
// This is thrown when the memory of the IE process is corrupted, _
455+
// and thus write protected.
450456
if (LogAndCheckDebugger(ex, "SetupWindow"))
451457
throw;
452458
}

0 commit comments

Comments
 (0)