我一直在研究_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 使用_vsnprintf
的是 ntdll.dll 还是 msvcrt.dll?