ScummVM API documentation
winexe_ne.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_NE_H
23#define COMMON_WINEXE_NE_H
24
25#include "common/formats/winexe.h"
26#include "common/list.h"
27#include "common/str.h"
28
29namespace Common {
30
40template<class T>
41class Array;
42class SeekableReadStream;
43
44// NE executable segment
45struct NESegment {
46 static constexpr uint16 kFlagSingleData = 1;
47 static constexpr uint16 kFlagMultipleData = 2;
48 static constexpr uint16 kFlagLinkError = 0x2000u;
49 static constexpr uint16 kFlagLibModule = 0x8000u;
50
51 uint32 offset;
52 uint32 size;
53 uint16 flags;
54};
55
62class NEResources : public WinResources {
63public:
66
67 static constexpr uint32 kInvalidAddress = 0xFFFFFFFF;
68
70 void clear() override;
71
74
76 bool loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle = DisposeAfterUse::YES) override;
77
79 const Array<WinResourceID> getIDList(const WinResourceID &type) const override;
80
82 SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &id) override;
83
85 String loadString(uint32 stringID) override;
86
88 const Array<NESegment> &getSegments() const { return _segments; }
89
90 /* Index of NE automatic segment */
91 uint32 getAutomaticSegmentIndex() const { return _autoSegmentIndex; }
92
93protected:
94 VersionInfo *parseVersionInfo(SeekableReadStream *stream) override;
95
96private:
98 struct Resource {
99 WinResourceID id;
100
101 WinResourceID type;
102
103 uint32 offset;
104 uint32 size;
105
106 uint16 flags;
107 uint16 handle;
108 uint16 usage;
109 };
110
111 SeekableReadStream *_exe;
112 DisposeAfterUse::Flag _disposeFileHandle;
113
114 uint32 _autoSegmentIndex = 0;
115 Array<NESegment> _segments;
116
118 List<Resource> _resources;
119
120 typedef HashMap<WinResourceID, Common::String, WinResourceID_Hash, WinResourceID_EqualTo> IDMap;
121 typedef HashMap<WinResourceID, IDMap, WinResourceID_Hash, WinResourceID_EqualTo> TypeMap;
122 TypeMap _nameTable;
123
125 uint32 getResourceTableOffset();
127 bool readResourceTable(uint32 offset);
128
130 bool readNameTable(uint32 offset, uint32 size);
131
133 const Resource *findResource(const WinResourceID &type, const WinResourceID &id) const;
134
136 static String getResourceString(SeekableReadStream &exe, uint32 offset);
137};
138
141} // End of namespace Common
142
143#endif
Definition: array.h:52
Definition: winexe_ne.h:62
bool loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle=DisposeAfterUse::YES) override
void clear() override
SeekableReadStream * getResource(const WinResourceID &type, const WinResourceID &id) override
const Array< WinResourceID > getIDList(const WinResourceID &type) const override
String loadString(uint32 stringID) override
const Array< NESegment > & getSegments() const
Definition: winexe_ne.h:88
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_ne.h:45