osInfo(), cpu() improved hypervisor, virtualization detection (windows)
This commit is contained in:
+13
-10
@@ -550,14 +550,14 @@ function getCpu() {
|
||||
cpuFlags().then(flags => {
|
||||
result.flags = flags;
|
||||
result.virtualization = flags.indexOf('vmx') > -1 || flags.indexOf('svm') > -1;
|
||||
if (_windows) {
|
||||
try {
|
||||
const systeminfo = execSync('systeminfo', util.execOptsWin).toString();
|
||||
result.virtualization = result.virtualization || (systeminfo.indexOf('Virtualization Enabled In Firmware: Yes') !== -1) || (systeminfo.indexOf('Virtualisierung in Firmware aktiviert: Ja') !== -1) || (systeminfo.indexOf('Virtualisation activée dans le microprogramme : Qiu') !== -1);
|
||||
} catch (e) {
|
||||
util.noop();
|
||||
}
|
||||
}
|
||||
// if (_windows) {
|
||||
// try {
|
||||
// const systeminfo = execSync('systeminfo', util.execOptsWin).toString();
|
||||
// result.virtualization = result.virtualization || (systeminfo.indexOf('Virtualization Enabled In Firmware: Yes') !== -1) || (systeminfo.indexOf('Virtualisierung in Firmware aktiviert: Ja') !== -1) || (systeminfo.indexOf('Virtualisation activée dans le microprogramme : Qiu') !== -1);
|
||||
// } catch (e) {
|
||||
// util.noop();
|
||||
// }
|
||||
// }
|
||||
if (_darwin) {
|
||||
exec('sysctl machdep.cpu hw.cpufrequency_max hw.cpufrequency_min hw.packages hw.physicalcpu_max hw.ncpu hw.tbfrequency hw.cpufamily hw.cpusubfamily', function (error, stdout) {
|
||||
let lines = stdout.toString().split('\n');
|
||||
@@ -753,6 +753,7 @@ function getCpu() {
|
||||
const workload = [];
|
||||
workload.push(util.wmic('cpu get /value'));
|
||||
workload.push(util.wmic('path Win32_CacheMemory get CacheType,InstalledSize,Purpose'));
|
||||
workload.push(util.powerShell('Get-ComputerInfo -property "HyperV*"'));
|
||||
|
||||
Promise.all(
|
||||
workload
|
||||
@@ -831,6 +832,10 @@ function getCpu() {
|
||||
}
|
||||
}
|
||||
});
|
||||
lines = data[2].split('\r\n');
|
||||
result.virtualization = (util.getValue(lines, 'HyperVRequirementVirtualizationFirmwareEnabled').toLowerCase() === 'true');
|
||||
result.virtualization = (util.getValue(lines, 'HyperVisorPresent').toLowerCase() === 'true');
|
||||
|
||||
resolve(result);
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -1608,5 +1613,3 @@ function fullLoad(callback) {
|
||||
}
|
||||
|
||||
exports.fullLoad = fullLoad;
|
||||
|
||||
|
||||
|
||||
+8
-5
@@ -18,7 +18,7 @@ const fs = require('fs');
|
||||
const util = require('./util');
|
||||
const exec = require('child_process').exec;
|
||||
const execSync = require('child_process').execSync;
|
||||
const execPromise = util.promisify(require('child_process').exec);
|
||||
// const execPromise = util.promisify(require('child_process').exec);
|
||||
|
||||
let _platform = process.platform;
|
||||
|
||||
@@ -323,7 +323,8 @@ function osInfo(callback) {
|
||||
try {
|
||||
const workload = [];
|
||||
workload.push(util.wmic('os get /value'));
|
||||
workload.push(execPromise('systeminfo', util.execOptsWin));
|
||||
// workload.push(execPromise('systeminfo', util.execOptsWin));
|
||||
workload.push(util.powerShell('Get-ComputerInfo -property "HyperV*"'));
|
||||
workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.SystemInformation]::TerminalServerSession'));
|
||||
util.promiseAll(
|
||||
workload
|
||||
@@ -334,8 +335,10 @@ function osInfo(callback) {
|
||||
result.build = util.getValue(lines, 'BuildNumber', '=').trim();
|
||||
result.servicepack = util.getValue(lines, 'ServicePackMajorVersion', '=').trim() + '.' + util.getValue(lines, 'ServicePackMinorVersion', '=').trim();
|
||||
result.codepage = util.getCodepage();
|
||||
const systeminfo = data.results[1] ? data.results[1].toString() : '';
|
||||
result.hypervisor = (systeminfo.indexOf('hypervisor has been detected') !== -1) || (systeminfo.indexOf('Es wurde ein Hypervisor erkannt') !== -1) || (systeminfo.indexOf('Un hyperviseur a ') !== -1);
|
||||
// const systeminfo = data.results[1] ? data.results[1].toString() : '';
|
||||
// result.hypervisor = (systeminfo.indexOf('hypervisor has been detected') !== -1) || (systeminfo.indexOf('Es wurde ein Hypervisor erkannt') !== -1) || (systeminfo.indexOf('Un hyperviseur a ') !== -1);
|
||||
const hyperv = data.results[1] ? data.results[1].toString().split('\r\n') : [];
|
||||
result.hypervisor = (util.getValue(hyperv, 'HyperVisorPresent').toLowerCase() === 'true');
|
||||
const term = data.results[2] ? data.results[2].toString() : '';
|
||||
result.remoteSession = (term.toString().toLowerCase().indexOf('true') >= 0);
|
||||
isUefiWindows().then(uefi => {
|
||||
@@ -384,7 +387,7 @@ function isUefiWindows() {
|
||||
exec('findstr /C:"Detected boot environment" "%windir%\\Panther\\setupact.log"', util.execOptsWin, function (error, stdout) {
|
||||
if (!error) {
|
||||
const line = stdout.toString().split('\n\r')[0];
|
||||
resolve(line.toLowerCase().indexOf('uefi') >= 0 || line.toLowerCase().indexOf(' efi') >= 0);
|
||||
resolve(line.toLowerCase().indexOf('efi') >= 0);
|
||||
return;
|
||||
} else {
|
||||
exec('echo %firmware_type%', util.execOptsWin, function (error, stdout) {
|
||||
|
||||
Reference in New Issue
Block a user