muta...@gmail.com
2021-04-30 07:43:18 UTC
I think I finally have the concept I want.
Forget Pos, Win32 APIs. Just stick with C90.
To conceptualize, start with MSVCRT.DLL.
When a Win32 application does an fread() it
will go to MSVCRT. Every application uses the
same MSVCRT.DLL, but it gets a fresh copy of
it so that the data areas are unique to this
executable, and the code pointers all point to
this data area.
Reentrant code is a job for another day and
conceptually unimportant.
The OS exports its own copy of the C90 library.
So:
typedef struct {
FILE/void *(*fopen)(char *filename, char *mode);
size_t (*fread)(void *ptr, size_t size, size_t nmemb, FILE/void *stream);
} C90;
MSVCRT may be implemented to make every C
function simply directly call its OS counterpart,
ie:
fread()
{
os_c90->fread();
}
fgets()
{
os_c90->fgets();
}
or it may just be fread() that calls os_c90, and
other functions like fgets() call a local (to
MSVCRT) fread(), ie:
fread()
{
os_c90->fread();
}
fgets()
{
fread();
}
Since the OS supports (via the BIOS) a hard disk
called 0x81, then the OS will do:
fopen(filename, mode)
{
if (strncmp(filename, "0x", 2) == 0)
{
bios_c90->fopen(filename, "r+b");
}
}
Since the OS supports FAT partitions within the hard
disk, it will do:
/* note - raw disk */
if (strcmp("filename, "C:") == 0)
{
fatpart_c90->fopen("fileptr:12340000,offset:512000", "r+b");
}
where fileptr is a pointer to the FILE * (or void *)
returned by the bios fopen of 0x81, and offset is
the byte offset within that hard disk. It is all
byte-based, sector size is transparent.
When a request from MSVCRT is received, it would
be a simple fopen("fred.txt") and the OS's fopen
would change that into:
fat_c90->fopen("fileptr:23450000,fred.txt");
where fileptr is what was returned by fatpart_c90.
I think mainframe CKD disks can be supported too,
as simple byte offsets, as the VTOC blocks are a
fixed size, and the data files can have a fixed
18452 block size, so everything should be at
predictable offsets and sizes, no different to FAT.
And a bios_c90->fopen("", "r");
would return a slew of information from the BIOS,
such as names that can be fopened to retrieve
available memory, available hard disks and
available floppies.
BFN. Paul.
Forget Pos, Win32 APIs. Just stick with C90.
To conceptualize, start with MSVCRT.DLL.
When a Win32 application does an fread() it
will go to MSVCRT. Every application uses the
same MSVCRT.DLL, but it gets a fresh copy of
it so that the data areas are unique to this
executable, and the code pointers all point to
this data area.
Reentrant code is a job for another day and
conceptually unimportant.
The OS exports its own copy of the C90 library.
So:
typedef struct {
FILE/void *(*fopen)(char *filename, char *mode);
size_t (*fread)(void *ptr, size_t size, size_t nmemb, FILE/void *stream);
} C90;
MSVCRT may be implemented to make every C
function simply directly call its OS counterpart,
ie:
fread()
{
os_c90->fread();
}
fgets()
{
os_c90->fgets();
}
or it may just be fread() that calls os_c90, and
other functions like fgets() call a local (to
MSVCRT) fread(), ie:
fread()
{
os_c90->fread();
}
fgets()
{
fread();
}
Since the OS supports (via the BIOS) a hard disk
called 0x81, then the OS will do:
fopen(filename, mode)
{
if (strncmp(filename, "0x", 2) == 0)
{
bios_c90->fopen(filename, "r+b");
}
}
Since the OS supports FAT partitions within the hard
disk, it will do:
/* note - raw disk */
if (strcmp("filename, "C:") == 0)
{
fatpart_c90->fopen("fileptr:12340000,offset:512000", "r+b");
}
where fileptr is a pointer to the FILE * (or void *)
returned by the bios fopen of 0x81, and offset is
the byte offset within that hard disk. It is all
byte-based, sector size is transparent.
When a request from MSVCRT is received, it would
be a simple fopen("fred.txt") and the OS's fopen
would change that into:
fat_c90->fopen("fileptr:23450000,fred.txt");
where fileptr is what was returned by fatpart_c90.
I think mainframe CKD disks can be supported too,
as simple byte offsets, as the VTOC blocks are a
fixed size, and the data files can have a fixed
18452 block size, so everything should be at
predictable offsets and sizes, no different to FAT.
And a bios_c90->fopen("", "r");
would return a slew of information from the BIOS,
such as names that can be fopened to retrieve
available memory, available hard disks and
available floppies.
BFN. Paul.