symbian:EKA2 或类似的 DLL 入口点?
目前,我正在开发一个 DLL,旨在链接到第 3 方应用程序,以测试该应用程序是否有资格在给定时间运行。
首先,我考虑创建一个 DLL 并处理 TInt E32Dll()
函数中所需的检查。但当我读到 EKA2 中的 DLL 加载/卸载时未调用此函数时,我感到非常惊讶。
所以现在我需要另一种方式来完成我的任务。我的目标是创建一些可以嵌入到第三方应用程序中的机制。应在应用程序启动时调用此机制,执行一些检查(特定 Symbian 服务器是否存在),如果检查失败,则应终止应用程序。另一个要求是,该机制对于那些第三方应用程序的开发人员来说最多应该是透明的。 (E32Dll() 函数是最好的候选者 - 只需将特定的库链接到项目即可完成...)
我将非常感谢任何其他想法。提前致谢。
Currently I'm developing a DLL which is intended to be linked to 3rd party applications in order to test whether this application is eligible to run at a given time.
First I thought about to create a DLL and handle the needed check in TInt E32Dll()
function. But I was very surprised when I've read that this function is not called on DLL load/unload in EKA2.
So now I need another way to achieve my task. My goal is to create some mechanism, which can be embedded in 3rd party applications. This mechanism should be called on application start, perform some check (presence of specific Symbian server), and if the check is failed, it should terminate the application. Another requirement is that this mechanism should be transparent at best to developers of those 3rd party applications. (The E32Dll() function was the best candidate - just link specific library to a project and you're done...)
I'll greatly appreciate any other ideas. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我实际上找到了一种方法来实现我的目标 - 在加载 DLL 时调用某些方法。这个想法是在 http://developer.symbian.org/forum/ 给我的showthread.php?p=30244。
只需要在某个 DLL 模块中声明某个全局对象,其构造函数就会在 DLL 加载时被调用。这个解决方案对我来说效果很好,事实上,这个答案确实应该被接受......
但是由于我不是这个解决方案的作者,并且当前接受的答案仍然包含有价值的信息,所以我不会更改接受的标志。就这样吧。 :)
I've actually found a way to achieve my goal - call some method when DLL is loaded. The idea was given to me at http://developer.symbian.org/forum/showthread.php?p=30244.
One just need to declare some global object in some DLL module, and its constructor will be called when the DLL will be loaded. This solution works fine for me, and, indeed, this answer should really be accepted...
... But since I'm not the author of this solution, and currently accepted answer still contain valuable information, I'll not change the mark of accepting. Just let it be so. :)
我不确定在 E32Dll() 中做一些事情,即使它有效(但它并不像你想象的那样)是一个好方法,因为在关闭应用程序之前,你必须向用户显示一些通知或对话框。为什么不制作一个普通的 DLL + 精简启动代码,它将加载(使用 RLibrary)并调用第一个序数函数:
BR
STeN
嗨 Haspemulator,这是我对您的评论的回答:
1) 不,第一个序数不是 E32Dll(),自 EKA2 以来无法调用此方法。检查下面的描述 (http://developer.symbian.org/wiki/Symbian_OS_Internals/10. _The_Loader):
请注意,在 EKA2 中,不再调用公共 DLL 入口点 E32Dll(TDllReason)。此函数必须存在于每个 EKA1 DLL 中,当 DLL 附加到进程或线程或从进程或线程分离时调用。不幸的是,这个入口点系统无法保证在指定时间使用适当的参数调用 E32Dll()。由于无法可靠地支持此功能,EKA2 删除了对其的支持。此删除简化了用于管理动态加载代码的内核端架构,从而提高了可靠性和健壮性。
2) 您也可以在这里找到有关此主题的有趣讨论:
http:// /discussion.forum.nokia.com/forum/showthread.php?80781-What-is-the-replacement-for-E32Dll-and-TDllReason
3) 在我们的例子中,第一个序数将是您的第一个函数将从 DLL 导出。您可以在此处找到如何编写此类 DLL 的信息:
http://developer .symbian.org/main/documentation/reference/s3/pdk/GUID-4A56B285-790E-5171-88F3-8C40B2AA9699.html
4)为了更具体地说明从 DLL 导出方法的含义,请检查代码下面(该方法当然可以返回一些变量 - 例如新创建的对象):
希望它有帮助......
BR
斯坦恩
I am not sure that doing something in E32Dll() even it work (but it doesn't as you figure out) is a good way, because prior to closing the application you have to show some notification or dialog to the user. Why not making a normal DLL + thin start-up code, which will load (using the RLibrary) and call the 1st ordinal function:
BR
STeN
Hi Haspemulator, There is my answer to your comment:
1) No, the 1st ordinal is not E32Dll(), this method cannot be called since EKA2. Check the description below (http://developer.symbian.org/wiki/Symbian_OS_Internals/10._The_Loader):
Note that, in EKA2, the public DLL entry-point, E32Dll(TDllReason) is no longer invoked. This function must be present in every EKA1 DLL, to be called when the DLL is attached to or detached from a process or thread. Unfortunately, this entry-point system cannot provide any guarantees that E32Dll() will be called with the appropriate parameter at the specified time. Because it is not possible to support this functionality reliably, EKA2 removes support for it. This removal simplifies the kernel-side architecture for managing dynamically loaded code, which improves reliability and robustness.
2) You can find an interesting discussion regarding this topic also here:
http://discussion.forum.nokia.com/forum/showthread.php?80781-What-is-the-replacement-for-E32Dll-and-TDllReason
3) In our case the 1st ordinal will be the 1st function you will export from the DLL. You can find information how to write such a DLL here:
http://developer.symbian.org/main/documentation/reference/s3/pdk/GUID-4A56B285-790E-5171-88F3-8C40B2AA9699.html
4) To be more concrete what I mean by exporting a method from DLL check the code below (the method can of course return some variable - e.g. newly created object):
Hope it helps...
BR
STeN