diff --git a/CHANGELOG.md b/CHANGELOG.md index 3eeec1e..b0d4153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 5.7.4 | 2021-05-27 | `osInfo()`, `cpu()` improved hypervisor, virtualization detection (windows) | | 5.7.3 | 2021-05-26 | `osInfo()` improved UEFI detection (windows) | | 5.7.2 | 2021-05-24 | `system()` virtual detection improvement | | 5.7.1 | 2021-05-20 | `graphics()` Check for qwMemorySize on Windows | diff --git a/docs/history.html b/docs/history.html index 52910df..8666a71 100644 --- a/docs/history.html +++ b/docs/history.html @@ -56,6 +56,11 @@ + + 5.7.4 + 2021-05-27 + osInfo(), cpu() improved hypervisor, virtualization detection (windows) + 5.7.3 2021-05-26 diff --git a/docs/index.html b/docs/index.html index b7aea19..36875fd 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
 
-
New Version: 5.7.3
+
New Version: 5.7.4
diff --git a/lib/cpu.js b/lib/cpu.js index 8ef1f02..aef117f 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -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; - - diff --git a/lib/osinfo.js b/lib/osinfo.js index 47ee62f..291aa1c 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -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) {