microsoft / DbgShell

A PowerShell front-end for the Windows debugger engine.
MIT License
674 stars 89 forks source link

Unhandled Exception: System.Exception: Could not load dbgeng.dll on Win7. #38

Open ebtaleb opened 6 years ago

ebtaleb commented 6 years ago

When running the latest binary release, on Windows 7 Pro SP1, both x86 and x64 version, I get the following error:

$ ./DbgShell.exe

Unhandled Exception: System.Exception: Could not load dbgeng.dll. at MS.DbgShell.MainClass._NormalModeMainWrapper(String[] args) in C:\src\DbgShell\DbgShell\MainClass.cs:line 467 at MS.DbgShell.MainClass.Main(String[] args) in C:\src\DbgShell\DbgShell\MainClass.cs:line 130

So I look at the incriminating code:

              string pathToDbgEng = Path.Combine( rootDir, "Debugger", "dbgeng.dll" );

            IntPtr hDbgEng = NativeMethods.LoadLibraryEx( pathToDbgEng,
                                                          IntPtr.Zero,
                                                          LoadLibraryExFlags.LOAD_WITH_ALTERED_SEARCH_PATH );
            if( IntPtr.Zero == hDbgEng )
                throw new Exception( "Could not load dbgeng.dll." );

The file is indeed in the Debugger folder, yet the error persists. I have tried to replace the file with the one from my WinDbg installation, but to no avail.

Is there something that I could have missed? Thanks.

jazzdelightsme commented 6 years ago

No, I don't think it is something you missed; sounds like a legit bug. I have not tested on Win7 in... a long time. I bet it is some missing dependency. I'll have to spin up a Win7 VM to figure out what it is.

In the meantime, something you can try is to load DbgShell from windbg. I.e. if you are looking at a dump file, for example, load it up in windbg (C:\Debuggers\windbg.exe -z C:\path\to\dump.dmp), then load the DbgShell extension (.load C:\Tools\DbgShell\x64\dbgshellext.dll), then you should be able to run !dbgshell and hopefully a DbgShell window pops up (which is using the already-loaded dbgeng.dll in the windbg process).

Then again, I have not tested on Win7... so maybe there will be other problems.

Just curious, what version of PowerShell do you have?

ebtaleb commented 6 years ago

Ok, I tried to load DbgShell from WinDbg by opening an executable. I get the following errors, depending on the version of WinDbg and DbgShellExt:

0:000> .load C:\Users\mu\Desktop\FLEGGO\dbs\dbg\DbgShell\DbgShell\x86\dbgshellext.dll The call to LoadLibrary(C:\Users\mu\Desktop\FLEGGO\dbs\dbg\DbgShell\DbgShell\x86\dbgshellext.dll) failed, Win32 error 0n193 "%1 is not a valid Win32 application." Please check your debugger configuration and/or network access.

0:000> .load C:\Users\mu\Desktop\FLEGGO\dbs\dbg\DbgShell\DbgShell\x64\DbgShellExt.dll The call to LoadLibrary(C:\Users\mu\Desktop\FLEGGO\dbs\dbg\DbgShell\DbgShell\x64\DbgShellExt.dll) failed, Win32 error 0n126 "The specified module could not be found." Please check your debugger configuration and/or network access.

As for the PowerShell version:

PS C:\Users\mu> $PSVersionTable.PSVersion

Major Minor Build Revision


5 1 14409 1005