Now I can load Dynamic-Link Libraries with static load(include the necessary headers, and use #pragma comment (lib, “xxx”)) and dynamic load(with function LoadLibrary or LoadLibraryEx).
Some companies ask the other ways to load Dynamic-Link Libraries in their interview.
But I wonder whether exists other ways to load the Dynamic-Link Libraries?
The term “loading” is a bit vague. A DLL never gets “loaded”. The term “dynamically loaded library” is from 16-bit Windows era. Today, contents of a DLL is mapped into the memory using paging. So if they mean copying it’s contents to memory by loading, you can even “load” a DLL by reading it directly.
If they mean calling their functions, you can also do that “without” loading the DLL, for instance by using
rundll32.exe(which maps the DLL into it’s own process space, not yours).And you can of course always imitate what
LoadLibrarydoes by initializing function pointers by analyzing DLL’s PE structure, callingDllMain()and scanning it’s export table.