This API allows a user to try to pre-load all delay load DLLs and get back information on any delay load DLLs that failed to load properly. You can also unload the delay load DLLs.
The API will first be described in a generic, language-agnostic manner. The C bindings will be given later.
The basic API operations (aka functions) are: LOAD, UNLOAD, GET_DLL_ERRORS, GET_FUNC_ERRORS, IS_DLL_LOADED, IS_DLL_FULLY_LOADED.
Each of the operations returns a status code along with any other return values. The status code is a Win32 error value. It is used to signal an error in calling the function (ERROR_INVALID_PARAMETER) or an out of memory condition (ERROR_NOT_ENOUGH_MEMORY). Otherwise, the status code will be zero (ERROR_SUCCESS).
ERROR_SUCCESS, ERROR_NOT_ENOUGH_MEMORY
handle = LOAD()
ERROR_SUCCESS, ERROR_INVALID_PARAMETER
UNLOAD(handle)
ERROR_SUCCESS, ERROR_INVALID_PARAMETER
dll_errors = GET_DLL_ERRORS(handle)
ERROR_SUCCESS, ERROR_INVALID_PARAMETER
func_errors = GET_FUNC_ERRORS(handle)
ERROR_SUCCESS, ERROR_INVALID_PARAMETER
boolean = IS_DLL_LOADED(handle, dll_name)
ERROR_SUCCESS, ERROR_INVALID_PARAMETER
boolean = IS_DLL_FULLY_LOADED(handle, dll_name)
API Function | C Function | |
LOAD | DelayLoadDllsLoad | |
UNLOAD | DelayLoadDllsFree | |
GET_DLL_ERRORS | DelayLoadDllsGetDllErrors | |
GET_FUNC_ERRORS | DelayLoadDllsGetFuncErrors | |
IS_DLL_LOADED | DelayLoadDllsLoadedDll | |
IS_DLL_FULLY_LOADED | DelayLoadDllsLoadedDllAll |
If a DLL fails to load, it would be nice to figure out whether it, in turn, failed to load a DLL. If so, report the failed DLL.
A potential way to do this might be to traverse a DLL's import table...TBD...
Write API documentation first. Take care to have better function names. (Reading Code Complete and writing the API documentation in a language-agnostic way (as opposed to C-centric) helps a lot.)