使用相同的导出功能的2个或更多dll. [英] 2 or more dlls using the same exported function.

查看:126
本文介绍了使用相同的导出功能的2个或更多dll.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于音频工作站的控制界面插件dll.
该工作站只允许将一个插件连接到一个Midi端口以进行输入和输出.
因此,为了支持多个控制界面,我制作了一个非常简单的主dll插件版本,该插件将Midi消息从其(第二个)端口转发到dll中的主插件进行处理.因此,我为第一个单元加载主dll,然后为第二个单元加载较小的I/O重定向器插件.一切都很好.这两个dll通过导出的函数进行通信以进行消息交换.

我希望能够为其他端口上的第三个甚至第四个单元加载另一个I/O重定向器dll,但希望DLL是通用的而不是特定于端口的.

我的问题是:当在相同的进程空间中加载相同的COM DLL并为传入数据导出相同的函数时会发生什么?

当我在DAW app exe文件中加载文件时检查dll的导出功能时,仅看到有关导出功能的一个实例"的导出.

我能否同时在两个DLL上魔术调用相同的函数?
可能不是.我想做类似的事情.

解决方案

一个写得很好的COM对象*对于每个实例都是离散的,因此您可以让一个COM dll服务器公开任何实例.相同对象类型的数量,并且应该没有碰撞

但是,从多个位置使用单个com对象实例将不是实例安全的,并且您确实可能会遇到一些线程同步问题

同样,带有导出函数的原始DLL不能假定为实例安全",除非它具有某种形式的句柄,需要区分实例,或者没有函数交互


*假设类不是单例的


我不特别了解COM(因为我使用的不多),但是常规的DLL将支持此功能,当然,鉴于您编写同时"性质的代码,因为这不是默认行为(您可能需要DLL管理器类,该类可加载所有可用的DLL并管理往返的调用,以支持前往多个地方的一个函数调用).


我认为我可能对自己的问题有解决方案,但还不太清楚如何解决.我没有DDLMain,因为这是COM接口?插入DAW软件.如果我可以通过较小的I/O重定向器插件的HInstance导出冲突的输出,那么我可以向Master插件发送要调用的特定实例函数的地址.

但是如果没有DLLMain,大多数goolge搜索都将毫无结果.

预先感谢您的帮助,



*********附录*********

theApp.m_hInstance是我对该实例的句柄.

但奇怪的是,我加载了DLL的2个副本,并将App.m_hInstance从这两个DLL传递到主DLL,以供参考,这让我很恼火,两个DLL都在为App.m_hInstance发送相同的确切值. br/>

I have a control surface plugin dll for an audio workstation.
The workstation only allows a plugin to be connected to one midi port for in and out.
So to support more than one of these control surfaces I made a very simple version of the primary dll plugin that forwards midi messages from it''s (second) port to the primary plug in dll for processing. So I load the primary dll for the 1st unit then the smaller I/O re-director plug in for the second unit. It all works great. The two dlls communicate via exported functions for message exchange.

I want to be able to load yet another I/O redirector dll for yet a third or even a forth unit on other ports but would like the DLLs to be generic and not specific to the ports.

My question is: What happens when you load the same COM DLL in the same process space and the same function exports for incoming data?

When I examine the exported functions of my dlls when loaded in the DAW app exe file I only see the exports for one "instance" of the exported function in question.

Will I be able to magicly call the same function on both DLLs simultaneously?
Probably not. I''d like to do something like that.

解决方案

a well written COM object* is discrete for each instance, so you can have one COM dll server exposing any number of the same object types, and you should have no collisions

However, using a single com object instance from multiple places will not be instance safe, and you may indeed get some thread synch issues

Similarly, a vanilla DLL with an exported function cannot assumed to be ''instance-safe'' unless it has some form of handle it needs to distinguish between instances, or none of its functions interact


*assuming class is not singleton


I don''t know about COM specifically (since I don''t use it much) but a regular DLL would support this, given of course that you code the "simultaneous" nature since that''s not default behavior (you probably need a DLL manager class that loads all available DLLs and manages calls to/from to support one function call going to multiple places).


I think I may have a solution to my own issue but can''t quite figure out how it might be done. I don''t have a DDLMain as this is a COM interfacing? plug in for the DAW software. If I could get the HInstance of the smaller I/O redirector plug with it''s conflicting exports then I could maybe send the Master plug the address of that particular instance''s function to be called.

But without a DLLMain most goolge searches are fruitless.

Thanks in advance for the help,



********* Addendumb *********

theApp.m_hInstance is my handle to the instance.

But curiously is I load 2 copies of the DLL and pass theApp.m_hInstance to the main DLL from both for a look-see, to my chagrin, both DLLs are sending over the same exact value for theApp.m_hInstance.


这篇关于使用相同的导出功能的2个或更多dll.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆