* PROJECT: ReactOS system libraries
* FILE: lib/ntdll/rtl/process.c
* PURPOSE: Process functions
- * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
+ * PROGRAMMER: Ariadne (ariadne@xs4all.nl)
* UPDATE HISTORY:
* Created 01/11/98
*/
*
* NOTE
* ProductType can be one of the following values:
- * 1 Workstation (Winnt)
- * 2 Server (Lanmannt)
- * 3 Advanced Server (Servernt)
+ * 1 Workstation (WinNT)
+ * 2 Server (LanmanNT)
+ * 3 Advanced Server (ServerNT)
*
* REVISIONS
* 2000-08-10 ekohl
* Get the version numbers of the run time library.
*
* ARGUMENTS
- * major [OUT] Destination for the Major version
- * minor [OUT] Destination for the Minor version
- * build [OUT] Destination for the Build version
+ * pdwMajorVersion [OUT] Destination for the Major version
+ * pdwMinorVersion [OUT] Destination for the Minor version
+ * pdwBuildNumber [OUT] Destination for the Build version
*
* RETURN VALUE
* Nothing.
*
- * NOTE
- * Introduced in Windows XP (NT5.1)
+ * NOTES
+ * - Introduced in Windows XP (NT 5.1)
+ * - Since this call didn't exist before XP, we report at least the version
+ * 5.1. This fixes the loading of msvcrt.dll as released with XP Home,
+ * which fails in DLLMain() if the major version isn't 5.
*
* @implemented
*/
-void NTAPI
-RtlGetNtVersionNumbers(LPDWORD major, LPDWORD minor, LPDWORD build)
+VOID NTAPI
+RtlGetNtVersionNumbers(OUT LPDWORD pdwMajorVersion,
+ OUT LPDWORD pdwMinorVersion,
+ OUT LPDWORD pdwBuildNumber)
{
- PPEB pPeb = NtCurrentPeb();
-
- if (major)
- {
- /* msvcrt.dll as released with XP Home fails in DLLMain() if the
- * major version is not 5. So, we should never set a version < 5 ...
- * This makes sense since this call didn't exist before XP anyway.
- */
- *major = pPeb->OSMajorVersion < 5 ? 5 : pPeb->OSMajorVersion;
- }
-
- if (minor)
- {
- if (pPeb->OSMinorVersion <= 5)
- *minor = pPeb->OSMinorVersion < 1 ? 1 : pPeb->OSMinorVersion;
- else
- *minor = pPeb->OSMinorVersion;
- }
-
- if (build)
- {
- /* FIXME: Does anybody know the real formula? */
- *build = (0xF0000000 | pPeb->OSBuildNumber);
- }
+ PPEB pPeb = NtCurrentPeb();
+
+ if (pdwMajorVersion)
+ {
+ *pdwMajorVersion = pPeb->OSMajorVersion < 5 ? 5 : pPeb->OSMajorVersion;
+ }
+
+ if (pdwMinorVersion)
+ {
+ if ( (pPeb->OSMajorVersion < 5) ||
+ ((pPeb->OSMajorVersion == 5) && (pPeb->OSMinorVersion < 1)) )
+ *pdwMinorVersion = 1;
+ else
+ *pdwMinorVersion = pPeb->OSMinorVersion;
+ }
+
+ if (pdwBuildNumber)
+ {
+ /* Windows really does this! */
+ *pdwBuildNumber = (0xF0000000 | pPeb->OSBuildNumber);
+ }
}
/*
RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)Info;
InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF;
InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF;
- InfoEx->wSuiteMask = SharedUserData->SuiteMask;
+ InfoEx->wSuiteMask = SharedUserData->SuiteMask & 0xFFFF;
InfoEx->wProductType = SharedUserData->NtProductType;
}
-/* COPYRIGHT: See COPYING in the top level directory
+/*
+ * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* PURPOSE: Runtime code
* FILE: lib/rtl/version.c
/* FUNCTIONS ****************************************************************/
-static inline NTSTATUS version_compare_values(ULONG left, ULONG right, UCHAR condition)
+static BOOLEAN
+RtlpVerCompare(ULONG left, ULONG right, UCHAR condition)
{
- switch (condition) {
+ switch (condition)
+ {
case VER_EQUAL:
- if (left != right) return STATUS_REVISION_MISMATCH;
- break;
+ return (left == right);
case VER_GREATER:
- if (left <= right) return STATUS_REVISION_MISMATCH;
- break;
+ return (left > right);
case VER_GREATER_EQUAL:
- if (left < right) return STATUS_REVISION_MISMATCH;
- break;
+ return (left >= right);
case VER_LESS:
- if (left >= right) return STATUS_REVISION_MISMATCH;
- break;
+ return (left < right);
case VER_LESS_EQUAL:
- if (left > right) return STATUS_REVISION_MISMATCH;
- break;
+ return (left <= right);
default:
- return STATUS_REVISION_MISMATCH;
+ break;
}
- return STATUS_SUCCESS;
+ return FALSE;
}
/*
{
RTL_OSVERSIONINFOEXW ver;
NTSTATUS status;
+ BOOLEAN comparison;
/* FIXME:
- Check the following special case on Windows (various versions):
status = RtlGetVersion( (PRTL_OSVERSIONINFOW)&ver );
if (status != STATUS_SUCCESS) return status;
- if(!(TypeMask && ConditionMask)) return STATUS_INVALID_PARAMETER;
+ if (!TypeMask || !ConditionMask) return STATUS_INVALID_PARAMETER;
- if(TypeMask & VER_PRODUCT_TYPE)
+ if (TypeMask & VER_PRODUCT_TYPE)
{
- status = version_compare_values(ver.wProductType, VersionInfo->wProductType, ConditionMask >> 7 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK);
- if (status != STATUS_SUCCESS)
- return status;
+ comparison = RtlpVerCompare(ver.wProductType,
+ VersionInfo->wProductType,
+ ConditionMask >> 7 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK);
+ if (!comparison)
+ return STATUS_REVISION_MISMATCH;
}
- if(TypeMask & VER_SUITENAME)
+
+ if (TypeMask & VER_SUITENAME)
{
- switch(ConditionMask >> 6 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK)
+ switch (ConditionMask >> 6 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK)
{
case VER_AND:
- if((VersionInfo->wSuiteMask & ver.wSuiteMask) != VersionInfo->wSuiteMask)
+ if ((VersionInfo->wSuiteMask & ver.wSuiteMask) != VersionInfo->wSuiteMask)
+ {
return STATUS_REVISION_MISMATCH;
+ }
break;
case VER_OR:
- if(!(VersionInfo->wSuiteMask & ver.wSuiteMask) && VersionInfo->wSuiteMask)
+ if (!(VersionInfo->wSuiteMask & ver.wSuiteMask) && VersionInfo->wSuiteMask)
+ {
return STATUS_REVISION_MISMATCH;
+ }
break;
default:
return STATUS_INVALID_PARAMETER;
}
}
- if(TypeMask & VER_PLATFORMID)
+
+ if (TypeMask & VER_PLATFORMID)
{
- status = version_compare_values(ver.dwPlatformId, VersionInfo->dwPlatformId, ConditionMask >> 3 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK);
- if (status != STATUS_SUCCESS)
- return status;
+ comparison = RtlpVerCompare(ver.dwPlatformId,
+ VersionInfo->dwPlatformId,
+ ConditionMask >> 3 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK);
+ if (!comparison)
+ return STATUS_REVISION_MISMATCH;
}
- if(TypeMask & VER_BUILDNUMBER)
+
+ if (TypeMask & VER_BUILDNUMBER)
{
- status = version_compare_values(ver.dwBuildNumber, VersionInfo->dwBuildNumber, ConditionMask >> 2 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK);
- if (status != STATUS_SUCCESS)
- return status;
+ comparison = RtlpVerCompare(ver.dwBuildNumber,
+ VersionInfo->dwBuildNumber,
+ ConditionMask >> 2 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK);
+ if (!comparison)
+ return STATUS_REVISION_MISMATCH;
}
- if(TypeMask & (VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR))
+
+ if (TypeMask & (VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR))
{
- unsigned char condition = 0;
+ UCHAR condition = 0;
BOOLEAN do_next_check = TRUE;
- if(TypeMask & VER_MAJORVERSION)
+ if (TypeMask & VER_MAJORVERSION)
condition = ConditionMask >> 1 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK;
- else if(TypeMask & VER_MINORVERSION)
+ else if (TypeMask & VER_MINORVERSION)
condition = ConditionMask >> 0 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK;
- else if(TypeMask & VER_SERVICEPACKMAJOR)
+ else if (TypeMask & VER_SERVICEPACKMAJOR)
condition = ConditionMask >> 5 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK;
- else if(TypeMask & VER_SERVICEPACKMINOR)
+ else if (TypeMask & VER_SERVICEPACKMINOR)
condition = ConditionMask >> 4 * VER_NUM_BITS_PER_CONDITION_MASK & VER_CONDITION_MASK;
- if(TypeMask & VER_MAJORVERSION)
+ comparison = TRUE;
+ if (TypeMask & VER_MAJORVERSION)
{
- status = version_compare_values(ver.dwMajorVersion, VersionInfo->dwMajorVersion, condition);
+ comparison = RtlpVerCompare(ver.dwMajorVersion,
+ VersionInfo->dwMajorVersion,
+ condition);
do_next_check = (ver.dwMajorVersion == VersionInfo->dwMajorVersion) &&
- ((condition != VER_EQUAL) || (status == STATUS_SUCCESS));
+ ((condition != VER_EQUAL) || comparison);
}
- if((TypeMask & VER_MINORVERSION) && do_next_check)
+ if ((TypeMask & VER_MINORVERSION) && do_next_check)
{
- status = version_compare_values(ver.dwMinorVersion, VersionInfo->dwMinorVersion, condition);
+ comparison = RtlpVerCompare(ver.dwMinorVersion,
+ VersionInfo->dwMinorVersion,
+ condition);
do_next_check = (ver.dwMinorVersion == VersionInfo->dwMinorVersion) &&
- ((condition != VER_EQUAL) || (status == STATUS_SUCCESS));
+ ((condition != VER_EQUAL) || comparison);
}
- if((TypeMask & VER_SERVICEPACKMAJOR) && do_next_check)
+ if ((TypeMask & VER_SERVICEPACKMAJOR) && do_next_check)
{
- status = version_compare_values(ver.wServicePackMajor, VersionInfo->wServicePackMajor, condition);
+ comparison = RtlpVerCompare(ver.wServicePackMajor,
+ VersionInfo->wServicePackMajor,
+ condition);
do_next_check = (ver.wServicePackMajor == VersionInfo->wServicePackMajor) &&
- ((condition != VER_EQUAL) || (status == STATUS_SUCCESS));
+ ((condition != VER_EQUAL) || comparison);
}
- if((TypeMask & VER_SERVICEPACKMINOR) && do_next_check)
+ if ((TypeMask & VER_SERVICEPACKMINOR) && do_next_check)
{
- status = version_compare_values(ver.wServicePackMinor, VersionInfo->wServicePackMinor, condition);
+ comparison = RtlpVerCompare(ver.wServicePackMinor,
+ VersionInfo->wServicePackMinor,
+ condition);
}
- if (status != STATUS_SUCCESS)
- return status;
+ if (!comparison)
+ return STATUS_REVISION_MISMATCH;
}
return STATUS_SUCCESS;