oldworldisobuilder: fix incorrect comparisons, ensure length is 512 bytes aligned

additionally, change readme: the Apple_Driver43.ptDR.drvr file from OSX install media causes a crash and cannot be used - the raw partition image should be used instead
This commit is contained in:
Rairii 2024-12-20 22:16:15 +00:00
parent 33ef0e697e
commit 1673a44b50
2 changed files with 13 additions and 6 deletions

View File

@ -208,11 +208,11 @@ static void usage(char* arg0) {
fseek(fFile, 0, SEEK_END); \
\
__auto_type lenFile = ftello(fFile); \
if (varLen > 0xFFFFFFFF) { \
if (lenFile > 0xFFFFFFFF) { \
printf("%s cannot be over 4GB\n", argv[i]); \
return -2; \
} \
if ((varLen % APM_SECTOR_SIZE_CD) != 0) { \
if ((lenFile % APM_SECTOR_SIZE_CD) != 0) { \
printf("%s size must be a multiple of 2048 bytes\n", argv[i]); \
return -2; \
} \
@ -242,11 +242,11 @@ static void usage(char* arg0) {
fseek(fFile, 0, SEEK_END); \
\
__auto_type lenFile = ftello(fFile); \
if (varLen > len) { \
if (lenFile > len) { \
printf("%s cannot be over %d bytes\n", argv[i], len); \
return -2; \
} \
if ((varLen % APM_SECTOR_SIZE_CD) != 0) { \
if ((len % APM_SECTOR_SIZE_CD) != 0) { \
printf("%s size must be a multiple of 2048 bytes\n", argv[i]); \
return -2; \
} \
@ -263,6 +263,10 @@ static void usage(char* arg0) {
return -2; \
} \
fclose(fFile); \
/* SCSI drivers must have a 512 byte-aligned length */ \
if ((varLen % APM_SECTOR_SIZE) != 0) { \
varLen += APM_SECTOR_SIZE - (varLen % APM_SECTOR_SIZE); \
} \
} while (0)
#define READ_FILE_MAXLEN(var, i, length) READ_FILE_MAXLEN_IMPL(p##var, len##var, i, length)
@ -316,6 +320,7 @@ int main(int argc, char** argv) {
if (len43CDrv > LEN_DRV2_CAP) len43CDrv = LEN_DRV2_CAP;
if (lenATAATPI > LEN_DRV2_CAP) lenATAATPI = LEN_DRV2_CAP;
// how big is the ISO(bytes)?
fseek(fIso, 0, SEEK_END);
__auto_type lenIso = ftello(fIso);

View File

@ -3,7 +3,7 @@ This tool will take a standard ISO file created by your favourite tool and injec
You need the driver files for this tool to work, you can extract them from a Mac OS X install media (path is something like `/System/Library/PrivateFrameworks/MediaKit.framework/Versions/A/Resources/MKDrivers.bundle/Contents/Resources`). The files you need are:
- `Apple_Driver43.ptDR.drvr` (SCSI patch driver)
- `Apple_Driver43.ptDR.drvr` (SCSI patch driver) **(but the one from this folder cannot be used, see below)**
- `Apple_Driver43_CD.CDrv.drvr` (SCSI CD driver)
- `Apple_Driver_ATAPI.ptDR.drvr` (ATAPI patch driver)
- `Apple_Driver_ATAPI.ATPI.drvr` (ATAPI main driver)
@ -12,8 +12,10 @@ The tool will also work with raw images of these partitions.
Additionally this tool needs the raw image of the CD Apple Patch partition (containing patches `mesh / Mesh Itt Patch`, `scsi / CD SCSIMgr` and `snag / CDSnag`), you can extract this from a Mac OS X install media using 7-Zip (v24.09 or higher, this version fixes some bugs in APM parsing), example command line: `7z x -tapm "Apple Mac OS X 10.3.0 - Disk 1.iso" "Patch Partition.Apple_Patches"`
**There is a bug in the SCSI patch driver provided in the FS of the OSX install media, using it will cause a crash trying to SCSI boot.** Therefore, you must use the raw image of the partition from the OSX install media. Example command line: `7z x -tapm "Apple Mac OS X 10.3.0 - Disk 1.iso" "Macintosh.Apple_Driver43"`
Command line for this tool is as follows:
`oldiso <iso> <hfs_partition.img> Apple_Driver43.ptDR.drvr Apple_Driver43_CD.CDrv.drvr Apple_Driver_ATAPI.ptDR.drvr Apple_Driver_ATAPI.ATPI.drvr Patch Partition.Apple_Patches`
`oldiso <iso> <hfs_partition.img> Macintosh.Apple_Driver43 Apple_Driver43_CD.CDrv.drvr Apple_Driver_ATAPI.ptDR.drvr Apple_Driver_ATAPI.ATPI.drvr Patch Partition.Apple_Patches`
The iso file provided will be overwritten on disk, so make a backup of the original first.