Overhaul of the Windows version detection code + added support for Windows 10 (Technical Preview).

This commit is contained in:
LoRd_MuldeR 2014-11-12 16:00:40 +01:00
parent f02f8ce0d9
commit add0de2472
4 changed files with 55 additions and 41 deletions

View File

@ -26,6 +26,7 @@ a:visited { color: #0000EE; }
<li>Updated Vorbis decoder to OggDec v1.10.1 (2014-06-25), using libVorbis v1.3.4
<li>Updated GnuPG to v1.4.18 (2014-06-30), compiled with GCC 4.9.1
<li>Fixed potential crash in Cue Sheet importer (occurred when *all* input files were missing)
<li>Experimental support for Windows 10 Technical Preview
</ul><br>
<a name="4.10"></a>Changes between v4.09 and v4.10 [2014-06-23]:<br><ul>

View File

@ -35,7 +35,7 @@
#define VER_LAMEXP_MINOR_LO 1
#define VER_LAMEXP_TYPE Alpha
#define VER_LAMEXP_PATCH 4
#define VER_LAMEXP_BUILD 1578
#define VER_LAMEXP_BUILD 1579
#define VER_LAMEXP_CONFG 1558
///////////////////////////////////////////////////////////////////////////////

View File

@ -91,16 +91,17 @@ typedef struct _lamexp_os_version_t
bool overrideFlag;
//comparision operators
inline bool operator== (const _lamexp_os_version_t &rhs) const { return (versionMajor == rhs.versionMajor) && (versionMinor == rhs.versionMinor); }
inline bool operator!= (const _lamexp_os_version_t &rhs) const { return (versionMajor != rhs.versionMajor) || (versionMinor != rhs.versionMinor); }
inline bool operator> (const _lamexp_os_version_t &rhs) const { return (versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor > rhs.versionMinor)); }
inline bool operator>= (const _lamexp_os_version_t &rhs) const { return (versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor >= rhs.versionMinor)); }
inline bool operator< (const _lamexp_os_version_t &rhs) const { return (versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor < rhs.versionMinor)); }
inline bool operator<= (const _lamexp_os_version_t &rhs) const { return (versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor <= rhs.versionMinor)); }
inline bool operator== (const _lamexp_os_version_t &rhs) const { return (versionMajor == rhs.versionMajor) && ((versionMinor == rhs.versionMinor)); }
inline bool operator!= (const _lamexp_os_version_t &rhs) const { return (versionMajor != rhs.versionMajor) || ((versionMinor != rhs.versionMinor)); }
inline bool operator> (const _lamexp_os_version_t &rhs) const { return (versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor > rhs.versionMinor)); }
inline bool operator>= (const _lamexp_os_version_t &rhs) const { return (versionMajor > rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor >= rhs.versionMinor)); }
inline bool operator< (const _lamexp_os_version_t &rhs) const { return (versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor < rhs.versionMinor)); }
inline bool operator<= (const _lamexp_os_version_t &rhs) const { return (versionMajor < rhs.versionMajor) || ((versionMajor == rhs.versionMajor) && (versionMinor <= rhs.versionMinor)); }
}
lamexp_os_version_t;
//Known Windows versions
extern const lamexp_os_version_t lamexp_winver_error;
extern const lamexp_os_version_t lamexp_winver_win2k;
extern const lamexp_os_version_t lamexp_winver_winxp;
extern const lamexp_os_version_t lamexp_winver_xpx64;
@ -108,6 +109,7 @@ extern const lamexp_os_version_t lamexp_winver_vista;
extern const lamexp_os_version_t lamexp_winver_win70;
extern const lamexp_os_version_t lamexp_winver_win80;
extern const lamexp_os_version_t lamexp_winver_win81;
extern const lamexp_os_version_t lamexp_winver_wn100;
//Beep types
typedef enum

View File

@ -126,6 +126,14 @@ while(0)
typedef HRESULT (WINAPI *SHGetKnownFolderPath_t)(const GUID &rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath);
typedef HRESULT (WINAPI *SHGetFolderPath_t)(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
//OS version info
typedef struct _lamexp_os_info_t
{
const lamexp_os_version_t version;
const char friendlyName[128];
}
lamexp_os_info_t;
///////////////////////////////////////////////////////////////////////////////
// CRITICAL SECTION
///////////////////////////////////////////////////////////////////////////////
@ -290,14 +298,31 @@ static FILE *g_lamexp_log_file = NULL;
const char* LAMEXP_DEFAULT_LANGID = "en";
const char* LAMEXP_DEFAULT_TRANSLATION = "LameXP_EN.qm";
//Known Windows versions - maps marketing names to the actual Windows NT versions
const lamexp_os_version_t lamexp_winver_win2k = {5,0};
const lamexp_os_version_t lamexp_winver_winxp = {5,1};
const lamexp_os_version_t lamexp_winver_xpx64 = {5,2};
const lamexp_os_version_t lamexp_winver_vista = {6,0};
const lamexp_os_version_t lamexp_winver_win70 = {6,1};
const lamexp_os_version_t lamexp_winver_win80 = {6,2};
const lamexp_os_version_t lamexp_winver_win81 = {6,3};
//Known Windows NT versions
const lamexp_os_version_t lamexp_winver_error = {0,0}; //N/A
const lamexp_os_version_t lamexp_winver_win2k = {5,0}; //2000
const lamexp_os_version_t lamexp_winver_winxp = {5,1}; //XP
const lamexp_os_version_t lamexp_winver_xpx64 = {5,2}; //XP_x64
const lamexp_os_version_t lamexp_winver_vista = {6,0}; //Vista
const lamexp_os_version_t lamexp_winver_win70 = {6,1}; //7
const lamexp_os_version_t lamexp_winver_win80 = {6,2}; //8
const lamexp_os_version_t lamexp_winver_win81 = {6,3}; //8.1
const lamexp_os_version_t lamexp_winver_wn100 = {6,4}; //10
//Maps marketing names to the actual Windows NT versions
static const lamexp_os_info_t lamexp_winver_lut[] =
{
{ lamexp_winver_win2k, "Windows 2000" }, //2000
{ lamexp_winver_winxp, "Windows XP or Windows XP Media Center Edition" }, //XP
{ lamexp_winver_xpx64, "Windows Server 2003 or Windows XP x64" }, //XP_x64
{ lamexp_winver_vista, "Windows Vista or Windows Server 2008" }, //Vista
{ lamexp_winver_win70, "Windows 7 or Windows Server 2008 R2" }, //7
{ lamexp_winver_win80, "Windows 8 or Windows Server 2012" }, //8
{ lamexp_winver_win81, "Windows 8.1 or Windows Server 2012 R2" }, //8.1
{ lamexp_winver_wn100, "Windows 10 or Windows Server 2014 (Preview)" }, //10
{ lamexp_winver_error, "" }
};
//GURU MEDITATION
static const char *GURU_MEDITATION = "\n\nGURU MEDITATION !!!\n\n";
@ -462,7 +487,7 @@ bool lamexp_detect_wine(void)
if(ntdll.load())
{
if(ntdll.resolve("wine_nt_to_unix_file_name") != NULL) g_lamexp_wine.bIsWine = true;
if(ntdll.resolve("wine_get_version") != NULL) g_lamexp_wine.bIsWine = true;
if(ntdll.resolve("wine_get_version") != NULL) g_lamexp_wine.bIsWine = true;
ntdll.unload();
}
g_lamexp_wine.bInitialized = true;
@ -1097,32 +1122,18 @@ bool lamexp_init_qt(int argc, char* argv[])
qFatal("%s", QApplication::tr("Executable '%1' requires Windows XP or later.").arg(executableName).toLatin1().constData());
}
//Supported Windows version?
if(osVersionNo == lamexp_winver_winxp)
//Check whether we are running on a supported Windows version
bool runningOnSupportedOSVersion = false;
for(size_t i = 0; lamexp_winver_lut[i].version != lamexp_winver_error; i++)
{
qDebug("Running on Windows XP or Windows XP Media Center Edition.\n"); //lamexp_check_compatibility_mode("GetLargePageMinimum", executableName);
if(osVersionNo == lamexp_winver_lut[i].version)
{
runningOnSupportedOSVersion = true;
qDebug("Running on %s (NT v%u.%u).\n", lamexp_winver_lut[i].friendlyName, osVersionNo.versionMajor, osVersionNo.versionMinor);
break;
}
}
else if(osVersionNo == lamexp_winver_xpx64)
{
qDebug("Running on Windows Server 2003, Windows Server 2003 R2 or Windows XP x64.\n"); //lamexp_check_compatibility_mode("GetLocaleInfoEx", executableName);
}
else if(osVersionNo == lamexp_winver_vista)
{
qDebug("Running on Windows Vista or Windows Server 2008.\n"); //lamexp_check_compatibility_mode("CreateRemoteThreadEx", executableName*/);
}
else if(osVersionNo == lamexp_winver_win70)
{
qDebug("Running on Windows 7 or Windows Server 2008 R2.\n"); //lamexp_check_compatibility_mode("CreateFile2", executableName);
}
else if(osVersionNo == lamexp_winver_win80)
{
qDebug("Running on Windows 8 or Windows Server 2012.\n"); //lamexp_check_compatibility_mode("FindPackagesByPackageFamily", executableName);
}
else if(osVersionNo == lamexp_winver_win81)
{
qDebug("Running on Windows 8.1 or Windows Server 2012 R2.\n"); //lamexp_check_compatibility_mode(NULL, executableName);
}
else
if(!runningOnSupportedOSVersion)
{
const QString message = QString().sprintf("Running on an unknown WindowsNT-based system (v%u.%u).", osVersionNo.versionMajor, osVersionNo.versionMinor);
qWarning("%s\n", QUTF8(message));
@ -1130,7 +1141,7 @@ bool lamexp_init_qt(int argc, char* argv[])
}
//Check for compat mode
if(osVersionNo.overrideFlag && (osVersionNo <= lamexp_winver_win81))
if(osVersionNo.overrideFlag && (osVersionNo <= lamexp_winver_wn100))
{
qWarning("Windows compatibility mode detected!");
if(!arguments.contains("--ignore-compat-mode", Qt::CaseInsensitive))