# HG changeset patch
# User Pascal Bellard <pascal.bellard@slitaz.org>
# Date 1364884643 -7200
# Node ID ada914860f3395f9dcc3594c376022108526d165
# Parent  ff85ea851c53bec33cf78b7017f9080726819005
syslinux/iso2exe: add boot error message

diff -r ff85ea851c53 -r ada914860f33 syslinux/stuff/iso2exe/bootiso.S
--- a/syslinux/stuff/iso2exe/bootiso.S	Mon Apr 01 17:47:04 2013 +0200
+++ b/syslinux/stuff/iso2exe/bootiso.S	Tue Apr 02 08:37:23 2013 +0200
@@ -87,24 +87,39 @@
 	cmpb	$0x80, %al
 	xchgw	%ax, %dx
 	jnz	dxloop
-fail:
-//	movw	$0x0600+noloader, %si
-//	call	putslp
-stop:
-	hlt
-	jmp	stop
 dxfound:
 	movw	%dx, 10(%bp)
+	call	checkboot
+noboot:
+	.ascii	"No isolinux mbr."
+noboot_end:
+
+	.org	0x0080
+////////////////////////////// EXE/PE header //////////////////////////////////
+
+	.org	0x01A0
+checkboot:
 	call	readsectorX
 	lodsw
+	popw	%si
 	shrw	$1, %ax
-	jz	fail			// read fail or not isohydrid
+	jz	error			// read fail or not isohydrid
 	popw	%es
 	popa
 	iret
 
-	.org	0x0080
-////////////////////////////// EXE/PE header //////////////////////////////////
+error:
+	movw	$noboot_end-noboot, %cx
+putsloop:
+	lodsb
+	movw	$7, %bx
+	movb	$0xE, %ah
+	int	$0x10
+	loop	putsloop
+halt:
+	hlt
+	jmp	halt
+	.org	0x01BE
 
 	.org	0x7EE0
 ////////////////////////////// DOS EXE code ///////////////////////////////////
diff -r ff85ea851c53 -r ada914860f33 syslinux/stuff/iso2exe/iso2exe.c
--- a/syslinux/stuff/iso2exe/iso2exe.c	Mon Apr 01 17:47:04 2013 +0200
+++ b/syslinux/stuff/iso2exe/iso2exe.c	Tue Apr 02 08:37:23 2013 +0200
@@ -70,7 +70,7 @@
 	* (unsigned long *) &bootiso[isohybrid + partition + 12] = cylinders * sectors * heads;
 
 	// Copy the partition table
-	memcpy(bootiso + 0x1B8, bootiso + isohybrid + 0x1B8, 0x48);
+	memcpy(bootiso + 0x1BE, bootiso + isohybrid + 0x1BE, 66);
 
 	// Install iso2exe boot sector
 	* (unsigned short *) (bootiso + 26) = rand();
diff -r ff85ea851c53 -r ada914860f33 syslinux/stuff/iso2exe/iso2exe.sh
--- a/syslinux/stuff/iso2exe/iso2exe.sh	Mon Apr 01 17:47:04 2013 +0200
+++ b/syslinux/stuff/iso2exe/iso2exe.sh	Tue Apr 02 08:37:23 2013 +0200
@@ -66,12 +66,13 @@
 	ddq if=/tmp/exe$$ of=$1 bs=128 count=1 conv=notrunc
 	store $((0x94)) $((0xE0 - 12*8)) $1
 	store $((0xF4)) $((16 - 12)) $1
-	ddq if=$1 of=/tmp/exe$$ bs=1 skip=$((0x178)) count=$((0x88))
-	ddq if=/tmp/exe$$ of=$1 conv=notrunc bs=1 seek=$((0x178 - 12*8))
-	ddq if=$2 bs=1 skip=$((0x1B8)) seek=$((0x1B8)) count=72 of=$1 conv=notrunc
+	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
 	store 510 $((0xAA55)) $1
-	rm -f /tmp/exe$$ 
+	rm -f /tmp/exe$$ /tmp/coff$$
 	printf "Moving syslinux hybrid boot record at %04X ...\n" $SIZE
 	ddq if=$2 bs=1 count=512 of=$1 seek=$SIZE conv=notrunc
 	OFS=$(($SIZE+512))
diff -r ff85ea851c53 -r ada914860f33 syslinux/stuff/iso2exe/mvcom.S
--- a/syslinux/stuff/iso2exe/mvcom.S	Mon Apr 01 17:47:04 2013 +0200
+++ b/syslinux/stuff/iso2exe/mvcom.S	Tue Apr 02 08:37:23 2013 +0200
@@ -10,10 +10,12 @@
 	movw	$0, %si		// .com size
 	movw	$0, %bx		// .com loc
 #if 1
+// Move up EXE/PE and DOS/COM to ensure that bootiso[]
+// in EXE/PE will not be affected by the DOS/COM move.
 	pushw	%si
 	leaw	1-64-256(%bx,%si), %cx
 	leaw	(%bx,%si), %si
-	movw	$0xF000, %di
+	movw	$0xF000, %di	// Keep 4K for stack
 	cmpw	%si, %di
 	jc	skip
 	std