Firefox Addon Dev: nativeHandle

Não há necessidade de js-ctypes e hacks. Por exemplo em janelas: O FindWindowtruque para obter a alça para janelas cromadas. Basta usar o nativeHandledo nsIBaseWindow.

var baseWindow = aDOMWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShellTreeItem).treeOwner.QueryInterface(Ci.nsIInterfaceRequestor).nsIBaseWindow;
var nativeHandle = baseWindow.nativeHandle;
//var targetWindow_handle = ctypes.voidptr_t(ctypes.UInt64(nativeHandle)); //may need to do this for certain applications (like plugging into a js-ctypes function with argument ctypes.voidptr_t

Não precisa mais deste hack (Windows):

Cu.import('resource://gre/modules/ctypes.jsm');

var user32 = ctypes.open('user32.dll');

var FindWindow = user32.declare('FindWindowW', ctypes.winapi_abi, ctypes.int32_t, ctypes.jschar.ptr, ctypes.jschar.ptr);

var targetWindow_title = aDOMWindow.document.documentElement.getAttribute('title');
var targetWindow_titleOriginal = targetWindow_title;
targetWindow_title
+= ' - blah blah blah';
aDOMWindow
.document.documentElement.setAttribute('title', targetWindow_title);
aDOMWindow
.alert('need to wait after set attribute on title for os to understand it');
var targetWindow_handle = FindWindow(null, targetWindow_title);
aDOMWindow
.document.documentElement.setAttribute('title', targetWindow_titleOriginal);