Home |
RTTarget-32 Programming Manual Running Win32 Programs without Win32 Running a Program on the Target Running with or without Paging Installing Hardware Interrupt Handlers Catching NULL Pointer Assignments Running without Run-Time System Configuration for Debug and Release Builds Loading DLLs through a File System Using the MetaWINDOW Graphics Library Custom MP Floating Pointer Structure Compiling and Linking with On Time RTOS-32 |
Loading DLLs through a File SystemRTTarget-32 can load DLLs as files in addition to loading them from the program image. This feature can be useful for applications using RTFiles-32, which need to dynamically load only a subset of available DLLs. The actual DLL file format used by RTTarget-32 is not identical (but similar) to the PE format used by Win32. Rather, DLM (Dynamically Loadable Modules) are used. Command line utility MakeDLM can convert a standard Win32 DLL to a DLM. Win32 API function LoadLibrary should always be passed the original DLL's file name; it will automatically convert extension DLL to DLM if the DLL is to be loaded as a file. LoadLibrary first checks whether the DLL is loaded already; if so, its reference count is incremented. If it is not found, LoadLibrary attempts to open the corresponding .DLM file. The file is first searched in the default directory, then in all directories given in the PATH environment variable (see RTLoc command SET on how to specify a PATH on the target). If the file is found, it is loaded. If no file is found, LoadLibrary attempts to locate the DLL in the program's image. Thus, a program image can contain a DLL which can be replaced with a DLM file without rebuilding the program image. DLLs loaded as DLM files cannot be statically referenced by the program EXE or any DLL the main EXE statically references, either directly or indirectly. DLMs can only be loaded through LoadLibrary. However, a DLM can reference other DLMs and DLLs of the program image. A single call to LoadLibrary can load any number of DLLs through the file system or from the program image. LoadLibrary does not support imports or exports by ordinal. The only exception are ordinal imports of DLLs linked into the program image that have been resolved through RTLoc's Link command. When LoadLibrary loads a DLM, it will require approximately 2k of stack space. The application should ensure that enough stack space is available. The maximum number of DLLs which can be loaded simultaneously is 63. This limit applies to all DLLs, regardless of how they were loaded. DLLs loaded as DLM files can be debugged with RTD32 just like DLLs loaded from the program image. However, the debugger will need access to the original DLL and to the associated debug symbols on the host. For Borland compilers, the symbol tables can reside within the DLL or in a separate TDS file. To reduce the memory requirements of a DLM at run time, it is recommended to move the debug symbol tables to a TDS file using Borland's command line utility TDSTRP32 prior to running MakeDLM. For Microsoft compilers, the TDS file can be generated by MakeDLM using command line option -g+. Demo program DLLDemo3 shows how DLMs can be used. DLLDemo3 does not actually need RTFiles-32. Instead, it loads a DLM file through RTTarget-32's RAM File System. Advantages of DLMs
Disadvantages of DLMs
|