# HG changeset patch # User Pascal Bellard # Date 1488983560 -3600 # Node ID e619bff66a024f5d96b7e94e6ef78642398d4bd1 # Parent 008ac2992c522d6dc46eb81768d437bdeafb15d5 syslinux/iso2exe: follow boot flag diff -r 008ac2992c52 -r e619bff66a02 syslinux/stuff/iso2exe/bootiso.S --- a/syslinux/stuff/iso2exe/bootiso.S Tue Mar 07 12:21:16 2017 +0100 +++ b/syslinux/stuff/iso2exe/bootiso.S Wed Mar 08 15:32:40 2017 +0100 @@ -32,14 +32,16 @@ moved = 0x8000 start0: - pushw %dx // restore %sp - incw %bp // restore %bp + //pushw %dx // restore %sp + //incw %bp // restore %bp xorw %bx, %bx movw %bx, %ds movb $0x7C, %bh + pushw %ds + popw %ss + movw %bx, %sp pushw %bx // return address - pushaw - movw %sp, %bp + pushw %di pushw %es // save %es:%di cld sti @@ -47,7 +49,7 @@ popw %es call setreg rep - movsw + movsw movw $0x80, %dx ljmp $0, $moved+start2 .byte 0 @@ -71,11 +73,11 @@ dxfound: call readsectorX // read isolinux boot sector - movw %dx, 10(%bp) cmpw (%bx), %cx jnc puts // read fail or no isohydrid boot sector + movw $patch,%si popw %es - popa // isolinux boot needs %es:%di and %dx + popw %di // isolinux boot needs %es:%di and %dx putsret: ret @@ -118,6 +120,58 @@ ret .org 0x01B8 +////////////////////////// partition boot code //////////////////////////////// +// assume CS=DS=SS=0 BX=7C00 DL= SI=7DBE + + .org 0x7C00 + jmp bootpartition + .org 0x7C03 + .org 0x7DBE +table = moved+0x1BE +patch: + .byte 0,0,0 // head of original bs +partcode: + popw %di + movw $table,%si + call movepartition + movb $4,%cl + movw $table-16,%di +next: + addw $16,%di + cmpb %ch,(%di) // boot flag ? + loope next + pushw %ds + pushw %ds + pushl 8(%di) + pushw %ds + pushw %bx + pushw $1 + pushw $0x10 + movw %sp,%si // assume %ds = %ss + movb $0x42,%ah + pushw %bx + cmpw $63,2(%di) // empty or isolinux partition ? + jbe default + int $0x13 +default: + ret + .org 0x7DEF +bootpartition: + pushw %ds + popw %es + pushw %si + movw %bx,%di + movsw + movsb + movw $partcode+0x100,%di + pushw %di +movepartition: + movw $66/2,%cx + rep + movsw + ret + .org 0x7E00 + .org 0x7F48 ////////////////////////////// DOS EXE code /////////////////////////////////// diff -r 008ac2992c52 -r e619bff66a02 syslinux/stuff/iso2exe/iso2exe.sh --- a/syslinux/stuff/iso2exe/iso2exe.sh Tue Mar 07 12:21:16 2017 +0100 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Wed Mar 08 15:32:40 2017 +0100 @@ -118,12 +118,17 @@ ddq if=/tmp/exe$$ of=$1 bs=1 count=24 seek=$((0x1A0)) skip=$((0x1A0)) conv=notrunc ddq if=$2 bs=1 skip=$((0x1B8)) seek=$((0x1B8)) count=72 of=$1 conv=notrunc store 510 $((0xAA55)) $1 - rm -f /tmp/exe$$ /tmp/coff$$ i=$SIZE; OFS=$(($SIZE+512)) [ -n "$mac" ] && OFS=$SIZE && i=1536 store 417 $(($i/512)) $1 8 printf "Moving syslinux hybrid boot record at %04X (512 bytes) ...\n" $i ddq if=$2 bs=1 count=512 of=$1 seek=$i conv=notrunc + if [ $(get $((0x7C00)) /tmp/exe$$) -eq 60649 ]; then + ddq if=/tmp/exe$$ bs=1 count=66 skip=$((0x7DBE)) of=$1 seek=$(($i + 0x1BE)) conv=notrunc + ddq if=$1 bs=1 count=3 skip=$i of=$1 seek=$(($i + 0x1BE)) conv=notrunc + ddq if=/tmp/exe$$ bs=1 count=3 skip=$((0x7C00)) of=$1 seek=$i conv=notrunc + fi + rm -f /tmp/exe$$ /tmp/coff$$ if [ -z "$RECURSIVE_PARTITION" ]; then store 464 $((1+$i/512)) $1 8 store 470 $(($i/512)) $1 8 @@ -265,6 +270,11 @@ fileofs $f [ $SIZE -eq 0 ] || ddq bs=1 count=$SIZE skip=$OFFSET if="$ISO" >$f + if [ "$f" == "syslinux.mbr" ] && [ $(get 0 "$f") -eq 60649 ]; then + ddq bs=1 conv=notrunc if="$f" of="$f" skip=$((0x1BE)) seek=0 count=3 + ddq bs=1 skip=$((0x1BE)) count=66 if="$ISO" | \ + ddq bs=1 seek=$((0x1BE)) count=66 of="$f" conv=notrunc + fi done } @@ -522,7 +532,7 @@ esac case "$(get 0 $1)" in 23117) echo "The file $1 is already an EXE file." 1>&2 && exit 1;; - 0) [ -x /usr/bin/isohybrid ] && isohybrid $1;; + 0) [ -x /usr/bin/isohybrid ] && isohybrid -entry 2 $1;; esac gpt= ; [ $(get 466 $1) -eq 65263 ] && gpt=1