wok-6.x rev 18780
syslinux/isohybrib.exe: check EXE file
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Jan 01 21:39:40 2016 +0100 (2016-01-01) |
parents | 4145d548de53 |
children | d334cc1613e2 |
files | syslinux/stuff/iso2exe/iso2exe.c syslinux/stuff/iso2exe/iso2exe.sh |
line diff
1.1 --- a/syslinux/stuff/iso2exe/iso2exe.c Fri Jan 01 19:26:32 2016 +0100 1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.c Fri Jan 01 21:39:40 2016 +0100 1.3 @@ -22,7 +22,8 @@ 1.4 typedef unsigned long uint32_t; 1.5 #include "iso2exe.h" 1.6 1.7 -static int fd, forced, uninstall, status = 1; 1.8 +static int fd, forced, uninstall; 1.9 +static unsigned status = 1; 1.10 static char *append, *initrd; 1.11 static char tazlitoinfo[0x8000U - BOOTISOSZ]; 1.12 #define buffer tazlitoinfo 1.13 @@ -315,6 +316,59 @@ 1.14 return UNINSTALLMSG; 1.15 } 1.16 1.17 + do { 1.18 + readsector(0UL); 1.19 + status = ALREADYEXEERR; 1.20 + if (buffer[0] == 'M' && buffer[1] == 'Z') 1.21 + break; 1.22 + 1.23 + /* Install hybridiso boot sector */ 1.24 + readsector(17UL); 1.25 + status = ELTORITOERR; 1.26 + if (strncmp(buffer+7, bootiso+ELTORITOERR+ELTORITOOFS, 23)) 1.27 + break; 1.28 + catalog = LONG(buffer + 71); 1.29 + readsector(catalog); 1.30 + status = CATALOGERR; 1.31 + if (LONG(buffer) != 1 || LONG(buffer + 30) != 0x88AA55UL) 1.32 + break; 1.33 + lba = LONG(buffer + 40); 1.34 + readsector(lba); 1.35 + status = HYBRIDERR; 1.36 + if (LONG(buffer + 64) != 1886961915UL) 1.37 + break; 1.38 + isohybrid = bootiso[417] * 512; 1.39 + LONG(bootiso + isohybrid + 432) = lba * 4; 1.40 + LONG(bootiso + isohybrid + 440) = rand(); 1.41 + LONG(bootiso + isohybrid + partition) = 0x10080UL; 1.42 + WORD(bootiso + isohybrid + 510) = 0xAA55U; 1.43 +#if 0 1.44 + size = lseek(fd, 0UL, SEEK_END); 1.45 + size += 0x000FFFFFUL; 1.46 + size &= 0xFFF00000UL; 1.47 +#else 1.48 + for (size = 0x000FFFFFUL; /* 1M - 1 */ 1.49 + read(fd, tazlitoinfo, 1024) == 1024; 1.50 + size += 1024); 1.51 + size &= 0xFFF00000UL; /* round */ 1.52 +#endif 1.53 + cylinders = (size >> 20) - 1; 1.54 + bootiso[isohybrid + partition + 4] = 23; /* "Windows hidden IFS" */ 1.55 + bootiso[isohybrid + partition + 5] = heads - 1; 1.56 + bootiso[isohybrid + partition + 6] = ((cylinders & 0x300) >> 2) + sectors; 1.57 + bootiso[isohybrid + partition + 7] = cylinders & 0xFF; 1.58 + LONG(bootiso + isohybrid + partition + 8) = 0; 1.59 + LONG(bootiso + isohybrid + partition + 12) = (size >> 9); 1.60 + 1.61 + /* Copy the partition table */ 1.62 + memcpy(bootiso + 0x1BE, bootiso + isohybrid + 0x1BE, 66); 1.63 + status = 0; 1.64 + } while (0); 1.65 + 1.66 + if (forced == 0 && status) 1.67 + return status; 1.68 + 1.69 + status = 1; 1.70 if (append || initrd) { 1.71 unsigned long pos = getcustomsector() * 2048UL; 1.72 lseek(fd, pos, SEEK_SET); 1.73 @@ -376,47 +430,6 @@ 1.74 } 1.75 } 1.76 1.77 - if (forced == 0) { 1.78 - status = 2; 1.79 - /* Install hybridiso boot sector */ 1.80 - readsector(17UL); 1.81 - if (strncmp(buffer+7, bootiso+ELTORITOERR+ELTORITOOFS, 23)) 1.82 - return ELTORITOERR; 1.83 - catalog = LONG(buffer + 71); 1.84 - readsector(catalog); 1.85 - if (LONG(buffer) != 1 || LONG(buffer + 30) != 0x88AA55UL) 1.86 - return CATALOGERR; 1.87 - lba = LONG(buffer + 40); 1.88 - readsector(lba); 1.89 - if (LONG(buffer + 64) != 1886961915UL) 1.90 - return HYBRIDERR; 1.91 - isohybrid = bootiso[417] * 512; 1.92 - LONG(bootiso + isohybrid + 432) = lba * 4; 1.93 - LONG(bootiso + isohybrid + 440) = rand(); 1.94 - LONG(bootiso + isohybrid + partition) = 0x10080UL; 1.95 - WORD(bootiso + isohybrid + 510) = 0xAA55U; 1.96 -#if 0 1.97 - size = lseek(fd, 0UL, SEEK_END); 1.98 - size += 0x000FFFFFUL; 1.99 - size &= 0xFFF00000UL; 1.100 -#else 1.101 - for (size = 0x000FFFFFUL; /* 1M - 1 */ 1.102 - read(fd, tazlitoinfo, 1024) == 1024; 1.103 - size += 1024); 1.104 - size &= 0xFFF00000UL; /* round */ 1.105 -#endif 1.106 - cylinders = (size >> 20) - 1; 1.107 - bootiso[isohybrid + partition + 4] = 23; /* "Windows hidden IFS" */ 1.108 - bootiso[isohybrid + partition + 5] = heads - 1; 1.109 - bootiso[isohybrid + partition + 6] = ((cylinders & 0x300) >> 2) + sectors; 1.110 - bootiso[isohybrid + partition + 7] = cylinders & 0xFF; 1.111 - LONG(bootiso + isohybrid + partition + 8) = 0; 1.112 - LONG(bootiso + isohybrid + partition + 12) = (size >> 9); 1.113 - 1.114 - /* Copy the partition table */ 1.115 - memcpy(bootiso + 0x1BE, bootiso + isohybrid + 0x1BE, 66); 1.116 - } 1.117 - 1.118 /* Install iso2exe boot sector */ 1.119 LONG(bootiso + 440) = time(NULL); 1.120
2.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Fri Jan 01 19:26:32 2016 +0100 2.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Fri Jan 01 21:39:40 2016 +0100 2.3 @@ -267,6 +267,7 @@ 2.4 MD5MSG Computing md5sum... 2.5 UNINSTALLMSG Uninstall done. 2.6 OPENINITRDERR Can't open the initrd file. 2.7 +ALREADYEXEERR Already an EXE file. 2.8 EOT 2.9 done 2.10 rm -rf $DATA