c++ - 是否可以从在 Wine 中运行的 Windows 应用程序调用 native Linux API?

标签 c++ c dll wine

场景

我有一个为 Windows 应用程序(使用 C++)编写的插件 (dll)。

该应用程序在 Wine 下的 Linux 上运行良好,但是,在插件中我想使用 Wine 中尚不可用的功能。

假设我可以在运行时检测到应用程序正在 Wine 中运行,我是否可以动态加载 native Linux 库(或以任何其他方式访问 native Linux API)以模拟所述功能?

我很好奇这是否可以在没有任何严重黑客攻击的情况下完成。

最佳答案

似乎有人遇到过类似的问题,或者至少已经预测到了这种情况。 Wrapper-library应该对你有帮助:

For one reason or another you may find yourself with a Linux library that you want to use as if it were a Windows DLL. There are various reasons for this including the following:

...

  1. You have a binary only Windows application that can be extended through plugins, such as a text editor or IDE.

简而言之 - 您应该创建精简的 Wine 内置 dll,它就像您的 PE 二进制文件的 ABI 和 native Linux 库的 ABI 之间的桥梁。然后你应该将你的代码链接到这个包装器。对于 Windows 发行版,您可以提供带有空 stub 的“包装器”。这种方法允许您为插件使用一个二进制文件,该二进制文件将在 Linux 上使用特定于 wine 的功能包装 DLL,在 Windows 上使用 stub DLL。

关于c++ - 是否可以从在 Wine 中运行的 Windows 应用程序调用 native Linux API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39574355/

相关文章:

c - 当我在 Unix 下运行 C 程序时,如何将参数读取为选项?

c++ - 启动使用附加库的可执行程序

C++::如何使用 sqlite3 insertquery 连接变量

c++ - "Expected unqualified-id"将我的代码设为模板时出现错误,而在将其设为模板之前没有出现该错误?

c++ - MFC:如何在单击按钮时最小化窗口?

c++删除排序数组中的重复项-打印新数组

c - 使用 SSE 反转字符串

c - gprof 中的问题(始终记为零)

c# - MarshalAs 属性案例研究

c++ - 我自己的 COM 组件上未注册类 (0x80040154)