COM CoCreateInstanceEx 如何尝试加载类型(对于非管理员 win 用户)?
我有一个非常复杂的问题,仅发生在非管理员 Windows 用户身上。
我运行驻留在桌面上的脚本 S 并调用 C++ dll 中的函数。然后流程如下:
- 我的C++ dll创建一个Delphi进程,向它发送一个GUID作为参数。
- 初始化时,我的 Delphi 进程使用 COM 对象工厂注册具有给定 GUID 的类 C。
- 我的 C++ dll 尝试使用相同的 GUID 调用 CoCreateInstanceEx。 ==>操作失败,HResult 0x80029c4a 加载类型库/DLL 时出错。
Delphi 方面没有抛出任何异常 - 注册似乎工作顺利。
我使用进程监视器并惊讶地发现,当调用 CoCreateInstanceEx 时,有人尝试从错误的位置读取我的 Delphi exe 文件。不是尝试访问exe注册的位置,而是尝试从脚本S所在的桌面访问exe,当然exe不在那里。
这种情况仅发生在非管理员用户身上。另外,如果管理员用户以前运行过此脚本,那么对于非管理员来说它运行得很好。
我现在试图找出为什么会发生这种情况。这就是为什么我尝试了解 CoCreateInstanceEx 的流程。我在网上没有找到任何有用的信息。那么 CoCreateInstanceEx 如何尝试加载类型呢?它试图在哪里寻找?您知道所描述的情况是如何发生的吗?
任何信息或想法将不胜感激!
I have a very complicated problem that occurs only for non-admin windows user.
I run a script S that resides on the desktop and calls a function in a C++ dll. Then the flow is as follows:
- My C++ dll creates a Delphi process, sending it a GUID as a parameter.
- On initialization, my Delphi process registers a class C with the given GUID using a COM object factory.
- My C++ dll tries to call CoCreateInstanceEx with the same GUID.
==> The operation fails with HResult 0x80029c4a Error loading type library/DLL.
No exception is thrown from the Delphi side - registration seems to work smoothly.
I used process monitor and saw to my surprise that when CoCreateInstanceEx is called, there is an attempt to read my Delphi exe file from a wrong location. Instead of trying to access where the exe is registered, there is an attempt to access the exe from the desktop, where script S resides, and of course the exe is not there.
This happens only to non-admin user. Also, if an admin user ever run this script before, it runs perfectly fine for the non-admin.
I now try to figure out why this is happening. This is why I try to understand the flow of CoCreateInstanceEx. I didn't find any useful information on the web. So how does CoCreateInstanceEx try to load types? Where does it try to look? Do you have any idea how the described situation can happen?
Any information or idea will be very appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原来Delphi进程的exe是用相对路径而不是完整路径注册的。
我仍然不确定为什么对于管理员用户来说它可以正常工作......所以如果有人有一个想法我会有兴趣听到。
Turns out that the exe of the Delphi process was registered with relative path instead of full path.
I'm still not sure why for admin user it worked correctly... So if anyone has an idea I'll be interested to hear.