extended windows support cpuFlags() (partially)

This commit is contained in:
Sebastian Hildebrandt
2017-10-15 11:49:19 +02:00
parent ba8743f3a6
commit 43bddba27d
4 changed files with 39 additions and 5 deletions
+23 -3
View File
@@ -394,10 +394,30 @@ function cpuFlags(callback) {
process.nextTick(() => {
let result = '';
if (_windows) {
if (callback) { callback(result) }
resolve(result);
exec(`reg query "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0" /v FeatureSet`, function (error, stdout) {
if (!error) {
let flag_hex = stdout.split("0x").pop().trim();
let flag_bin_unpadded = parseInt(flag_hex, 16).toString(2);
let flag_bin = "0".repeat(32 - flag_bin_unpadded.length) + flag_bin_unpadded;
// empty flags are the reserved fields in the CPUID feature bit list
// as found on wikipedia:
// https://en.wikipedia.org/wiki/CPUID
let all_flags = [
"fpu", "vme", "de", "pse", "tsc", "msr", "pae", "mce", "cx8", "apic",
"", "sep", "mtrr", "pge", "mca", "cmov", "pat", "pse-36", "psn", "clfsh",
"", "ds", "acpi", "mmx", "fxsr", "sse", "sse2", "ss", "htt", "tm", "ia64", "pbe"
]
for (let f = 0; f < all_flags.length; f++) {
if (flag_bin[f] === "1" && all_flags[f] !== "") {
result += " " + all_flags[f];
}
}
result = result.trim();
}
if (callback) { callback(result) }
resolve(result);
});
}
if (_linux) {
exec("lscpu", function (error, stdout) {
if (!error) {