Bug 1255472 - Add support for the WOW64 mode to the WindowsRegistry. r=gfritzsche, a=ritu

This commit is contained in:
Alessio Placitelli 2016-04-15 10:23:00 +02:00
parent d59eb8fc6e
commit 63dd70e978
3 changed files with 16 additions and 7 deletions

View File

@ -1259,7 +1259,8 @@ EnvironmentCache.prototype = {
// Query the UBR key and only add it to the environment if it's available. // Query the UBR key and only add it to the environment if it's available.
// |readRegKey| doesn't throw, but rather returns 'undefined' on error. // |readRegKey| doesn't throw, but rather returns 'undefined' on error.
let ubr = WindowsRegistry.readRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE, let ubr = WindowsRegistry.readRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
WINDOWS_UBR_KEY_PATH, "UBR"); WINDOWS_UBR_KEY_PATH, "UBR",
Ci.nsIWindowsRegKey.WOW64_64);
data.windowsUBR = (ubr !== undefined) ? ubr : null; data.windowsUBR = (ubr !== undefined) ? ubr : null;
} }
data.installYear = getSysinfoProperty("installYear", null); data.installYear = getSysinfoProperty("installYear", null);

View File

@ -518,8 +518,8 @@ function checkSystemSection(data) {
} }
if ("windowsUBR" in osData) { if ("windowsUBR" in osData) {
// This might not be available on all Windows platforms. // This might not be available on all Windows platforms.
Assert.ok(Number.isFinite(osData["windowsUBR"]), Assert.ok((osData["windowsUBR"] === null) || Number.isFinite(osData["windowsUBR"]),
"windowsUBR must be a number."); "windowsUBR must be null or a number.");
} }
} else if (gIsAndroid || gIsGonk) { } else if (gIsAndroid || gIsGonk) {
Assert.ok(checkNullOrString(osData.kernelVersion)); Assert.ok(checkNullOrString(osData.kernelVersion));

View File

@ -17,15 +17,19 @@ var WindowsRegistry = {
* The registry path to the key. * The registry path to the key.
* @param aKey * @param aKey
* The key name. * The key name.
* @param [aRegistryNode=0]
* Optionally set to nsIWindowsRegKey.WOW64_64 (or nsIWindowsRegKey.WOW64_32)
* to access a 64-bit (32-bit) key from either a 32-bit or 64-bit application.
* @return The key value or undefined if it doesn't exist. If the key is * @return The key value or undefined if it doesn't exist. If the key is
* a REG_MULTI_SZ, an array is returned. * a REG_MULTI_SZ, an array is returned.
*/ */
readRegKey: function(aRoot, aPath, aKey) { readRegKey: function(aRoot, aPath, aKey, aRegistryNode=0) {
const kRegMultiSz = 7; const kRegMultiSz = 7;
const kMode = Ci.nsIWindowsRegKey.ACCESS_READ | aRegistryNode;
let registry = Cc["@mozilla.org/windows-registry-key;1"]. let registry = Cc["@mozilla.org/windows-registry-key;1"].
createInstance(Ci.nsIWindowsRegKey); createInstance(Ci.nsIWindowsRegKey);
try { try {
registry.open(aRoot, aPath, Ci.nsIWindowsRegKey.ACCESS_READ); registry.open(aRoot, aPath, kMode);
if (registry.hasValue(aKey)) { if (registry.hasValue(aKey)) {
let type = registry.getValueType(aKey); let type = registry.getValueType(aKey);
switch (type) { switch (type) {
@ -57,13 +61,17 @@ var WindowsRegistry = {
* The registry path to the key. * The registry path to the key.
* @param aKey * @param aKey
* The key name. * The key name.
* @param [aRegistryNode=0]
* Optionally set to nsIWindowsRegKey.WOW64_64 (or nsIWindowsRegKey.WOW64_32)
* to access a 64-bit (32-bit) key from either a 32-bit or 64-bit application.
*/ */
removeRegKey: function(aRoot, aPath, aKey) { removeRegKey: function(aRoot, aPath, aKey, aRegistryNode=0) {
let registry = Cc["@mozilla.org/windows-registry-key;1"]. let registry = Cc["@mozilla.org/windows-registry-key;1"].
createInstance(Ci.nsIWindowsRegKey); createInstance(Ci.nsIWindowsRegKey);
try { try {
let mode = Ci.nsIWindowsRegKey.ACCESS_QUERY_VALUE | let mode = Ci.nsIWindowsRegKey.ACCESS_QUERY_VALUE |
Ci.nsIWindowsRegKey.ACCESS_SET_VALUE; Ci.nsIWindowsRegKey.ACCESS_SET_VALUE |
aRegistryNode;
registry.open(aRoot, aPath, mode); registry.open(aRoot, aPath, mode);
if (registry.hasValue(aKey)) { if (registry.hasValue(aKey)) {
registry.removeValue(aKey); registry.removeValue(aKey);