osInfo(), cpu() improved hypervisor, virtualization detection (windows)

This commit is contained in:
Sebastian Hildebrandt 2021-05-27 15:46:27 +02:00
parent df9b7aa5ef
commit 1eea10ea54
5 changed files with 28 additions and 16 deletions

View File

@ -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 |

View File

@ -56,6 +56,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.7.4</th>
<td>2021-05-27</td>
<td><span class="code">osInfo(), cpu()</span> improved hypervisor, virtualization detection (windows)</td>
</tr>
<tr>
<th scope="row">5.7.3</th>
<td>2021-05-26</td>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.7.3</span></div>
<div class="version">New Version: <span id="version">5.7.4</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div>
<div class="down">

View File

@ -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;

View File

@ -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) {