问题描述
我已经在我的项目中添加了延迟加载,使用
I have already added delay loading to my project, using the instructions inhttp://msdn.microsoft.com/en-us/library/151kt790.aspx
在delayhlp.cpp(一个示例执行DLL加载帮助程序) __ HrLoadAllImportsForDll
,我看到作者避免使用任何标准C库(MSVCRT)函数。我需要在我的处理函数中执行相同操作,这将由示例DLL加载帮助程序调用?
In the "delayhlp.cpp" (a sample implementation of the DLL load helper) __HrLoadAllImportsForDll
, I saw that the writer avoids using any Standard C Library (MSVCRT) functions. Do I need to do the same in my handler function, which will be called by the sample DLL load helper?
我认为作者的原因是有人可能会尝试延迟-load MSVCRT本身。我不会这样做是否安全使用MSVCRT功能?
I think the writer's reason is that someone might try to delay-load MSVCRT itself. I'm not going to do this. Will it then be safe for me to use MSVCRT functions?
背景信息延迟加载第三方DLL的原因是因为是两个版本之间的函数签名更改,我需要使用任一版本运行我的程序。然后我提供一个简单的包装函数来调整DLL的功能签名。当 GetProcAddress
失败时,此功能由延迟加载处理程序( __ pfnDliFailureHook2
)注册。
Background Info. The reason for delay-loading the 3rd party DLL is because there is a function signature change between two versions, and I need to run my program using either version. I then provide a simple wrapper function to adapt the DLL's function signature to the one needed. This function is registered by the Delay-Load Handler (__pfnDliFailureHook2
), when GetProcAddress
fails.
某些测试。我在处理函数开头添加了一个断点。我发现当断点被击中时,已经加载了 msvcrt.dll
和 msvcr90d.dll
等Studio的Modules窗格)。这是否意味着我可以安全地调用CRT函数?
Some testing. I added a breakpoint at the beginning of my handler function. I found that when the breakpoint is hit, the msvcrt.dll
and msvcr90d.dll
etc are already loaded (from Visual Studio's Modules pane). Does it mean that I can call CRT functions safely?
推荐答案
// Check to see if it is the DLL we want to load.
// Intentionally case sensitive to avoid complication of using the CRT
// for those that don't use the CRT...the user can replace this with
// a variant of a case insenstive comparison routine.
//
这是更相关的评论,对于那些不使用CRT 。您不会有问题,CRT始终由启动代码加载。
That's the more relevant comment, for those that don't use the CRT. You won't have a problem, the CRT is always loaded by the startup code.
这篇关于我可以在我的DLL延迟加载处理程序中使用MSVCRT函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!