Skip to content

cm3d2.dll API

Geoffrey Horsington edited this page Jun 23, 2018 · 25 revisions

Filesystem types

CM3D2.dll recognizes two filesystem types: Windows (0) and Archive (1).

Filesystem structures

Externally, a filesystem is a struct:

struct FileSystem {
    int* internals_ptr;    // Pointer to the internal structure
    int  fs_type;          // Type of the filesystem (0 = windows, 1 = archive)
};

Internal file system

An internal file system consists of the following interfaces: InterfaceFileShare, InterfaceFileSystemAnsi, InterfaceFileSystemWide, InterfaceFileSystemUtf8, InterfaceFileSystem.

Archive internals

Internally, the class of

The archives' internals contains the following values.

The location is in bytes and relative to structure's start address.

Type Location (HEX) Value Notes
Address 0 0x7FFF0F641A10 Pointer to a part of vftable for FileSystemArchive
Address 8 0x7FFF0F6419E8 Pointer to compile-time constant; Value: 0xF8FF FFFF 7000 0000
Address 10 0x7FFF0F641498 Pointer to a part of vftable for FileSystemArchive
Address 18 0x7FFF0F641D88 Pointer to compile-time constant; Value: 0xF8FF FFFF 6000 0000
Address 20 0x7FFF0F641A50 Pointer to a part of vftable for FileSystemArchive
Address 28 0x7FFF0F641C30 Pointer to compile-time constant; Value: 0xF8FF FFFF 5000 0000
std::wstring 30 - 50 0x0000ADBA0DF0ADBA Current base directory
std::list 58-60 0x0 List of loaded ARCs?
Value 68 0x0 NULL
Value 70 0x0DF0ADBA00000000 Junk?
Address 78 0x7FFF0F6419D8 Pointer to vftable of FileSystemArchive

Notes

  • Only the 4 top bytes are used fron 8, 18 and 28. Thus essentially they contain values 70, 60 and 50 respectively
  • qword at 0x7FFF26350DE8 contains a running counter (of how many filesystems are initialized?)

FileSystemArchive

Signature:

public class FileSystemArchive: public InterfaceFileSystem;

public class InterfaceFileSystem: public InterfaceFileSystemAnsi, public InterfaceFileSystemWide, public InterfaceFileSystemUtf8;

public class InterfaceFileSystemAnsi: public InterfaceFileShare;
public class InterfaceFileSystemWide: public InterfaceFileShare;
public class InterfaceFileSystemUtf8: public InterfaceFileShare;

public virtual class InterfaceFileShare;

FileSystemArchive has the following functions:

First VFTable

Index Function signature
0
1
2
3
4 Internal function for SetBaseDirectory
5 void SetBaseDirectory(*this, char* path)
6 Internal function for AddArchive
7
8 Internal for AddArchive
9 void AddArchive(*this, char* path)
10 void AddAutoPathForAllFolder(*this)
11
12
13 void AddAutoPath(*this, char* path)
14
15
16
17
18
19
20
21 Pointer to _LocaleUpdate::GetLocaleT()

Second VFTable (implements InterfaceFileSystemWide)

Index Function signature
0
1
2 CreateFileTraverse_Impl (used only locally, not in the public API)

Third VFTable

Index Function signature
0 FileMemory* GetFile(*this, char* file_str)
1
2 std::vector<std::string*>* CreateList(*this, std::vector<std::string*>* vector, char* path, ListType list_type)
3 (NOTE: Is structure; likely a lambda)
4
5
6
7
8 BOOL IsExistentFile(*this, char* path)
9
10

Fourth VFTable (InterfaceFileShare)

Index Function signature
0 bool IsValid(*this)
1

File lists

A file list is a struct

struct FileListData 
{
    std::vector<std::string*> *file_list;
    int size;
}

The pointer to the vector is a simple IntPtr in C#.

Clone this wiki locally