ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

winexe_pe.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef COMMON_WINEXE_PE_H
00024 #define COMMON_WINEXE_PE_H
00025 
00026 #include "common/hash-str.h"
00027 #include "common/hashmap.h"
00028 #include "common/str.h"
00029 #include "common/winexe.h"
00030 
00031 namespace Common {
00032 
00033 template<class T> class Array;
00034 class SeekableReadStream;
00035 
00037 enum PEResourceType {
00038     kPECursor =       0x01,
00039     kPEBitmap =       0x02,
00040     kPEIcon =         0x03,
00041     kPEMenu =         0x04,
00042     kPEDialog =       0x05,
00043     kPEString =       0x06,
00044     kPEFontDir =      0x07,
00045     kPEFont =         0x08,
00046     kPEAccelerator =  0x09,
00047     kPERCData =       0x0A,
00048     kPEMessageTable = 0x0B,
00049     kPEGroupCursor =  0x0C,
00050     kPEGroupIcon =    0x0E,
00051     kPEVersion =      0x10,
00052     kPEDlgInclude =   0x11,
00053     kPEPlugPlay =     0x13,
00054     kPEVXD =          0x14,
00055     kPEAniCursor =    0x15,
00056     kPEAniIcon =      0x16
00057 };
00058 
00063 class PEResources {
00064 public:
00065     PEResources();
00066     ~PEResources();
00067 
00069     void clear();
00070 
00072     bool loadFromEXE(const String &fileName);
00073 
00075     bool loadFromEXE(SeekableReadStream *stream);
00076 
00078     const Array<WinResourceID> getTypeList() const;
00079 
00081     const Array<WinResourceID> getNameList(const WinResourceID &type) const;
00082 
00084     const Array<WinResourceID> getLangList(const WinResourceID &type, const WinResourceID &name) const;
00085 
00087     SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &name);
00088 
00090     SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &name, const WinResourceID &lang);
00091 
00092 private:
00093     struct Section {
00094         uint32 virtualAddress;
00095         uint32 size;
00096         uint32 offset;
00097     };
00098 
00099     HashMap<String, Section, IgnoreCase_Hash, IgnoreCase_EqualTo> _sections;
00100 
00101     SeekableReadStream *_exe;
00102 
00103     void parseResourceLevel(Section &section, uint32 offset, int level);
00104     WinResourceID _curType, _curName, _curLang;
00105 
00106     struct Resource {
00107         uint32 offset;
00108         uint32 size;
00109     };
00110 
00111     typedef HashMap<WinResourceID, Resource, WinResourceID_Hash, WinResourceID_EqualTo> LangMap;
00112     typedef HashMap<WinResourceID,  LangMap, WinResourceID_Hash, WinResourceID_EqualTo> NameMap;
00113     typedef HashMap<WinResourceID,  NameMap, WinResourceID_Hash, WinResourceID_EqualTo> TypeMap;
00114 
00115     TypeMap _resources;
00116 };
00117 
00118 } // End of namespace Common
00119 
00120 #endif


Generated on Sat May 18 2019 05:01:30 for ResidualVM by doxygen 1.7.1
curved edge   curved edge