1
0
mirror of https://github.com/dockur/windows.git synced 2026-07-27 21:42:36 +07:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Kroese b903e7d306 Update install.sh 2026-07-26 15:58:25 +02:00
Kroese bada80331d fix: Derive NT5 boot load size from extracted image (#1991) 2026-07-26 08:34:21 +02:00
Kroese c589e1be18 fix: Extract legacy boot images using virtual sectors (#1990) 2026-07-26 08:02:28 +02:00
2 changed files with 47 additions and 39 deletions
+43 -35
View File
@@ -1044,43 +1044,53 @@ EOC
getBootLoadSize() {
local iso="$1"
local desc="$2"
local boot_info value
local dir="$2"
local desc="$3"
local boot_info size value
if ! boot_info=$(isoinfo -d -i "$iso"); then
case "${DETECTED,,}" in
"win2k"* | "winxp"* | "win2003"* )
case "${DETECTED,,}" in
"win2k"* | "winxp"* | "win2003"* )
BOOT_LOAD_SIZE=4
return 0
;;
esac
if [ ! -s "$dir/$ETFS" ]; then
error "Failed to locate file \"$ETFS\" in $desc ISO image!"
return 1
fi
error "Failed to read boot image information from $desc ISO!"
return 1
fi
if ! size=$(stat -c%s "$dir/$ETFS"); then
error "Failed to determine boot image size from $desc ISO!"
return 1
fi
value=$(awk '/Nsect / { print $NF; exit }' <<< "$boot_info")
if (( size < 512 || size % 512 != 0 )); then
error "Invalid boot image size found in $desc ISO!"
return 1
fi
if [ -z "$value" ]; then
BOOT_LOAD_SIZE=$((size / 512))
;;
case "${DETECTED,,}" in
"win2k"* | "winxp"* | "win2003"* )
BOOT_LOAD_SIZE=4
return 0
;;
esac
* )
error "Failed to determine boot image load size from $desc ISO!"
return 1
fi
if ! boot_info=$(isoinfo -d -i "$iso"); then
error "Failed to read boot image information from $desc ISO!"
return 1
fi
if [[ ! "$value" =~ ^[0-9]+$ ]] || [ "${#value}" -gt 5 ]; then
error "Invalid boot image load size found in $desc ISO!"
return 1
fi
value=$(awk '/Nsect / { print $NF; exit }' <<< "$boot_info")
BOOT_LOAD_SIZE=$((10#$value))
if [ -z "$value" ]; then
error "Failed to determine boot image load size from $desc ISO!"
return 1
fi
if [[ ! "$value" =~ ^[0-9]+$ ]] || [ "${#value}" -gt 5 ]; then
error "Invalid boot image load size found in $desc ISO!"
return 1
fi
BOOT_LOAD_SIZE=$((10#$value))
;;
esac
if (( BOOT_LOAD_SIZE < 1 || BOOT_LOAD_SIZE > 65535 )); then
error "Invalid boot image load size found in $desc ISO!"
@@ -1097,9 +1107,9 @@ extractBootImage() {
local desc="$3"
local tmp="$TMP/boot-images"
local max_size=$((32 * 1024 * 1024))
local rc size offset image=""
local msg="using legacy extraction..."
local expected_size=$((BOOT_LOAD_SIZE * 512))
local boot_info
local -a images=()
@@ -1130,8 +1140,8 @@ extractBootImage() {
warn "The extracted BIOS boot image is empty, $msg"
elif ! size=$(stat -c%s "$image"); then
warn "Failed to determine the BIOS boot image size, $msg"
elif (( size > max_size )); then
warn "The extracted BIOS boot image exceeds 32 MB, $msg"
elif (( size != expected_size )); then
enabled "$DEBUG" && warn "The extracted BIOS boot image has an unexpected size, $msg"
else
if ! mv -f "$image" "$dir/$ETFS"; then
rm -rf "$tmp" || true
@@ -1162,8 +1172,6 @@ extractBootImage() {
rm -rf "$tmp" || true
local boot_info
if ! boot_info=$(isoinfo -d -i "$iso"); then
error "Failed to read boot image information from $desc ISO!"
return 1
@@ -1184,9 +1192,9 @@ extractBootImage() {
if ! dd \
"if=$iso" \
"of=$dir/$ETFS" \
bs=2048 \
bs=512 \
"count=$BOOT_LOAD_SIZE" \
"skip=$offset" \
"skip=$((offset * 4))" \
status=none; then
rm -f "$dir/$ETFS" || true
error "Failed to extract boot image from $desc ISO!"
+4 -4
View File
@@ -733,8 +733,8 @@ setMachine() {
BOOT_MODE="windows_legacy"
[ -z "${ADAPTER:-}" ] && ADAPTER="rtl8139" ;;
"winxp"* )
DISK_TYPE="blk"
"winxpx86"* )
DISK_TYPE="ide"
BOOT_MODE="windows_legacy"
[ -z "${SOUND:-}" ] && SOUND="usb-audio"
@@ -745,7 +745,7 @@ setMachine() {
fi
fi ;;
"win2003"* )
"win2003"* | "winxpx64"* )
DISK_TYPE="blk"
BOOT_MODE="windows_legacy"
[ -z "${SOUND:-}" ] && SOUND="usb-audio" ;;
@@ -784,7 +784,7 @@ prepareImage() {
if [[ "${BOOT_MODE,,}" == "windows_legacy" &&
"${DETECTED,,}" != "win9"* ]]; then
getBootLoadSize "$iso" "$desc" || return 1
getBootLoadSize "$iso" "$dir" "$desc" || return 1
fi
skipVersion "$DETECTED" && return 0