Skip to content

Commit

Permalink
Fix window targeting crashing if BCU runs as 32bit but targeted proce…
Browse files Browse the repository at this point in the history
…ss is 64bit
  • Loading branch information
Klocman committed Mar 4, 2023
1 parent cc4b517 commit d72788b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/KlocTools/Controls/WindowTargeter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Apache License Version 2.0
*/

using System;
using System.ComponentModel;
using System.Windows.Forms;
using Klocman.Subsystems;

Expand Down Expand Up @@ -48,7 +49,15 @@ private void SearcherOnHoveredWindowChanged(object sender, WindowHoverEventArgs
{
label1.Text = windowHoverEventArgs.TargetWindow.WindowText;
label2.Text = windowHoverEventArgs.TargetWindow.WindowRect.ToString();
label3.Text = windowHoverEventArgs.TargetWindow.GetRunningProcess().MainModule?.FileName ?? "---";
try
{
label3.Text = windowHoverEventArgs.TargetWindow.GetRunningProcess().MainModule?.FileName ?? "---";
}
catch (SystemException ex)
{
// Getting MainModule on a 64 bit process throws if BCU is running as 32 bit
label3.Text = ex.Message;
}
}
}
}

0 comments on commit d72788b

Please sign in to comment.