场景
我有一个为 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:
...
- 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/