Find better version of `dbghelp.dll` automagically.
This tool has a powerful features, but the user could not see them, because they depend on better version of dbghelp.dll than the default one. Automagically find better version of dbghelp.dll. It is usually located at c:\Program Files (x86)\Windows Kits\10\Debuggers\x64\dbghelp.dll for x64 version of the app on x64 version of the Windows. Or at C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\dbghelp.dll for x86 version of the app on x64 version of the Windows. Or at C:\Program Files\Windows Kits\10\Debuggers\x86\dbghelp.dll for x86 version of the app on x86 version of the Windows. Of course, the path to Program Files directory might be different on each computer, better use SHGetKnownFolderPath or something similar to get it. Of course, the path to Windows Kits directory might be different on each computer, better use SOFTWARE\Microsoft\Windows Kits\Installed Roots under HKLM or something similar to get it.
That's good suggestion, I'm considering to implement it, thanks.
In the latest and greatest version of WinDepends, currently 2510-beta, it is already fixed.
@hfiref0x
I recently noticed several issues related to dbghelp.dll on Windows 7.
Currently, WinDbg throws the following error on startup if a Windows 7 system has a relatively newer Windows SDK installed.
This happens because dbghelp.dll depends on the following apiset DLLs:
api-ms-win-core-com-l1-1-0.dll
api-ms-win-core-sysinfo-l1-2-0.dll
api-ms-win-downlevel-kernel32-l2-1-0.dll
The C:\Program Files (x86)\Windows Kits\10\Debuggers\x64 directory already contains these DLLs. For example, Windows SDK 10.0.26100.7175 ships with them, and its dbghelp.dll works correctly on Windows 7.
However, WinDepends only searches for these dependencies in WinDepends.exe’s own directory and the %PATH% environment variable. Because of this, the error above occurs. Manually selecting dbghelp.dll from another directory (such as C:\newdbghelp\ or the one in ``Debuggers\x64) via Configuration > Symbols` does not help.
As a workaround, we can either copy these DLLs into the WinDepends directory or modify %PATH% to include their location. Adding them to %PATH% is not ideal, since WinDepends also uses %PATH% during analysis.
Instead, copying the files into the WinDepends directory works. After doing this, WinDepends starts without errors and can download and display symbols correctly.
api-ms-win-core-com-l1-1-0.dll
api-ms-win-core-file-l2-1-1.dll
api-ms-win-core-sysinfo-l1-2-0.dll
api-ms-win-downlevel-kernel32-l2-1-0.dll
dbghelp.dll
symsrv.dll
However, this approach introduces another problem.
When scanning binaries that actually import these DLLs, WinDepends may use the copies located in its own directory during analysis, which can be confusing.
I recently discovered this by scanning some files in WinDbg directory, I noticed one export error highlighted in red on dbghelp.dll. This was confusing because the dbghelp.dll build number matched the windbg.exe in the same directory. I manually verified the import using CFF Explorer and confirmed that it was present. At first, I thought I had found a rare import-handling bug in WinDepends and was kinda excited, lol.
Then i clicked “View Full Path,” and the cause became clear.
For now, I worked around this by removing these DLLs from WinDepends directory and patching the dbghelp.dll located in the SDK Debuggers directory.
That said, this is only a local workaround and doesn’t address the underlying behavior in WinDepends, which can lead to confusing or misleading analysis results in similar scenarios.
Any of the following solutions would be helpful. Implementing all of them eventually might be ideal, as they each seem like improvements.
- Exclude WinDepends’s own directory from analysis so DLLs located there are not used for analysis.
- Allow
dbghelp.dllto load its dependencies relative to its own location. - Add an exclude option to “Module Search Order.” I have multiple tools in my
%PATH%, and some include many DLLs that can interfere with or confuse analysis. While writing this, I noticed a greyed-out “Delete” button—once this is implemented or enabled, it may already address most of these issues.
I think there are some real bugs related to Module Search Order. I’m posting this here since it’s related to the report above.
When WinDepends is launched and no file has been scanned yet, “The Application Directory” points to the WinDepends installation directory.
After scanning a file, this changes to the actual application directory, which I assume is intentional.
However, as shown in the screenshots above, The Application Directory is listed above the System Path section.
Despite this ordering, %PATH% is still prioritized over the application directory during analysis.
For example, Kdiff3/bin is present in the system path:
@i486 That is because currently it prioritizes what is found by WinSXS (activation context) lookup. This is exactly why you see KDIFF3\BIN folder here it comes from SearchPathW with activated activation context not from %PATH%. This maybe changed next. Reference this as a new issue please.
Add an exclude option to “Module Search Order.” I have multiple tools in my %PATH%, and some include many DLLs that can interfere with or confuse analysis. While writing this, I noticed a greyed-out “Delete” button—once this is implemented or enabled, it may already address most of these issues.
The Delete button is enabled only for user defined directories. E.g.
Other values considered as system and cannot be deleted.
However, WinDepends only searches for these dependencies in WinDepends.exe’s own directory and the %PATH% environment variable. Because of this, the error above occurs. Manually selecting dbghelp.dll from another directory (such as C:\newdbghelp\ or the one in ``Debuggers\x64) via Configuration > Symbols` does not help.
That need investigation but currently I don't have win7 VM for that, thats too old it is a miracle that WinDepends is still work on it. As a workaround you can use SDK/WinDbg that was specifically created for Windows 7 use.