列出DLL的导出函数 [英] Listing the exported functions of a DLL
本文介绍了列出DLL的导出函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一种方式(在C ++ / Windows中),使用dbgHelp列出DLL中的导出函数(甚至可能是未导出的方法)。
有没有人知道哪种方法可以做到?
谢谢:)
I'm looking for a way (in C++/Windows) to list the exported functions in a DLL (and maybe even methods which are not exported) using dbgHelp.
Does anybody know which method can do it?
thanks :)
推荐答案
有代码 here 这样做。我已经清理了一下,它在下面所示的情况下工作,从 Kernel32.Dll
中检索功能名称。
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;
}
这篇关于列出DLL的导出函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文