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
30namespace Common {
31
41template<class T> class Array;
42class SeekableReadStream;
43
48class PEResources : public WinResources {
49public:
52
54 void clear() override;
55
58
60 bool loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle = DisposeAfterUse::YES) override;
61
63 const Array<WinResourceID> getIDList(const WinResourceID &type) const override;
64
66 const Array<WinResourceID> getLangList(const WinResourceID &type, const WinResourceID &id) const override;
67
69 SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &id) override;
70
72 SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &id, const WinResourceID &lang) override;
73
75 String loadString(uint32 stringID) override;
76
79
80protected:
81 VersionInfo *parseVersionInfo(SeekableReadStream *stream) override;
82
83private:
84 struct Section {
85 uint32 virtualAddress;
86 uint32 size;
87 uint32 offset;
88 };
89
91
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
103 typedef HashMap<WinResourceID, Resource, WinResourceID_Hash, WinResourceID_EqualTo> LangMap;
104 typedef HashMap<WinResourceID, LangMap, WinResourceID_Hash, WinResourceID_EqualTo> IDMap;
105 typedef HashMap<WinResourceID, IDMap, WinResourceID_Hash, WinResourceID_EqualTo> TypeMap;
106
107 TypeMap _resources;
108};
109
112} // End of namespace Common
113
114#endif
Definition: array.h:52
Definition: hashmap.h:85
Definition: winexe_pe.h:48
const Array< WinResourceID > getTypeList() const
void clear() override
SeekableReadStream * getResource(const WinResourceID &type, const WinResourceID &id) override
bool loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle=DisposeAfterUse::YES) override
SeekableReadStream * getResource(const WinResourceID &type, const WinResourceID &id, const WinResourceID &lang) override
String loadString(uint32 stringID) override
const Array< WinResourceID > getIDList(const WinResourceID &type) const override
const Array< WinResourceID > getLangList(const WinResourceID &type, const WinResourceID &id) const override
Definition: stream.h:745
Definition: str.h:59
Definition: winexe.h:69
Definition: winexe.h:110
virtual bool loadFromEXE(const Path &fileName)
Definition: algorithm.h:29
Definition: winexe.h:149