# Исправление: у пункта Ventoy команда от BootPass и наоборот. Правятся оба файла # (рабочий F:\grldr и шаблон efi\Paravis\Boot\g4d\grldr). $ErrorActionPreference = 'Stop' $files = @('F:\grldr', 'F:\efi\Paravis\Boot\g4d\grldr') function Find-Bytes([byte[]]$hay, [byte[]]$needle, [int]$from = 0) { for ($i = $from; $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 } function LineEnd([byte[]]$hay, [int]$from) { for ($i = $from; $i -lt $hay.Length; $i++) { if ($hay[$i] -eq 0x0A) { return $i } } return -1 } foreach ($f in $files) { if (-not (Test-Path $f)) { " нет файла $f"; continue } $b = [IO.File]::ReadAllBytes($f) $titleV = [Text.Encoding]::UTF8.GetBytes('title' + (' ' * 13) + 'Ventoy (ISO образы)') $titleB = [Text.Encoding]::UTF8.GetBytes('title' + (' ' * 6) + 'Запуск Windows 7 PE BootPass') $iV = Find-Bytes $b $titleV $iB = Find-Bytes $b $titleB if ($iV -lt 0 -or $iB -lt 0) { " $f : заголовки не найдены (V=$iV B=$iB)"; continue } if ($iB -lt $iV) { throw "$f : неожиданный порядок пунктов" } # конец каждого блока = конец строки команды (вторая строка после title) $vCmdStart = (LineEnd $b $iV) + 1 $vEnd = (LineEnd $b $vCmdStart) $bCmdStart = (LineEnd $b $iB) + 1 $bEnd = (LineEnd $b $bCmdStart) if ($vEnd -lt 0 -or $bEnd -lt 0) { throw "$f : не найдены границы" } $newV = [Text.Encoding]::UTF8.GetBytes("title" + (' ' * 13) + "Ventoy (ISO образы)`nchainloader (bd)/efi/Paravis/boot/g4d/Ventoy") $newB = [Text.Encoding]::UTF8.GetBytes("title" + (' ' * 6) + "Запуск Windows 7 PE BootPass`nchainloader (bd)/efi/Paravis/Boot/mgr/bootpass") # заменяем с конца, чтобы не сбить смещения $out = New-Object System.Collections.Generic.List[byte] $out.AddRange([byte[]]$b[0..($bCmdStart-1)]) $out.AddRange($newB) $out.AddRange([byte[]]$b[($bEnd)..($iV-1)]) $out.AddRange($newV) $out.AddRange([byte[]]$b[($vEnd)..($b.Length-1)]) [IO.File]::WriteAllBytes($f, $out.ToArray()) $nb = [IO.File]::ReadAllBytes($f) "--- $f : {0} байт (было {1})" -f $nb.Length, $b.Length $s = [Text.Encoding]::UTF8.GetString($nb) $j = $s.IndexOf('Ventoy (ISO') $ls = $s.LastIndexOf("`n", $j) + 1 $seg = $s.Substring($ls, 220) ($seg -split "`n") | Select-Object -First 4 | ForEach-Object { ' ' + ($_ -replace ' ', '·') } }