Overview
The Load Module APIs allow you to dynamically load a module (shared library/DLL) into a process at runtime. This is useful for injecting code, loading plugins, or dynamically extending functionality.lm_module_t Structure
Thelm_module_t structure contains information about a loaded module:
Fields
Base address where the module is loaded in memory
End address of the module in memory
Total size of the module in bytes
Full file system path to the module
Name of the module (filename)
LM_LoadModule
Loads a module from a specified path into the current process.Signature
Parameters
The path of the module to be loaded. This should be the full file system path to the library/DLL file.
A pointer to a
lm_module_t type, which is used to store information about the loaded module (optional). Pass LM_NULLPTR if you don’t need the module information.Returns
ReturnsLM_TRUE if the module was loaded successfully, or LM_FALSE if it fails.
Example
Loading Without Module Info
If you don’t need information about the loaded module, you can passLM_NULLPTR for the module_out parameter:
LM_LoadModuleEx
Loads a module from a specified path into a specified process.Signature
Parameters
The process that the module will be loaded into.
The path of the module to be loaded. This should be the full file system path to the library/DLL file.
A pointer to a
lm_module_t type, which is used to store information about the loaded module (optional). Pass LM_NULLPTR if you don’t need the module information.Returns
ReturnsLM_TRUE if the module was loaded successfully, or LM_FALSE if it fails.
Example
Platform-Specific Notes
Windows
- Uses
LoadLibraryinternally - Requires full path or the DLL must be in the system search path
- File extensions:
.dll
Linux/FreeBSD
- Uses
dlopeninternally - File extensions:
.so,.so.1, etc. - Module must be in the library search path or use an absolute path
Cross-Platform Example
See Also
- Unload Module - Unload a module from a process
- Find Module - Find a loaded module by name
- Enumerate Modules - Enumerate all modules in a process