Add build, deploy and test sources
This commit is contained in:
1 parent
aeae61245d
commit
6035f75ea8
11 files changed
+360
No files matched your search
@@ -0,0 +1,25 @@
|
||||
param(
|
||||
[Parameter(Mandatory=$true)][int]$Disk,
|
||||
[Parameter(Mandatory=$true)][string]$Boot,
|
||||
[Parameter(Mandatory=$true)][string]$Out
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$bootData = [IO.File]::ReadAllBytes($Boot)
|
||||
if ($bootData.Length -lt 512) { throw "Bad boot.img: $Boot" }
|
||||
|
||||
$mbr = New-Object byte[] 512
|
||||
$fs = [IO.File]::Open("\\.\PhysicalDrive$Disk", [IO.FileMode]::Open, [IO.FileAccess]::Read, [IO.FileShare]::ReadWrite)
|
||||
try {
|
||||
$fs.Read($mbr, 0, 512) | Out-Null
|
||||
}
|
||||
finally {
|
||||
$fs.Close()
|
||||
}
|
||||
|
||||
# 0..439 — наш boot-код; 440..511 — текущая таблица разделов/подпись диска
|
||||
$img = New-Object byte[] 512
|
||||
[Array]::Copy($bootData, 0, $img, 0, 440)
|
||||
[Array]::Copy($mbr, 440, $img, 440, 72)
|
||||
[IO.File]::WriteAllBytes($Out, $img)
|
||||
Reference in new issue
Block a user