Information on File Handles, the System File Table, etc.

On this page, I will try to have information on DOS's file handles, the System File Table, and other information about files. Most of this information is undocumented by DOS.

What value is specified for FILES=n in CONFIG.SYS without reading CONFIG.SYS
To find out what FILES=n is set to, you have to walk through the SFTs (System File Tables).

In the List of Lists, (service 52h of DOS returns address), offset 04h holds a far pointer to the SFTs. Then each SFT holds a far pointer to the next SFT and a number of entries in this table.

If the offset to the next SFT specified is 0xFFFF then this is the last SFT.

Here is a little code in C to count the amount file files allowed. Please note: DOS 1.x used FCBs, not handles, so this will not work on DOS 1.x

#include <dos.h>
#include <stdio.h>
#include <stdlib.h>

union REGS regs;
struct SREGS sregs;

unsigned int  far *ptr;
         int  files = 0;

int main(int argc, char *argv[]) {
  regs.h.ah = 0x52;
  intdosx(&regs, &regs, &sregs);
  
  ptr = (unsigned int far *) (((unsigned long) sregs.es << 16) | (unsigned) regs.x.bx + 4);
  ptr = (unsigned int far *) (((unsigned long) ptr[1] << 16) | (unsigned) ptr[0]);
  while ( FP_OFF(ptr) != 0xFFFF ) {
    files += ptr[2];
    ptr = (unsigned int far *) (((long) ptr[1] << 16) | (unsigned) ptr[0]);
  }
  
  printf("\nFILES=%u\n", files);
}