Skip to content

Commit

Permalink
Don't load dbgeng.dll explicitly on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
k15tfu committed May 26, 2021
1 parent e9c1faa commit d1f7759
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
Expand All @@ -18,10 +17,6 @@ internal static class Program
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool IsWow64Process(IntPtr hProcess, out bool isWow64Process);

[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, int dwFlags);
private const int LoadLibrarySearchDllLoadDir = 0x00000100;

private static int RerunMainAs32BitProcess(string[] args)
{
var platformSpecificExecutable = "ClrStack32.exe";
Expand Down Expand Up @@ -50,14 +45,6 @@ private static int RerunMainAs32BitProcess(string[] args)
return process.ExitCode;
}

private static void EnsureDbgEngineIsLoaded()
{
var systemFolder = Environment.GetFolderPath(Environment.SpecialFolder.System);
var res = LoadLibraryEx(Path.Combine(systemFolder, "dbgeng.dll"), IntPtr.Zero, LoadLibrarySearchDllLoadDir);
if (res == IntPtr.Zero)
throw new Win32Exception(Marshal.GetLastWin32Error());
}

public static void Main(string[] args)
{
if (args.Length != 1 ||
Expand Down Expand Up @@ -87,8 +74,6 @@ public static void Main(string[] args)
var output = new StringBuilder();
try
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
EnsureDbgEngineIsLoaded();
using (var target = DataTarget.AttachToProcess(pid, true))
{
var clrVersion = target.ClrVersions.FirstOrDefault();
Expand Down

0 comments on commit d1f7759

Please sign in to comment.