LoadLibrary 失败 0x000001e7 Attempt to access invalid address

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

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

/FIXED   Property PagesLinkerAdvanced | Fixed Base Address : Image must be loaded at a fixed address (/FIXED)。

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


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

原文地址:https://www.cnblogs.com/happylong/p/4501489.html