Mozilla uses C DLL with js-ctypes
I am linking to create a dll and then using it with a Firefox extension.
I managed to create a DLL using gcc under Windows:
#include<stdio.h>
int add(int a,int b)
{
return(a+b);
}
I am trying to use it through my DLL. After reading some posts, especially this one, I was not able to get this working: Binary component link to js-ctypes
Every time I try ctypes.open, I get an error: Could not load library . However, the path to the DLL is correct. Here is the JS code:
Components.utils.import("resource://gre/modules/ctypes.jsm");
AddonManager.getAddonByID("greenfox@octo.com", function(addon)
{
var libcPath = addon.getResourceURI("components/library.dll");
if (libcPath instanceof Components.interfaces.nsIURI)
{
var libc = ctypes.open(libcPath.path);
var libc = ctypes.open(libc);
/* import a function */
var puts = libc.declare("add", /* function name */
ctypes.default_abi, /* call ABI */
ctypes.int32_t, /* return type */
ctypes.int32_t, /* argument type */
ctypes.int32_t /* argument type */
);
var ret = puts(1,2);
alert("1+2="+ret);
}
Do you have any ideas?
+1
source to share