11 changed files with 345 additions and 52 deletions
@ -0,0 +1,58 @@
|
||||
|
||||
#include "SetupTaskEntry.hpp" |
||||
|
||||
#include "LoadingUtils.hpp" |
||||
#include "StoredEnum.hpp" |
||||
|
||||
STORED_FLAGS_MAP(StoredSetupTaskOptions0, |
||||
toExclusive, |
||||
toUnchecked, |
||||
toRestart, |
||||
toCheckedOnce, |
||||
); |
||||
|
||||
// starting with version 4.2.3
|
||||
STORED_FLAGS_MAP(StoredSetupTaskOptions1, |
||||
toExclusive, |
||||
toUnchecked, |
||||
toRestart, |
||||
toCheckedOnce, |
||||
toDontInheritCheck, |
||||
); |
||||
|
||||
void SetupTaskEntry::load(std::istream & is, const InnoVersion & version) { |
||||
|
||||
is >> EncodedString(name, version.codepage()); |
||||
is >> EncodedString(description, version.codepage()); |
||||
is >> EncodedString(groupDescription, version.codepage()); |
||||
is >> EncodedString(components, version.codepage()); |
||||
if(version >= INNO_VERSION(4, 0, 1)) { |
||||
is >> EncodedString(languages, version.codepage()); |
||||
} else { |
||||
languages.clear(); |
||||
} |
||||
if(version >= INNO_VERSION(3, 0, 8)) { |
||||
is >> EncodedString(check, version.codepage()); |
||||
level = loadNumber<s32>(is); |
||||
used = loadNumber<u8>(is); |
||||
} else { |
||||
check.clear(), level = 0, used = true; |
||||
} |
||||
|
||||
minVersion.load(is, version); |
||||
onlyBelowVersion.load(is, version); |
||||
|
||||
if(version >= INNO_VERSION(4, 2, 3)) { |
||||
options = StoredFlags<StoredSetupTaskOptions1>(is).get(); |
||||
} else { |
||||
options = StoredFlags<StoredSetupTaskOptions0>(is).get(); |
||||
} |
||||
} |
||||
|
||||
ENUM_NAMES(SetupTaskOptions::Enum, "Setup Task Option", |
||||
"exclusive", |
||||
"unchecked", |
||||
"restart", |
||||
"checked once", |
||||
"don't inherit check", |
||||
) |
||||
@ -0,0 +1,44 @@
|
||||
|
||||
#ifndef INNOEXTRACT_SETUPTASKENTRY_HPP |
||||
#define INNOEXTRACT_SETUPTASKENTRY_HPP |
||||
|
||||
#include <iostream> |
||||
#include "Version.hpp" |
||||
#include "WindowsVersion.hpp" |
||||
#include "Flags.hpp" |
||||
#include "Enum.hpp" |
||||
|
||||
FLAGS(SetupTaskOptions, |
||||
toExclusive, |
||||
toUnchecked, |
||||
toRestart, |
||||
toCheckedOnce, |
||||
toDontInheritCheck, |
||||
) |
||||
|
||||
NAMED_ENUM(SetupTaskOptions::Enum) |
||||
|
||||
struct SetupTaskEntry { |
||||
|
||||
// introduced after 1.3.26
|
||||
|
||||
std::string name; |
||||
std::string description; |
||||
std::string groupDescription; |
||||
std::string components; |
||||
std::string languages; |
||||
std::string check; |
||||
|
||||
int level; |
||||
bool used; |
||||
|
||||
WindowsVersion minVersion; |
||||
WindowsVersion onlyBelowVersion; |
||||
|
||||
SetupTaskOptions options; |
||||
|
||||
void load(std::istream & is, const InnoVersion & version); |
||||
|
||||
}; |
||||
|
||||
#endif // INNOEXTRACT_SETUPTASKENTRY_HPP
|
||||
@ -0,0 +1,118 @@
|
||||
|
||||
#include "WindowsVersion.hpp" |
||||
|
||||
#include "LoadingUtils.hpp" |
||||
#include "Utils.hpp" |
||||
|
||||
const WindowsVersion WindowsVersion::none = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0 } }; |
||||
|
||||
void WindowsVersion::Version::load(std::istream& is, const InnoVersion& version) { |
||||
|
||||
if(version > INNO_VERSION(1, 2, 16)) { |
||||
build = loadNumber<u16>(is); |
||||
} else { |
||||
build = 0; |
||||
} |
||||
|
||||
minor = loadNumber<u8>(is); |
||||
major = loadNumber<u8>(is); |
||||
|
||||
} |
||||
|
||||
void WindowsVersion::load(std::istream & is, const InnoVersion & version) { |
||||
|
||||
winVersion.load(is, version); |
||||
ntVersion.load(is, version); |
||||
|
||||
if(version > INNO_VERSION(1, 2, 16)) { |
||||
ntServicePack.minor = loadNumber<u8>(is); |
||||
ntServicePack.major = loadNumber<u8>(is); |
||||
} else { |
||||
ntServicePack.major = 0, ntServicePack.minor = 0; |
||||
} |
||||
|
||||
} |
||||
|
||||
namespace { |
||||
|
||||
struct WindowsVersionName { |
||||
|
||||
const char * name; |
||||
|
||||
WindowsVersion::Version version; |
||||
|
||||
bool nt; |
||||
|
||||
}; |
||||
|
||||
WindowsVersionName windowsVersionNames[] = { |
||||
{ "Windows 1.0", { 1, 4, 0 } }, |
||||
{ "Windows 2.0", { 2, 11, 0 } }, |
||||
{ "Windows 3.0", { 3, 0, 0 } }, |
||||
{ "Windows NT Workstation 3.5", { 3, 5, 807 }, true }, |
||||
{ "Windows NT 3.1", { 3, 10, 528 }, true }, |
||||
{ "Windows for Workgroups 3.11", { 3, 11, 0 } }, |
||||
{ "Windows NT Workstation 3.51", { 3, 51, 1057 }, true }, |
||||
{ "Windows 95", { 4, 0, 950 } }, |
||||
{ "Windows NT Workstation 4.0", { 4, 0, 1381 }, true }, |
||||
{ "Windows 98", { 4, 1, 1998 } }, |
||||
{ "Windows 98 Second Edition", { 4, 1, 2222 } }, |
||||
{ "Windows ME", { 4, 90, 3000 } }, |
||||
{ "Windows 2000", { 5, 0, 2195 }, true }, |
||||
{ "Windows XP", { 5, 1, 2600 }, true }, |
||||
{ "Windows XP x64", { 5, 2, 3790 }, true }, |
||||
{ "Windows Vista", { 6, 0, 6000 }, true }, |
||||
{ "Windows 7", { 6, 1, 7600 }, true } |
||||
}; |
||||
|
||||
const char * getVersionName(const WindowsVersion::Version & version, bool nt = false) { |
||||
for(size_t i = 0; i < ARRAY_SIZE(windowsVersionNames); i++) { |
||||
const WindowsVersionName & v = windowsVersionNames[i]; |
||||
if(v.version.major != version.major || v.version.minor < version.minor) { |
||||
continue; |
||||
} |
||||
if(nt != v.nt) { |
||||
continue; |
||||
} |
||||
return v.name; |
||||
}; |
||||
return NULL; |
||||
} |
||||
|
||||
} |
||||
|
||||
std::ostream & operator<<(std::ostream & os, const WindowsVersion::Version & v) { |
||||
os << v.major << '.' << v.minor; |
||||
if(v.build) { |
||||
os << v.build; |
||||
} |
||||
} |
||||
|
||||
std::ostream & operator<<(std::ostream & os, const WindowsVersion & v) { |
||||
os << v.winVersion; |
||||
if(v.ntVersion != v.winVersion) { |
||||
os << " nt " << v.ntVersion; |
||||
} |
||||
const char * winName = getVersionName(v.winVersion); |
||||
const char * ntName = getVersionName(v.ntVersion, true); |
||||
if(winName || ntName) { |
||||
os << " ("; |
||||
if(winName) { |
||||
os << winName; |
||||
} |
||||
if(ntName && ntName != winName) { |
||||
if(winName) { |
||||
os << " / "; |
||||
} |
||||
os << ntName; |
||||
} |
||||
os << ')'; |
||||
} |
||||
if(v.ntServicePack.major || v.ntServicePack.minor) { |
||||
os << " service pack " << v.ntServicePack.major; |
||||
if(v.ntServicePack.minor) { |
||||
os << '.' << v.ntServicePack.minor; |
||||
} |
||||
} |
||||
return os; |
||||
} |
||||
@ -0,0 +1,68 @@
|
||||
|
||||
#ifndef INNOEXTRACT_SETUPVERSIONDATA_HPP |
||||
#define INNOEXTRACT_SETUPVERSIONDATA_HPP |
||||
|
||||
#include <iostream> |
||||
#include "Types.hpp" |
||||
#include "Version.hpp" |
||||
|
||||
struct WindowsVersion { |
||||
|
||||
struct Version { |
||||
|
||||
unsigned major; |
||||
unsigned minor; |
||||
unsigned build; |
||||
|
||||
inline bool operator==(const Version & o) const { |
||||
return (build == o.build && major == o.major && minor == o.minor); |
||||
} |
||||
|
||||
inline bool operator!=(const Version & o) const { |
||||
return !(*this == o); |
||||
} |
||||
|
||||
void load(std::istream & is, const InnoVersion & version); |
||||
|
||||
}; |
||||
|
||||
Version winVersion; |
||||
Version ntVersion; |
||||
|
||||
struct ServicePack { |
||||
|
||||
unsigned major; |
||||
unsigned minor; |
||||
|
||||
inline bool operator==(const ServicePack & o) const { |
||||
return (major == o.major && minor == o.minor); |
||||
} |
||||
|
||||
inline bool operator!=(const ServicePack & o) const { |
||||
return !(*this == o); |
||||
} |
||||
|
||||
}; |
||||
|
||||
ServicePack ntServicePack; |
||||
|
||||
void load(std::istream & is, const InnoVersion & version); |
||||
|
||||
inline bool operator==(const WindowsVersion & o) const { |
||||
return (winVersion == o.winVersion |
||||
&& ntServicePack == o.ntServicePack |
||||
&& ntServicePack == o.ntServicePack); |
||||
} |
||||
|
||||
inline bool operator!=(const WindowsVersion & o) const { |
||||
return !(*this == o); |
||||
} |
||||
|
||||
const static WindowsVersion none; |
||||
|
||||
}; |
||||
|
||||
std::ostream & operator<<(std::ostream & os, const WindowsVersion::Version & svd); |
||||
std::ostream & operator<<(std::ostream & os, const WindowsVersion & svd); |
||||
|
||||
#endif // INNOEXTRACT_SETUPVERSIONDATA_HPP
|
||||
Loading…
Reference in new issue