From e112a1245bb61d562daf6da9c350ccdd5db6e135 Mon Sep 17 00:00:00 2001 From: Michael Larabel Date: Sat, 15 May 2021 13:01:35 -0500 Subject: [PATCH] phodevi: Fill in some Windows gaps --- .../phodevi/components/phodevi_audio.php | 16 ++++++++++++- .../phodevi/components/phodevi_cpu.php | 14 +++++++++++ .../phodevi/components/phodevi_disk.php | 15 +++++++++++- .../phodevi/components/phodevi_monitor.php | 4 ++++ .../components/phodevi_motherboard.php | 24 +++++++++++++++++++ 5 files changed, 71 insertions(+), 2 deletions(-) diff --git a/pts-core/objects/phodevi/components/phodevi_audio.php b/pts-core/objects/phodevi/components/phodevi_audio.php index ec36fd5aa4..3534be7bd2 100644 --- a/pts-core/objects/phodevi/components/phodevi_audio.php +++ b/pts-core/objects/phodevi/components/phodevi_audio.php @@ -51,7 +51,21 @@ public static function audio_processor_string() } else if(phodevi::is_windows()) { - // TODO: implement + $win_sound = array(); + $win32_sounddevice = shell_exec('powershell "(Get-WMIObject -Class win32_sounddevice | Select Name)"'); + if(($x = strpos($win32_sounddevice, '----')) !== false) + { + $win32_sounddevice = trim(substr($win32_sounddevice, $x + 4)); + foreach(explode("\n", $win32_sounddevice) as $sd) + { + if(!empty($sd)) + { + $win_sound[] = $sd; + } + } + } + $win_sound = array_unique($win_sound); + $audio = implode(' + ', $win_sound); } else if(phodevi::is_linux()) { diff --git a/pts-core/objects/phodevi/components/phodevi_cpu.php b/pts-core/objects/phodevi/components/phodevi_cpu.php index 7afd4e67a7..9e3db99557 100644 --- a/pts-core/objects/phodevi/components/phodevi_cpu.php +++ b/pts-core/objects/phodevi/components/phodevi_cpu.php @@ -383,6 +383,20 @@ public static function cpu_microcode_version() { $ucode_version = self::read_cpuinfo_line('microcode'); } + else if(phodevi::is_windows()) + { + $reg = shell_exec('reg query HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0'); + if(($x = strpos($reg, 'Update Revision')) !== false) + { + $reg = substr($reg, $x); + $reg = substr($reg, 0, strpos($reg, "\n")); + $ucode = substr($reg, strrpos($reg, ' ')); + if(is_numeric($ucode)) + { + $ucode_version = $ucode; + } + } + } if(empty($ucode_version) && phodevi::is_macos()) { diff --git a/pts-core/objects/phodevi/components/phodevi_disk.php b/pts-core/objects/phodevi/components/phodevi_disk.php index 02b0d5b3ab..d3c60e1b61 100644 --- a/pts-core/objects/phodevi/components/phodevi_disk.php +++ b/pts-core/objects/phodevi/components/phodevi_disk.php @@ -96,7 +96,7 @@ public static function block_size() { $path = PTS_IS_CLIENT ? pts_client::test_install_root_path() : '.'; $block_size = -1; - if(PTS_IS_CLIENT && pts_client::executable_in_path('stat')) + if(PTS_IS_CLIENT && pts_client::executable_in_path('stat') && !phodevi::is_windows()) { $stat = trim(shell_exec('stat -f -c %S ' . $path)); @@ -105,6 +105,19 @@ public static function block_size() $block_size = $stat; } } + else if(phodevi::is_windows()) + { + $wmi = shell_exec('powershell "Get-WmiObject -Class Win32_Volume | Select-Object DriveLetter, BlockSize"'); + if(($x = strpos($wmi, 'C:')) !== false) + { + $wmi = substr($wmi, ($x + 3)); + $wmi = trim(substr($wmi, 0, strpos($wmi, "\n"))); + if(is_numeric($wmi)) + { + $block_size = $wmi; + } + } + } return $block_size; } diff --git a/pts-core/objects/phodevi/components/phodevi_monitor.php b/pts-core/objects/phodevi/components/phodevi_monitor.php index 888e0f4175..3517b576bd 100644 --- a/pts-core/objects/phodevi/components/phodevi_monitor.php +++ b/pts-core/objects/phodevi/components/phodevi_monitor.php @@ -52,6 +52,10 @@ public static function monitor_string() $monitor = array($monitor); } } + else if(phodevi::is_windows()) + { + $monitor[] = trim(shell_exec('powershell "$((Get-WmiObject WmiMonitorID -Namespace root\wmi) | %{ $Name = $($_.UserFriendlyName -notmatch 0 | ForEach{[char]$_}) -join \"\"; Write-Output $Name }) -join \";\""')); + } else if(phodevi::is_nvidia_graphics() && isset(phodevi::$vfs->xorg_log)) { $log_parse = phodevi::$vfs->xorg_log; diff --git a/pts-core/objects/phodevi/components/phodevi_motherboard.php b/pts-core/objects/phodevi/components/phodevi_motherboard.php index c802237a3e..44c4fccca1 100644 --- a/pts-core/objects/phodevi/components/phodevi_motherboard.php +++ b/pts-core/objects/phodevi/components/phodevi_motherboard.php @@ -53,6 +53,18 @@ public static function secure_boot() $status = 'Disabled'; } } + else if(phodevi::is_windows()) + { + $confirm = shell_exec('powershell "Confirm-SecureBootUEFI"'); + if(strpos($confirm, 'True') !== false) + { + $status = 'Enabled'; + } + else if(strpos($confirm, 'False') !== false) + { + $status = 'Disabled'; + } + } return $status; } @@ -71,6 +83,18 @@ public static function boot_mode() $boot_mode = 'EFI'; } } + else if(phodevi::is_windows()) + { + $bcdedit = shell_exec('bcdedit'); + if(strpos($bcdedit, '.efi') !== false) + { + $boot_mode = 'EFI'; + } + else if(strpos($bcdedit, 'path') !== false) + { + $boot_mode = 'Legacy BIOS'; + } + } return $boot_mode; }