Thursday, August 21, 2008

Explicitly Load the DLL Module -- flags of LoadLibraryEx()

HINSTANCE LoadLibraryEx(
PCTSTR pszDLLPathName,
HANDLE hFile,
DWORD dwFlags);

DONT_RESOLVE_DLL_REFERENCES
1. Causes the system to simply map the file image without calling DllMain.
2. The system does not automatically load any of the additional DLLs that required by this DLL into the process's address space.

LOAD_LIBRARY_AS_DATAFILE
1. Load a DLL that contains only resources and no functions. The HINSTANCE value returned from LoadLibraryEx in calls to functions that load resources.
2. Also, you can use the LOAD_LIBRARY_AS_DATAFILE flag if you want to use resources that are contained in an .exe file. Normally, loading an .exe file starts a new process, but you can also use the LoadLibraryEx function to map an .exe file's image into a process's address space. With the mapped .exe file's HINSTANCE value, you can access resources within it. Because an .exe file doesn't have the DllMain function, you must specify the LOAD_LIBRARY_AS_DATAFILE flag when you call LoadLibraryEx to load an .exe file.

LOAD_WITH_ALTERED_SEARCH_PATH
Changes the search algorithm that LoadLibraryEx uses to locate the specified DLL file.

Note: The search algorithm is discussed in Chapter 18.

No comments: