wok-current rev 17810
syslinux/iso2exe: one boot checksum only
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Mar 21 11:15:53 2015 +0100 (2015-03-21) |
parents | e47d84d4acac |
children | 57b29da0fd99 |
files | syslinux/stuff/iso2exe/bootiso.S syslinux/stuff/iso2exe/init syslinux/stuff/iso2exe/iso2exe.c syslinux/stuff/iso2exe/iso2exe.sh syslinux/stuff/iso2exe/taziso |
line diff
1.1 --- a/syslinux/stuff/iso2exe/bootiso.S Sat Mar 21 10:25:00 2015 +0100 1.2 +++ b/syslinux/stuff/iso2exe/bootiso.S Sat Mar 21 11:15:53 2015 +0100 1.3 @@ -24,13 +24,13 @@ 1.4 .word 0xFFF0 // Initial (relative) CS value 1.5 initramfssize: 1.6 .word 0 // File address of relocation table 1.7 -id: 1.8 - .word 0 // Overlay number 1.9 -fdcnt: // File address of relocation table 1.10 +fdcnt: // Overlay number 1.11 .byte 0 // Bootstrap floppy sector count 1.12 + .ascii "slitaz" 1.13 1.14 /////////////////////// Master Boot Record code ////////////////////////////// 1.15 1.16 +moved = 0x8000 1.17 start0: 1.18 pushw %dx // restore %sp 1.19 incw %bp // restore %bp 1.20 @@ -49,17 +49,59 @@ 1.21 rep 1.22 movsw 1.23 movw $0x80, %dx 1.24 - ljmp $0, $0x0600+start2 1.25 - 1.26 - .org 60 1.27 - .long 0x0080 // PE header offset 1.28 + ljmp $0, $moved+start2 1.29 + .byte 0 1.30 +// .org 60 1.31 +// .long 0x0080 // PE header offset 1.32 + .org 64 1.33 end_header: 1.34 -chksum: 1.35 - .word 0 1.36 comstart: 1.37 .word 0 1.38 1.39 - .org 68 1.40 + .org 66 1.41 +dxloop: 1.42 +start2: 1.43 + call readsector1 // look for the boot device 1.44 + repe 1.45 + cmpsw 1.46 + je dxfound 1.47 + movb $0, %cl // ch = 0 1.48 + addb $0x7D, %dl // try every hard disk 1.49 + jno dxloop 1.50 + 1.51 +dxfound: 1.52 + call readsectorX // read isolinux boot sector 1.53 + movw %dx, 10(%bp) 1.54 + cmpw (%bx), %cx 1.55 + jnc puts // read fail or no isohydrid boot sector 1.56 + popw %es 1.57 + popa 1.58 +putsret: 1.59 + ret 1.60 + 1.61 +putstrlp: 1.62 + movw $7, %bx 1.63 + movb $0xE, %ah 1.64 + int $0x10 1.65 +error: 1.66 + lodsb 1.67 + cmp $1, %al 1.68 + jg putstrlp 1.69 + jz putsret 1.70 +puts: 1.71 + movb $0x80, %ah 1.72 + xchgw %ax, %si 1.73 + jnc error 1.74 +halt: 1.75 + hlt 1.76 + jmp halt 1.77 +nobsmsg: 1.78 + .asciz "No isolinux." 1.79 + 1.80 + .org 0x0080 1.81 +////////////////////////////// EXE/PE header ////////////////////////////////// 1.82 + 1.83 + .org 0x01A0 1.84 readsectorX: // read isolinux boot sector 1.85 movb $0xA5, %cl // patched by installer 1.86 readsector1: 1.87 @@ -70,62 +112,18 @@ 1.88 int $0x13 1.89 setreg: 1.90 movw %bx, %si 1.91 - movw $0x0600, %di 1.92 + movw $moved, %di 1.93 movw $0x0100, %cx 1.94 -return: 1.95 + movb $nobsmsg, %al 1.96 ret 1.97 -dxloop: 1.98 -start2: 1.99 - call readsector1 // look for the boot device 1.100 - repe 1.101 - cmpsw 1.102 - je dxfound 1.103 - movb $0, %cl // ch = 0 1.104 - addb $0x7D, %dl // try every hard disk 1.105 - jno dxloop 1.106 -dxfound: 1.107 - call readsectorX // read isolinux boot sector 1.108 - movw %dx, 10(%bp) 1.109 - call checkboot 1.110 - .asciz "No isolinux bs" 1.111 + .org 0x01B8 1.112 1.113 - .org 0x0080 1.114 -////////////////////////////// EXE/PE header ////////////////////////////////// 1.115 - 1.116 - .org 0x01A0 1.117 -checkboot: 1.118 - cmpw %cx, (%bx) 1.119 - popw %si 1.120 - jc error // read fail or no isohydrid boot sector 1.121 - popw %es 1.122 - popa 1.123 -putsret: 1.124 - ret 1.125 -putstrlp: 1.126 - movw $7, %bx 1.127 - movb $0xE, %ah 1.128 - int $0x10 1.129 -error: 1.130 - lodsb 1.131 - cmp $1, %al 1.132 - jg putstrlp 1.133 - jz putsret 1.134 -putstr: 1.135 - movb $0x80, %ah 1.136 - xchgw %ax, %si 1.137 - jnc error 1.138 -halt: 1.139 - hlt 1.140 - jmp halt 1.141 - .org 0x01BE 1.142 - 1.143 - .org 0x7F26 1.144 + .org 0x7F48 1.145 ////////////////////////////// DOS EXE code /////////////////////////////////// 1.146 1.147 exestart: 1.148 cld 1.149 - movw $0x100, %si 1.150 - movw -127(%si), %ax 1.151 + movw 129, %ax 1.152 cmpb $0x2F, %al 1.153 je ishelp 1.154 cmpw $0x2F20, %ax 1.155 @@ -134,24 +132,12 @@ 1.156 cwd // clear dx 1.157 pushw %dx // dos exit() 1.158 je abort 1.159 - pushw %si 1.160 int $0x21 // get DOS version 1.161 - popw %di // %di = 0x100: .COM start address 1.162 addb $-3, %al 1.163 - movb $EXESTR(noDOS3), %al 1.164 - jnc abort 1.165 - movw $(EXELOC(0x8000))/2, %cx 1.166 -chklp: 1.167 - lodsw 1.168 - addw %ax, %dx // break C 1.169 - loop chklp 1.170 -chked: 1.171 - movw $0x1000+EXESTR(chkerr), %ax 1.172 - je tst386 // dx == 0 ? 1.173 + movw $0x1000+EXESTR(noDOS3), %ax 1.174 + jc tst386 1.175 abort: 1.176 -puts: 1.177 - clc 1.178 - jmp putstr 1.179 + jmp puts 1.180 1.181 tst386: 1.182 pushfw // save flags 1.183 @@ -165,7 +151,7 @@ 1.184 popfw // restore flags (IOPL) 1.185 addb %ah, %bh // test F0 and 00 cases 1.186 cmpb %ah, %bh 1.187 - movb $EXESTR(no386), %al 1.188 + movw $0x100, %di 1.189 jbe is86 // C=8086/80186, Z=80286 1.190 is386: 1.191 smsww %ax // not privileged 1.192 @@ -176,10 +162,11 @@ 1.193 incl %eax 1.194 movb $EXESTR(rmPaging), %al 1.195 js abort 1.196 - movb $EXESTR(realmodemsg), %al 1.197 + inc %ax 1.198 + //movb $EXESTR(realmodemsg), %al 1.199 realmode: 1.200 + call puts 1.201 is86: 1.202 - call puts 1.203 movw comstart-end_header(%di), %si // .com address 1.204 pushw %di 1.205 movb $0x7C/2, %ch // 31K-31.5K, > com length 1.206 @@ -193,8 +180,8 @@ 1.207 jnc realmode // %si = 0 1.208 tstvcpi: 1.209 pushw %ds 1.210 - movw %dx, %ds // %dx = 0 1.211 - movw 0x67*4+2, %ds 1.212 + movw %si, %ds // %si = 10 1.213 + movw (0x67*4)+2-(16*10)-0x100(%di), %ds 1.214 lodsw 1.215 xorw $0x4D45, %ax // EM(MX) or EM(MQ) 1.216 lodsw 1.217 @@ -222,18 +209,13 @@ 1.218 1.219 vm86modemsg: 1.220 // --------------- Must be in 7F40 7FFF range ------------------------ 1.221 - .ascii "vm86" // vm86 mode 1.222 + .ascii "86" // 86 mode 1.223 .byte EXESTR(mode) 1.224 ERRvcpi: 1.225 - .ascii "EMM" // EMM386 need 1.226 -no386: 1.227 - .ascii "386" // 386 need 1.228 + .ascii "VCPI4" // VCPI4? 1.229 .byte EXESTR(need) 1.230 -chkerr: 1.231 - .ascii "Bad c" // Bad code 1.232 - .byte EXESTR(ode) 1.233 rmPaging: 1.234 - .ascii "Un" // Unreal mode 1.235 + .ascii "X" // Xreal mode 1.236 realmodemsg: 1.237 .ascii "real" // real mode 1.238 // --------------- Must be in 7FC0 7FFF range ------------------------ 1.239 @@ -243,15 +225,15 @@ 1.240 .ascii "ode" 1.241 .byte EXESTR(eol) 1.242 noDOS3: 1.243 - .ascii "DOS3" // DOS3 need 1.244 + .ascii "DOS3" // DOS3? 1.245 need: 1.246 - .ascii " need" 1.247 + .ascii "?" 1.248 .byte EXESTR(eol) 1.249 help: 1.250 .ascii "SliTaz iso boot" // SliTaz iso boot 1.251 eol: 1.252 .ascii "\r\n" 1.253 - .byte 1 // putstr will return 1.254 + .byte 1 // puts will return 1.255 1.256 .space 16,0 // ISO md5 1.257 .org 0x8000
2.1 --- a/syslinux/stuff/iso2exe/init Sat Mar 21 10:25:00 2015 +0100 2.2 +++ b/syslinux/stuff/iso2exe/init Sat Mar 21 11:15:53 2015 +0100 2.3 @@ -126,7 +126,7 @@ 2.4 gettazboot() 2.5 { 2.6 echo "Creating $(basename $1) ..." 2.7 - O=$(($(get 66 /mnt/$ISO) - 0xC0)) 2.8 + O=$(($(get 64 /mnt/$ISO) - 0xC0)) 2.9 L=$(($(get 20 /mnt/$ISO) - 0xC0 - $(get 24 /mnt/$ISO) - $O)) 2.10 S=$((32+$L)) 2.11 P=$((($S+511)/512)) 2.12 @@ -692,10 +692,10 @@ 2.13 " 10 70 2.14 [ $? -eq 0 ] || return 2.15 ddq if=/mnt/$ISO of=/tmp/bootiso bs=1 count=512 \ 2.16 - skip=$(( $(get 66 /mnt/$ISO) - $sz )) 2.17 + skip=$(( $(get 64 /mnt/$ISO) - $sz )) 2.18 echo "$ISO" | ddq of=/tmp/bootiso bs=512 seek=1 count=1 2.19 ddq if=/mnt/$ISO of=/tmp/bootiso bs=1 count=$sz seek=2 \ 2.20 - skip=$(( $(get 66 /mnt/$ISO) - $sz + 512 )) 2.21 + skip=$(( $(get 64 /mnt/$ISO) - $sz + 512 )) 2.22 mkfloppy /tmp/bootiso 2.23 rm -f /tmp/bootiso 2.24 }
3.1 --- a/syslinux/stuff/iso2exe/iso2exe.c Sat Mar 21 10:25:00 2015 +0100 3.2 +++ b/syslinux/stuff/iso2exe/iso2exe.c Sat Mar 21 11:15:53 2015 +0100 3.3 @@ -29,7 +29,7 @@ 3.4 } 3.5 } 3.6 3.7 -static int domd5 = 0; 3.8 +static int skipmd5 = 0; 3.9 #define ALIGN1 3.10 3.11 typedef struct { 3.12 @@ -268,7 +268,7 @@ 3.13 readsector(0UL); 3.14 n = BUFFERSZ; 3.15 if (WORD(buffer) == 23117) { 3.16 - readsector((unsigned long) buffer[69]); 3.17 + readsector((unsigned long) buffer[417]); 3.18 n = 0; 3.19 } 3.20 lseek(fd, 0UL, SEEK_SET); 3.21 @@ -294,7 +294,7 @@ 3.22 readsector(lba); 3.23 if (LONG(buffer + 64) != 1886961915UL) 3.24 return HYBRIDERR; 3.25 - isohybrid = bootiso[69] * 512; 3.26 + isohybrid = bootiso[417] * 512; 3.27 LONG(bootiso + isohybrid + 432) = lba * 4; 3.28 LONG(bootiso + isohybrid + 440) = rand(); 3.29 LONG(bootiso + isohybrid + partition) = 0x10080UL; 3.30 @@ -322,35 +322,30 @@ 3.31 } 3.32 3.33 /* Install iso2exe boot sector */ 3.34 - WORD(bootiso + 26) = rand(); 3.35 + LONG(bootiso + 440) = time(NULL); 3.36 3.37 /* read tazlito flavor data */ 3.38 lseek(fd, 1024UL, SEEK_SET); 3.39 read(fd, tazlitoinfo, sizeof(tazlitoinfo)); 3.40 3.41 /* Update iso image */ 3.42 - n = (bootiso[69] + 1) * 512; 3.43 + n = (bootiso[417] + 1) * 512; 3.44 lseek(fd, 0UL, SEEK_SET); 3.45 write(fd, bootiso, n); /* EXE/PE + isohybrid mbr */ 3.46 write(fd, tazlitoinfo, sizeof(tazlitoinfo)); 3.47 write(fd, bootiso + n, BOOTISOSZ - n); /* COM + rootfs + EXE/DOS */ 3.48 3.49 - if (domd5) { 3.50 + /* Compute the boot checksums */ 3.51 + if (!skipmd5) { 3.52 puts(bootiso + MD5MSG); 3.53 md5sum(); 3.54 - } 3.55 - 3.56 - /* Compute the boot checksums */ 3.57 - if ((WORD(bootiso + 64) = chksum(66, 32768)) != 0) { 3.58 - if (domd5) { 3.59 - lseek(fd, 0UL, SEEK_SET); 3.60 - write(fd, bootiso, 512); 3.61 - n = WORD(bootiso + 2) - 512*(WORD(bootiso + 4) - 1); 3.62 - WORD(bootiso + 18) = chksum(0, (unsigned short) n) - 1; 3.63 - } 3.64 lseek(fd, 0UL, SEEK_SET); 3.65 write(fd, bootiso, 512); 3.66 + n = WORD(bootiso + 2) - 512*(WORD(bootiso + 4) - 1); 3.67 + WORD(bootiso + 18) = chksum(0, (unsigned short) n) - 1; 3.68 } 3.69 + lseek(fd, 0UL, SEEK_SET); 3.70 + write(fd, bootiso, 512); 3.71 close(fd); 3.72 status = 0; 3.73 return SUCCESSMSG; 3.74 @@ -364,7 +359,7 @@ 3.75 while ((unsigned)(*s - '-') <= ('/' - '-')) s++; 3.76 switch (*s | 0x20) { 3.77 case 'f' : forced++; break; 3.78 - case 'm' : domd5++; break; 3.79 + case 'q' : skipmd5++; break; 3.80 case 'u' : uninstall++; break; 3.81 } 3.82 }
4.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Sat Mar 21 10:25:00 2015 +0100 4.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Sat Mar 21 11:15:53 2015 +0100 4.3 @@ -71,7 +71,7 @@ 4.4 OFS=$(( $OFS - $SIZE )) 4.5 printf "Adding DOS boot file at %04X (%d bytes) ...\n" $OFS $SIZE 4.6 $0 --get boot.com | ddq of=$1 bs=1 seek=$OFS conv=notrunc 4.7 - store 66 $(($OFS+0xC0)) $1 4.8 + store 64 $(($OFS+0xC0)) $1 4.9 } 4.10 4.11 add_win32exe() 4.12 @@ -86,9 +86,9 @@ 4.13 store $((0xF4)) $((16 - 12)) $1 4.14 ddq if=$1 of=/tmp/coff$$ bs=1 skip=$((0x178)) count=$((0x88)) 4.15 ddq if=/tmp/coff$$ of=$1 conv=notrunc bs=1 seek=$((0x178 - 12*8)) 4.16 - ddq if=/tmp/exe$$ of=$1 bs=1 count=30 seek=$((0x1A0)) skip=$((0x1A0)) conv=notrunc 4.17 - ddq if=$2 bs=1 skip=$((0x1BE)) seek=$((0x1BE)) count=66 of=$1 conv=notrunc 4.18 - store 69 $(($SIZE/512)) $1 8 4.19 + ddq if=/tmp/exe$$ of=$1 bs=1 count=24 seek=$((0x1A0)) skip=$((0x1A0)) conv=notrunc 4.20 + ddq if=$2 bs=1 skip=$((0x1B8)) seek=$((0x1B8)) count=72 of=$1 conv=notrunc 4.21 + store 417 $(($SIZE/512)) $1 8 4.22 store 510 $((0xAA55)) $1 4.23 rm -f /tmp/exe$$ /tmp/coff$$ 4.24 printf "Moving syslinux hybrid boot record at %04X (512 bytes) ...\n" $SIZE 4.25 @@ -107,7 +107,7 @@ 4.26 ddq of=$1 bs=1 count=512 seek=$OFS conv=notrunc 4.27 $0 --get bootfd.bin | \ 4.28 ddq of=$1 bs=1 skip=1024 seek=$((512 + $OFS)) conv=notrunc 4.29 - store 28 $(($SIZE/512)) $1 8 4.30 + store 26 $(($SIZE/512)) $1 8 4.31 fi 4.32 } 4.33 case "$1" in 4.34 @@ -211,7 +211,7 @@ 4.35 fi 4.36 done <<EOT 4.37 READSECTORERR Read sector failure. 4.38 -USAGE Usage: isohybrid.exe file.iso [--forced|--undo|--md5] 4.39 +USAGE Usage: isohybrid.exe file.iso [--forced|--undo|--quick] 4.40 OPENERR Can't open r/w the iso file. 4.41 ELTORITOERR No EL TORITO SPECIFICATION signature. 4.42 CATALOGERR Invalid boot catalog. 4.43 @@ -258,7 +258,7 @@ 4.44 -u*|-r*|-w*) 4.45 case "$(get 0 $1)" in 4.46 23117) 4.47 - ddq if=$1 bs=512 count=2 skip=$(get 69 $1 1) of=$1 conv=notrunc 4.48 + ddq if=$1 bs=512 count=2 skip=$(get 417 $1 1) of=$1 conv=notrunc 4.49 ddq if=/dev/zero bs=1k seek=1 count=31 of=$1 conv=notrunc ;; 4.50 *) ddq if=/dev/zero bs=1k count=32 of=$1 conv=notrunc ;; 4.51 esac 4.52 @@ -284,7 +284,7 @@ 4.53 add_doscom $1 4.54 add_fdbootstrap $1 4.55 printf "%d free bytes in %04X..%04X\n" $(($OFS-$HOLE)) $HOLE $OFS 4.56 - store 26 ${RANDOM:-0} $1 4.57 + store 440 $(date +%s) $1 32 4.58 [ "$2" ] && echo "$2 " | \ 4.59 ddq bs=1 seek=$((0x7FDE)) count=15 conv=notrunc of=$1 4.60 if [ $(stat -c %s $1) -gt 34816 ]; then 4.61 @@ -294,8 +294,6 @@ 4.62 ddq bs=16 seek=2047 conv=notrunc of=$1 4.63 fi 4.64 echo -n "Adding boot checksum..." 4.65 - store 64 $(od -v -j 66 -N 32702 -t u2 -w2 -An $1 | \ 4.66 - awk '{ i+= $0 } END { print -(i % 65536) }') $1 4.67 if [ $(stat -c %s $1) -gt 32768 ]; then 4.68 n=$(($(get 2 $1) - 1 + ($(get 4 $1) - 1)*512)) 4.69 n=$(($(od -v -N $n -t u2 -w2 -An $1 | \
5.1 --- a/syslinux/stuff/iso2exe/taziso Sat Mar 21 10:25:00 2015 +0100 5.2 +++ b/syslinux/stuff/iso2exe/taziso Sat Mar 21 11:15:53 2015 +0100 5.3 @@ -33,7 +33,7 @@ 5.4 { 5.5 echo "Creating $(basename $1) ..." 5.6 if [ $(get 0 $ISO) -eq 23117 ]; then 5.7 - O=$(($(get 66 $ISO) - 0xC0)) 5.8 + O=$(($(get 64 $ISO) - 0xC0)) 5.9 L=$(($(get 20 $ISO) - 0xC0 - $(get 24 $ISO) - $O)) 5.10 S=$((32+$L)) 5.11 P=$((($S+511)/512))