无法在 firefox 插件中使用 ctypes.open 打开库(错误 126)

标签 c firefox dll firefox-addon jsctypes

开发 Firefox 插件,使用 ctypes 加载自定义 DLL - 在我的真实计算机(win 7/64)上,DLL 加载顺利,但在我使用相同操作系统的测试 VM 中,出现以下错误:

console.error: bzaddon:
  Message: Error: couldn't open library .\BZAddOnHelper.dll: error 126
  Stack:
    @resource://bzaddon/index.js:25:11
run@resource://gre/modules/commonjs/sdk/addon/runner.js:145:19
startup/</<@resource://gre/modules/commonjs/sdk/addon/runner.js:86:7
Handler.prototype.process@resource://gre/modules/Promise-backend.js:867:23
this.PromiseWalker.walkerLoop@resource://gre/modules/Promise-backend.js:746:7
this.PromiseWalker.scheduleWalkerLoop/<@resource://gre/modules/Promise-backend.j
s:688:37

加载库的代码:

// Get the chrome components
let { Ci, Cu, Cr } = require('chrome');
// Get ctypes
Cu.import("resource://gre/modules/ctypes.jsm");
// External DLL
var lib = ctypes.open(".\\BZAddonHelper.dll");

我什至尝试使用完全空的 DLL,它不依赖于 msvc*:

screenshot of 'depends' on the target vm

我尝试使用将 DLL 移动到数据目录并使用 self.data.url 并且根本不使用任何路径。我尝试使用完整路径。唯一可行的是将我的 DLL 复制到 SysWow64(DLL 是 32 位,因为 firefox 是 32 位)。同样,在我的(开发)机器上运行它可以使用“.\dllname” - 但不能在任何其他计算机上运行......我完全不知所措......有人吗?

最佳答案

您不必安装到 system32,请参阅这个使用自定义 dll 的工作插件:github.com/NoitForks/Firefox_addon_sdk_jsctypes 和这个:github.com/NoitForks/fx-sapi-test 我确定你错了不使用使用 file://协议(protocol)的字符串。如果它在 C:\blah.dll 做 ctypes.open('file://C:/blah.dll')

关于无法在 firefox 插件中使用 ctypes.open 打开库(错误 126),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33231974/

相关文章:

c - openCL 中的字符串扩展

c - C宏扩展如何工作?

c# - 从 Gecko 拦截(和重定向)样式表、图像和字体加载

javascript - window.addEventListener ('message' , myFunction(event)) 不起作用

c++ - DLL 中的函数

c++ - 错误: lvalue required as a left operand of assignment

c - 将参数传递给函数指针数组

macos - 这是 Mac OS 上 Firefox 扩展的已知问题吗?

debugging - 使用 rebase.exe 从 msys/mingw gcc 构建的 dll 中提取调试信息?

c++ - 创建并链接到从旧 DLL 文件生成的 .lib 文件