wok diff syslinux/stuff/iso2exe/iso2exe.c @ rev 17492
syslinux/iso2exe: check ISO md5
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Jan 03 21:41:48 2015 +0100 (2015-01-03) |
parents | aca562aa836e |
children | 52c9cc2da3c6 |
line diff
1.1 --- a/syslinux/stuff/iso2exe/iso2exe.c Wed Dec 17 12:25:20 2014 +0100 1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.c Sat Jan 03 21:41:48 2015 +0100 1.3 @@ -12,7 +12,7 @@ 1.4 #include "iso2exe.h" 1.5 1.6 static int fd, forced, status = 1; 1.7 -static char tazlitoinfo[10*1024]; 1.8 +static char tazlitoinfo[0x8000U - BOOTISOSZ]; 1.9 #define buffer tazlitoinfo 1.10 #define BUFFERSZ 2048 1.11 #define WORD(n) * (unsigned short *) (n) 1.12 @@ -31,7 +31,7 @@ 1.13 { 1.14 #define heads 64 1.15 #define sectors 32 1.16 -#define partition 446 1.17 +#define partition (446+16) 1.18 #define trksz (512UL * heads * sectors) 1.19 unsigned long size, catalog, lba; 1.20 int cylinders, i, j, isohybrid; 1.21 @@ -69,14 +69,23 @@ 1.22 LONG(bootiso + isohybrid + 440) = rand(); 1.23 LONG(bootiso + isohybrid + partition) = 0x10080UL; 1.24 WORD(bootiso + isohybrid + 510) = 0xAA55U; 1.25 +#if 0 1.26 size = lseek(fd, 0UL, SEEK_END); 1.27 - cylinders = (size + trksz - 1) / trksz; 1.28 + size += 0x000FFFFFUL; 1.29 + size &= 0xFFF00000UL; 1.30 +#else 1.31 + for (size = 0x000FFFFFUL; /* 1M - 1 */ 1.32 + read(fd, tazlitoinfo, 1024) == 1024; 1.33 + size += 1024); 1.34 + size &= 0xFFF00000UL; /* round */ 1.35 +#endif 1.36 + cylinders = (size >> 20) - 1; 1.37 bootiso[isohybrid + partition + 4] = 23; /* "Windows hidden IFS" */ 1.38 bootiso[isohybrid + partition + 5] = heads - 1; 1.39 - bootiso[isohybrid + partition + 6] = (((cylinders - 1) & 0x300) >> 2) + sectors; 1.40 - bootiso[isohybrid + partition + 7] = (cylinders - 1) & 0xFF; 1.41 + bootiso[isohybrid + partition + 6] = ((cylinders & 0x300) >> 2) + sectors; 1.42 + bootiso[isohybrid + partition + 7] = cylinders & 0xFF; 1.43 LONG(bootiso + isohybrid + partition + 8) = 0; 1.44 - LONG(bootiso + isohybrid + partition + 12) = cylinders * sectors * heads; 1.45 + LONG(bootiso + isohybrid + partition + 12) = (size >> 9); 1.46 1.47 /* Copy the partition table */ 1.48 memcpy(bootiso + 0x1BE, bootiso + isohybrid + 0x1BE, 66); 1.49 @@ -93,8 +102,7 @@ 1.50 n = (bootiso[69] + 1) * 512; 1.51 lseek(fd, 0UL, SEEK_SET); 1.52 write(fd, bootiso, n); /* EXE/PE + isohybrid mbr */ 1.53 - write(fd, tazlitoinfo, ((0x8000U - BOOTISOSZ) > sizeof(tazlitoinfo)) 1.54 - ? sizeof(tazlitoinfo) : (0x8000U - BOOTISOSZ)); 1.55 + write(fd, tazlitoinfo, sizeof(tazlitoinfo)); 1.56 write(fd, bootiso + n, BOOTISOSZ - n); /* COM + rootfs + EXE/DOS */ 1.57 1.58 /* Compute the checksum */