ScummVM API documentation
winexe_pe.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef COMMON_WINEXE_PE_H
23 #define COMMON_WINEXE_PE_H
24 
25 #include "common/hash-str.h"
26 #include "common/hashmap.h"
27 #include "common/str.h"
28 #include "common/formats/winexe.h"
29 
30 namespace Common {
31 
41 template<class T> class Array;
42 class SeekableReadStream;
43 
48 class PEResources : public WinResources {
49 public:
50  PEResources();
51  ~PEResources();
52 
54  void clear();
55 
58 
60  bool loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle = DisposeAfterUse::YES);
61 
63  const Array<WinResourceID> getTypeList() const;
64 
66  const Array<WinResourceID> getIDList(const WinResourceID &type) const;
67 
69  const Array<WinResourceID> getLangList(const WinResourceID &type, const WinResourceID &id) const;
70 
73 
75  SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &id, const WinResourceID &lang);
76 
78  String loadString(uint32 stringID);
79 
80 protected:
81  VersionInfo *parseVersionInfo(SeekableReadStream *stream);
82 
83 private:
84  struct Section {
85  uint32 virtualAddress;
86  uint32 size;
87  uint32 offset;
88  };
89 
91 
92  SeekableReadStream *_exe;
93  DisposeAfterUse::Flag _disposeFileHandle;
94 
95  void parseResourceLevel(Section &section, uint32 offset, int level);
96  WinResourceID _curType, _curID, _curLang;
97 
98  struct Resource {
99  uint32 offset;
100  uint32 size;
101  };
102 
106 
107  TypeMap _resources;
108 };
109 
112 } // End of namespace Common
113 
114 #endif
String loadString(uint32 stringID)
Definition: str.h:59
const Array< WinResourceID > getLangList(const WinResourceID &type, const WinResourceID &id) const
Definition: winexe_pe.h:48
const Array< WinResourceID > getIDList(const WinResourceID &type) const
Definition: array.h:52
Definition: stream.h:745
virtual bool loadFromEXE(const Path &fileName)
SeekableReadStream * getResource(const WinResourceID &type, const WinResourceID &id)
Definition: hashmap.h:85
Definition: algorithm.h:29
Definition: winexe.h:69
const Array< WinResourceID > getTypeList() const
Definition: winexe.h:110
Definition: winexe.h:149
bool loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle=DisposeAfterUse::YES)