# HG changeset patch # User Pascal Bellard # Date 1426932953 -3600 # Node ID 6a2e6eb3573584e2663fdae3cd8c77c77d264b03 # Parent e47d84d4acac51e13f8678c6f40800b4d093e122 syslinux/iso2exe: one boot checksum only diff -r e47d84d4acac -r 6a2e6eb35735 syslinux/stuff/iso2exe/bootiso.S --- a/syslinux/stuff/iso2exe/bootiso.S Sat Mar 21 10:25:00 2015 +0100 +++ b/syslinux/stuff/iso2exe/bootiso.S Sat Mar 21 11:15:53 2015 +0100 @@ -24,13 +24,13 @@ .word 0xFFF0 // Initial (relative) CS value initramfssize: .word 0 // File address of relocation table -id: - .word 0 // Overlay number -fdcnt: // File address of relocation table +fdcnt: // Overlay number .byte 0 // Bootstrap floppy sector count + .ascii "slitaz" /////////////////////// Master Boot Record code ////////////////////////////// +moved = 0x8000 start0: pushw %dx // restore %sp incw %bp // restore %bp @@ -49,17 +49,59 @@ rep movsw movw $0x80, %dx - ljmp $0, $0x0600+start2 - - .org 60 - .long 0x0080 // PE header offset + ljmp $0, $moved+start2 + .byte 0 +// .org 60 +// .long 0x0080 // PE header offset + .org 64 end_header: -chksum: - .word 0 comstart: .word 0 - .org 68 + .org 66 +dxloop: +start2: + call readsector1 // look for the boot device + repe + cmpsw + je dxfound + movb $0, %cl // ch = 0 + addb $0x7D, %dl // try every hard disk + jno dxloop + +dxfound: + call readsectorX // read isolinux boot sector + movw %dx, 10(%bp) + cmpw (%bx), %cx + jnc puts // read fail or no isohydrid boot sector + popw %es + popa +putsret: + ret + +putstrlp: + movw $7, %bx + movb $0xE, %ah + int $0x10 +error: + lodsb + cmp $1, %al + jg putstrlp + jz putsret +puts: + movb $0x80, %ah + xchgw %ax, %si + jnc error +halt: + hlt + jmp halt +nobsmsg: + .asciz "No isolinux." + + .org 0x0080 +////////////////////////////// EXE/PE header ////////////////////////////////// + + .org 0x01A0 readsectorX: // read isolinux boot sector movb $0xA5, %cl // patched by installer readsector1: @@ -70,62 +112,18 @@ int $0x13 setreg: movw %bx, %si - movw $0x0600, %di + movw $moved, %di movw $0x0100, %cx -return: + movb $nobsmsg, %al ret -dxloop: -start2: - call readsector1 // look for the boot device - repe - cmpsw - je dxfound - movb $0, %cl // ch = 0 - addb $0x7D, %dl // try every hard disk - jno dxloop -dxfound: - call readsectorX // read isolinux boot sector - movw %dx, 10(%bp) - call checkboot - .asciz "No isolinux bs" + .org 0x01B8 - .org 0x0080 -////////////////////////////// EXE/PE header ////////////////////////////////// - - .org 0x01A0 -checkboot: - cmpw %cx, (%bx) - popw %si - jc error // read fail or no isohydrid boot sector - popw %es - popa -putsret: - ret -putstrlp: - movw $7, %bx - movb $0xE, %ah - int $0x10 -error: - lodsb - cmp $1, %al - jg putstrlp - jz putsret -putstr: - movb $0x80, %ah - xchgw %ax, %si - jnc error -halt: - hlt - jmp halt - .org 0x01BE - - .org 0x7F26 + .org 0x7F48 ////////////////////////////// DOS EXE code /////////////////////////////////// exestart: cld - movw $0x100, %si - movw -127(%si), %ax + movw 129, %ax cmpb $0x2F, %al je ishelp cmpw $0x2F20, %ax @@ -134,24 +132,12 @@ cwd // clear dx pushw %dx // dos exit() je abort - pushw %si int $0x21 // get DOS version - popw %di // %di = 0x100: .COM start address addb $-3, %al - movb $EXESTR(noDOS3), %al - jnc abort - movw $(EXELOC(0x8000))/2, %cx -chklp: - lodsw - addw %ax, %dx // break C - loop chklp -chked: - movw $0x1000+EXESTR(chkerr), %ax - je tst386 // dx == 0 ? + movw $0x1000+EXESTR(noDOS3), %ax + jc tst386 abort: -puts: - clc - jmp putstr + jmp puts tst386: pushfw // save flags @@ -165,7 +151,7 @@ popfw // restore flags (IOPL) addb %ah, %bh // test F0 and 00 cases cmpb %ah, %bh - movb $EXESTR(no386), %al + movw $0x100, %di jbe is86 // C=8086/80186, Z=80286 is386: smsww %ax // not privileged @@ -176,10 +162,11 @@ incl %eax movb $EXESTR(rmPaging), %al js abort - movb $EXESTR(realmodemsg), %al + inc %ax + //movb $EXESTR(realmodemsg), %al realmode: + call puts is86: - call puts movw comstart-end_header(%di), %si // .com address pushw %di movb $0x7C/2, %ch // 31K-31.5K, > com length @@ -193,8 +180,8 @@ jnc realmode // %si = 0 tstvcpi: pushw %ds - movw %dx, %ds // %dx = 0 - movw 0x67*4+2, %ds + movw %si, %ds // %si = 10 + movw (0x67*4)+2-(16*10)-0x100(%di), %ds lodsw xorw $0x4D45, %ax // EM(MX) or EM(MQ) lodsw @@ -222,18 +209,13 @@ vm86modemsg: // --------------- Must be in 7F40 7FFF range ------------------------ - .ascii "vm86" // vm86 mode + .ascii "86" // 86 mode .byte EXESTR(mode) ERRvcpi: - .ascii "EMM" // EMM386 need -no386: - .ascii "386" // 386 need + .ascii "VCPI4" // VCPI4? .byte EXESTR(need) -chkerr: - .ascii "Bad c" // Bad code - .byte EXESTR(ode) rmPaging: - .ascii "Un" // Unreal mode + .ascii "X" // Xreal mode realmodemsg: .ascii "real" // real mode // --------------- Must be in 7FC0 7FFF range ------------------------ @@ -243,15 +225,15 @@ .ascii "ode" .byte EXESTR(eol) noDOS3: - .ascii "DOS3" // DOS3 need + .ascii "DOS3" // DOS3? need: - .ascii " need" + .ascii "?" .byte EXESTR(eol) help: .ascii "SliTaz iso boot" // SliTaz iso boot eol: .ascii "\r\n" - .byte 1 // putstr will return + .byte 1 // puts will return .space 16,0 // ISO md5 .org 0x8000 diff -r e47d84d4acac -r 6a2e6eb35735 syslinux/stuff/iso2exe/init --- a/syslinux/stuff/iso2exe/init Sat Mar 21 10:25:00 2015 +0100 +++ b/syslinux/stuff/iso2exe/init Sat Mar 21 11:15:53 2015 +0100 @@ -126,7 +126,7 @@ gettazboot() { echo "Creating $(basename $1) ..." - O=$(($(get 66 /mnt/$ISO) - 0xC0)) + O=$(($(get 64 /mnt/$ISO) - 0xC0)) L=$(($(get 20 /mnt/$ISO) - 0xC0 - $(get 24 /mnt/$ISO) - $O)) S=$((32+$L)) P=$((($S+511)/512)) @@ -692,10 +692,10 @@ " 10 70 [ $? -eq 0 ] || return ddq if=/mnt/$ISO of=/tmp/bootiso bs=1 count=512 \ - skip=$(( $(get 66 /mnt/$ISO) - $sz )) + skip=$(( $(get 64 /mnt/$ISO) - $sz )) echo "$ISO" | ddq of=/tmp/bootiso bs=512 seek=1 count=1 ddq if=/mnt/$ISO of=/tmp/bootiso bs=1 count=$sz seek=2 \ - skip=$(( $(get 66 /mnt/$ISO) - $sz + 512 )) + skip=$(( $(get 64 /mnt/$ISO) - $sz + 512 )) mkfloppy /tmp/bootiso rm -f /tmp/bootiso } diff -r e47d84d4acac -r 6a2e6eb35735 syslinux/stuff/iso2exe/iso2exe.c --- a/syslinux/stuff/iso2exe/iso2exe.c Sat Mar 21 10:25:00 2015 +0100 +++ b/syslinux/stuff/iso2exe/iso2exe.c Sat Mar 21 11:15:53 2015 +0100 @@ -29,7 +29,7 @@ } } -static int domd5 = 0; +static int skipmd5 = 0; #define ALIGN1 typedef struct { @@ -268,7 +268,7 @@ readsector(0UL); n = BUFFERSZ; if (WORD(buffer) == 23117) { - readsector((unsigned long) buffer[69]); + readsector((unsigned long) buffer[417]); n = 0; } lseek(fd, 0UL, SEEK_SET); @@ -294,7 +294,7 @@ readsector(lba); if (LONG(buffer + 64) != 1886961915UL) return HYBRIDERR; - isohybrid = bootiso[69] * 512; + isohybrid = bootiso[417] * 512; LONG(bootiso + isohybrid + 432) = lba * 4; LONG(bootiso + isohybrid + 440) = rand(); LONG(bootiso + isohybrid + partition) = 0x10080UL; @@ -322,35 +322,30 @@ } /* Install iso2exe boot sector */ - WORD(bootiso + 26) = rand(); + LONG(bootiso + 440) = time(NULL); /* read tazlito flavor data */ lseek(fd, 1024UL, SEEK_SET); read(fd, tazlitoinfo, sizeof(tazlitoinfo)); /* Update iso image */ - n = (bootiso[69] + 1) * 512; + n = (bootiso[417] + 1) * 512; lseek(fd, 0UL, SEEK_SET); write(fd, bootiso, n); /* EXE/PE + isohybrid mbr */ write(fd, tazlitoinfo, sizeof(tazlitoinfo)); write(fd, bootiso + n, BOOTISOSZ - n); /* COM + rootfs + EXE/DOS */ - if (domd5) { + /* Compute the boot checksums */ + if (!skipmd5) { puts(bootiso + MD5MSG); md5sum(); - } - - /* Compute the boot checksums */ - if ((WORD(bootiso + 64) = chksum(66, 32768)) != 0) { - if (domd5) { - lseek(fd, 0UL, SEEK_SET); - write(fd, bootiso, 512); - n = WORD(bootiso + 2) - 512*(WORD(bootiso + 4) - 1); - WORD(bootiso + 18) = chksum(0, (unsigned short) n) - 1; - } lseek(fd, 0UL, SEEK_SET); write(fd, bootiso, 512); + n = WORD(bootiso + 2) - 512*(WORD(bootiso + 4) - 1); + WORD(bootiso + 18) = chksum(0, (unsigned short) n) - 1; } + lseek(fd, 0UL, SEEK_SET); + write(fd, bootiso, 512); close(fd); status = 0; return SUCCESSMSG; @@ -364,7 +359,7 @@ while ((unsigned)(*s - '-') <= ('/' - '-')) s++; switch (*s | 0x20) { case 'f' : forced++; break; - case 'm' : domd5++; break; + case 'q' : skipmd5++; break; case 'u' : uninstall++; break; } } diff -r e47d84d4acac -r 6a2e6eb35735 syslinux/stuff/iso2exe/iso2exe.sh --- a/syslinux/stuff/iso2exe/iso2exe.sh Sat Mar 21 10:25:00 2015 +0100 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Sat Mar 21 11:15:53 2015 +0100 @@ -71,7 +71,7 @@ OFS=$(( $OFS - $SIZE )) printf "Adding DOS boot file at %04X (%d bytes) ...\n" $OFS $SIZE $0 --get boot.com | ddq of=$1 bs=1 seek=$OFS conv=notrunc - store 66 $(($OFS+0xC0)) $1 + store 64 $(($OFS+0xC0)) $1 } add_win32exe() @@ -86,9 +86,9 @@ store $((0xF4)) $((16 - 12)) $1 ddq if=$1 of=/tmp/coff$$ bs=1 skip=$((0x178)) count=$((0x88)) ddq if=/tmp/coff$$ of=$1 conv=notrunc bs=1 seek=$((0x178 - 12*8)) - ddq if=/tmp/exe$$ of=$1 bs=1 count=30 seek=$((0x1A0)) skip=$((0x1A0)) conv=notrunc - ddq if=$2 bs=1 skip=$((0x1BE)) seek=$((0x1BE)) count=66 of=$1 conv=notrunc - store 69 $(($SIZE/512)) $1 8 + 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 417 $(($SIZE/512)) $1 8 store 510 $((0xAA55)) $1 rm -f /tmp/exe$$ /tmp/coff$$ printf "Moving syslinux hybrid boot record at %04X (512 bytes) ...\n" $SIZE @@ -107,7 +107,7 @@ ddq of=$1 bs=1 count=512 seek=$OFS conv=notrunc $0 --get bootfd.bin | \ ddq of=$1 bs=1 skip=1024 seek=$((512 + $OFS)) conv=notrunc - store 28 $(($SIZE/512)) $1 8 + store 26 $(($SIZE/512)) $1 8 fi } case "$1" in @@ -211,7 +211,7 @@ fi done <