# HG changeset patch # User Pascal Bellard # Date 1365067159 -7200 # Node ID 19258b949c1b098dbd16393a9a399671fd38f784 # Parent ada914860f3395f9dcc3594c376022108526d165 syslinux/iso2exe: do not overload (setup) version in bootlinux.c diff -r ada914860f33 -r 19258b949c1b syslinux/stuff/iso2exe/Makefile --- a/syslinux/stuff/iso2exe/Makefile Tue Apr 02 08:37:23 2013 +0200 +++ b/syslinux/stuff/iso2exe/Makefile Thu Apr 04 11:19:19 2013 +0200 @@ -17,7 +17,7 @@ $(BCC) $(BCCFLAGS) -o $@ iso2exe.c && upx --ultra-brute $@ iso2exe.exe: iso2exe.c iso2exe.h - i586-pc-mingw32-gcc -s -o $@ iso2exe.c -lws2_32 + i586-pc-mingw32-gcc -Os -s -o $@ iso2exe.c -lws2_32 isohybrid.exe: iso2exe.sh mvcom.bin iso2exe.com iso2exe.exe ./iso2exe.sh --exe mvcom.bin iso2exe.com iso2exe.exe > $@ @@ -39,7 +39,7 @@ i586-pc-mingw32-windres $< -O coff -o $@ win32.exe: win32.c win32.res - i586-pc-mingw32-gcc -s -o $@ $< win32.res -mwindows -lws2_32 && upx --ultra-brute $@ + i586-pc-mingw32-gcc -Os -s -o $@ $< win32.res -mwindows -lws2_32 && upx --ultra-brute $@ %.o: %.c $(BCC) $(BCCFLAGS) -A-l -A$*.lst -c -o $@ $< diff -r ada914860f33 -r 19258b949c1b syslinux/stuff/iso2exe/boot.c --- a/syslinux/stuff/iso2exe/boot.c Tue Apr 02 08:37:23 2013 +0200 +++ b/syslinux/stuff/iso2exe/boot.c Thu Apr 04 11:19:19 2013 +0200 @@ -88,7 +88,9 @@ char *kernel, *initrd, *cmdline, *cmdfile, *s; argv[0] = progname(); - bootiso(argv + (argc == 2)); // iso ? parsing is /init.exe stuff ! + bootiso(argv); // iso ? parsing is /init.exe stuff ! + if (argc == 2) + bootiso(argv + 1); chdirname(*argv); cmdfile = "tazboot.cmd"; diff -r ada914860f33 -r 19258b949c1b syslinux/stuff/iso2exe/bootlinux.c --- a/syslinux/stuff/iso2exe/bootlinux.c Tue Apr 02 08:37:23 2013 +0200 +++ b/syslinux/stuff/iso2exe/bootlinux.c Thu Apr 04 11:19:19 2013 +0200 @@ -166,7 +166,7 @@ unsigned long loadkernel(void) { unsigned setup, n = BUFFERSZ; - unsigned long syssize = 0, version = 0; + unsigned long syssize = 0, kernel_version = 0; do { isoread(buffer, n); @@ -267,11 +267,11 @@ shld edx, eax, #8 loop next pop ds - mov .loadkernel.version[bp], edx + mov .loadkernel.kernel_version[bp], edx noversion: #endasm load(&kernelmem, syssize); - return version; + return kernel_version; } void loadinitrd(void) diff -r ada914860f33 -r 19258b949c1b syslinux/stuff/iso2exe/iso2exe.c --- a/syslinux/stuff/iso2exe/iso2exe.c Tue Apr 02 08:37:23 2013 +0200 +++ b/syslinux/stuff/iso2exe/iso2exe.c Thu Apr 04 11:19:19 2013 +0200 @@ -1,27 +1,26 @@ #include #include #include +#ifdef WIN32 +#include +#endif #include "iso2exe.h" -static int fd; +static int fd, status = 1; static char tazlitoinfo[10*1024]; #define buffer tazlitoinfo #define BUFFERSZ 2048 -static void quit(char *msg) -{ - fprintf(stderr,"%s.\n", msg); - exit(1); -} - static void readsector(unsigned long sector) { if (lseek(fd, sector * BUFFERSZ, SEEK_SET) == -1 || - read(fd, buffer, BUFFERSZ) != BUFFERSZ) - quit("read sector failure"); + read(fd, buffer, BUFFERSZ) != BUFFERSZ) { + puts("Read sector failure.\n"); + exit(1); + } } -int main(int argc, char *argv[]) +static char *install(char *filename) { #define heads 64 #define sectors 32 @@ -32,29 +31,29 @@ unsigned n; #ifndef WIN32 char *bootiso; - for (bootiso = (char *) main; + for (bootiso = (char *) install; bootiso[0] != 'M' || bootiso[1] != 'Z' || bootiso[2] != 0xEB; - bootiso++) if (bootiso < (char *) main) quit("bootiso not found"); + bootiso++) if (bootiso < (char *) install) return "No bootiso data.\n"; #endif - if (argc < 2) - quit("Usage : isohybrid.exe file.iso"); - fd = open(argv[1],O_RDWR|O_BINARY); + if (!filename) + return "Usage: isohybrid.exe file.iso\n"; + fd = open(filename,O_RDWR|O_BINARY); if (fd == -1) - quit("Can't open rw"); + return "Can't open rw the iso file.\n"; // Install hybridiso boot sector readsector(17UL); if (strncmp(buffer+7, "EL TORITO SPECIFICATION", 23)) - quit("No EL TORITO boot record found"); + return "No EL TORITO signature.\n"; catalog = * (unsigned long *) (buffer + 71); readsector(catalog); if (* (unsigned long *) buffer != 1 || * (unsigned long *) (buffer + 30) != 0x88AA55) - quit("invalid boot catalog."); + return "Invalid boot catalog.\n"; lba = * (unsigned long *) (buffer + 40); readsector(lba); if (* (unsigned long *) (buffer + 64) != 1886961915) - quit("no isolinux.bin hybrid signature in bootloader"); + return "No isolinux.bin hybrid signature.\n"; isohybrid = bootiso[69] * 512; * (unsigned long *) &bootiso[isohybrid + 432] = lba * 4; * (unsigned long *) &bootiso[isohybrid + 440] = rand(); @@ -100,6 +99,16 @@ write(fd, bootiso, 512); nochksum: close(fd); - printf("Note you can create a USB key with %s.\n" - "Simply rename it to a .exe file and run it.\n", argv[1]); + status = 0; + return "Now you can create a USB key with your .iso file.\n" + "Simply rename it to a .exe file and run it.\n"; } + +int main(int argc, char *argv[]) +{ + puts(install(argv[1])); +#ifdef WIN32 + Sleep(2000); +#endif + return status; +} diff -r ada914860f33 -r 19258b949c1b syslinux/stuff/iso2exe/iso2exe.sh --- a/syslinux/stuff/iso2exe/iso2exe.sh Tue Apr 02 08:37:23 2013 +0200 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Thu Apr 04 11:19:19 2013 +0200 @@ -80,12 +80,15 @@ add_fdbootstrap() { - SIZE=$($0 --get bootfd.bin 2> /dev/null | tee /tmp/exe$$ | wc -c) + SIZE=$($0 --get bootfd.bin 2> /dev/null | wc -c) if [ $SIZE -ne 0 ]; then - OFS=$(( $OFS - $SIZE )) + OFS=$(( $OFS - $SIZE + 512 )) printf "Adding floppy bootstrap file at %04X...\n" $OFS - $0 --get bootfd.bin | ddq of=$1 bs=1 seek=$OFS conv=notrunc - store 28 $(($SIZE/512)) $1 8 + $0 --get bootfd.bin | \ + ddq of=$1 bs=1 count=512 seek=$OFS conv=notrunc + $0 --get bootfd.bin | \ + ddq of=$1 bs=1 skip=1024 seek=$((512 + $OFS)) conv=notrunc + store 28 $(($SIZE/512 - 1)) $1 8 fi } case "$1" in diff -r ada914860f33 -r 19258b949c1b syslinux/stuff/iso2exe/win32.c --- a/syslinux/stuff/iso2exe/win32.c Tue Apr 02 08:37:23 2013 +0200 +++ b/syslinux/stuff/iso2exe/win32.c Thu Apr 04 11:19:19 2013 +0200 @@ -84,10 +84,11 @@ return (magic == 1886961915); } +static char buffer[512]; + #define MODE_READ 0 #define MODE_WRITE 1 -static int rdwrsector(int mode, int drive, unsigned long startingsector, - unsigned long count, char *buffer) +static int rdwrsector(int mode, int drive, unsigned long startingsector) { HANDLE hDevice; DWORD result; @@ -107,11 +108,11 @@ return -1; SetFilePointer(hDevice, (startingsector*512), NULL, FILE_BEGIN); if (mode == MODE_READ) { - if (!ReadFile(hDevice, buffer, 512*count, &result, NULL)) + if (!ReadFile(hDevice, buffer, 512, &result, NULL)) result = -1; } else { - if (!WriteFile(hDevice, buffer, 512*count, &result, NULL)) + if (!WriteFile(hDevice, buffer, 512, &result, NULL)) result = -1; } CloseHandle(hDevice); @@ -121,18 +122,15 @@ static int rawrite(unsigned long drive, char *isoFileName) { int fdiso, s, dev; - char buffer[2048]; if (drive == 0) return; for (dev = 128; (drive & 1) == 0; dev++) drive >>= 1; fdiso = open(isoFileName, O_RDONLY|O_BINARY); - for (s = 0;;) { + for (s = 0;; s++) { int s, n = read(fdiso, buffer, sizeof(buffer)); if (n <= 0) break; - n = (n+511)/512; - rdwrsector(MODE_WRITE, dev, s, n, buffer); - s += n; + rdwrsector(MODE_WRITE, dev, s); } close(fdiso); return dev; @@ -141,9 +139,9 @@ static unsigned long drives(void) { int i, mask, result; - char buffer[512]; + for (i = result = 0, mask = 1; i < 8; i++, mask <<= 1) { - if (rdwrsector(MODE_READ, i+128, 0, 1, buffer) != -1) + if (rdwrsector(MODE_READ, i+128, 0) != -1) result |= mask; } return result; @@ -151,7 +149,6 @@ static void writefloppy(char *isoFileName) { - char buffer[512]; int i, n, fd; buffer[BOOTSTRAP_SECTOR_COUNT_OFFSET] = 0; @@ -162,10 +159,10 @@ if (n != 0 && lseek(fd, * (unsigned short *) (buffer + 66) - (512 * n), SEEK_SET) != -1) { - for (i = 0; i < n; i++) { - read(fd, buffer, 512); + for (i = 0; i <= n; i++) { if (i == 1) strncpy(buffer, isoFileName, 512); - rdwrsector(MODE_WRITE, 0, i, 1, buffer); + else read(fd, buffer, 512); + rdwrsector(MODE_WRITE, 0, i); } } close(fd); diff -r ada914860f33 -r 19258b949c1b syslinux/stuff/iso2exe/win32.rc --- a/syslinux/stuff/iso2exe/win32.rc Tue Apr 02 08:37:23 2013 +0200 +++ b/syslinux/stuff/iso2exe/win32.rc Thu Apr 04 11:19:19 2013 +0200 @@ -16,7 +16,7 @@ VALUE "FileVersion", "1.0" VALUE "InternalName", "iso2exe" VALUE "LegalCopyright", "SliTaz" - VALUE "OriginalFilename", "win32.exe" +/* VALUE "OriginalFilename", "win32.exe" */ VALUE "ProductName", "iso2exe" VALUE "ProductVersion", "1.0" END