Improved compatibility mode detection, taking into account Windows 8.1.
This commit is contained in:
parent
2accc11d4f
commit
3d7fbf70f5
@ -536,9 +536,10 @@ static bool lamexp_verify_os_version(const DWORD major, const DWORD minor)
|
|||||||
/*
|
/*
|
||||||
* Determine the *real* Windows version
|
* Determine the *real* Windows version
|
||||||
*/
|
*/
|
||||||
static bool lamexp_get_real_os_version(unsigned int *major, unsigned int *minor)
|
static bool lamexp_get_real_os_version(unsigned int *major, unsigned int *minor, bool *pbOverride)
|
||||||
{
|
{
|
||||||
*major = *minor = 0;
|
*major = *minor = 0;
|
||||||
|
*pbOverride = false;
|
||||||
|
|
||||||
//Initialize local variables
|
//Initialize local variables
|
||||||
OSVERSIONINFOEXW osvi;
|
OSVERSIONINFOEXW osvi;
|
||||||
@ -546,13 +547,22 @@ static bool lamexp_get_real_os_version(unsigned int *major, unsigned int *minor)
|
|||||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
|
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
|
||||||
|
|
||||||
//Try GetVersionEx() first
|
//Try GetVersionEx() first
|
||||||
if(GetVersionExW((LPOSVERSIONINFOW)&osvi) != FALSE)
|
if(GetVersionExW((LPOSVERSIONINFOW)&osvi) == FALSE)
|
||||||
{
|
{
|
||||||
if(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
qWarning("GetVersionEx() has failed, cannot detect Windows version!");
|
||||||
{
|
return false;
|
||||||
*major = osvi.dwMajorVersion;
|
}
|
||||||
*minor = osvi.dwMinorVersion;
|
|
||||||
}
|
//Make sure we are running on NT
|
||||||
|
if(osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||||
|
{
|
||||||
|
*major = osvi.dwMajorVersion;
|
||||||
|
*minor = osvi.dwMinorVersion;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning("Not running on Windows NT, unsupported operating system!");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Determine the real *major* version first
|
//Determine the real *major* version first
|
||||||
@ -561,6 +571,7 @@ static bool lamexp_get_real_os_version(unsigned int *major, unsigned int *minor)
|
|||||||
const DWORD nextMajor = (*major) + 1;
|
const DWORD nextMajor = (*major) + 1;
|
||||||
if(lamexp_verify_os_version(nextMajor, 0))
|
if(lamexp_verify_os_version(nextMajor, 0))
|
||||||
{
|
{
|
||||||
|
*pbOverride = true;
|
||||||
*major = nextMajor;
|
*major = nextMajor;
|
||||||
*minor = 0;
|
*minor = 0;
|
||||||
continue;
|
continue;
|
||||||
@ -574,13 +585,14 @@ static bool lamexp_get_real_os_version(unsigned int *major, unsigned int *minor)
|
|||||||
const DWORD nextMinor = (*minor) + 1;
|
const DWORD nextMinor = (*minor) + 1;
|
||||||
if(lamexp_verify_os_version((*major), nextMinor))
|
if(lamexp_verify_os_version((*major), nextMinor))
|
||||||
{
|
{
|
||||||
|
*pbOverride = true;
|
||||||
*minor = nextMinor;
|
*minor = nextMinor;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ((*major) > 0);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -602,11 +614,12 @@ const lamexp_os_version_t &lamexp_get_os_version(void)
|
|||||||
//Detect OS version
|
//Detect OS version
|
||||||
if(!g_lamexp_os_version.bInitialized)
|
if(!g_lamexp_os_version.bInitialized)
|
||||||
{
|
{
|
||||||
unsigned int major, minor;
|
unsigned int major, minor; bool oflag;
|
||||||
if(lamexp_get_real_os_version(&major, &minor))
|
if(lamexp_get_real_os_version(&major, &minor, &oflag))
|
||||||
{
|
{
|
||||||
g_lamexp_os_version.version.versionMajor = major;
|
g_lamexp_os_version.version.versionMajor = major;
|
||||||
g_lamexp_os_version.version.versionMinor = minor;
|
g_lamexp_os_version.version.versionMinor = minor;
|
||||||
|
g_lamexp_os_version.version.overrideFlag = oflag;
|
||||||
g_lamexp_os_version.bInitialized = true;
|
g_lamexp_os_version.bInitialized = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1001,22 +1014,22 @@ static HANDLE lamexp_debug_thread_init(void)
|
|||||||
/*
|
/*
|
||||||
* Check for compatibility mode
|
* Check for compatibility mode
|
||||||
*/
|
*/
|
||||||
static bool lamexp_check_compatibility_mode(const char *exportName, const QString &executableName)
|
//static bool lamexp_check_compatibility_mode(const char *exportName, const QString &executableName)
|
||||||
{
|
//{
|
||||||
QLibrary kernel32("kernel32.dll");
|
// QLibrary kernel32("kernel32.dll");
|
||||||
|
//
|
||||||
if((exportName != NULL) && kernel32.load())
|
// if((exportName != NULL) && kernel32.load())
|
||||||
{
|
// {
|
||||||
if(kernel32.resolve(exportName) != NULL)
|
// if(kernel32.resolve(exportName) != NULL)
|
||||||
{
|
// {
|
||||||
qWarning("Function '%s' exported from 'kernel32.dll' -> Windows compatibility mode!", exportName);
|
// qWarning("Function '%s' exported from 'kernel32.dll' -> Windows compatibility mode!", exportName);
|
||||||
qFatal("%s", QApplication::tr("Executable '%1' doesn't support Windows compatibility mode.").arg(executableName).toLatin1().constData());
|
// qFatal("%s", QApplication::tr("Executable '%1' doesn't support Windows compatibility mode.").arg(executableName).toLatin1().constData());
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return true;
|
// return true;
|
||||||
}
|
//}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Computus according to H. Lichtenberg
|
* Computus according to H. Lichtenberg
|
||||||
@ -1139,7 +1152,7 @@ static bool lamexp_broadcast(int eventType, bool onlyToVisible)
|
|||||||
* Qt event filter
|
* Qt event filter
|
||||||
*/
|
*/
|
||||||
static bool lamexp_event_filter(void *message, long *result)
|
static bool lamexp_event_filter(void *message, long *result)
|
||||||
{
|
{
|
||||||
if((!(LAMEXP_DEBUG)) && lamexp_check_for_debugger())
|
if((!(LAMEXP_DEBUG)) && lamexp_check_for_debugger())
|
||||||
{
|
{
|
||||||
lamexp_fatal_exit(L"Not a debug build. Please unload debugger and try again!");
|
lamexp_fatal_exit(L"Not a debug build. Please unload debugger and try again!");
|
||||||
@ -1283,36 +1296,36 @@ bool lamexp_init_qt(int argc, char* argv[])
|
|||||||
qFatal("%s", QApplication::tr("Executable '%1' requires Windows XP or later.").arg(executableName).toLatin1().constData());
|
qFatal("%s", QApplication::tr("Executable '%1' requires Windows XP or later.").arg(executableName).toLatin1().constData());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check for compat mode
|
//Supported Windows version?
|
||||||
if(osVersionNo == lamexp_winver_winxp)
|
if(osVersionNo == lamexp_winver_winxp)
|
||||||
{
|
{
|
||||||
qDebug("Running on Windows XP.\n");
|
qDebug("Running on Windows XP or Windows XP Media Center Edition.\n");
|
||||||
lamexp_check_compatibility_mode("GetLargePageMinimum", executableName);
|
//lamexp_check_compatibility_mode("GetLargePageMinimum", executableName);
|
||||||
}
|
}
|
||||||
else if(osVersionNo == lamexp_winver_xpx64)
|
else if(osVersionNo == lamexp_winver_xpx64)
|
||||||
{
|
{
|
||||||
qDebug("Running on Windows Server 2003 or Windows XP x64-Edition.\n");
|
qDebug("Running on Windows Server 2003, Windows Server 2003 R2 or Windows XP x64.\n");
|
||||||
lamexp_check_compatibility_mode("GetLocaleInfoEx", executableName);
|
//lamexp_check_compatibility_mode("GetLocaleInfoEx", executableName);
|
||||||
}
|
}
|
||||||
else if(osVersionNo == lamexp_winver_vista)
|
else if(osVersionNo == lamexp_winver_vista)
|
||||||
{
|
{
|
||||||
qDebug("Running on Windows Vista or Windows Server 2008.\n");
|
qDebug("Running on Windows Vista or Windows Server 2008.\n");
|
||||||
lamexp_check_compatibility_mode("CreateRemoteThreadEx", executableName);
|
//lamexp_check_compatibility_mode("CreateRemoteThreadEx", executableName*/);
|
||||||
}
|
}
|
||||||
else if(osVersionNo == lamexp_winver_win70)
|
else if(osVersionNo == lamexp_winver_win70)
|
||||||
{
|
{
|
||||||
qDebug("Running on Windows 7 or Windows Server 2008 R2.\n");
|
qDebug("Running on Windows 7 or Windows Server 2008 R2.\n");
|
||||||
lamexp_check_compatibility_mode("CreateFile2", executableName);
|
//lamexp_check_compatibility_mode("CreateFile2", executableName);
|
||||||
}
|
}
|
||||||
else if(osVersionNo == lamexp_winver_win80)
|
else if(osVersionNo == lamexp_winver_win80)
|
||||||
{
|
{
|
||||||
qDebug("Running on Windows 8 or Windows Server 2012.\n");
|
qDebug("Running on Windows 8 or Windows Server 2012.\n");
|
||||||
lamexp_check_compatibility_mode("FindPackagesByPackageFamily", executableName);
|
//lamexp_check_compatibility_mode("FindPackagesByPackageFamily", executableName);
|
||||||
}
|
}
|
||||||
else if(osVersionNo == lamexp_winver_win81)
|
else if(osVersionNo == lamexp_winver_win81)
|
||||||
{
|
{
|
||||||
qDebug("Running on Windows 8.1 or Windows Server 2012 R2.\n");
|
qDebug("Running on Windows 8.1 or Windows Server 2012 R2.\n");
|
||||||
lamexp_check_compatibility_mode(NULL, executableName);
|
//lamexp_check_compatibility_mode(NULL, executableName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1321,6 +1334,13 @@ bool lamexp_init_qt(int argc, char* argv[])
|
|||||||
MessageBoxW(NULL, QWCHAR(message), L"LameXP", MB_OK | MB_TOPMOST | MB_ICONWARNING);
|
MessageBoxW(NULL, QWCHAR(message), L"LameXP", MB_OK | MB_TOPMOST | MB_ICONWARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Check for compat mode
|
||||||
|
if(osVersionNo.overrideFlag && (osVersionNo < lamexp_winver_win81))
|
||||||
|
{
|
||||||
|
qFatal("%s", QApplication::tr("Executable '%1' doesn't support Windows compatibility mode.").arg(executableName).toLatin1().constData());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//Check for Wine
|
//Check for Wine
|
||||||
if(lamexp_detect_wine())
|
if(lamexp_detect_wine())
|
||||||
{
|
{
|
||||||
|
@ -85,6 +85,7 @@ typedef struct _lamexp_os_version_t
|
|||||||
{
|
{
|
||||||
unsigned int versionMajor;
|
unsigned int versionMajor;
|
||||||
unsigned int versionMinor;
|
unsigned int versionMinor;
|
||||||
|
bool overrideFlag;
|
||||||
|
|
||||||
//comparision operators
|
//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); }
|
||||||
|
Loading…
Reference in New Issue
Block a user