poidasmith / winrun4j

WinRun4J Java Application Launcher
http://winrun4j.sourceforge.net
212 stars 63 forks source link

Resource.cpp: Fixed a security bug while working with the PE's resources #58

Closed talkain closed 10 years ago

talkain commented 10 years ago

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

poidasmith commented 10 years ago

Nice change. Thanks!