Firefox addon FF插件,js ctypes:canned';t开放库(dll)
我正在构建一个firefox插件,它使用js ctypes加载一个C库。该库包含在插件本身中(即“数据”目录中)。它在Linux和OSX中运行良好,我分别加载了.so和.dylib文件。但是当我尝试在windows中加载.dll时,它失败了 消息:错误:无法打开库c:\users…\appdata\local\temp…\customlib.dll 当我沿着这个路径走的时候,customlib.dll文件确实是ctypes正在查看的地方。当我用dllexp打开它时,我看到了所有的符号,所以我认为.dll本身很好 我不确定该提供什么信息。这就是我试图用ctypes打开库的方式Firefox addon FF插件,js ctypes:canned';t开放库(dll),firefox-addon,firefox-addon-sdk,jsctypes,Firefox Addon,Firefox Addon Sdk,Jsctypes,我正在构建一个firefox插件,它使用js ctypes加载一个C库。该库包含在插件本身中(即“数据”目录中)。它在Linux和OSX中运行良好,我分别加载了.so和.dylib文件。但是当我尝试在windows中加载.dll时,它失败了 消息:错误:无法打开库c:\users…\appdata\local\temp…\customlib.dll 当我沿着这个路径走的时候,customlib.dll文件确实是ctypes正在查看的地方。当我用dllexp打开它时,我看到了所有的符号,所以我认为
var {Cc, Cu, Ci} = require("chrome");
Cu.import("resource://gre/modules/Services.jsm");
var {ctypes} = Cu.import("resource://gre/modules/ctypes.jsm", null);
function resolveToFile(uri) {
var ResProtocolHandler = Services.io.getProtocolHandler("resource")
.QueryInterface(Ci.nsIResProtocolHandler);
var ChromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIChromeRegistry);
switch (uri.scheme) {
case "chrome":
return resolveToFile(ChromeRegistry.convertChromeURL(uri));
case "resource":
return resolveToFile(Services.io.newURI(ResProtocolHandler.resolveURI(uri), null, null));
case "file":
return uri.QueryInterface(Ci.nsIFileURL).file;
default:
throw new Error("Cannot resolve");
}
}
function getLibName(){
return "customlib.dll";
}
var loc = resolveToFile(Services.io.newURI(self.data.url(getLibName()),null,null));
var lib = ctypes.open(loc.path);
我从这里得到了resolveToFile(),它就像一个符咒,它找到了加载项中包含的LIB的正确路径。但同样,它不会在Windows中打开。而不是
var{ctypes}=Cu.import(“resource://gre/modules/ctypes.jsm“,空)代码>只执行Cu.import(“resource://gre/modules/ctypes.jsm");代码>
这个代码是从ChromeWorker运行的吗
也要这样做:
var self = require("sdk/self");
ctypes.open(self.data.url('customlib.dll'));
我还尝试了对dll的路径进行编码,得到了相同的消息。我需要对.dll做些什么吗?e、 权限之类的?你能弄明白吗?我错过了这个主题,因为我通常只关注firefox插件主题。你可能会发现这篇文章很有用: