简体   繁体   English

复制到程序文件(x86)时无法执行我的DLL

[英]Cannot execute my DLL when copied to Program Files (x86)

I have a funny problem: 我有一个有趣的问题:

A program I've written uses a DLL. 我编写的程序使用DL​​L。 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.

相关问题 我在笔记本电脑上找不到文件夹C:\\ Program Files(x86)\\ Microsoft Visual Studio 14.0 \\ VC \\ include \\ gl。 如何添加? - I cannot find the folder C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\gl on my laptop. How do I add it? LNK1104: 无法打开文件 'C:\\Program Files (x86)\\Windows Kits\\10\\\\lib.obj' - LNK1104: cannot open file 'C:\Program Files (x86)\Windows Kits\10\\lib.obj' 在Windows中是否有一个简单的C ++程序文件/程序文件(x86)指令? - Is there a simple Program Files/Program Files (x86) directive for C++ in windows? (__ printf __)在DLL(programfiles(x86)\\ codeblocks \\ mingw \\ bin \\ as.exe)中找不到 - ( __ printf __ ) cannot be found in DLL (programfiles(x86)\codeblocks\mingw\bin\as.exe) C++ | 如何删除位于 (C:\Program Files (x86)) 的文件夹中的文件 - C++ | How can i delete files in a folder located in (C:\Program Files (x86)) 从x64注入器注入x86 dll的x86目标 - Injecting a x86 target with a x86 dll from a x64 injector 在x86中引用C ++ / CLI DLL的C#项目进行编译时,MSBuild无法生成 - MSBuild fails to build when compiling C# project referencing C++/CLI DLL in x86 在x86应用程序中使用x64 dll - Using x64 dll in x86 application Visual Studio致命错误C1084:无法读取包含文件:'c:\\ program files(x86)\\ microsoft visual studio 10.0 \\ vc \\ include \\ map':权限被拒绝 - Visual Studio fatal error C1084: Cannot read include file: 'c:\program files (x86)\microsoft visual studio 10.0\vc\include\map': Permission denied Qt可执行文件在发行文件夹中运行-程序文件(x86)中的运行时错误 - Qt executable running in release folder - Runtime error in Program Files (x86)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM