39 lines
1.8 KiB
PowerShell
39 lines
1.8 KiB
PowerShell
# Заливка ia32: конфиг без KRD + картинки без строки Kaspersky.
|
|
$ErrorActionPreference = 'Stop'
|
|
Add-Type -AssemblyName System.Drawing
|
|
if (Get-Process -Name vmware-vmx -ErrorAction SilentlyContinue) { throw 'VM запущена' }
|
|
|
|
# 1) конфиг
|
|
Copy-Item 'C:\PF\KRD\images\xor\x86.xor' 'F:\efi\Boot\x86.xor' -Force
|
|
' x86.xor: {0:N0} байт' -f (Get-Item 'F:\efi\Boot\x86.xor').Length
|
|
|
|
# 2) картинки (PNG -> BMP с исходным заголовком)
|
|
$map = @(
|
|
@{ png='C:\PF\KRD\images\x86-1-nokrd.png'; src='C:\PF\PSD\UEFI\x86\main\main1.bmp'; dst='F:\efi\Boot\1x86.bmp' },
|
|
@{ png='C:\PF\KRD\images\x86-2-nokrd.png'; src='C:\PF\PSD\UEFI\x86\main\main2.bmp'; dst='F:\efi\Boot\2x86.bmp' }
|
|
)
|
|
foreach ($m in $map) {
|
|
$srcBytes = [IO.File]::ReadAllBytes($m.src)
|
|
$off = [BitConverter]::ToUInt32($srcBytes, 10)
|
|
$w = [BitConverter]::ToInt32($srcBytes, 18); $h = [BitConverter]::ToInt32($srcBytes, 22)
|
|
$img = [System.Drawing.Image]::FromFile($m.png)
|
|
$bmp = New-Object System.Drawing.Bitmap $img; $img.Dispose()
|
|
$rowBytes = $w * 3
|
|
$pix = New-Object byte[] ($rowBytes * $h)
|
|
for ($y = 0; $y -lt $h; $y++) {
|
|
$srcY = $h - 1 - $y
|
|
for ($x = 0; $x -lt $w; $x++) {
|
|
$c = $bmp.GetPixel($x, $srcY)
|
|
$o = $y * $rowBytes + $x * 3
|
|
$pix[$o] = $c.B; $pix[$o+1] = $c.G; $pix[$o+2] = $c.R
|
|
}
|
|
}
|
|
$bmp.Dispose()
|
|
$outBytes = New-Object byte[] $srcBytes.Length
|
|
[Array]::Copy($srcBytes, $outBytes, $srcBytes.Length)
|
|
[Array]::Copy($pix, 0, $outBytes, [int]$off, $pix.Length)
|
|
[IO.File]::WriteAllBytes($m.dst, $outBytes)
|
|
' {0}: {1:N0} байт' -f $m.dst, (Get-Item $m.dst).Length
|
|
}
|
|
'--- свободно: {0:N0} МБ' -f ((Get-Volume -DriveLetter F).SizeRemaining/1MB)
|