DLL Common Specifications

DLL Common Specifications

This specification defines a common interface for DLL modules used in SHIORI, SAORI, and other systems.

Memory management

All argument/return value processing is performed using Windows Global Memory. Specifically, the following procedure is used:

Important notes:

request function

extern "C" __declspec(dllexport) HGLOBAL __cdecl request(HGLOBAL h, long *len);

All requests are made through a single function, request, which is the primary interface to the module and handles all requests from the baseware.

The request data format is designed with reference to the HTTP and SSTP header formats, and follows the rules below:

Life cycle functions

The following functions are called when loading and unloading DLLs.

loadu function

extern "C" __declspec(dllexport) BOOL __cdecl loadu(HGLOBAL h, long len);

Function to initialize the module.
The first argument, global memory, contains the module's directory path in UTF-8 encoding.

Implemented since SSP 2.6.92 (2025/1/16). Prior to that, only "load" was implemented.

Example of processing content:

  • Load the necessary data files using the passed path as the current directory
  • Initialize resources required for module operation
  • Initialize log files and databases as needed

Important notes:

  • Always release passed global memory even when string data is not needed
  • Returns TRUE if initialization succeeds, FALSE if it fails
  • This function is preferentially used by baseware

load function

extern "C" __declspec(dllexport) BOOL __cdecl load(HGLOBAL h, long len);

Previous version of the loadu function.
Same specification as the loadu function, except that the module directory path of the first argument is encoded in the default OEM codepage (CP932 in a Japanese environment).

Important notes:

  • Used as a fallback designation when the loadu function is not implemented
  • For compatibility, it is desirable to implement both "load" and "loadu", and ignore "load" if it is called when "loadu" is already initialized
  • For Unicode support, the received path must be converted to a full-width string where appropriate

unload function

extern "C" __declspec(dllexport) BOOL __cdecl unload();

Function to handle module termination. This function is called by the baseware when a module is unloaded.

Processes that should be implemented:

  • Release a file handle opened by CreateFile, etc.
  • Release synchronization objects created by CreateMutex, etc.
  • Wait for threads created by CreateThread, etc., to finish and perform post-processing
  • Release all other system resources reserved by the module

The return value is not currently used, but should return TRUE for future expandability.