Firefox addon 如何在Mozilla Firefox 32+插件中使用Windows本机dll?

Firefox addon 如何在Mozilla Firefox 32+插件中使用Windows本机dll?,firefox-addon,firefox-addon-sdk,Firefox Addon,Firefox Addon Sdk,我想恢复一个为Firefox11创建的废弃插件。此加载项通过本机dll控制设备。使用Firefox 32插件api和ctx,我不知道如何: 1将冗长的自定义初始化代码插入bootstrap.js或harnese-options.json 2将其他二进制文件包括到xpi归档中 3发现或确定在我的加载项中使用外部代码的可执行路径 我有一份原始xpi的副本。我可以看到他们如何将所需的dll放入“.\plugins\5.9.6.0000\foobar.dll”中。我可以看到他们在.\bootstrap.

我想恢复一个为Firefox11创建的废弃插件。此加载项通过本机dll控制设备。使用Firefox 32插件api和ctx,我不知道如何:

1将冗长的自定义初始化代码插入bootstrap.js或harnese-options.json

2将其他二进制文件包括到xpi归档中

3发现或确定在我的加载项中使用外部代码的可执行路径

我有一份原始xpi的副本。我可以看到他们如何将所需的dll放入“.\plugins\5.9.6.0000\foobar.dll”中。我可以看到他们在.\bootstrap.js中使用了“安装”功能。我在这里包含了bootstrap.js中的一些原始代码

function registerPlugin()
{
   var profPath = Components.classes["@mozilla.org/file/directory_service;1"].getService( Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile).path;  
var wrk = Components.classes["@mozilla.org/windows-registry-key;1"]
                    .createInstance(Components.interfaces.nsIWindowsRegKey);
wrk.open(wrk.ROOT_KEY_CURRENT_USER, "SOFTWARE", wrk.ACCESS_ALL);
if(!wrk.hasChild("MozillaPlugins"))
  wrk = wrk.createChild("MozillaPlugins", wrk.ACCESS_ALL);  
else
  wrk = wrk.openChild("MozillaPlugins", wrk.ACCESS_ALL);
var t1 = wrk.createChild("blueglow@hardcorps.com", wrk.ACCESS_ALL);
t1.writeStringValue("Description", "CanCan extension for BagMan");         
t1.writeStringValue("ProductName", "CanCan extension for BagMan");
t1.writeStringValue("Vendor", "Hardcorps Inc.");
t1.writeStringValue("Version", "5.9.6.0000");
t1.writeStringValue("Path", profPath + "\\extensions\\blueglow@hardcorps.com\\plugins\\5.9.6.0000\\foobar.dll" );
var t2 = t1.createChild("MimeTypes", wrk.ACCESS_ALL);
t2.createChild("application/blueglow-ff-plugin", wrk.ACCESS_ALL);
t2.close();
t1.close();
wrk.close();

Components.classes['@mozilla.org/appshell/window-mediator;1']
                       .getService(Ci.nsIWindowMediator)
                       .getMostRecentWindow('navigator:browser')
                       .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                       .getInterface(Components.interfaces.nsIWebNavigation)
                       .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
                       .rootTreeItem
                       .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
                       .getInterface(Components.interfaces.nsIDOMWindow).navigator.plugins.refresh(false);
}


function install(data, reason)
{
  registerPlugin();
}

将dll放入插件中,然后通过js ctypes使用它

下面是Mac上的一个示例,它们使用.dylib而不是.dll:

资料来源:


编译源:

谢谢。不幸的是,这个例子是针对Firefox4-11的,看起来比我的Windows插件例子还要旧。因为它是OSX,所以我无法构建它来测试它是否能够很好地支持FF 32。可能有用的信息是,这个示例将所有内容转储到chrome/dockprogress/content文件夹中,javascript似乎采用了一条路径。我不知道这是否适用于我。var file=this.getFilechrome://dockprogress/content/DockProgressC.dylib; var lib=this.lib=ctypes.openfile;在windows中的操作方式与此完全相同。它与FF4-11中的相同再次感谢,我将尝试它。顺便说一句,如果您使用的是addon sdk,请将dll放到数据文件夹中,然后执行:ctypes.openself.data.url'my.dll'