IE BHO c++选项卡之间的数据共享

发布于 2024-12-02 22:37:55 字数 1105 浏览 2 评论 0原文

我希望 IE 扩展的 BHO 实例能够共享通用数据。我只需要他们共享几个变量,所以我试图找到一个简单的解决方案来解决这个问题。

我能想到的替代方案(从更简单到更复杂)是:

1)从文件系统或注册表写入/读取数据,请参阅 MSDN 文章代码项目文章问题:可以从不同线程中运行的 BHO 实例访问此信息吗?

2) 开发与所有 BHO 实例通信的 Windows 服务或后台应用程序,请参阅 MSDN 文章问题:我不知道如何做到这一点,或者从哪里开始。我担心用户必须安装很多东西。

3)提供IPC机制,使得不同的BHO实例可以直接相互通信。与使用 IGlobalInterfaceTable 一样,请参阅 ookii 文章问题:是的,您可以在此IGlobalInterfaceTable中存储指针并获取cookie来访问它们,但是如何与BHO实例2共享在BHO实例1中获得的一个cookie,以便第二个实例可以访问第一个实例插入到 IGlobalInterfaceTable 中的数据?我们不是又遇到同样的数据共享问题了吗?

好吧,正如您所看到的,在寻找解决方案整整一周之后,我根本不知道如何开始处理这个问题。任何帮助将不胜感激。

I would like the BHO instances of my IE extension to be able to share common data. I just need them to share a couple of variables, so I am trying to find an easy solution for the problem.

The alternatives I can think of, from easier to more complex are:

1) Writing/reading data to/from the file system or to the registry, see MSDN article and Codeproject article. Question: is this information accessible from BHO instances running in different threads?

2) Developing a Windows Service or a background application that communicates with all BHO instances, see MSDN article. Problem: I have NO IDEA how to make this, or where to start with. I am worried about the user having to install to many things.

3) Providing IPC mechanisms so that the different BHO instances can communicate directly to each other. Like using the IGlobalInterfaceTable, see ookii article. Problem: Yes, you can store pointers in this IGlobalInterfaceTable and get cookies to access them back, but how can you share one cookie obtained in BHO Instance 1 with BHO Instance 2, so that the second instance can access the data inserted in the IGlobalInterfaceTable by the first one? Aren't we having here the same data sharing problem again?

Well, as you see, after a whole week looking for a solution I simply don't know how to start dealing with this problem. Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

养猫人 2024-12-09 22:37:55

通常,内存映射文件用于此目的。然而,这是一项不小的工作量,因为您必须确保它们正确地进行了 ACL,以允许跨进程访问(每个选项卡可能位于不同的进程中)并跨多个完整性级别工作。

Often, Memory Mapped Files are used for this purpose. It's a non-trivial amount of work, however, as you must ensure that they are ACL'd properly to allow cross-process access (each tab may be in a different process) and work across multiple integrity levels.

仅此而已 2024-12-09 22:37:55

1 类,除了普通网站可以写入的地方与可访问的受信任网站隔离

2 编写服务可能是最简单的方法,因为有大量关于如何编写 Windows 服务的文档(如果您使用 Visual C++,您甚至可以获得 ATL 项目向导),并且您的代理代码可以在选项卡进程崩溃甚至崩溃时幸存下来用户注销。

3 确实,您再次遇到相同的共享问题,COM消息被UIPI阻止,除非您可以更改消息过滤器,但COM使用的消息没有记录。我会使用诸如命名管道/内存文件映射之类的东西。

您需要将通信代理代码托管在某处并且仅创建一次。您可以编写类似于工作组中的计算机如何选择主浏览器(有点闲聊)的内容,或者有一个代理进程来完成通信工作(例如在Windows服务中)。

1 sort of, except the place a normal web site can write is isolated from a trusted web site can access.

2 Writing a service is probably the easiest way, given the abundant amount of documentation on how to write a windows service (you even get an ATL project wizard if you use Visual C++), and your broker code can survive a tab processes crash or even a user log off.

3 Indeed you have the same sharing problem again, COM messages are blocked by UIPI unless you can change the message filter, but the messages used by COM are not documented. I would use something like named pipe/memory file mapping.

You need to host the communication broker code somewhere and only create it once. You can write something like how computers in a workgroup elect the master browser (kind of chatty), or have a broker process to do the communication work (e.g in a windows service).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文