WinDepends
WinDepends copied to clipboard
Does not handle forwarders.
Describe the bug
- When a module depends on another module (such as an
*.exedepends on a*.dll, or a*.dlldepends on a*.dll) it can depend on a name or on an ordinal. But it is possible that this name or ordinal is not actually inside the target*.dll, it is not exported as an address. The target*.dllcould forward its own export to yet another*.dll. - Example:
program.exedepends onliba.dll, because it wants to usefunca. - But
liba.dllexportsfuncanot as an address, but as a forwarder. It forwards it tolibb.funcb. - Thus,
program.exedepends onfuncbfromlibb.dllstatically at start-up time. - Your program does not take this into account.
To Reproduce Steps to reproduce the behavior:
- compile
program.exe,liba.dllandlibb.dll - open
program.exein your tool
Expected behavior
program.exedepends onliba.dllwhich itself depends onlibb.dll
Actual behavior
program.exedepends onliba.dllonly
Screenshots
- none
Desktop (please complete the following information):
- Windows Server 2022 x64, all updates
- Microsoft Windows [Version 10.0.20348.3932]
Additional context
- the https://github.com/lucasg/Dependencies program does not show this correctly
- the https://github.com/MarekKnapek/DependencyViewer program does not show this correctly
- the https://www.dependencywalker.com program is stuck consuming 100% of single CPU
Files
program.cpp
#include <iostream>
extern "C" [[nodiscard]] __declspec(dllimport) int __stdcall funca(int a, int b) noexcept;
int main()
{
int sum = funca(2, 3);
std::cout << "The result is " << sum << ".\n";
}
liba.asm
.386
.model flat, stdcall
option prologue:none
option epilogue:none
.code
entry proc instance:dword, reason:dword, reserved:dword
mov eax, 1
ret
entry endp
end
liba.def
LIBRARY liba
EXPORTS
funca=libb.funcb
libb.asm
.386
.model flat, stdcall
option prologue:none
option epilogue:none
.code
entry proc instance:dword, reason:dword, reserved:dword
mov eax, 1
ret
entry endp
funcb proc a:dword, b:dword
mov eax, [esp + 4]
mov ecx, [esp + 8]
add eax, ecx
retn 8
funcb endp
end
libb.def
LIBRARY libb
EXPORTS
funcb
build.bat
rem Use the x86 (32-bit) vcvarsall environment.
ml /c /coff libb.asm
link /SUBSYSTEM:CONSOLE /DLL /ENTRY:entry /DEF:libb.def libb.obj
ml /c /coff liba.asm
link /SUBSYSTEM:CONSOLE /DLL /ENTRY:entry /DEF:liba.def liba.obj libb.lib
cl /c /EHsc program.cpp
link /SUBSYSTEM:CONSOLE program.obj liba.lib
Update: After quite long time (more than 30min) the original Dependency Walker is un-stuck and it correctly shows the dependency.
Closed, discussion continues in #39