LibLoader (v2) 2.0.1.4
Project rewrite
Started code from scratch, to improve code logic and eliminate errors that were introduced in v1 causing slow load/eternal loop/crashes.
Change Log: Core_LibLoader.pas (v1) to Loader.pas (v2)
Overview
This document outlines the significant changes and improvements made in the rewrite of the Lib-Loader unit from version 1 (Core_LibLoader.pas) to version 2 (Loader.pas). The new version introduces enhancements in configuration handling, modular loading, compatibility checks, logging, and overall code structure.
Key Changes and Improvements
Configuration Handling
- Whitespace Handling:
- v1: Potential issues with parsing directories and file lists with whitespace.
- v2: Improved handling of whitespace in directory and file lists to prevent parsing errors.
Modular Loading
-
Modular Loading Process:
- v1: Basic modular loading with limited functionality.
- v2: Enhanced loading process with the ability to load multiple modules specified in the configuration file, and support for the newest version of modules when multiple versions are found.
-
Retry Logic:
- v1: No retry logic for loading modules.
- v2: Introduced retry logic with a configurable maximum number of retries for loading modules.
Compatibility Checks
- Architecture Compatibility:
- v1: Limited or no checks for architecture compatibility between the host and the modules.
- v2: Implemented comprehensive compatibility checks to ensure that only modules compatible with the host architecture (x86/x64) are loaded.
Logging Enhancements
-
Detailed and Structured Logs:
- v1: Introduced detailed logging with Indentation and other features to output a clean/readable log file.
- v2: Detailed logging with clear indentation and structure for readability. Cut back on too much debug details.
-
Customizable Debug Output:
- v1: No support for toggling debug messages.
- v2: Debug messages can be toggled on or off via the configuration file.
Code Structure and Maintenance
- Improved Code Structure:
- v1: Monolithic code structure with less modularity.
- v2: Refactored into a more modular and maintainable structure with clear separation of concerns.
Detailed Description of Changes
Modular Loading
- Enhanced Loading Process:
- Introduced a new method to identify and load the newest version of a module when multiple versions are found.
- Detailed logging of the module search and loading process.
- Retry logic for loading modules, with configurable maximum retries.
Compatibility Checks
- Implemented Architecture Compatibility:
- Functions
IsHostX64andIsDllX64determine the architecture of the host and modules. - Ensures that only modules compatible with the host architecture are loaded.
- Functions
Enhanced Logging usage
-
Detailed and Structured Logs:
- Logs include detailed information about each step of the loading process.
- Clear indentation and structure for readability.
- Headers and horizontal rules improve log readability.
-
Customizable Debug Output:
- Debug messages can be toggled via the configuration file, allowing for verbose logging during development and concise logging in production.
Code Structure and Maintenance
-
Refactored Code Structure:
- Improved modularity and maintainability.
- Clear separation of concerns, with each function and procedure handling specific tasks.
-
Enhanced Documentation:
- Added detailed comments and documentation for better code understanding and maintenance.
- Improved readability and maintainability of the code.
Usage Instructions
Configuration File (Loader.cfg)
The configuration file should be structured as follows:
[Loader]
Enabled = 1
Files = Test.dll, PEInfo_x64.dll
ModFolders = C:\GameFolder\mods, D:\Projects\Git\Test\Win64\Debug
[Debug]
Enabled = 1
[Log]
Append = 0
[Experimental]
ManualMap = 0