wok-next rev 17592
syslinux/isohybrib.exe: add --md5, --undo (again)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Feb 10 13:31:26 2015 +0100 (2015-02-10) |
parents | 52c9cc2da3c6 |
children | 4a3d38846288 |
files | syslinux/stuff/iso2exe/chkmd5.sh syslinux/stuff/iso2exe/iso2exe.c |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/syslinux/stuff/iso2exe/chkmd5.sh Tue Feb 10 13:31:26 2015 +0100 1.3 @@ -0,0 +1,45 @@ 1.4 +#!/bin/sh 1.5 + 1.6 +ddq() 1.7 +{ 1.8 + dd $@ 2> /dev/null 1.9 +} 1.10 + 1.11 +get() 1.12 +{ 1.13 + od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An $2 2>/dev/null || 1.14 + hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %d\n\"" $2 1.15 +} 1.16 + 1.17 +[ -z "$1" ] && echo "usage: $0 file.iso" && exit 1 1.18 + 1.19 +echo "iso data sectors 16..$(echo $(get 32848 $1 4))" 1.20 +ddq if=$1 bs=2k skip=16 count=$(echo $(get 32848 $1 4)) | md5sum 1.21 +ddq if=$1 bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | sed 's/ //g' 1.22 +n=$(($(get 2 $1)-1+($(get 4 $1)-1)*512)) 1.23 +[ 0 -ne $(get 18 $1) ] && [ $n -lt 50000 ] && [ $n -gt 32768 ] && 1.24 +printf "exe16 chk 0..%04X (65535) %d\n" $n $(get 0 $1 2 $n | awk '{ i+= $0 } END { print i % 65536 }') 1.25 +echo -n "boot chk 40..8000 (0) " 1.26 +get 64 $1 2 32704 | awk '{ i+= $0 } END { print i % 65536 }' 1.27 +if [ 23117 -eq $(get 0 $1) ]; then 1.28 + win32sz=$((512*$(get 69 $1 1))) 1.29 + [ 17744 -eq $(get 128 $1) ] && printf "WIN32 file at 0000 (%d bytes)\n" $win32sz 1.30 + [ 29538 -eq $(get 125 $1) ] && echo "bootiso head at 0000" 1.31 + if [ $win32sz -ne 0 ]; then 1.32 + printf "syslinux hybrid boot record at %04X (512 bytes)\n" $win32sz 1.33 + printf "tazlito data record at %04X (512 bytes)\n" $(($win32sz+512)) 1.34 + fi 1.35 + dosexe=$(($(get 20 $1) - 0xC0)) 1.36 + rootfs=$(($dosexe - $(get 24 $1))) 1.37 + doscom=$(get 66 $1) 1.38 + fdsect=$(get 28 $1 1) 1.39 + printf "%d free bytes at %04X..%04X\n" $(($doscom - (512*$fdsect) - $win32sz - 1024)) $(($win32sz+1024)) $(($doscom - (512*$fdsect))) 1.40 + [ $fdsect -ne 0 ] && 1.41 + printf "floppy bootstrap file at %04X (%d bytes)\n" $(($doscom - (512*$fdsect))) $((512*$fdsect)) 1.42 + [ $doscom -ne 0 ] && 1.43 + printf "DOS boot file at %04X (%d bytes)\n" $doscom $(($rootfs - $doscom)) 1.44 + [ $dosexe -ne $rootfs ] && 1.45 + printf "rootfs.gz file at %04X (%d bytes)\n" $rootfs $(($dosexe - $rootfs)) 1.46 + printf "DOS/EXE stub at %04X (%d bytes)\n" $dosexe $((0x8000 - $dosexe)) 1.47 + [ 0 -ne $(get 32756 $1) ] && echo "ISO image md5 at 7FF0 (16 bytes)" 1.48 +fi
2.1 --- a/syslinux/stuff/iso2exe/iso2exe.c Tue Feb 10 08:53:27 2015 +0100 2.2 +++ b/syslinux/stuff/iso2exe/iso2exe.c Tue Feb 10 13:31:26 2015 +0100 2.3 @@ -346,7 +346,7 @@ 2.4 lseek(fd, 0UL, SEEK_SET); 2.5 write(fd, bootiso, 512); 2.6 n = WORD(bootiso + 2) - 512*(WORD(bootiso + 4) - 1); 2.7 - WORD(bootiso + 18) = chksum(0, n) - 1; 2.8 + WORD(bootiso + 18) = chksum(0, (unsigned short) n) - 1; 2.9 } 2.10 lseek(fd, 0UL, SEEK_SET); 2.11 write(fd, bootiso, 512);