Detect 64bit FF browser in addon

Hi Everyone,
We had already developed Firefox addon and it is currently working on 32bit Firefox browsers.
Now we need to support this addon on 64bit browsers as well.

Internally our addon , launches DLL ,using “ctypes.open”.
But before that we need to know, whether to launch 32bit /64bit version of dll.

So is there a way to detect whether our addon is running under 32bit or 64bit version of FF browser.

Thanks
Girish

You can detected 64bit in a coule of ways.

One is to use the global OS variable:

OS.Constants.Sys.bits // 32 or 64

This OS variable is available by default in ChromeWoker’s, (i’m not sure about WebWorker’s). However if you need it in a non-woker scope, and it is not there by default (check first I’m not sure), then you can import it with -

Components.utils.import("resource://gre/modules/osfile.jsm")

If you are using ctypes, which it looks like you are, you can also test for 32bit like this:

ctypes.voidptr_t.size == 4 ? 32 : 64;

Pointer size on 64bit is 8 bytes and on 32bit it is 4 bytes.

Hello,
Well, pardon my naivety, but what about this ?
https://msdn.microsoft.com/en-us/library/system.environment.is64bitoperatingsystem(v=vs.110).aspx
http://stackoverflow.com/questions/14423057/how-to-check-if-os-is-32-bit-os-or-64-bit

1 Like

Thanks @gloops for suggesting that I appreciate it! That method will only work on Windows though, and it requires a platform dependent system call, which is more expensive then using OS variable, which is no cost.

It can be useful to get the if the system is actually 64bit while the program is only 32bit, however its not useful in most cases. We just need to know if the process/program is 32bit, if it is, then we use all 32bit calls.

If you do need to know if the system is 64bit, there is a no cost XPCOM way to determine it, it’s available via Services.appinfo.