LoadLibrary 失败 0x000001e7 Attempt to access invalid address

现象:LoadLibrary 偶尔会失败,返回值   NULL, @err,hr     0x000001e7 Attempt to access invalid address. 

 

原因在于DLL,当DLL link 的时候指定了:

/FIXED   Property Pages\Linker\Advanced | Fixed Base Address : Image must be loaded at a fixed address (/FIXED)。

说明该 DLL 被加载到固定地址。而默认的编译选项是允许 DLL 被加载到任意位置的 /FIXED:NO。


当 DLL 被强制要求加载到固定地址时,该 DLL 不会有重定位表, 用 dumpbin 打开发现果然没有.reloc 段。

posted @ 2015-05-13 19:47  嗨皮龙  阅读(277)  评论(0编辑  收藏  举报