wok rev 19827
syslinux/iso2exe: follow boot flag
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Mar 08 15:32:40 2017 +0100 (2017-03-08) |
parents | 008ac2992c52 |
children | fd4b65b5c1de |
files | syslinux/stuff/iso2exe/bootiso.S syslinux/stuff/iso2exe/iso2exe.sh |
line diff
1.1 --- a/syslinux/stuff/iso2exe/bootiso.S Tue Mar 07 12:21:16 2017 +0100 1.2 +++ b/syslinux/stuff/iso2exe/bootiso.S Wed Mar 08 15:32:40 2017 +0100 1.3 @@ -32,14 +32,16 @@ 1.4 1.5 moved = 0x8000 1.6 start0: 1.7 - pushw %dx // restore %sp 1.8 - incw %bp // restore %bp 1.9 + //pushw %dx // restore %sp 1.10 + //incw %bp // restore %bp 1.11 xorw %bx, %bx 1.12 movw %bx, %ds 1.13 movb $0x7C, %bh 1.14 + pushw %ds 1.15 + popw %ss 1.16 + movw %bx, %sp 1.17 pushw %bx // return address 1.18 - pushaw 1.19 - movw %sp, %bp 1.20 + pushw %di 1.21 pushw %es // save %es:%di 1.22 cld 1.23 sti 1.24 @@ -47,7 +49,7 @@ 1.25 popw %es 1.26 call setreg 1.27 rep 1.28 - movsw 1.29 + movsw 1.30 movw $0x80, %dx 1.31 ljmp $0, $moved+start2 1.32 .byte 0 1.33 @@ -71,11 +73,11 @@ 1.34 1.35 dxfound: 1.36 call readsectorX // read isolinux boot sector 1.37 - movw %dx, 10(%bp) 1.38 cmpw (%bx), %cx 1.39 jnc puts // read fail or no isohydrid boot sector 1.40 + movw $patch,%si 1.41 popw %es 1.42 - popa // isolinux boot needs %es:%di and %dx 1.43 + popw %di // isolinux boot needs %es:%di and %dx 1.44 putsret: 1.45 ret 1.46 1.47 @@ -118,6 +120,58 @@ 1.48 ret 1.49 .org 0x01B8 1.50 1.51 +////////////////////////// partition boot code //////////////////////////////// 1.52 +// assume CS=DS=SS=0 BX=7C00 DL=<drive> SI=7DBE 1.53 + 1.54 + .org 0x7C00 1.55 + jmp bootpartition 1.56 + .org 0x7C03 1.57 + .org 0x7DBE 1.58 +table = moved+0x1BE 1.59 +patch: 1.60 + .byte 0,0,0 // head of original bs 1.61 +partcode: 1.62 + popw %di 1.63 + movw $table,%si 1.64 + call movepartition 1.65 + movb $4,%cl 1.66 + movw $table-16,%di 1.67 +next: 1.68 + addw $16,%di 1.69 + cmpb %ch,(%di) // boot flag ? 1.70 + loope next 1.71 + pushw %ds 1.72 + pushw %ds 1.73 + pushl 8(%di) 1.74 + pushw %ds 1.75 + pushw %bx 1.76 + pushw $1 1.77 + pushw $0x10 1.78 + movw %sp,%si // assume %ds = %ss 1.79 + movb $0x42,%ah 1.80 + pushw %bx 1.81 + cmpw $63,2(%di) // empty or isolinux partition ? 1.82 + jbe default 1.83 + int $0x13 1.84 +default: 1.85 + ret 1.86 + .org 0x7DEF 1.87 +bootpartition: 1.88 + pushw %ds 1.89 + popw %es 1.90 + pushw %si 1.91 + movw %bx,%di 1.92 + movsw 1.93 + movsb 1.94 + movw $partcode+0x100,%di 1.95 + pushw %di 1.96 +movepartition: 1.97 + movw $66/2,%cx 1.98 + rep 1.99 + movsw 1.100 + ret 1.101 + .org 0x7E00 1.102 + 1.103 .org 0x7F48 1.104 ////////////////////////////// DOS EXE code /////////////////////////////////// 1.105
2.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Tue Mar 07 12:21:16 2017 +0100 2.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Wed Mar 08 15:32:40 2017 +0100 2.3 @@ -118,12 +118,17 @@ 2.4 ddq if=/tmp/exe$$ of=$1 bs=1 count=24 seek=$((0x1A0)) skip=$((0x1A0)) conv=notrunc 2.5 ddq if=$2 bs=1 skip=$((0x1B8)) seek=$((0x1B8)) count=72 of=$1 conv=notrunc 2.6 store 510 $((0xAA55)) $1 2.7 - rm -f /tmp/exe$$ /tmp/coff$$ 2.8 i=$SIZE; OFS=$(($SIZE+512)) 2.9 [ -n "$mac" ] && OFS=$SIZE && i=1536 2.10 store 417 $(($i/512)) $1 8 2.11 printf "Moving syslinux hybrid boot record at %04X (512 bytes) ...\n" $i 2.12 ddq if=$2 bs=1 count=512 of=$1 seek=$i conv=notrunc 2.13 + if [ $(get $((0x7C00)) /tmp/exe$$) -eq 60649 ]; then 2.14 + ddq if=/tmp/exe$$ bs=1 count=66 skip=$((0x7DBE)) of=$1 seek=$(($i + 0x1BE)) conv=notrunc 2.15 + ddq if=$1 bs=1 count=3 skip=$i of=$1 seek=$(($i + 0x1BE)) conv=notrunc 2.16 + ddq if=/tmp/exe$$ bs=1 count=3 skip=$((0x7C00)) of=$1 seek=$i conv=notrunc 2.17 + fi 2.18 + rm -f /tmp/exe$$ /tmp/coff$$ 2.19 if [ -z "$RECURSIVE_PARTITION" ]; then 2.20 store 464 $((1+$i/512)) $1 8 2.21 store 470 $(($i/512)) $1 8 2.22 @@ -265,6 +270,11 @@ 2.23 fileofs $f 2.24 [ $SIZE -eq 0 ] || 2.25 ddq bs=1 count=$SIZE skip=$OFFSET if="$ISO" >$f 2.26 + if [ "$f" == "syslinux.mbr" ] && [ $(get 0 "$f") -eq 60649 ]; then 2.27 + ddq bs=1 conv=notrunc if="$f" of="$f" skip=$((0x1BE)) seek=0 count=3 2.28 + ddq bs=1 skip=$((0x1BE)) count=66 if="$ISO" | \ 2.29 + ddq bs=1 seek=$((0x1BE)) count=66 of="$f" conv=notrunc 2.30 + fi 2.31 done 2.32 } 2.33 2.34 @@ -522,7 +532,7 @@ 2.35 esac 2.36 case "$(get 0 $1)" in 2.37 23117) echo "The file $1 is already an EXE file." 1>&2 && exit 1;; 2.38 - 0) [ -x /usr/bin/isohybrid ] && isohybrid $1;; 2.39 + 0) [ -x /usr/bin/isohybrid ] && isohybrid -entry 2 $1;; 2.40 esac 2.41 2.42 gpt= ; [ $(get 466 $1) -eq 65263 ] && gpt=1