Documentation Index
Fetch the complete documentation index at: https://mintlify.com/garatc/BitUnlocker/llms.txt
Use this file to discover all available pages before exploring further.
patch_sdi.py builds a modified SDI file by appending a custom WinRE.wim to a stock boot.sdi and patching the WIM blob entry in the blob table so that the Windows boot manager loads the custom WIM instead of the original. The stock boot.sdi is never touched — the script always writes a new output file.
The stock SDI is never modified. The script reads it, then creates a separate
patched copy at the output path you specify.
Usage
Arguments
Path to the stock
boot.sdi file. This file is read but never modified —
a patched copy is written to the output path.Path to the custom WIM file to append — for example, a modified
WinRE.wim
that has cmd.exe set as the launch application.Output path for the patched SDI file. Must differ from the input
--sdi
path; the script exits with an error if both resolve to the same file.How it works
Read and validate the stock SDI
The script reads the entire stock SDI into memory and checks that the first
eight bytes match the
$SDI0001 signature. A warning is printed if the
signature does not match, but execution continues.Locate the WIM and PART blob entries
The blob table lives at offset
0x200 and contains 64 entries of 64 bytes
each. The script scans those entries for the WIM\x00 and PART type
tags. It exits with an error if either tag is not found.Calculate an aligned append offset
The append position is computed by rounding the stock SDI size up to
the next 4 KiB page boundary (
align_up(stock_size, 0x1000)). Any gap
between the end of the stock SDI and that boundary is filled with null
bytes.Copy the stock SDI and append the custom WIM
The stock SDI is copied verbatim to the output path using
shutil.copy2. The padding bytes are then appended, followed by the
custom WIM in 1 MiB chunks.Patch the WIM blob entry
The script reopens the output file in read-write mode and writes two
64-bit little-endian values into the WIM blob entry:
data_offset(at entry offset0x10) — set to the calculated append position so the boot manager finds the custom WIM.data_size(at entry offset0x18) — set to the byte size of the custom WIM file.
Print the ramdisk buffer layout summary
After patching, the script prints a map showing where each region will
reside in the ramdisk buffer when the boot manager loads the SDI: the
header and blob table, the PART (NTFS) data, the appended custom WIM, and
the position of the trusted WIM that the boot manager hash-verifies but
does not actually boot from.
Example output
Verify the result
After patching, runparse_sdi.py on the output file to confirm the blob
table is correct before booting:
0x501000 (or whatever append offset
was printed in the patch plan), that the WIM entry size matches your custom WIM
file size, and that no WARNING: extends past EOF lines appear. See
parse_sdi.py for full details on the output.
Getting a custom WinRE.wim
The custom WIM must havecmd.exe configured as the WinRE launch application
so that a command prompt opens automatically after the SDI is loaded, giving
access to the decrypted OS volume. Building a custom WIM requires mounting and
modifying a stock WinRE.wim.
If you do not want to build your own, the pre-built boot_patched.sdi
available in the project Releases already contains a WIM with cmd.exe set as
the launch application — download it and place it directly in USB/sdi/ or
TFTP-root/sdi/ without running this script.