diff --git a/reactos/dll/ntdll/rtl/version.c b/reactos/dll/ntdll/rtl/version.c index c55db1a252a..ce832c3e4fc 100644 --- a/reactos/dll/ntdll/rtl/version.c +++ b/reactos/dll/ntdll/rtl/version.c @@ -3,7 +3,7 @@ * 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 */ @@ -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 @@ RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType) * 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 @@ RtlGetVersion(RTL_OSVERSIONINFOW *Info) 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; } diff --git a/reactos/dll/win32/kernel32/client/version.c b/reactos/dll/win32/kernel32/client/version.c index f1757af64eb..e8303086bb8 100644 --- a/reactos/dll/win32/kernel32/client/version.c +++ b/reactos/dll/win32/kernel32/client/version.c @@ -73,12 +73,11 @@ WINAPI 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 ); } /* diff --git a/reactos/include/psdk/ntverp.h b/reactos/include/psdk/ntverp.h index e892c6359ab..d52f29ec88b 100644 --- a/reactos/include/psdk/ntverp.h +++ b/reactos/include/psdk/ntverp.h @@ -9,7 +9,7 @@ * The VER_PRODUCTBUILD lines must contain the product * comments and end with the build#. * The VER_PRODUCTBETA_STR lines must contain the product - * comments and end with "somestring". * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) */ diff --git a/reactos/lib/rtl/version.c b/reactos/lib/rtl/version.c index e467d3d5193..f29d3d40362 100644 --- a/reactos/lib/rtl/version.c +++ b/reactos/lib/rtl/version.c @@ -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 @@ RtlGetVersion( /* 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; } /* @@ -59,6 +57,7 @@ RtlVerifyVersionInfo( { RTL_OSVERSIONINFOEXW ver; NTSTATUS status; + BOOLEAN comparison; /* FIXME: - Check the following special case on Windows (various versions): @@ -71,81 +70,104 @@ RtlVerifyVersionInfo( 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; diff --git a/reactos/ntoskrnl/ex/init.c b/reactos/ntoskrnl/ex/init.c index 847ddc30d0b..4006494d998 100644 --- a/reactos/ntoskrnl/ex/init.c +++ b/reactos/ntoskrnl/ex/init.c @@ -1077,15 +1077,16 @@ ExpInitializeExecutive(IN ULONG Cpu, 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 */ diff --git a/reactos/ntoskrnl/mm/ARM3/mminit.c b/reactos/ntoskrnl/mm/ARM3/mminit.c index 8b7e87ecefb..a5e6f9c4d99 100644 --- a/reactos/ntoskrnl/mm/ARM3/mminit.c +++ b/reactos/ntoskrnl/mm/ARM3/mminit.c @@ -2398,7 +2398,7 @@ MmArmInitSystem(IN ULONG Phase, } 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 @@ MmArmInitSystem(IN ULONG Phase, } else { - /* Otherwise it must be a normal server */ + /* Otherwise it must be a normal server (Se for ServerNT) */ SharedUserData->NtProductType = NtProductServer; } diff --git a/reactos/ntoskrnl/rtl/misc.c b/reactos/ntoskrnl/rtl/misc.c index 01665c55881..2ad6931fda7 100644 --- a/reactos/ntoskrnl/rtl/misc.c +++ b/reactos/ntoskrnl/rtl/misc.c @@ -67,7 +67,7 @@ RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation) 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; }