如何确定哪个 Windows DLL 用于函数调用
How can I determine which Windows DLL is being used for a function call?
我一直在研究_vsnprintf
,并了解到它在ntdll.dll和msvcrt.dll中可用。
我可以使用GetModuleHandle
和GetProcAddress
来访问_vsnprintf
,例如:
static int(__cdecl *p__vsnprintf)(char *str, size_t count, const char *format, va_list valist);
static void init(const char *dll)
{
HMODULE hmod = GetModuleHandleA(dll);
if (hmod)
{
printf("*** Testing %s ***n", dll);
p__vsnprintf = (void *)GetProcAddress(hmod, "_vsnprintf");
if (p__vsnprintf) test__vsnprintf();
else printf("_vsnprintf not found in %s.n", dll);
}
else printf("*** Unable to load %s ***n", dll);
printf("n");
}
int main(void)
{
init("ntdll.dll"); /* ntdll _vsnprintf */
init("msvcrt.dll"); /* msvcrt _vsnprintf */
printf("*** Testing normal function call ***n");
test_vsnprintf(); /* _vsnprintf in ??? */
return 0;
}
对于通用调用,如何判断 Windows 使用的是来自 ntdll.dll 还是 msvcrt.dll 的_vsnprintf
?
dumpbin /imports
会告诉你。 此外,方便的depends
实用程序。
要务实地做到这一点,您有两个主要选项:
- 如果是静态导入,则可以对 IAT 进行探测并检查其导入的模块。
- 如果你是动态的(即:使用
GetProcAddress
),你可以使用VirtualQuery
和GetModuleFileName
来找出它的模块。还有用于查找模块名称GetModuleBaseName
。 - 只需跟踪在上面的示例中成功
GetProcAddress
时使用的HMODULE
即可。
相关文章:
- 将 C# DLL 导入 C++ 以用于 JNI
- 用于LabView中使用的本机c++的c++/cli dll包装器
- 如何使函数返回数组?用于制作在VB.NET中使用的DLL
- c++\CLI dll包装器,用于调用c++类中的虚拟成员
- 为什么 C# 封送字符串不适用于C++ DLL
- Unity3D 导入 C++ DLL 用于按引用方法传递
- 可以将Delphi dll用于C#
- C DLL通过C#UWP应用程序中的Win运行时组件适用于ARM,但对于X86/X64不适用于
- P/调用C++用于填充托管缓冲区的 DLL
- 创建用于 C# 程序的 CPP DLL
- 查找适用于"The specified module could not be found"的 DLL
- 关于为什么Windows的.dll不适用于Linux的细节
- openCV_FFMPEG **.opencv 2.4.11中的dll错误,用于IP摄像机访问
- 一个用于操作字符串以在vba中使用的c++dll
- Cython:在DLL中注册用于回调的Python函数
- C# 调试 C++ dll 适用于 VS2013,但不适用于 VS2010
- 如何确定哪个 Windows DLL 用于函数调用
- 用于生成 dll 的发布文件夹的目录
- Dll 注入器不适用于 x64 进程
- 调用64位Excel中的C DLL用于VBA