ScummVM API documentation
winexe.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_H
23 #define COMMON_WINEXE_H
24 
25 #include "common/hash-str.h"
26 #include "common/str.h"
27 #include "common/types.h"
28 
29 namespace Common {
30 
40 class Path;
41 class SeekableReadStream;
42 
45  kWinCursor = 0x01,
46  kWinBitmap = 0x02,
47  kWinIcon = 0x03,
48  kWinMenu = 0x04,
49  kWinDialog = 0x05,
50  kWinString = 0x06,
51  kWinFontDir = 0x07,
52  kWinFont = 0x08,
53  kWinAccelerator = 0x09,
54  kWinRCData = 0x0A,
55  kWinMessageTable = 0x0B,
56  kWinGroupCursor = 0x0C,
57  kWinGroupIcon = 0x0E,
58  kWinNameTable = 0x0F,
59  kWinVersion = 0x10,
60  kWinDlgInclude = 0x11,
61  kWinPlugPlay = 0x13,
62  kWinVXD = 0x14,
63  kWinAniCursor = 0x15,
64  kWinAniIcon = 0x16,
65  kWinHTML = 0x17,
66  kWinManifest = 0x18
67 };
68 
70 public:
71  WinResourceID() { _idType = kIDTypeNull; _id = 0; }
72  WinResourceID(String x) { _idType = kIDTypeString; _name = x; }
73  WinResourceID(uint32 x) { _idType = kIDTypeNumerical; _id = x; }
74 
75  WinResourceID &operator=(const String &x);
76  WinResourceID &operator=(uint32 x);
77 
78  bool operator==(const String &x) const;
79  bool operator==(const uint32 &x) const;
80  bool operator==(const WinResourceID &x) const;
81 
82  String getString() const;
83  uint32 getID() const;
84  String toString() const;
85 
86 private:
88  enum IDType {
89  kIDTypeNull,
90  kIDTypeNumerical,
91  kIDTypeString
92  } _idType;
93 
94  String _name;
95  uint32 _id;
96 };
97 
99  uint operator()(const WinResourceID &id) const { return id.toString().hash(); }
100 };
101 
103  bool operator()(const WinResourceID &id1, const WinResourceID &id2) const { return id1 == id2; }
104 };
105 
111 public:
112  virtual ~WinResources() {};
113 
115  virtual void clear() = 0;
116 
118  virtual bool loadFromEXE(const Path &fileName);
119 
121  virtual bool loadFromCompressedEXE(const Path &fileName);
122 
124  virtual bool loadFromEXE(SeekableReadStream *stream, DisposeAfterUse::Flag disposeFileHandle = DisposeAfterUse::YES) = 0;
125 
127  virtual const Array<WinResourceID> getIDList(const WinResourceID &type) const = 0;
128 
130  virtual const Array<WinResourceID> getLangList(const WinResourceID &type, const WinResourceID &id) const {
131  Array<WinResourceID> array;
132  return array;
133  }
134 
136  virtual SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &id) = 0;
137 
139  virtual SeekableReadStream *getResource(const WinResourceID &type, const WinResourceID &id, const WinResourceID &lang) {
140  return getResource(type, id);
141  }
142 
143  static WinResources *createFromEXE(const Path &fileName);
144  static WinResources *createFromEXE(SeekableReadStream *stream);
145 
147 
149  struct VersionInfo {
150  VersionInfo();
151 
152  uint16 fileVersion[4];
153  uint16 productVersion[4];
154  uint32 fileFlagsMask;
155  uint32 fileFlags;
156  uint32 fileOS;
157  uint32 fileType;
158  uint32 fileSubtype;
159  uint32 fileDate[2];
160 
161  VersionHash hash;
162 
163  bool readVSVersionInfo(SeekableReadStream *res);
164  };
165 
166  VersionInfo *getVersionResource(const WinResourceID &id);
167 
169  virtual String loadString(uint32 stringID) = 0;
170 
171 protected:
172  virtual VersionInfo *parseVersionInfo(SeekableReadStream *stream) = 0;
173 };
174 
177 } // End of namespace Common
178 
179 #endif
Definition: str.h:59
Definition: array.h:52
Definition: path.h:52
Definition: stream.h:745
WinResourceType
Definition: winexe.h:44
Definition: winexe.h:102
Path
Definition: game.h:75
Definition: winexe.h:98
Definition: algorithm.h:29
Definition: winexe.h:69
virtual SeekableReadStream * getResource(const WinResourceID &type, const WinResourceID &id, const WinResourceID &lang)
Definition: winexe.h:139
Definition: winexe.h:110
virtual const Array< WinResourceID > getLangList(const WinResourceID &type, const WinResourceID &id) const
Definition: winexe.h:130
Definition: winexe.h:149