# HG changeset patch # User Pascal Bellard # Date 1360103537 -3600 # Node ID b5ea41033c2135a8a73f0421f2ac8fd8fc3f8767 # Parent 6f9ba9c78afedb793385b2c1d426280af5768106 syslinux/iso2exe: add win32 stub diff -r 6f9ba9c78afe -r b5ea41033c21 syslinux/receipt --- a/syslinux/receipt Mon Feb 04 12:44:22 2013 +0000 +++ b/syslinux/receipt Tue Feb 05 23:32:17 2013 +0100 @@ -8,7 +8,7 @@ TARBALL="$PACKAGE-$VERSION.tar.xz" WEB_SITE="http://syslinux.zytor.com/" WGET_URL="ftp://ftp.kernel.org/pub/linux/utils/boot/syslinux/$TARBALL" -BUILD_DEPENDS="kbd-base perl nasm dev86 lzma" +BUILD_DEPENDS="kbd-base perl nasm dev86 lzma mingw32-gcc upx" DEPENDS="gpxe memtest" CONFIG_FILES="/boot/isolinux" diff -r 6f9ba9c78afe -r b5ea41033c21 syslinux/stuff/iso2exe/Makefile --- a/syslinux/stuff/iso2exe/Makefile Mon Feb 04 12:44:22 2013 +0000 +++ b/syslinux/stuff/iso2exe/Makefile Tue Feb 05 23:32:17 2013 +0100 @@ -2,15 +2,14 @@ BCC=bcc -ansi -O -0 -C-t BCCFLAGS=-D__MSDOS__ -Md -iso2exe: iso2exe.sh bootiso.bin lzcom.bin boot.com init +iso2exe: iso2exe.sh boot.com bootiso.bin init win32.exe cp iso2exe.sh $@ chmod +x $@ - lzma e boot.com boot.com.lzma -eos - ./$@ --build bootiso.bin lzcom.bin boot.com.lzma init + ./$@ --build boot.com bootiso.bin init win32.exe OBJS = boot.o iso9660.o libdos.o bootlinux.o boot.com: $(OBJS) - $(BCC) $(BCCFLAGS) -o $@ $(OBJS) + $(BCC) $(BCCFLAGS) -o $@ $(OBJS) && upx --ultra-brute $@ boot.o: boot.c iso9660.h bootlinux.h libdos.h @@ -20,8 +19,9 @@ libdos.o: libdos.c libdos.h -lzcom.bin: lzcom.S unlzma.S - +win32.exe: win32.c + i586-pc-mingw32-gcc -s -o $@ $< -lws2_32 && upx --ultra-brute $@ + %.o: %.c $(BCC) $(BCCFLAGS) -A-l -A$*.lst -c -o $@ $< diff -r 6f9ba9c78afe -r b5ea41033c21 syslinux/stuff/iso2exe/README --- a/syslinux/stuff/iso2exe/README Mon Feb 04 12:44:22 2013 +0000 +++ b/syslinux/stuff/iso2exe/README Tue Feb 05 23:32:17 2013 +0100 @@ -47,8 +47,8 @@ - tazlito stores extra flavor info at the 2nd Kb for 'tazlito iso2flavor'. The iso2exe tool moves the isolinux boot sector, installs its own boot sector -with a DOS .EXE header, and adds a DOS .COM Linux loader and an initramfs in -the end of the first 32Kb. +with a DOS .EXE header, and adds a WIN32 .EXE installer, a DOS .COM Linux +loader and an initramfs in the end of the first 32Kb. +-----------------+ | untouched | ISO9660 files including /boot/bzImage and /boot/rootfs* @@ -57,6 +57,8 @@ +-----------------+ | DOS .COM loader | Load bzImage, the last rootfs*.gz and the ISO initramfs +-----------------+ + | WIN32 PE .exe | Windows UMSDOS like installer / USB Key creator. + +-----------------+ unused +-----------------+ | tazlito info | Flavor missing data for 'tazlito iso2flavor' @@ -64,7 +66,7 @@ | isohybrid boot | Starts isolinux.bin 512 +-----------------+ | iso2exe boot | Boot starts isohybrid (*), .EXE starts DOS .COM loader - 0 +-----------------+ + 0 +-----------------+ or 32 bits Windows UMSDOS like installer * Eltorito boot (i.e. bootable CD-ROM by BIOS) is not concerned by iso2exe. @@ -77,6 +79,8 @@ - Image/zImage format not supported, bzImage only. Can't boot memtest or gpxe. +- posixovl still needs fixes ! + - The tiny Linux loader can't load more than 15Mb of files. (not really a problem since many-in-1 ISO format). diff -r 6f9ba9c78afe -r b5ea41033c21 syslinux/stuff/iso2exe/boot.c --- a/syslinux/stuff/iso2exe/boot.c Mon Feb 04 12:44:22 2013 +0000 +++ b/syslinux/stuff/iso2exe/boot.c Tue Feb 05 23:32:17 2013 +0100 @@ -42,7 +42,7 @@ loadkernel(); isoopen(rootfs); loadinitrd(); - lseek(isofd, 28, SEEK_SET); + lseek(isofd, 24, SEEK_SET); read(isofd, &magic, 4); isofilesize = magic & 0xFFFF; isofileofs = 0x8000 - isofilesize; diff -r 6f9ba9c78afe -r b5ea41033c21 syslinux/stuff/iso2exe/bootiso.S --- a/syslinux/stuff/iso2exe/bootiso.S Mon Feb 04 12:44:22 2013 +0000 +++ b/syslinux/stuff/iso2exe/bootiso.S Tue Feb 05 23:32:17 2013 +0100 @@ -3,14 +3,14 @@ .org 0 CODESZ = 0x8000 // 16 sectors = 32Kb -#define EXEADRS(x) x+0xE0 -#define EXESTR(x) x-0x20 +#define EXEADRS(x) x+0xC0 +#define EXESTR(x) x-0x40 .globl _start _start: decw %bp // Magic number: MZ popw %dx - jmp start // Bytes on last page of file + jmp start0 // Bytes on last page of file .word (CODESZ+511)/512 // Pages in file .word 0 // Relocations .word (end_header-_start)/16 // Size of header in paragraphs @@ -21,24 +21,16 @@ .word 0 // Checksum .word EXEADRS(exestart) // Initial IP value .word 0xFFF0 // Initial (relative) CS value - .word 0x001C // File address of relocation table +initramfssize: + .word 0 // File address of relocation table +id: .word 0 // Overlay number -initramfssize: - .word 0 -id: - .word 0 -end_header: - -chksum: - .word 0 -comstart: - .word 0 /////////////////////// Master Boot Record code ////////////////////////////// -start: - incw %bp +start0: // File address of relocation table pushw %dx // restore SP + incw %bp // restore %bp pushw $0 popw %ds movw $0x7C00, %bx @@ -48,10 +40,22 @@ pushaw movw %sp, %bp pushw %es + cld + pushw %ds + popw %es call setreg rep movsw + movw $0x80, %dx ljmp $0, $0x0600+start2 + + .org 60 + .long 0 // PE header offset +end_header: +chksum: + .word 0 +comstart: + .word 0 readsector2: incw %cx @@ -61,16 +65,12 @@ movw $0x201, %ax int $0x13 setreg: - cld - pushw %ds - popw %es movw %bx, %si movw $0x0600, %di movw $0x0100, %cx return: ret start2: - movw $0x80, %dx dxloop: call readsector1 repe @@ -122,7 +122,7 @@ .ascii "Invalid: paging + " // Invalid: paging + real mode. realmodemsg: .ascii "real" // real mode. -// --------------- Must be in 00A0 011F range ------------------------ +// --------------- Must be in 00C0 013F range ------------------------ mode: .ascii " mod" eeol: diff -r 6f9ba9c78afe -r b5ea41033c21 syslinux/stuff/iso2exe/init --- a/syslinux/stuff/iso2exe/init Mon Feb 04 12:44:22 2013 +0000 +++ b/syslinux/stuff/iso2exe/init Tue Feb 05 23:32:17 2013 +0100 @@ -17,8 +17,8 @@ gettazboot() { echo "Creating $(basename $1) ..." - O=$(($(get 34 /mnt/$ISO) - 0xE0)) - L=$((0x8000 - $(get 28 /mnt/$ISO) - $O)) + O=$(($(get 66 /mnt/$ISO) - 0xE0)) + L=$((0x8000 - $(get 24 /mnt/$ISO) - $O)) S=$((32+$L)) P=$((($S+511)/512)) E=$((4096-(32*$P))) @@ -32,7 +32,7 @@ checkmagic() { - [ -s $1 ] && [ $(getarg magic) == $(get 28 $1 4) ] + [ -s $1 ] && [ $(getarg magic) == $(get 24 $1 4) ] } getiso() diff -r 6f9ba9c78afe -r b5ea41033c21 syslinux/stuff/iso2exe/iso2exe.sh --- a/syslinux/stuff/iso2exe/iso2exe.sh Mon Feb 04 12:44:22 2013 +0000 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Tue Feb 05 23:32:17 2013 +0100 @@ -25,6 +25,11 @@ done | xargs echo -en | ddq bs=1 conv=notrunc of=$3 seek=$(($1)) } +get() +{ + echo $(od -j $(($1)) -N ${3:-2} -t u${3:-2} -An $2) +} + main() { case "$1" in @@ -58,25 +63,36 @@ ( cd $TMP ; find * | cpio -o -H newc ) | \ lzma e $TMP/rootfs.gz -si 2> /dev/null SIZE=$(wc -c < $TMP/rootfs.gz) - store 28 $SIZE $1 + store 24 $SIZE $1 OFS=$(( 0x8000 - $SIZE )) printf "Adding rootfs.gz file at %04X...\n" $OFS cat $TMP/rootfs.gz | ddq of=$1 bs=1 seek=$OFS conv=notrunc rm -rf $TMP - SIZE=$($0 --get lzcom.bin boot.com.lzma | wc -c) + SIZE=$($0 --get boot.com | wc -c) OFS=$(( $OFS - $SIZE )) printf "Adding DOS boot file at %04X...\n" $OFS - $0 --get lzcom.bin boot.com.lzma | ddq of=$1 bs=1 seek=$OFS conv=notrunc - store 34 $(($OFS+0xE0)) $1 - store 30 ${RANDOM:-0} $1 + $0 --get boot.com | ddq of=$1 bs=1 seek=$OFS conv=notrunc + store 66 $(($OFS+0xC0)) $1 + SIZE=$($0 --get win32.exe | tee /tmp/exe$$ | wc -c) + OFS=$(( 128 + ( ($OFS - $SIZE + 128) & 0xFE00 ) )) + printf "Adding WIN32 file at %04X...\n" $OFS + LOC=$((0xAC+$(get 0x94 /tmp/exe$$))) + for i in $(seq 1 $(get 0x86 /tmp/exe$$)); do + store $LOC $(($(get $LOC /tmp/exe$$)+$OFS-128)) /tmp/exe$$ + LOC=$(($LOC+40)) + done + ddq if=/tmp/exe$$ of=$1 bs=1 skip=128 seek=$OFS conv=notrunc + rm -f /tmp/exe$$ + store 60 $OFS $1 + store 26 ${RANDOM:-0} $1 i=34 n=0 echo -n "Adding checksum..." while [ $i -lt 32768 ]; do - n=$(($n + $(od -j $i -N 2 -t u2 -An $1) )) + n=$(($n + $(get $i $1) )) i=$(($i + 2)) done - store 32 -$n $1 + store 64 -$n $1 echo " done." } diff -r 6f9ba9c78afe -r b5ea41033c21 syslinux/stuff/iso2exe/win32.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/syslinux/stuff/iso2exe/win32.c Tue Feb 05 23:32:17 2013 +0100 @@ -0,0 +1,6 @@ +#include + +int main() +{ + printf("No support for Windows yet.\n"); +}