42 lines
1.6 KiB
PowerShell
42 lines
1.6 KiB
PowerShell
# Анализ описаний в BCD: сколько NBSP слева/справа у каждого пункта.
|
|
$store = 'F:\efi\Paravis\Boot\bcd\bcd'
|
|
$b = [IO.File]::ReadAllBytes($store)
|
|
|
|
function Find-Utf16([byte[]]$hay, [string]$s) {
|
|
$needle = [Text.Encoding]::Unicode.GetBytes($s)
|
|
for ($i = 0; $i -le $hay.Length - $needle.Length; $i++) {
|
|
$ok = $true
|
|
for ($j = 0; $j -lt $needle.Length; $j++) { if ($hay[$i+$j] -ne $needle[$j]) { $ok = $false; break } }
|
|
if ($ok) { return $i }
|
|
}
|
|
return -1
|
|
}
|
|
|
|
$texts = @(
|
|
'Super Grub2',
|
|
'Поиск и запуск Windows 7-11',
|
|
'Установка Windows 7, 10, 11 x64',
|
|
'Установка Windows 7, 10 x86',
|
|
'Запуск Windows 7 PE BootPass',
|
|
'Ventoy (ISO образы)',
|
|
'Kaspersky Rescue Disk 24',
|
|
'Перезагрузка',
|
|
'Выключение',
|
|
'Windows PE Strelec',
|
|
'Утилиты для диагностики',
|
|
'Windows MSDaRT',
|
|
'Установка/Запуск Linux'
|
|
)
|
|
|
|
'текст | слева | справа | всего'
|
|
foreach ($t in $texts) {
|
|
$p = Find-Utf16 $b $t
|
|
if ($p -lt 0) { ' {0} : не найдено' -f $t; continue }
|
|
$lead = 0
|
|
while ($p - 2 - $lead*2 -ge 0 -and $b[$p-2-$lead*2] -eq 0xA0 -and $b[$p-1-$lead*2] -eq 0x00) { $lead++ }
|
|
$end = $p + [Text.Encoding]::Unicode.GetByteCount($t)
|
|
$trail = 0
|
|
while ($end + $trail*2 + 1 -lt $b.Length -and $b[$end+$trail*2] -eq 0xA0 -and $b[$end+$trail*2+1] -eq 0x00) { $trail++ }
|
|
' {0,-36} {1,3} {2,3} {3,4}' -f $t, $lead, $trail, ($lead + $t.Length + $trail)
|
|
}
|