By calling LoadLibrary, the Resource class loads the executable and runs
its DllMain (in case of a DLL). This behavior is incorrect since the user
expects the PE to be loaded as a data file in order to work with its
resources.
By replacing LoadLibrary with the call to LoadLibraryEx with the proper
flags (LOAD_LIBRARY_AS_DATAFILE flag for read-only access and
LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE for write access) the class loads
the executable without executing its code.
By calling LoadLibrary, the Resource class loads the executable and runs its DllMain (in case of a DLL). This behavior is incorrect since the user expects the PE to be loaded as a data file in order to work with its resources.
By replacing LoadLibrary with the call to LoadLibraryEx with the proper flags (LOAD_LIBRARY_AS_DATAFILE flag for read-only access and LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE for write access) the class loads the executable without executing its code.
More information can be found under: http://msdn.microsoft.com/en-us/library/windows/desktop/ms684179(v=vs.85).aspx
Signed-off-by: Tal Kain tal@kain.net