Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SYS: When OEM compatibility boot sector enabled and in use, /FORCE:LBA and /FORCE:CHS are silently ignored #94

Open
ecm-pushbx opened this issue Dec 31, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@ecm-pushbx
Copy link
Contributor

This is the part that applies the patches to the standard boot sector loader:

kernel/sys/sys.c

Lines 1562 to 1601 in 302b002

if (opts->kernel.stdbs)
{
/* copy over appropriate boot sector, FAT12 or FAT16 */
memcpy(newboot, (fs == FAT16) ? fat16com : fat12com, SEC_SIZE);
/* !!! if boot sector changes then update these locations !!! */
{
unsigned offset;
offset = (fs == FAT16) ? 0x176 : 0x179;
if ( (newboot[offset]==0x84) && (newboot[offset+1]==0xD2) ) /* test dl,dl */
{
/* if always use LBA then NOP out conditional jmp over LBA logic if A: */
if (opts->force==LBA)
{
offset+=2; /* jz */
newboot[offset] = 0x90; /* NOP */ ++offset;
newboot[offset] = 0x90; /* NOP */
}
else if (opts->force==CHS) /* if force CHS then always skip LBA logic */
{
newboot[offset] = 0x30; /* XOR */
}
}
else
{
printf("%s : fat boot sector does not match expected layout\n", pgm);
exit(1);
}
}
}
else
{
#ifdef WITHOEMCOMPATBS
printf("Using OEM (PC/MS-DOS) compatible boot sector.\n");
memcpy(newboot, (fs == FAT16) ? oemfat16 : oemfat12, SEC_SIZE);
#else
printf("Internal Error: no OEM compatible boot sector!\n");
#endif
}

For the OEM compatibility boot sector loader, no patches are applied. And that is true even though the LBA detection is very similar for the OEM loader, and could be patched similarly:

%ifdef TRYLBAREAD

@ecm-pushbx
Copy link
Contributor Author

Like my INSTSECT the SYS program could detect the unit handling and LBA detection sequences automatically, without need for the hardcoded offset value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants