我使用my.dll中的代码,它是odbc驱动程序: ...
__pfnDliFailureHook2 = DliErrorHook;<---exception
__pfnDliNotifyHook2 = DliErrorHook;
...
我已经在VS2010中构建了它,并且工作正常。 但是将其迁移到VS2017之后,我收到了
odbcad32.exe中0x000007FEDF4CBFB1的未处理异常: 0xC0000005:访问冲突写入位置0x000007FEDF57DAC8。 发生
我在delayimp.h中发现了一条有趣的评论:
/ Prior to Visual Studio 2015 Update 3, these hooks were non-const. They were
// made const to improve security (global, writable function pointers are bad).
// If for backwards compatibility you require the hooks to be writable, define
// the macro DELAYIMP_INSECURE_WRITABLE_HOOKS prior to including this header and
// provide your own non-const definition of the hooks.
ExternC
#ifndef DELAYIMP_INSECURE_WRITABLE_HOOKS
const
#endif
PfnDliHook __pfnDliNotifyHook2;
但是我看不到要更改代码才能做什么? 宏始终定义为书面形式,还有什么?
我在代码中声明
PfnDliHook __pfnDliNotifyHook22;
PfnDliHook __pfnDliFailureHook22
并分配了功能指针-可以正常工作。 但是当我尝试将函数指针分配给
时extern PfnDliHook __pfnDliNotifyHook2;
extern PfnDliHook __pfnDliFailureHook2;
,实际上是在delayimp.h中声明的 我收到0xC0000005:访问冲突写入位置