wok-next rev 14268
syslinux/iso2exe: do not overload (setup) version in bootlinux.c
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Apr 04 11:19:19 2013 +0200 (2013-04-04) |
parents | ada914860f33 |
children | 68d68791ced5 |
files | syslinux/stuff/iso2exe/Makefile syslinux/stuff/iso2exe/boot.c syslinux/stuff/iso2exe/bootlinux.c syslinux/stuff/iso2exe/iso2exe.c syslinux/stuff/iso2exe/iso2exe.sh syslinux/stuff/iso2exe/win32.c syslinux/stuff/iso2exe/win32.rc |
line diff
1.1 --- a/syslinux/stuff/iso2exe/Makefile Tue Apr 02 08:37:23 2013 +0200 1.2 +++ b/syslinux/stuff/iso2exe/Makefile Thu Apr 04 11:19:19 2013 +0200 1.3 @@ -17,7 +17,7 @@ 1.4 $(BCC) $(BCCFLAGS) -o $@ iso2exe.c && upx --ultra-brute $@ 1.5 1.6 iso2exe.exe: iso2exe.c iso2exe.h 1.7 - i586-pc-mingw32-gcc -s -o $@ iso2exe.c -lws2_32 1.8 + i586-pc-mingw32-gcc -Os -s -o $@ iso2exe.c -lws2_32 1.9 1.10 isohybrid.exe: iso2exe.sh mvcom.bin iso2exe.com iso2exe.exe 1.11 ./iso2exe.sh --exe mvcom.bin iso2exe.com iso2exe.exe > $@ 1.12 @@ -39,7 +39,7 @@ 1.13 i586-pc-mingw32-windres $< -O coff -o $@ 1.14 1.15 win32.exe: win32.c win32.res 1.16 - i586-pc-mingw32-gcc -s -o $@ $< win32.res -mwindows -lws2_32 && upx --ultra-brute $@ 1.17 + i586-pc-mingw32-gcc -Os -s -o $@ $< win32.res -mwindows -lws2_32 && upx --ultra-brute $@ 1.18 1.19 %.o: %.c 1.20 $(BCC) $(BCCFLAGS) -A-l -A$*.lst -c -o $@ $<
2.1 --- a/syslinux/stuff/iso2exe/boot.c Tue Apr 02 08:37:23 2013 +0200 2.2 +++ b/syslinux/stuff/iso2exe/boot.c Thu Apr 04 11:19:19 2013 +0200 2.3 @@ -88,7 +88,9 @@ 2.4 char *kernel, *initrd, *cmdline, *cmdfile, *s; 2.5 2.6 argv[0] = progname(); 2.7 - bootiso(argv + (argc == 2)); // iso ? parsing is /init.exe stuff ! 2.8 + bootiso(argv); // iso ? parsing is /init.exe stuff ! 2.9 + if (argc == 2) 2.10 + bootiso(argv + 1); 2.11 2.12 chdirname(*argv); 2.13 cmdfile = "tazboot.cmd";
3.1 --- a/syslinux/stuff/iso2exe/bootlinux.c Tue Apr 02 08:37:23 2013 +0200 3.2 +++ b/syslinux/stuff/iso2exe/bootlinux.c Thu Apr 04 11:19:19 2013 +0200 3.3 @@ -166,7 +166,7 @@ 3.4 unsigned long loadkernel(void) 3.5 { 3.6 unsigned setup, n = BUFFERSZ; 3.7 - unsigned long syssize = 0, version = 0; 3.8 + unsigned long syssize = 0, kernel_version = 0; 3.9 3.10 do { 3.11 isoread(buffer, n); 3.12 @@ -267,11 +267,11 @@ 3.13 shld edx, eax, #8 3.14 loop next 3.15 pop ds 3.16 - mov .loadkernel.version[bp], edx 3.17 + mov .loadkernel.kernel_version[bp], edx 3.18 noversion: 3.19 #endasm 3.20 load(&kernelmem, syssize); 3.21 - return version; 3.22 + return kernel_version; 3.23 } 3.24 3.25 void loadinitrd(void)
4.1 --- a/syslinux/stuff/iso2exe/iso2exe.c Tue Apr 02 08:37:23 2013 +0200 4.2 +++ b/syslinux/stuff/iso2exe/iso2exe.c Thu Apr 04 11:19:19 2013 +0200 4.3 @@ -1,27 +1,26 @@ 4.4 #include <sys/types.h> 4.5 #include <fcntl.h> 4.6 #include <stdio.h> 4.7 +#ifdef WIN32 4.8 +#include <windows.h> 4.9 +#endif 4.10 #include "iso2exe.h" 4.11 4.12 -static int fd; 4.13 +static int fd, status = 1; 4.14 static char tazlitoinfo[10*1024]; 4.15 #define buffer tazlitoinfo 4.16 #define BUFFERSZ 2048 4.17 4.18 -static void quit(char *msg) 4.19 -{ 4.20 - fprintf(stderr,"%s.\n", msg); 4.21 - exit(1); 4.22 -} 4.23 - 4.24 static void readsector(unsigned long sector) 4.25 { 4.26 if (lseek(fd, sector * BUFFERSZ, SEEK_SET) == -1 || 4.27 - read(fd, buffer, BUFFERSZ) != BUFFERSZ) 4.28 - quit("read sector failure"); 4.29 + read(fd, buffer, BUFFERSZ) != BUFFERSZ) { 4.30 + puts("Read sector failure.\n"); 4.31 + exit(1); 4.32 + } 4.33 } 4.34 4.35 -int main(int argc, char *argv[]) 4.36 +static char *install(char *filename) 4.37 { 4.38 #define heads 64 4.39 #define sectors 32 4.40 @@ -32,29 +31,29 @@ 4.41 unsigned n; 4.42 #ifndef WIN32 4.43 char *bootiso; 4.44 - for (bootiso = (char *) main; 4.45 + for (bootiso = (char *) install; 4.46 bootiso[0] != 'M' || bootiso[1] != 'Z' || bootiso[2] != 0xEB; 4.47 - bootiso++) if (bootiso < (char *) main) quit("bootiso not found"); 4.48 + bootiso++) if (bootiso < (char *) install) return "No bootiso data.\n"; 4.49 #endif 4.50 - if (argc < 2) 4.51 - quit("Usage : isohybrid.exe file.iso"); 4.52 - fd = open(argv[1],O_RDWR|O_BINARY); 4.53 + if (!filename) 4.54 + return "Usage: isohybrid.exe file.iso\n"; 4.55 + fd = open(filename,O_RDWR|O_BINARY); 4.56 if (fd == -1) 4.57 - quit("Can't open rw"); 4.58 + return "Can't open rw the iso file.\n"; 4.59 4.60 // Install hybridiso boot sector 4.61 readsector(17UL); 4.62 if (strncmp(buffer+7, "EL TORITO SPECIFICATION", 23)) 4.63 - quit("No EL TORITO boot record found"); 4.64 + return "No EL TORITO signature.\n"; 4.65 catalog = * (unsigned long *) (buffer + 71); 4.66 readsector(catalog); 4.67 if (* (unsigned long *) buffer != 1 || 4.68 * (unsigned long *) (buffer + 30) != 0x88AA55) 4.69 - quit("invalid boot catalog."); 4.70 + return "Invalid boot catalog.\n"; 4.71 lba = * (unsigned long *) (buffer + 40); 4.72 readsector(lba); 4.73 if (* (unsigned long *) (buffer + 64) != 1886961915) 4.74 - quit("no isolinux.bin hybrid signature in bootloader"); 4.75 + return "No isolinux.bin hybrid signature.\n"; 4.76 isohybrid = bootiso[69] * 512; 4.77 * (unsigned long *) &bootiso[isohybrid + 432] = lba * 4; 4.78 * (unsigned long *) &bootiso[isohybrid + 440] = rand(); 4.79 @@ -100,6 +99,16 @@ 4.80 write(fd, bootiso, 512); 4.81 nochksum: 4.82 close(fd); 4.83 - printf("Note you can create a USB key with %s.\n" 4.84 - "Simply rename it to a .exe file and run it.\n", argv[1]); 4.85 + status = 0; 4.86 + return "Now you can create a USB key with your .iso file.\n" 4.87 + "Simply rename it to a .exe file and run it.\n"; 4.88 } 4.89 + 4.90 +int main(int argc, char *argv[]) 4.91 +{ 4.92 + puts(install(argv[1])); 4.93 +#ifdef WIN32 4.94 + Sleep(2000); 4.95 +#endif 4.96 + return status; 4.97 +}
5.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Tue Apr 02 08:37:23 2013 +0200 5.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Thu Apr 04 11:19:19 2013 +0200 5.3 @@ -80,12 +80,15 @@ 5.4 5.5 add_fdbootstrap() 5.6 { 5.7 - SIZE=$($0 --get bootfd.bin 2> /dev/null | tee /tmp/exe$$ | wc -c) 5.8 + SIZE=$($0 --get bootfd.bin 2> /dev/null | wc -c) 5.9 if [ $SIZE -ne 0 ]; then 5.10 - OFS=$(( $OFS - $SIZE )) 5.11 + OFS=$(( $OFS - $SIZE + 512 )) 5.12 printf "Adding floppy bootstrap file at %04X...\n" $OFS 5.13 - $0 --get bootfd.bin | ddq of=$1 bs=1 seek=$OFS conv=notrunc 5.14 - store 28 $(($SIZE/512)) $1 8 5.15 + $0 --get bootfd.bin | \ 5.16 + ddq of=$1 bs=1 count=512 seek=$OFS conv=notrunc 5.17 + $0 --get bootfd.bin | \ 5.18 + ddq of=$1 bs=1 skip=1024 seek=$((512 + $OFS)) conv=notrunc 5.19 + store 28 $(($SIZE/512 - 1)) $1 8 5.20 fi 5.21 } 5.22 case "$1" in
6.1 --- a/syslinux/stuff/iso2exe/win32.c Tue Apr 02 08:37:23 2013 +0200 6.2 +++ b/syslinux/stuff/iso2exe/win32.c Thu Apr 04 11:19:19 2013 +0200 6.3 @@ -84,10 +84,11 @@ 6.4 return (magic == 1886961915); 6.5 } 6.6 6.7 +static char buffer[512]; 6.8 + 6.9 #define MODE_READ 0 6.10 #define MODE_WRITE 1 6.11 -static int rdwrsector(int mode, int drive, unsigned long startingsector, 6.12 - unsigned long count, char *buffer) 6.13 +static int rdwrsector(int mode, int drive, unsigned long startingsector) 6.14 { 6.15 HANDLE hDevice; 6.16 DWORD result; 6.17 @@ -107,11 +108,11 @@ 6.18 return -1; 6.19 SetFilePointer(hDevice, (startingsector*512), NULL, FILE_BEGIN); 6.20 if (mode == MODE_READ) { 6.21 - if (!ReadFile(hDevice, buffer, 512*count, &result, NULL)) 6.22 + if (!ReadFile(hDevice, buffer, 512, &result, NULL)) 6.23 result = -1; 6.24 } 6.25 else { 6.26 - if (!WriteFile(hDevice, buffer, 512*count, &result, NULL)) 6.27 + if (!WriteFile(hDevice, buffer, 512, &result, NULL)) 6.28 result = -1; 6.29 } 6.30 CloseHandle(hDevice); 6.31 @@ -121,18 +122,15 @@ 6.32 static int rawrite(unsigned long drive, char *isoFileName) 6.33 { 6.34 int fdiso, s, dev; 6.35 - char buffer[2048]; 6.36 6.37 if (drive == 0) return; 6.38 for (dev = 128; (drive & 1) == 0; dev++) 6.39 drive >>= 1; 6.40 fdiso = open(isoFileName, O_RDONLY|O_BINARY); 6.41 - for (s = 0;;) { 6.42 + for (s = 0;; s++) { 6.43 int s, n = read(fdiso, buffer, sizeof(buffer)); 6.44 if (n <= 0) break; 6.45 - n = (n+511)/512; 6.46 - rdwrsector(MODE_WRITE, dev, s, n, buffer); 6.47 - s += n; 6.48 + rdwrsector(MODE_WRITE, dev, s); 6.49 } 6.50 close(fdiso); 6.51 return dev; 6.52 @@ -141,9 +139,9 @@ 6.53 static unsigned long drives(void) 6.54 { 6.55 int i, mask, result; 6.56 - char buffer[512]; 6.57 + 6.58 for (i = result = 0, mask = 1; i < 8; i++, mask <<= 1) { 6.59 - if (rdwrsector(MODE_READ, i+128, 0, 1, buffer) != -1) 6.60 + if (rdwrsector(MODE_READ, i+128, 0) != -1) 6.61 result |= mask; 6.62 } 6.63 return result; 6.64 @@ -151,7 +149,6 @@ 6.65 6.66 static void writefloppy(char *isoFileName) 6.67 { 6.68 - char buffer[512]; 6.69 int i, n, fd; 6.70 6.71 buffer[BOOTSTRAP_SECTOR_COUNT_OFFSET] = 0; 6.72 @@ -162,10 +159,10 @@ 6.73 if (n != 0 && 6.74 lseek(fd, * (unsigned short *) (buffer + 66) - (512 * n), 6.75 SEEK_SET) != -1) { 6.76 - for (i = 0; i < n; i++) { 6.77 - read(fd, buffer, 512); 6.78 + for (i = 0; i <= n; i++) { 6.79 if (i == 1) strncpy(buffer, isoFileName, 512); 6.80 - rdwrsector(MODE_WRITE, 0, i, 1, buffer); 6.81 + else read(fd, buffer, 512); 6.82 + rdwrsector(MODE_WRITE, 0, i); 6.83 } 6.84 } 6.85 close(fd);
7.1 --- a/syslinux/stuff/iso2exe/win32.rc Tue Apr 02 08:37:23 2013 +0200 7.2 +++ b/syslinux/stuff/iso2exe/win32.rc Thu Apr 04 11:19:19 2013 +0200 7.3 @@ -16,7 +16,7 @@ 7.4 VALUE "FileVersion", "1.0" 7.5 VALUE "InternalName", "iso2exe" 7.6 VALUE "LegalCopyright", "SliTaz" 7.7 - VALUE "OriginalFilename", "win32.exe" 7.8 +/* VALUE "OriginalFilename", "win32.exe" */ 7.9 VALUE "ProductName", "iso2exe" 7.10 VALUE "ProductVersion", "1.0" 7.11 END