Initial source release
This commit is contained in:
commit
11301fae04
55 files changed
+2652
No files matched your search
@@ -0,0 +1,46 @@
|
||||
# Замена блока KRD в основном меню grub4dos (g4d\grldr), длина блока сохраняется.
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$f = 'F:\efi\Paravis\Boot\g4d\grldr'
|
||||
$bak = 'C:\PF\Ventoy\backup\g4d-grldr-KRD18.bin'
|
||||
|
||||
$b = [IO.File]::ReadAllBytes($f)
|
||||
$s = [Text.Encoding]::ASCII.GetString($b)
|
||||
|
||||
$start = $s.IndexOf('title Kaspersky Rescue Disk 18')
|
||||
if ($start -lt 0) { throw 'KRD-блок не найден' }
|
||||
$endMarker = "initrd`t%path%/initrd.xz`n"
|
||||
$endPos = $s.IndexOf($endMarker, $start)
|
||||
if ($endPos -lt 0) { throw 'конец KRD-блока не найден' }
|
||||
$blockLen = ($endPos + $endMarker.Length) - $start
|
||||
|
||||
$lines = @(
|
||||
'title Kaspersky Rescue Disk 24',
|
||||
'set path=/efi/Paravis/KRD',
|
||||
'set lang=ru',
|
||||
'find --set-root %path%/live/vmlinuz',
|
||||
"kernel`t%path%/live/vmlinuz boot=live components live-media-path=%path%/live locales=ru_RU.UTF-8",
|
||||
"initrd`t%path%/live/initrd.img"
|
||||
)
|
||||
$new = ($lines -join "`n") + "`n"
|
||||
if ($new.Length -gt $blockLen) { throw ("Новый блок длиннее старого: {0} > {1}" -f $new.Length, $blockLen) }
|
||||
$new = $new + (' ' * ($blockLen - $new.Length))
|
||||
if ($new.Length -ne $blockLen) { throw 'Ошибка выравнивания длины' }
|
||||
|
||||
if (-not (Test-Path $bak)) { Copy-Item $f $bak -Force; ' бэкап: ' + $bak }
|
||||
Set-ItemProperty -Path $f -Name IsReadOnly -Value $false -ErrorAction SilentlyContinue
|
||||
|
||||
$out = New-Object System.Collections.Generic.List[byte]
|
||||
$out.AddRange([byte[]]$b[0..($start-1)])
|
||||
$out.AddRange([Text.Encoding]::ASCII.GetBytes($new))
|
||||
$out.AddRange([byte[]]$b[($start+$blockLen)..($b.Length-1)])
|
||||
[IO.File]::WriteAllBytes($f, $out.ToArray())
|
||||
|
||||
$nb = [IO.File]::ReadAllBytes($f)
|
||||
"--- размер: {0} (было {1}), дельта {2}" -f $nb.Length, $b.Length, ($nb.Length - $b.Length)
|
||||
"--- блок KRD теперь:"
|
||||
$ns = [Text.Encoding]::ASCII.GetString($nb[$start..($start+$blockLen-1)])
|
||||
($ns -split "`n") | ForEach-Object { ' |' + $_ }
|
||||
"--- остались ли ссылки на старый KRD:"
|
||||
$all = [Text.Encoding]::ASCII.GetString($nb)
|
||||
" k-x86: {0}, initrd.xz: {1}, Disk 18: {2}" -f ([regex]::Matches($all,'k-x86').Count), ([regex]::Matches($all,'initrd\.xz').Count), ([regex]::Matches($all,'Disk 18').Count)
|
||||
"--- хвост (шрифт) на месте: {0}" -f $(if ($nb[$nb.Length-1] -eq $b[$b.Length-1]) { 'да' } else { 'ПРОВЕРИТЬ' })
|
||||
Reference in new issue
Block a user