1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
|
/*************************************************************************/
/* Copyright (c) 2015 dx, http://kaimi.ru */
/* */
/* Permission is hereby granted, free of charge, to any person */
/* obtaining a copy of this software and associated documentation */
/* files (the "Software"), to deal in the Software without */
/* restriction, including without limitation the rights to use, */
/* copy, modify, merge, publish, distribute, sublicense, and/or */
/* sell copies of the Software, and to permit persons to whom the */
/* Software is furnished to do so, subject to the following conditions: */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "file_version_info.h"
#include "pe_structures.h"
namespace pe_bliss
{
using namespace pe_win;
//Default constructor
file_version_info::file_version_info()
:file_version_ms_(0), file_version_ls_(0),
product_version_ms_(0), product_version_ls_(0),
file_flags_(0),
file_os_(0),
file_type_(0), file_subtype_(0),
file_date_ms_(0), file_date_ls_(0)
{}
//Constructor from Windows fixed version info structure
file_version_info::file_version_info(const vs_fixedfileinfo& info)
:file_version_ms_(info.dwFileVersionMS), file_version_ls_(info.dwFileVersionLS),
product_version_ms_(info.dwProductVersionMS), product_version_ls_(info.dwProductVersionLS),
file_flags_(info.dwFileFlags),
file_os_(info.dwFileOS),
file_type_(info.dwFileType), file_subtype_(info.dwFileSubtype),
file_date_ms_(info.dwFileDateMS), file_date_ls_(info.dwFileDateLS)
{}
//Returns true if file is debug-built
bool file_version_info::is_debug() const
{
return file_flags_ & vs_ff_debug ? true : false;
}
//Returns true if file is release-built
bool file_version_info::is_prerelease() const
{
return file_flags_ & vs_ff_prerelease ? true : false;
}
//Returns true if file is patched
bool file_version_info::is_patched() const
{
return file_flags_ & vs_ff_patched ? true : false;
}
//Returns true if private build
bool file_version_info::is_private_build() const
{
return file_flags_ & vs_ff_privatebuild ? true : false;
}
//Returns true if special build
bool file_version_info::is_special_build() const
{
return file_flags_ & vs_ff_specialbuild ? true : false;
}
//Returns true if info inferred
bool file_version_info::is_info_inferred() const
{
return file_flags_ & vs_ff_infoinferred ? true : false;
}
//Retuens file flags (raw DWORD)
uint32_t file_version_info::get_file_flags() const
{
return file_flags_;
}
//Returns file version most significant DWORD
uint32_t file_version_info::get_file_version_ms() const
{
return file_version_ms_;
}
//Returns file version least significant DWORD
uint32_t file_version_info::get_file_version_ls() const
{
return file_version_ls_;
}
//Returns product version most significant DWORD
uint32_t file_version_info::get_product_version_ms() const
{
return product_version_ms_;
}
//Returns product version least significant DWORD
uint32_t file_version_info::get_product_version_ls() const
{
return product_version_ls_;
}
//Returns file OS type (raw DWORD)
uint32_t file_version_info::get_file_os_raw() const
{
return file_os_;
}
//Returns file OS type
file_version_info::file_os_type file_version_info::get_file_os() const
{
//Determine file operation system type
switch(file_os_)
{
case vos_dos:
return file_os_dos;
case vos_os216:
return file_os_os216;
case vos_os232:
return file_os_os232;
case vos_nt:
return file_os_nt;
case vos_wince:
return file_os_wince;
case vos__windows16:
return file_os_win16;
case vos__pm16:
return file_os_pm16;
case vos__pm32:
return file_os_pm32;
case vos__windows32:
return file_os_win32;
case vos_dos_windows16:
return file_os_dos_win16;
case vos_dos_windows32:
return file_os_dos_win32;
case vos_os216_pm16:
return file_os_os216_pm16;
case vos_os232_pm32:
return file_os_os232_pm32;
case vos_nt_windows32:
return file_os_nt_win32;
}
return file_os_unknown;
}
//Returns file type (raw DWORD)
uint32_t file_version_info::get_file_type_raw() const
{
return file_type_;
}
//Returns file type
file_version_info::file_type file_version_info::get_file_type() const
{
//Determine file type
switch(file_type_)
{
case vft_app:
return file_type_application;
case vft_dll:
return file_type_dll;
case vft_drv:
return file_type_driver;
case vft_font:
return file_type_font;
case vft_vxd:
return file_type_vxd;
case vft_static_lib:
return file_type_static_lib;
}
return file_type_unknown;
}
//Returns file subtype (usually non-zero for drivers and fonts)
uint32_t file_version_info::get_file_subtype() const
{
return file_subtype_;
}
//Returns file date most significant DWORD
uint32_t file_version_info::get_file_date_ms() const
{
return file_date_ms_;
}
//Returns file date least significant DWORD
uint32_t file_version_info::get_file_date_ls() const
{
return file_date_ls_;
}
//Helper to set file flag
void file_version_info::set_file_flag(uint32_t flag)
{
file_flags_ |= flag;
}
//Helper to clear file flag
void file_version_info::clear_file_flag(uint32_t flag)
{
file_flags_ &= ~flag;
}
//Helper to set or clear file flag
void file_version_info::set_file_flag(uint32_t flag, bool set_flag)
{
set_flag ? set_file_flag(flag) : clear_file_flag(flag);
}
//Sets if file is debug-built
void file_version_info::set_debug(bool debug)
{
set_file_flag(vs_ff_debug, debug);
}
//Sets if file is prerelease
void file_version_info::set_prerelease(bool prerelease)
{
set_file_flag(vs_ff_prerelease, prerelease);
}
//Sets if file is patched
void file_version_info::set_patched(bool patched)
{
set_file_flag(vs_ff_patched, patched);
}
//Sets if private build
void file_version_info::set_private_build(bool private_build)
{
set_file_flag(vs_ff_privatebuild, private_build);
}
//Sets if special build
void file_version_info::set_special_build(bool special_build)
{
set_file_flag(vs_ff_specialbuild, special_build);
}
//Sets if info inferred
void file_version_info::set_info_inferred(bool info_inferred)
{
set_file_flag(vs_ff_infoinferred, info_inferred);
}
//Sets flags (raw DWORD)
void file_version_info::set_file_flags(uint32_t file_flags)
{
file_flags_ = file_flags;
}
//Sets file version most significant DWORD
void file_version_info::set_file_version_ms(uint32_t file_version_ms)
{
file_version_ms_ = file_version_ms;
}
//Sets file version least significant DWORD
void file_version_info::set_file_version_ls(uint32_t file_version_ls)
{
file_version_ls_ = file_version_ls;
}
//Sets product version most significant DWORD
void file_version_info::set_product_version_ms(uint32_t product_version_ms)
{
product_version_ms_ = product_version_ms;
}
//Sets product version least significant DWORD
void file_version_info::set_product_version_ls(uint32_t product_version_ls)
{
product_version_ls_ = product_version_ls;
}
//Sets file OS type (raw DWORD)
void file_version_info::set_file_os_raw(uint32_t file_os)
{
file_os_ = file_os;
}
//Sets file OS type
void file_version_info::set_file_os(file_os_type file_os)
{
//Determine file operation system type
switch(file_os)
{
case file_os_dos:
file_os_ = vos_dos;
return;
case file_os_os216:
file_os_ = vos_os216;
return;
case file_os_os232:
file_os_ = vos_os232;
return;
case file_os_nt:
file_os_ = vos_nt;
return;
case file_os_wince:
file_os_ = vos_wince;
return;
case file_os_win16:
file_os_ = vos__windows16;
return;
case file_os_pm16:
file_os_ = vos__pm16;
return;
case file_os_pm32:
file_os_ = vos__pm32;
return;
case file_os_win32:
file_os_ = vos__windows32;
return;
case file_os_dos_win16:
file_os_ = vos_dos_windows16;
return;
case file_os_dos_win32:
file_os_ = vos_dos_windows32;
return;
case file_os_os216_pm16:
file_os_ = vos_os216_pm16;
return;
case file_os_os232_pm32:
file_os_ = vos_os232_pm32;
return;
case file_os_nt_win32:
file_os_ = vos_nt_windows32;
return;
default:
return;
}
}
//Sets file type (raw DWORD)
void file_version_info::set_file_type_raw(uint32_t file_type)
{
file_type_ = file_type;
}
//Sets file type
void file_version_info::set_file_type(file_type file_type)
{
//Determine file type
switch(file_type)
{
case file_type_application:
file_type_ = vft_app;
return;
case file_type_dll:
file_type_ = vft_dll;
return;
case file_type_driver:
file_type_ = vft_drv;
return;
case file_type_font:
file_type_ = vft_font;
return;
case file_type_vxd:
file_type_ = vft_vxd;
return;
case file_type_static_lib:
file_type_ = vft_static_lib;
return;
default:
return;
}
}
//Sets file subtype (usually non-zero for drivers and fonts)
void file_version_info::set_file_subtype(uint32_t file_subtype)
{
file_subtype_ = file_subtype;
}
//Sets file date most significant DWORD
void file_version_info::set_file_date_ms(uint32_t file_date_ms)
{
file_date_ms_ = file_date_ms;
}
//Sets file date least significant DWORD
void file_version_info::set_file_date_ls(uint32_t file_date_ls)
{
file_date_ls_ = file_date_ls;
}
}
|