poidasmith/winrun4j — pull request #58 by talkain (2014-01-02 23:35:59+00:00)
Title: Resource.cpp: Fixed a security bug while working with the PE's resources

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