Author: tfaber
Date: Thu Sep 20 19:53:14 2012
New Revision: 57354
URL:
http://svn.reactos.org/svn/reactos?rev=57354&view=rev
Log:
[NTOSKRNL][NTDLL][RTL][KERNEL32]
- Code simplification and clarification for version-reporting functionality. Patch by
Hermès Bélusca (1/X)
CORE-6611
Modified:
trunk/reactos/dll/ntdll/rtl/version.c
trunk/reactos/dll/win32/kernel32/client/version.c
trunk/reactos/include/psdk/ntverp.h
trunk/reactos/lib/rtl/version.c
trunk/reactos/ntoskrnl/ex/init.c
trunk/reactos/ntoskrnl/mm/ARM3/mminit.c
trunk/reactos/ntoskrnl/rtl/misc.c
Modified: trunk/reactos/dll/ntdll/rtl/version.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/ntdll/rtl/version.c?re…
==============================================================================
--- trunk/reactos/dll/ntdll/rtl/version.c [iso-8859-1] (original)
+++ trunk/reactos/dll/ntdll/rtl/version.c [iso-8859-1] Thu Sep 20 19:53:14 2012
@@ -3,7 +3,7 @@
* PROJECT: ReactOS system libraries
* FILE: lib/ntdll/rtl/process.c
* PURPOSE: Process functions
- * PROGRAMMER: Ariadne ( ariadne(a)xs4all.nl)
+ * PROGRAMMER: Ariadne (ariadne(a)xs4all.nl)
* UPDATE HISTORY:
* Created 01/11/98
*/
@@ -31,9 +31,9 @@
*
* 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
@@ -56,46 +56,48 @@
* 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();
+ 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 (pdwMajorVersion)
+ {
+ *pdwMajorVersion = pPeb->OSMajorVersion < 5 ? 5 : pPeb->OSMajorVersion;
+ }
- if (minor)
- {
- if (pPeb->OSMinorVersion <= 5)
- *minor = pPeb->OSMinorVersion < 1 ? 1 : pPeb->OSMinorVersion;
- else
- *minor = pPeb->OSMinorVersion;
- }
+ if (pdwMinorVersion)
+ {
+ if ( (pPeb->OSMajorVersion < 5) ||
+ ((pPeb->OSMajorVersion == 5) && (pPeb->OSMinorVersion < 1))
)
+ *pdwMinorVersion = 1;
+ else
+ *pdwMinorVersion = pPeb->OSMinorVersion;
+ }
- if (build)
- {
- /* FIXME: Does anybody know the real formula? */
- *build = (0xF0000000 | pPeb->OSBuildNumber);
- }
+ if (pdwBuildNumber)
+ {
+ /* Windows really does this! */
+ *pdwBuildNumber = (0xF0000000 | pPeb->OSBuildNumber);
+ }
}
/*
@@ -134,7 +136,7 @@
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;
}
Modified: trunk/reactos/dll/win32/kernel32/client/version.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/version.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/version.c [iso-8859-1] Thu Sep 20 19:53:14
2012
@@ -73,12 +73,11 @@
GetVersion(VOID)
{
PPEB Peb = NtCurrentPeb();
- DWORD Result;
-
- Result = MAKELONG(MAKEWORD(Peb->OSMajorVersion, Peb->OSMinorVersion),
- (Peb->OSPlatformId ^ 2) << 14);
- Result |= LOWORD(Peb->OSBuildNumber) << 16;
- return Result;
+
+ return (DWORD)( ((Peb->OSPlatformId ^ 2) << 30) |
+ (Peb->OSBuildNumber << 16) |
+ (Peb->OSMinorVersion << 8 ) |
+ Peb->OSMajorVersion );
}
/*
Modified: trunk/reactos/include/psdk/ntverp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/ntverp.h?rev=…
==============================================================================
--- trunk/reactos/include/psdk/ntverp.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/ntverp.h [iso-8859-1] Thu Sep 20 19:53:14 2012
@@ -9,7 +9,7 @@
* The VER_PRODUCTBUILD lines must contain the product
* comments and end with the build#<CR><LF>.
* The VER_PRODUCTBETA_STR lines must contain the product
- * comments and end with "somestring"<CR><LF.
+ * comments and end with "somestring"<CR><LF>.
* PROGRAMMERS: Alex Ionescu (alex.ionescu(a)reactos.org)
*/
Modified: trunk/reactos/lib/rtl/version.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/version.c?rev=5735…
==============================================================================
--- trunk/reactos/lib/rtl/version.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/version.c [iso-8859-1] Thu Sep 20 19:53:14 2012
@@ -1,4 +1,5 @@
-/* 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
@@ -22,28 +23,25 @@
/* 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;
+ return (left == right);
+ case VER_GREATER:
+ return (left > right);
+ case VER_GREATER_EQUAL:
+ return (left >= right);
+ case VER_LESS:
+ return (left < right);
+ case VER_LESS_EQUAL:
+ return (left <= right);
+ default:
break;
- case VER_GREATER:
- if (left <= right) return STATUS_REVISION_MISMATCH;
- break;
- case VER_GREATER_EQUAL:
- if (left < right) return STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS:
- if (left >= right) return STATUS_REVISION_MISMATCH;
- break;
- case VER_LESS_EQUAL:
- if (left > right) return STATUS_REVISION_MISMATCH;
- break;
- default:
- return STATUS_REVISION_MISMATCH;
- }
- return STATUS_SUCCESS;
+ }
+ return FALSE;
}
/*
@@ -59,6 +57,7 @@
{
RTL_OSVERSIONINFOEXW ver;
NTSTATUS status;
+ BOOLEAN comparison;
/* FIXME:
- Check the following special case on Windows (various versions):
@@ -71,81 +70,104 @@
status = RtlGetVersion( (PRTL_OSVERSIONINFOW)&ver );
if (status != STATUS_SUCCESS) return status;
- if(!(TypeMask && ConditionMask)) return STATUS_INVALID_PARAMETER;
-
- 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;
- }
- if(TypeMask & VER_SUITENAME)
- {
- switch(ConditionMask >> 6 * VER_NUM_BITS_PER_CONDITION_MASK &
VER_CONDITION_MASK)
+ if (!TypeMask || !ConditionMask) return STATUS_INVALID_PARAMETER;
+
+ if (TypeMask & VER_PRODUCT_TYPE)
+ {
+ 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)
+ {
+ 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)
- {
- 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;
- }
- 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;
- }
- if(TypeMask &
(VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR))
- {
- unsigned char condition = 0;
+
+ if (TypeMask & VER_PLATFORMID)
+ {
+ 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)
+ {
+ 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))
+ {
+ 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)
- {
- status = version_compare_values(ver.dwMajorVersion,
VersionInfo->dwMajorVersion, condition);
+ comparison = TRUE;
+ if (TypeMask & VER_MAJORVERSION)
+ {
+ comparison = RtlpVerCompare(ver.dwMajorVersion,
+ VersionInfo->dwMajorVersion,
+ condition);
do_next_check = (ver.dwMajorVersion == VersionInfo->dwMajorVersion)
&&
- ((condition != VER_EQUAL) || (status == STATUS_SUCCESS));
- }
- if((TypeMask & VER_MINORVERSION) && do_next_check)
- {
- status = version_compare_values(ver.dwMinorVersion,
VersionInfo->dwMinorVersion, condition);
+ ((condition != VER_EQUAL) || comparison);
+ }
+ if ((TypeMask & VER_MINORVERSION) && do_next_check)
+ {
+ comparison = RtlpVerCompare(ver.dwMinorVersion,
+ VersionInfo->dwMinorVersion,
+ condition);
do_next_check = (ver.dwMinorVersion == VersionInfo->dwMinorVersion)
&&
- ((condition != VER_EQUAL) || (status == STATUS_SUCCESS));
- }
- if((TypeMask & VER_SERVICEPACKMAJOR) && do_next_check)
- {
- status = version_compare_values(ver.wServicePackMajor,
VersionInfo->wServicePackMajor, condition);
+ ((condition != VER_EQUAL) || comparison);
+ }
+ if ((TypeMask & VER_SERVICEPACKMAJOR) && do_next_check)
+ {
+ comparison = RtlpVerCompare(ver.wServicePackMajor,
+ VersionInfo->wServicePackMajor,
+ condition);
do_next_check = (ver.wServicePackMajor == VersionInfo->wServicePackMajor)
&&
- ((condition != VER_EQUAL) || (status == STATUS_SUCCESS));
- }
- if((TypeMask & VER_SERVICEPACKMINOR) && do_next_check)
- {
- status = version_compare_values(ver.wServicePackMinor,
VersionInfo->wServicePackMinor, condition);
- }
-
- if (status != STATUS_SUCCESS)
- return status;
+ ((condition != VER_EQUAL) || comparison);
+ }
+ if ((TypeMask & VER_SERVICEPACKMINOR) && do_next_check)
+ {
+ comparison = RtlpVerCompare(ver.wServicePackMinor,
+ VersionInfo->wServicePackMinor,
+ condition);
+ }
+
+ if (!comparison)
+ return STATUS_REVISION_MISMATCH;
}
return STATUS_SUCCESS;
Modified: trunk/reactos/ntoskrnl/ex/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/init.c?rev=573…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/init.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/init.c [iso-8859-1] Thu Sep 20 19:53:14 2012
@@ -1077,15 +1077,16 @@
CmGetSystemControlValues(LoaderBlock->RegistryBase, CmControlVector);
/* Load static defaults for Service Pack 1 and add our SVN revision */
+ /* Format of CSD : SPMajor - SPMinor */
CmNtCSDVersion = 0x100 | (KERNEL_VERSION_BUILD_HEX << 16);
CmNtCSDReleaseType = 0;
/* Set Service Pack data for Service Pack 1 */
- CmNtSpBuildNumber = 1830;
+ CmNtSpBuildNumber = VER_PRODUCTBUILD_QFE;
if (!(CmNtCSDVersion & 0xFFFF0000))
{
/* Check the release type */
- if (CmNtCSDReleaseType == 1) CmNtSpBuildNumber |= 1830 << 16;
+ if (CmNtCSDReleaseType == 1) CmNtSpBuildNumber |= VER_PRODUCTBUILD_QFE <<
16;
}
/* Add loaded CmNtGlobalFlag value */
Modified: trunk/reactos/ntoskrnl/mm/ARM3/mminit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/mminit.c?…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/ARM3/mminit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/mm/ARM3/mminit.c [iso-8859-1] Thu Sep 20 19:53:14 2012
@@ -2398,7 +2398,7 @@
}
else
{
- /* Check for LanMan server */
+ /* Check for LanMan server (La for LanmanNT) */
if (MmProductType == '\0a\0L')
{
/* This is a domain controller */
@@ -2406,7 +2406,7 @@
}
else
{
- /* Otherwise it must be a normal server */
+ /* Otherwise it must be a normal server (Se for ServerNT) */
SharedUserData->NtProductType = NtProductServer;
}
Modified: trunk/reactos/ntoskrnl/rtl/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/rtl/misc.c?rev=57…
==============================================================================
--- trunk/reactos/ntoskrnl/rtl/misc.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/rtl/misc.c [iso-8859-1] Thu Sep 20 19:53:14 2012
@@ -67,7 +67,7 @@
RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)lpVersionInformation;
InfoEx->wServicePackMajor = (USHORT)(CmNtCSDVersion >> 8) & 0xFF;
InfoEx->wServicePackMinor = (USHORT)(CmNtCSDVersion & 0xFF);
- InfoEx->wSuiteMask = (USHORT)SharedUserData->SuiteMask;
+ InfoEx->wSuiteMask = (USHORT)(SharedUserData->SuiteMask & 0xFFFF);
InfoEx->wProductType = SharedUserData->NtProductType;
}