I'm looking for a way (in C++/Windows) to list the exported functions of a DLL (and maybe even methods which are not exported) using dbgHelp.
Does anybody know which method can do it?
Asked
Active
Viewed 1.8k times
7

Micha Wiedenmann
- 19,979
- 21
- 92
- 137

Idov
- 5,006
- 17
- 69
- 106
-
1possible duplicate of [Win32 API to enumerate dll export functions?](http://stackoverflow.com/questions/1128150/win32-api-to-enumerate-dll-export-functions) – icecrime Dec 04 '10 at 10:50
-
1A debugger doesn't care whether a function is exported or not. Code sample is here: http://msdn.microsoft.com/en-us/library/ms679318%28VS.85%29.aspx – Hans Passant Dec 04 '10 at 14:36
-
but I'm looking at a case in which I don't have the PDBs. Will SymLoadModuleEx help me here? – Idov Dec 04 '10 at 15:44
-
hmm... "SymEnumSymbols", not SymLoadModuleEx, I don't know why I wrote it... – Idov Dec 04 '10 at 16:51
2 Answers
11
If you're content with other tools then there are a number that do list exported functions. One is Microsoft's dumpbin
, use the /exports
option.

Micha Wiedenmann
- 19,979
- 21
- 92
- 137

Cheers and hth. - Alf
- 142,714
- 15
- 209
- 331
10
There is code here to do this. I have cleaned it up a bit and it worked in the scenario shown below, retrieving function names from Kernel32.Dll
.
#include "imagehlp.h"
void ListDLLFunctions(string sADllName, vector<string>& slListOfDllFunctions)
{
DWORD *dNameRVAs(0);
_IMAGE_EXPORT_DIRECTORY *ImageExportDirectory;
unsigned long cDirSize;
_LOADED_IMAGE LoadedImage;
string sName;
slListOfDllFunctions.clear();
if (MapAndLoad(sADllName.c_str(), NULL, &LoadedImage, TRUE, TRUE))
{
ImageExportDirectory = (_IMAGE_EXPORT_DIRECTORY*)
ImageDirectoryEntryToData(LoadedImage.MappedAddress,
false, IMAGE_DIRECTORY_ENTRY_EXPORT, &cDirSize);
if (ImageExportDirectory != NULL)
{
dNameRVAs = (DWORD *)ImageRvaToVa(LoadedImage.FileHeader,
LoadedImage.MappedAddress,
ImageExportDirectory->AddressOfNames, NULL);
for(size_t i = 0; i < ImageExportDirectory->NumberOfNames; i++)
{
sName = (char *)ImageRvaToVa(LoadedImage.FileHeader,
LoadedImage.MappedAddress,
dNameRVAs[i], NULL);
slListOfDllFunctions.push_back(sName);
}
}
UnMapAndLoad(&LoadedImage);
}
}
int main(int argc, char* argv[])
{
vector<string> names;
ListDLLFunctions("KERNEL32.DLL", names);
return 0;
}

Steve Townsend
- 53,498
- 9
- 91
- 140
-
The OP is asking for a dbghelp-based solution, which would include non-exported symbols... – wj32 Dec 05 '10 at 02:59