-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscratch.ps1
More file actions
34 lines (31 loc) · 1.15 KB
/
scratch.ps1
File metadata and controls
34 lines (31 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$bootloaderOffset = "0x8f8"
# Read everything before offset
$offset = [Convert]::ToInt32($bootloaderOffset, 16)
# Read the bytes before the offset
$prefix = [System.IO.File]::ReadAllBytes($source)[0..($offset - 1)]
# Read the content of the nmodified partition
$main = [System.IO.File]::ReadAllBytes($compressedFile)
# Combine the two
$combined = $prefix + $main
# Write to the output file
[System.IO.File]::WriteAllBytes($outputFile, $combined)
# Check that output file exists
if (-Not (Test-Path $outputFile)) {
Write-Host "Output file not found: $outputFile" -ForegroundColor Red
exit 1
} else {
Write-Host "Output file created successfully: $outputFile" -ForegroundColor Green
}
# Combine firmware and suffix
# read the content of the compressed partition
$main = [System.IO.File]::ReadAllBytes($compressedFile)
# Combine the two
$combined = $main + $suffix
[System.IO.File]::WriteAllBytes($outputFile, $combined)
# Check that output file exists
if (-Not (Test-Path $outputFile)) {
Write-Host "Output file not found: $outputFile" -ForegroundColor Red
exit 1
} else {
Write-Host "Output file created successfully: $outputFile" -ForegroundColor Green
}