Reputation: 11763
I have a question related to invoking functions in a dll file. If I understand well, in a dll file we can define a lot of different functions that may be invoked by a .exe file. For example, the functions that can be invoked from a.dll
file includes the following functions:
void fun1(int k);
int fun2(float value);
float fun3(double sig);
For a specific program, for example, a.exe
, it may only invoke fun1
function in a.dll
without using other functions. Then my question is, how can I know which functions are invoked when runing the .exe program.
Upvotes: 2
Views: 628
Reputation: 16563
You can check the symbol table of the executable for imported symbols. For windows (.exe
files) you can use the DUMPBIN
utility with /IMPORTS
as described here.
Update: As mentioned in the comments, an executable could load DLLs and access them dynamically in a way that does not create symbols at compile time. For example, by calling GetProcAddress after loading the DLL using LoadLibrary. In this case, there will not be a symbol present and DUMPBIN
will not list it, but the funciton may or may not be called.
If you know more or less how the exe works and it doesn't seem to be doing stuff dynamically (such as loading code from plugin DLLs) then it might be safe to assume no dynamic loading is occurring. Furthermore, if the exe's symbol table shows some functions from a given DLL, it's unlikely that the exe is dynamically accessing functions from that same DLL.
Also, the fact that a function appears in the symbol table does not guarantee that it will be called by the exe, but in any normal, static case it makes it quite likely.
Upvotes: 4
Reputation: 3416
You can use Dependency Walker
"Dependency Walker is a free utility that scans any 32-bit or 64-bit Windows module (exe, dll, ocx, sys, etc.) and builds a hierarchical tree diagram of all dependent modules. For each module found, it lists all the functions that are exported by that module, and which of those functions are actually being called by other modules. Another view displays the minimum set of required files, along with detailed information about each file including a full path to the file, base address, version numbers, machine type, debug information, and more."
Upvotes: 1