================================================================================ Irrlicht Windows Resource Archive Loader (c) Gaz Davidson 2009 ================================================================================ 1. About ================================================================================ This archive loader can be used to read resources from Windows PE and PE32+ binaries. This is useful for extracting icons and other data from exe and DLL files in a cross platform way. It would have been much more sensible to use the Win32 API to do this, if you're not using windows then why on earth do you need to load resources from windows executables? Well, it's an interesting problem and I couldn't find an open source c++ resource decompiler, so I made this one! ================================================================================ 2. Details ================================================================================ By default this archive loader supports Windows PE binaries with the file extension .exe, .dll, .ocx, .cpl and .scr. Inside such binaries, resources are held in a path in the form: TYPE/NAME/LANG Where: TYPE is the type identifier NAME is the name or number of the entry, and LANG is the language code However, this loader converts this to a nicer format: [LANG/]NAME.EXT Where: LANG is the optional path to the file NAME is the ID of the file EXT is the extension of this type of file data, or the TYPE if unknown Because the file headers are missing from some types of file data, you wouldn't be able to pass this file directly to Irrlicht's loaders and have it automagically open. So, I've taken the liberty of reconstructing the file data for some known data types so that this action is completely transparent. +--------------+------------+---------------------------------------------+ | File type | Extension | Data details and changes | +--------------+------------+---------------------------------------------+ | Cursor | .cur | Cursor without file header, header is added | | Cursor Group | .group.cur | References to many cursors, file is built | | Bitmap | .bmp | Bitmap header is edited and extended. | | Icon | .ico | Icon without file header, header is added. | | Icon Group | .group.ico | References to many icons, file is built | | Manifest | .xml | No changes. UTF8 so not readable by irrXML | +--------------+------------+---------------------------------------------+ All other data types are dumped out as they are inside the EXE. JPEG and DIB files work without messing with the data. I expect GIF files would also if Irrlicht had a GIF loader. ================================================================================ 3. Usage ================================================================================ /* The following code shows how to load a bitmap from one of the standard executables that comes with Windows XP/2k/Vista and display it in the GUI. */ // create an instance of the loader and add it to the filesystem io::CArchiveLoaderRes* resLoader = new io::CArchiveLoaderRes(fs); fs->addArchiveLoader(resLoader); // We created it with new, so we must drop() when finished with it. resLoader->drop(); // Now we can add an executable to the filesystem as an archive. // By default we ignore the paths which may mean we get the wrong language // but most of the time this won't matter. fs->addFileArchive("c:\\windows\\system32\\inetcpl.cpl"); // now let's extract a bitmap and add it to the GUI guienv->addImage(driver->getTexture("4474.bmp"), core::vector2di(0,0)); ================================================================================ 3. License ================================================================================ Copyright (c) 2009 Gaz Davidson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.