wok diff syslinux/stuff/iso2exe/iso2exe.sh @ rev 13972
syslinux/iso2exe: add win32 stub
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Feb 05 23:32:17 2013 +0100 (2013-02-05) |
parents | 9d2380009b81 |
children | e487d594117f |
line diff
1.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Tue Dec 18 16:09:07 2012 +0100 1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Tue Feb 05 23:32:17 2013 +0100 1.3 @@ -25,6 +25,11 @@ 1.4 done | xargs echo -en | ddq bs=1 conv=notrunc of=$3 seek=$(($1)) 1.5 } 1.6 1.7 +get() 1.8 +{ 1.9 + echo $(od -j $(($1)) -N ${3:-2} -t u${3:-2} -An $2) 1.10 +} 1.11 + 1.12 main() 1.13 { 1.14 case "$1" in 1.15 @@ -58,25 +63,36 @@ 1.16 ( cd $TMP ; find * | cpio -o -H newc ) | \ 1.17 lzma e $TMP/rootfs.gz -si 2> /dev/null 1.18 SIZE=$(wc -c < $TMP/rootfs.gz) 1.19 - store 28 $SIZE $1 1.20 + store 24 $SIZE $1 1.21 OFS=$(( 0x8000 - $SIZE )) 1.22 printf "Adding rootfs.gz file at %04X...\n" $OFS 1.23 cat $TMP/rootfs.gz | ddq of=$1 bs=1 seek=$OFS conv=notrunc 1.24 rm -rf $TMP 1.25 - SIZE=$($0 --get lzcom.bin boot.com.lzma | wc -c) 1.26 + SIZE=$($0 --get boot.com | wc -c) 1.27 OFS=$(( $OFS - $SIZE )) 1.28 printf "Adding DOS boot file at %04X...\n" $OFS 1.29 - $0 --get lzcom.bin boot.com.lzma | ddq of=$1 bs=1 seek=$OFS conv=notrunc 1.30 - store 34 $(($OFS+0xE0)) $1 1.31 - store 30 ${RANDOM:-0} $1 1.32 + $0 --get boot.com | ddq of=$1 bs=1 seek=$OFS conv=notrunc 1.33 + store 66 $(($OFS+0xC0)) $1 1.34 + SIZE=$($0 --get win32.exe | tee /tmp/exe$$ | wc -c) 1.35 + OFS=$(( 128 + ( ($OFS - $SIZE + 128) & 0xFE00 ) )) 1.36 + printf "Adding WIN32 file at %04X...\n" $OFS 1.37 + LOC=$((0xAC+$(get 0x94 /tmp/exe$$))) 1.38 + for i in $(seq 1 $(get 0x86 /tmp/exe$$)); do 1.39 + store $LOC $(($(get $LOC /tmp/exe$$)+$OFS-128)) /tmp/exe$$ 1.40 + LOC=$(($LOC+40)) 1.41 + done 1.42 + ddq if=/tmp/exe$$ of=$1 bs=1 skip=128 seek=$OFS conv=notrunc 1.43 + rm -f /tmp/exe$$ 1.44 + store 60 $OFS $1 1.45 + store 26 ${RANDOM:-0} $1 1.46 i=34 1.47 n=0 1.48 echo -n "Adding checksum..." 1.49 while [ $i -lt 32768 ]; do 1.50 - n=$(($n + $(od -j $i -N 2 -t u2 -An $1) )) 1.51 + n=$(($n + $(get $i $1) )) 1.52 i=$(($i + 2)) 1.53 done 1.54 - store 32 -$n $1 1.55 + store 64 -$n $1 1.56 echo " done." 1.57 } 1.58