[英]Cannot execute my DLL when copied to Program Files (x86)
I have a funny problem: 我有一个有趣的问题:
A program I've written uses a DLL. 我编写的程序使用DLL。 When installed, both the program exe and the DLL are under c:\\Program Files (x86)\\MyProduct
安装后,程序exe和DLL都位于c:\\ Program Files(x86)\\ MyProduct下
Normally the loaded DLL is a 3rd party driver . 通常,加载的DLL是第三方驱动程序 。 For testing purposes I replaced it with my own implementation.
出于测试目的,我将其替换为自己的实现。 When I overwrite the 3rd party DLL with my own in the program files folder my program EXE cannot start the DLL, LoadLibraray returns 0 and GetLastError returns -529697949.
当我在程序文件文件夹中用自己的第三者DLL覆盖我的程序EXE无法启动DLL时,LoadLibraray返回0,GetLastError返回-529697949。 Now when I copy the whole MyProduct folder to, let's say c:\\temp and start the program EXE the DLL can be loaded.
现在,当我将整个MyProduct文件夹复制到时,假设c:\\ temp并启动程序EXE,则可以加载DLL。
So I guess my problem is related to Windows security. 所以我想我的问题与Windows安全性有关。 Both the programm and my version of the DLL are written in C++.
我的DLL程序和我的版本都是用C ++编写的。 My user accoount has Administrator access and it does not seem to matter if I execute the program as Administrator or not.
我的用户权限具有管理员访问权限,我是否以管理员身份执行程序似乎并不重要。 Does anybody know if there is a windows protection mechanism that might prevent that the DLL is loaded?
有人知道是否有Windows保护机制可能阻止DLL加载吗?
Thank you 谢谢
Update 更新资料
I think the problem is related to the fact that my DLL tries to write to the execution directory in the DLL init function. 我认为问题与我的DLL试图写入DLL初始化函数中的执行目录有关。 When executing in Program Files directory windows does not allow this.
在“程序文件”目录中执行时,Windows不允许这样做。
Yes, I finally got it running. 是的,我终于开始运行了。 The problem is that my DLL tried to write to the exe folder during DLL initialization.
问题是我的DLL试图在DLL初始化期间写入exe文件夹。 Windows seems to detect this and the LoadLibrary call fails.
Windows似乎检测到此问题,并且LoadLibrary调用失败。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.