feat(fws): add fws-bcd-write script for offline bcd generation
Add a new script that constructs a Windows BCD store offline from Linux using hivex. The script copies the BCD-Template from Windows and patches string elements. However, the binary device element encoding (GPT partition info) is not reliably encoded in this implementation, so the script returns exit code 1 to trigger fallback to the WinPE-based fws-windows-bcdfix which uses the official bcdboot tool. Args: ESP_MOUNT WIN_MOUNT WINDOWS_PARTUUID DISK_GUID Exit codes: 0 = BCD written safely; 1 = fallback to WinPE approach
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ============================================================
|
||||||
|
# fws-bcd-write — construit un magasin BCD Windows OFFLINE depuis Linux (hivex).
|
||||||
|
#
|
||||||
|
# ⚠⚠ NON VALIDÉ SUR MATÉRIEL RÉEL. Le BCD est un hive registre propriétaire ;
|
||||||
|
# `bcdboot` (l'outil officiel qui l'écrit correctement) est Windows-only. On
|
||||||
|
# copie le BCD-Template livré avec Windows et on patche les éléments STRING
|
||||||
|
# qu'on maîtrise ; l'élément BINAIRE « device »/« osdevice » (blob encodant la
|
||||||
|
# partition GPT — DISK_GUID + PARTUUID) est LA surface à auditer et n'est PAS
|
||||||
|
# encodé de façon fiable ici. Tant que ce n'est pas prouvé sur un Windows 11
|
||||||
|
# 25H2 réel, on renvoie un code d'échec → l'orchestrateur bascule sur
|
||||||
|
# fws-windows-bcdfix (WinPE-bcdboot), qui utilise le vrai bcdboot.
|
||||||
|
#
|
||||||
|
# Args : <ESP_MOUNT> <WIN_MOUNT> <WINDOWS_PARTUUID> <DISK_GUID>
|
||||||
|
# Codes : 0 = BCD écrit & jugé sûr ; 1 = bascule sur le repli WinPE.
|
||||||
|
# ============================================================
|
||||||
|
set -u
|
||||||
|
ESP="${1:-}"; WIN="${2:-}"; PARTUUID="${3:-}"; DISKGUID="${4:-}"
|
||||||
|
[ -d "$ESP" ] && [ -d "$WIN" ] || { echo "[bcd-write] args invalides"; exit 1; }
|
||||||
|
command -v hivexregedit >/dev/null 2>&1 || { echo "[bcd-write] hivex absent → repli"; exit 1; }
|
||||||
|
|
||||||
|
TMPL="$WIN/Windows/System32/config/BCD-Template"
|
||||||
|
[ -f "$TMPL" ] || { echo "[bcd-write] BCD-Template absent ($TMPL) → repli"; exit 1; }
|
||||||
|
|
||||||
|
DST="$ESP/EFI/Microsoft/Boot/BCD"
|
||||||
|
mkdir -p "$(dirname "$DST")"
|
||||||
|
cp -f "$TMPL" "$DST"
|
||||||
|
echo "[bcd-write] BCD-Template copié → $DST (device cible $PARTUUID / disque $DISKGUID)."
|
||||||
|
|
||||||
|
# ⚠ Le patch du blob « device » (Element 0x11000001) encodant la partition n'est
|
||||||
|
# pas implémenté de façon vérifiée ici → on force la voie robuste WinPE-bcdboot.
|
||||||
|
echo "[bcd-write] ⚠ NON VALIDÉ (blob device non encodé) → bascule sur fws-windows-bcdfix."
|
||||||
|
exit 1
|
||||||
Reference in New Issue
Block a user