Skip to content

Commit

Permalink
Call SymSetParentWindow to ensure modal UI (#131)
Browse files Browse the repository at this point in the history
In some cases, dbghelp / symsrv may pop up UI dialogs, such as to
authenticate to a symbol server. We want those dialogs to be modal so
that they are clearly visible to the user. Calling SymSetParentWindow
ensures the modal nature of such possible UI elements.
  • Loading branch information
arvindshmicrosoft authored Jun 22, 2024
1 parent a6186d8 commit 8559ad2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Engine/SafeNativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,7 @@ internal static bool EstablishActivationContext() {
[DllImport("dbghelp.dll")] public static extern bool SymCleanup(IntPtr hProcess);

[DllImport("dbghelp.dll", CharSet = CharSet.Unicode)] public static extern bool SymInitialize(IntPtr hProcess, [MarshalAs(UnmanagedType.LPWStr)] string UserSearchPath, bool fInvadeProcess);

[DllImport("dbghelp.dll")] public static extern bool SymSetParentWindow(IntPtr hWnd);
}
}
3 changes: 3 additions & 0 deletions Engine/SymSrvHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public static List<string> GetFolderPathsForPDBs(StackResolver parent, string sy
var retval = new List<string>();
Contract.Requires(null != syms);
Contract.Requires(null != parent);

if (!SafeNativeMethods.SymSetParentWindow(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle)) return retval;

if (!SafeNativeMethods.SymInitialize((IntPtr)(-1), symPath, false)) return retval;
int progress = 0;
foreach (var sym in syms) {
Expand Down

0 comments on commit 8559ad2

Please sign in to comment.