One of the solutions:
Put
Struct Pakfilesystem
{
RTFILESYSTEM DFS;
Pakopenfile * files;
}
Change to
Struct Pakfilesystem
{
RTWINFILESYSTEM DFS;
Pakopenfile * files;
}
And this structure must be rwmalloc or rwcalloc, because it is to be released through RWFree, cannot be global variables.
Because this custom file system uses the FSCLOSE function pointer points to the default file system's function, that is, Windows, that function will access an RTWINFILESYSTEM structure, which is through the incoming RTFileSystem type pointer.
But RTWInfileSystem is larger than RTFileSystem. Leading upwards.
The Windows default file system is installed in Win.C RWBool PsinstallFileSystem (Void), then RTWINFSYSTEMINIT (). Refer to the function in RTFSWIN.C in the SRC, fs-> fsclose = tkinfsclose;
Static void TkwinfsClose (RTFileSystem * WinFileSystem).
I used to rely on this issue for Renderware Support, and their solutions were different from me, as if they were replaced by FSCLOSE points to.