Skip to content

Commit 86db573

Browse files
ecm-pushbxPerditionC
authored andcommitted
sys.c: in _dos_findfirst set DTA rather than copying from PSP:80h
Running prior to this commit, a /K switch with a name at a certain position will write all-blanks into the boot sector loader. If that happens, lDOS instsect will not detect a valid load file name: C:\>sys a: /bootonly /k ldos.com System transferred. C:\>instsect /bo a: Detected FAT12 FS. Keeping original sector loader. Sector valid, FS ID match and proper jump. Type heuristic: "FreeDOS (FreeDOS)" No name detected. Unit selection code not found in sector. Keeping as is. Part info code not found in sector. Keeping as is. Query geometry code not found in sector. Keeping as is. Auto LBA detection (HDD only) found in sector. Keeping as is. Previous geometry: 2 CHS Heads, 18 CHS Sectors, 0 Hidden Writing boot sector to sector. C:\> Running after this commit sets the name as desired: C:\>sys a: /bootonly /k ldos.com System transferred. C:\>instsect /bo a: Detected FAT12 FS. Keeping original sector loader. Sector valid, FS ID match and proper jump. Type heuristic: "FreeDOS (FreeDOS)" 1st name: "LDOS.COM" Unit selection code not found in sector. Keeping as is. Part info code not found in sector. Keeping as is. Query geometry code not found in sector. Keeping as is. Auto LBA detection (HDD only) found in sector. Keeping as is. Previous geometry: 2 CHS Heads, 18 CHS Sectors, 0 Hidden Writing boot sector to sector. C:\> For reference, the libi86 implementation of _dos_findfirst also sets the DTA to the user buffer rather than copying around the resulting search record. So it is likely that Turbo C or Watcom do it similarly to this: https://gitlab.com/tkchia/libi86/-/blob/3ecc4164999a5807c40cf2c159dc94dd07f7df03/host-gcc/dos/dos-findfirst.c#L43
1 parent 383c05a commit 86db573

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sys/sys.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,19 @@ int _dos_findfirst(const char *file_name, unsigned int attr,
197197
struct find_t *find_tbuf)
198198
{
199199
union REGS in, out;
200+
struct SREGS sr;
201+
in.h.ah = 0x1A; /* set DTA */
202+
in.x.dx = FP_OFF(find_tbuf);
203+
sr.ds = FP_SEG(find_tbuf);
204+
intdosx(&in, &out, &sr);
200205
in.h.ah = 0x4e;
201206
in.x.dx = FP_OFF(file_name);
202207
in.x.cx = attr;
203208
intdos(&in, &out);
204209
if (out.x.cflag)
205210
return out.x.ax;
206-
memcpy(find_tbuf, (void *)0x80, sizeof(*find_tbuf));
211+
/* memcpy(find_tbuf, (void *)0x80, sizeof(*find_tbuf)); */
212+
/* did set DTA to find_tbuf prior */
207213
return 0;
208214
}
209215
#else

0 commit comments

Comments
 (0)