I use the code in my.dll, it is odbc driver: ...
__pfnDliFailureHook2 = DliErrorHook;<---exception
__pfnDliNotifyHook2 = DliErrorHook;
...
I have built it in VS2010 and it worked ok. But after I migrated it to VS2017 I receive the
Unhandled exception at 0x000007FEDF4CBFB1 in odbcad32.exe: 0xC0000005: Access violation writing location 0x000007FEDF57DAC8. occurred
I have found this interesting comment in 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;
But I do not see what can I change to make code working? The macro always defined as written, what else?
I declared in my code
PfnDliHook __pfnDliNotifyHook22;
PfnDliHook __pfnDliFailureHook22
and assigned the function pointer - it works ok. But when I try to assign the function pointer to
extern PfnDliHook __pfnDliNotifyHook2;
extern PfnDliHook __pfnDliFailureHook2;
and by fact declared in the delayimp.h I receive the 0xC0000005: Access violation writing location
User contributions licensed under CC BY-SA 3.0