[BOOTDATA]

- Remove hardcoded registry values: CurrentVersion, CSDVersion and CurrentBuildNumber from HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion. They are computed and stored there by the kernel.
- All the versioning is controlled by the two values: CSDReleaseType and CSDVersion in HKLM\SYSTEM\CurrentControlSet\Control\Windows. Currently we target SP1.

[NTDLL]
The lpVersionInformation->szCSDVersion string should not be built by RtlGetVersion, but instead retrieved from the Peb->CSDVersion string that in turn is initialized by the NTDLL PE Loader. Normally this is a App-Compatibility-dependent string, but for now we somewhat hardcode it (it is built using the actual Peb->OSCSDVersion number).

[RTL]: Rename some variables "à la NT" and use adequate types (but no code changes otherwise).

[NTOS]
- Fix PsGetVersion that should use the CmCSDVersionString variable. This API also returns TRUE if we are in checked build mode (the high byte of NtBuildNumber is flagged).
- The kernel should initialize the CurrentVersion, CSDVersion and CurrentBuildNumber registry values (and few other ones) from the two main CSDReleaseType and CSDVersion values.
- Fix the ReactOS-specific version+revision display in SOS mode.

CORE-6611 CORE-7889 CORE-8877

svn path=/trunk/; revision=66735
This commit is contained in:
Hermès Bélusca-Maïto 2015-03-16 03:14:16 +00:00
parent 7dbea55bd3
commit c32ac4bd68
12 changed files with 345 additions and 240 deletions

View file

@ -154,9 +154,6 @@ HKLM,"SOFTWARE\Microsoft\Command Processor","AutoRun",0x00020000,""
HKLM,"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall",,0x00000012
; Version Information
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","CurrentVersion",0x00000000,"5.2"
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","CSDVersion",0x00000000,"Service Pack 2"
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","CurrentBuildNumber",0x00000000,"3790"
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","InstallDate",0x00010003,0
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","ProductName",2,"ReactOS"
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion","RegDone",0x00000002,""

View file

@ -1220,6 +1220,7 @@ HKLM,"SYSTEM\CurrentControlSet\Control\ProductOptions","ProductSuite",0x00010002
; but we can also report as Workstation if some application needs it.
HKLM,"SYSTEM\CurrentControlSet\Control\ReactOS\Settings\Version","ReportAsWorkstation",0x00010001,0x00000000
; Some installers check for SP1
HKLM,"SYSTEM\CurrentControlSet\Control\Windows","CSDReleaseType",0x00010001,0x00000000
HKLM,"SYSTEM\CurrentControlSet\Control\Windows","CSDVersion",0x00010001,0x00000100
HKLM,"SYSTEM\CurrentControlSet\Control\SecurityProviders","SecurityProviders",2,"schannel.dll"

View file

@ -1775,7 +1775,7 @@ LdrpInitializeProcess(IN PCONTEXT Context,
/* Check if we failed */
if (!NT_SUCCESS(Status))
{
/* Aassume System32 */
/* Assume System32 */
LdrpKnownDllObjectDirectory = NULL;
RtlInitUnicodeString(&LdrpKnownDllPath, StringBuffer);
LdrpKnownDllPath.Length -= sizeof(WCHAR);
@ -2070,6 +2070,40 @@ LdrpInitializeProcess(IN PCONTEXT Context,
&ExecuteOptions,
sizeof(ULONG));
// FIXME: Should be done by Application Compatibility features,
// by reading the registry, etc...
// For now, this is the old code from ntdll!RtlGetVersion().
RtlInitEmptyUnicodeString(&Peb->CSDVersion, NULL, 0);
if (((Peb->OSCSDVersion >> 8) & 0xFF) != 0)
{
WCHAR szCSDVersion[128];
ULONG i;
ULONG Length = ARRAYSIZE(szCSDVersion) - 1;
i = _snwprintf(szCSDVersion, Length,
L"Service Pack %d",
((Peb->OSCSDVersion >> 8) & 0xFF));
if (i < 0)
{
/* Null-terminate if it was overflowed */
szCSDVersion[Length] = UNICODE_NULL;
}
Length *= sizeof(WCHAR);
Peb->CSDVersion.Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
0,
Length + sizeof(UNICODE_NULL));
if (Peb->CSDVersion.Buffer)
{
Peb->CSDVersion.Length = Length;
Peb->CSDVersion.MaximumLength = Length + sizeof(UNICODE_NULL);
RtlCopyMemory(Peb->CSDVersion.Buffer,
szCSDVersion,
Peb->CSDVersion.MaximumLength);
Peb->CSDVersion.Buffer[Peb->CSDVersion.Length / sizeof(WCHAR)] = UNICODE_NULL;
}
}
/* Check if we had Shim Data */
if (OldShimData)
{

View file

@ -204,6 +204,7 @@ LdrpFreeUnicodeString(IN PUNICODE_STRING StringIn)
/* Zero it out */
RtlInitEmptyUnicodeString(StringIn, NULL, 0);
}
BOOLEAN
NTAPI
LdrpCallInitRoutine(IN PDLL_INIT_ROUTINE EntryPoint,

View file

@ -69,26 +69,26 @@ SetRosSpecificInfo(IN OUT PRTL_OSVERSIONINFOEXW VersionInformation)
}
/**********************************************************************
* NAME EXPORTED
* RtlGetNtProductType
* NAME EXPORTED
* RtlGetNtProductType
*
* DESCRIPTION
* Retrieves the OS product type.
* Retrieves the OS product type.
*
* ARGUMENTS
* ProductType Pointer to the product type variable.
* ProductType Pointer to the product type variable.
*
* RETURN VALUE
* TRUE if successful, otherwise FALSE
* TRUE if successful, otherwise FALSE
*
* NOTE
* ProductType can be one of the following values:
* 1 Workstation (WinNT)
* 2 Server (LanmanNT)
* 3 Advanced Server (ServerNT)
* ProductType can be one of the following values:
* 1 Workstation (WinNT)
* 2 Server (LanmanNT)
* 3 Advanced Server (ServerNT)
*
* REVISIONS
* 2000-08-10 ekohl
* 2000-08-10 ekohl
*
* @implemented
*/
@ -100,53 +100,53 @@ RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
}
/**********************************************************************
* NAME EXPORTED
* RtlGetNtVersionNumbers
* NAME EXPORTED
* RtlGetNtVersionNumbers
*
* DESCRIPTION
* Get the version numbers of the run time library.
* Get the version numbers of the run time library.
*
* ARGUMENTS
* pdwMajorVersion [OUT] Destination for the Major version
* pdwMinorVersion [OUT] Destination for the Minor version
* pdwBuildNumber [OUT] Destination for the Build version
* pMajorVersion [OUT] Destination for the Major version
* pMinorVersion [OUT] Destination for the Minor version
* pBuildNumber [OUT] Destination for the Build version
*
* RETURN VALUE
* Nothing.
* Nothing.
*
* 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.
* - 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(OUT LPDWORD pdwMajorVersion,
OUT LPDWORD pdwMinorVersion,
OUT LPDWORD pdwBuildNumber)
RtlGetNtVersionNumbers(OUT PULONG pMajorVersion,
OUT PULONG pMinorVersion,
OUT PULONG pBuildNumber)
{
PPEB pPeb = NtCurrentPeb();
if (pdwMajorVersion)
if (pMajorVersion)
{
*pdwMajorVersion = pPeb->OSMajorVersion < 5 ? 5 : pPeb->OSMajorVersion;
*pMajorVersion = pPeb->OSMajorVersion < 5 ? 5 : pPeb->OSMajorVersion;
}
if (pdwMinorVersion)
if (pMinorVersion)
{
if ( (pPeb->OSMajorVersion < 5) ||
((pPeb->OSMajorVersion == 5) && (pPeb->OSMinorVersion < 1)) )
*pdwMinorVersion = 1;
*pMinorVersion = 1;
else
*pdwMinorVersion = pPeb->OSMinorVersion;
*pMinorVersion = pPeb->OSMinorVersion;
}
if (pdwBuildNumber)
if (pBuildNumber)
{
/* Windows really does this! */
*pdwBuildNumber = (0xF0000000 | pPeb->OSBuildNumber);
*pBuildNumber = (0xF0000000 | pPeb->OSBuildNumber);
}
}
@ -157,50 +157,51 @@ RtlGetNtVersionNumbers(OUT LPDWORD pdwMajorVersion,
NTSTATUS NTAPI
RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
{
LONG i, MaxLength;
ULONG Length;
PPEB Peb = NtCurrentPeb();
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
if (lpVersionInformation->dwOSVersionInfoSize != sizeof(RTL_OSVERSIONINFOW) &&
lpVersionInformation->dwOSVersionInfoSize != sizeof(RTL_OSVERSIONINFOEXW))
{
PPEB Peb = NtCurrentPeb();
lpVersionInformation->dwMajorVersion = Peb->OSMajorVersion;
lpVersionInformation->dwMinorVersion = Peb->OSMinorVersion;
lpVersionInformation->dwBuildNumber = Peb->OSBuildNumber;
lpVersionInformation->dwPlatformId = Peb->OSPlatformId;
RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
if(((Peb->OSCSDVersion >> 8) & 0xFF) != 0)
{
MaxLength = (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0])) - 1;
i = _snwprintf(lpVersionInformation->szCSDVersion,
MaxLength,
L"Service Pack %d",
((Peb->OSCSDVersion >> 8) & 0xFF));
if (i < 0)
{
/* Null-terminate if it was overflowed */
lpVersionInformation->szCSDVersion[MaxLength] = L'\0';
}
}
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{
PRTL_OSVERSIONINFOEXW InfoEx = (PRTL_OSVERSIONINFOEXW)lpVersionInformation;
InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF;
InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF;
InfoEx->wSuiteMask = SharedUserData->SuiteMask & 0xFFFF;
InfoEx->wProductType = SharedUserData->NtProductType;
InfoEx->wReserved = 0;
/* HACK: ReactOS specific changes, see bug-reports CORE-6611 and CORE-4620 (aka. #5003) */
SetRosSpecificInfo(InfoEx);
}
return STATUS_SUCCESS;
return STATUS_INVALID_PARAMETER;
}
return STATUS_INVALID_PARAMETER;
lpVersionInformation->dwMajorVersion = Peb->OSMajorVersion;
lpVersionInformation->dwMinorVersion = Peb->OSMinorVersion;
lpVersionInformation->dwBuildNumber = Peb->OSBuildNumber;
lpVersionInformation->dwPlatformId = Peb->OSPlatformId;
RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
/* If we have a CSD version string, initialized by Application Compatibility... */
if (Peb->CSDVersion.Length && Peb->CSDVersion.Buffer && Peb->CSDVersion.Buffer[0] != UNICODE_NULL)
{
/* ... copy it... */
Length = min(wcslen(Peb->CSDVersion.Buffer), ARRAYSIZE(lpVersionInformation->szCSDVersion) - 1);
wcsncpy(lpVersionInformation->szCSDVersion, Peb->CSDVersion.Buffer, Length);
}
else
{
/* ... otherwise we just null-terminate it */
Length = 0;
}
/* Always null-terminate the user CSD version string */
lpVersionInformation->szCSDVersion[Length] = UNICODE_NULL;
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
{
PRTL_OSVERSIONINFOEXW InfoEx = (PRTL_OSVERSIONINFOEXW)lpVersionInformation;
InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF;
InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF;
InfoEx->wSuiteMask = SharedUserData->SuiteMask & 0xFFFF;
InfoEx->wProductType = SharedUserData->NtProductType;
InfoEx->wReserved = 0;
/* HACK: ReactOS specific changes, see bug-reports CORE-6611 and CORE-4620 (aka. #5003) */
SetRosSpecificInfo(InfoEx);
}
return STATUS_SUCCESS;
}
/* EOF */

View file

@ -22,14 +22,14 @@ RtlGetVersion(OUT PRTL_OSVERSIONINFOW lpVersionInformation);
/* FUNCTIONS ****************************************************************/
static BYTE
RtlpVerGetCondition(IN ULONGLONG dwlConditionMask,
IN DWORD dwTypeBitMask);
static UCHAR
RtlpVerGetCondition(IN ULONGLONG ConditionMask,
IN ULONG TypeMask);
static BOOLEAN
RtlpVerCompare(ULONG left, ULONG right, UCHAR condition)
RtlpVerCompare(ULONG left, ULONG right, UCHAR Condition)
{
switch (condition)
switch (Condition)
{
case VER_EQUAL:
return (left == right);
@ -56,9 +56,9 @@ RtlVerifyVersionInfo(IN PRTL_OSVERSIONINFOEXW VersionInfo,
IN ULONG TypeMask,
IN ULONGLONG ConditionMask)
{
NTSTATUS Status;
RTL_OSVERSIONINFOEXW ver;
NTSTATUS status;
BOOLEAN comparison;
BOOLEAN Comparison;
/* FIXME:
- Check the following special case on Windows (various versions):
@ -68,17 +68,17 @@ RtlVerifyVersionInfo(IN PRTL_OSVERSIONINFOEXW VersionInfo,
*/
ver.dwOSVersionInfoSize = sizeof(ver);
status = RtlGetVersion((PRTL_OSVERSIONINFOW)&ver);
if (status != STATUS_SUCCESS) return status;
Status = RtlGetVersion((PRTL_OSVERSIONINFOW)&ver);
if (Status != STATUS_SUCCESS) return Status;
if (!TypeMask || !ConditionMask) return STATUS_INVALID_PARAMETER;
if (TypeMask & VER_PRODUCT_TYPE)
{
comparison = RtlpVerCompare(ver.wProductType,
Comparison = RtlpVerCompare(ver.wProductType,
VersionInfo->wProductType,
RtlpVerGetCondition(ConditionMask, VER_PRODUCT_TYPE));
if (!comparison)
if (!Comparison)
return STATUS_REVISION_MISMATCH;
}
@ -105,19 +105,19 @@ RtlVerifyVersionInfo(IN PRTL_OSVERSIONINFOEXW VersionInfo,
if (TypeMask & VER_PLATFORMID)
{
comparison = RtlpVerCompare(ver.dwPlatformId,
Comparison = RtlpVerCompare(ver.dwPlatformId,
VersionInfo->dwPlatformId,
RtlpVerGetCondition(ConditionMask, VER_PLATFORMID));
if (!comparison)
if (!Comparison)
return STATUS_REVISION_MISMATCH;
}
if (TypeMask & VER_BUILDNUMBER)
{
comparison = RtlpVerCompare(ver.dwBuildNumber,
Comparison = RtlpVerCompare(ver.dwBuildNumber,
VersionInfo->dwBuildNumber,
RtlpVerGetCondition(ConditionMask, VER_BUILDNUMBER));
if (!comparison)
if (!Comparison)
return STATUS_REVISION_MISMATCH;
}
@ -130,79 +130,79 @@ RtlVerifyVersionInfo(IN PRTL_OSVERSIONINFOEXW VersionInfo,
* operator for VER_MAJORVERSION supersedes the others for VER_MINORVERSION,
* VER_SERVICEPACKMAJOR and VER_SERVICEPACKMINOR).
*/
BYTE condition = RtlpVerGetCondition(ConditionMask, TypeMask);
UCHAR Condition = RtlpVerGetCondition(ConditionMask, TypeMask);
comparison = TRUE;
Comparison = TRUE;
if (TypeMask & VER_MAJORVERSION)
{
comparison = RtlpVerCompare(ver.dwMajorVersion,
Comparison = RtlpVerCompare(ver.dwMajorVersion,
VersionInfo->dwMajorVersion,
condition);
Condition);
do_next_check = (ver.dwMajorVersion == VersionInfo->dwMajorVersion) &&
((condition != VER_EQUAL) || comparison);
((Condition != VER_EQUAL) || Comparison);
}
if ((TypeMask & VER_MINORVERSION) && do_next_check)
{
comparison = RtlpVerCompare(ver.dwMinorVersion,
Comparison = RtlpVerCompare(ver.dwMinorVersion,
VersionInfo->dwMinorVersion,
condition);
Condition);
do_next_check = (ver.dwMinorVersion == VersionInfo->dwMinorVersion) &&
((condition != VER_EQUAL) || comparison);
((Condition != VER_EQUAL) || Comparison);
}
if ((TypeMask & VER_SERVICEPACKMAJOR) && do_next_check)
{
comparison = RtlpVerCompare(ver.wServicePackMajor,
Comparison = RtlpVerCompare(ver.wServicePackMajor,
VersionInfo->wServicePackMajor,
condition);
Condition);
do_next_check = (ver.wServicePackMajor == VersionInfo->wServicePackMajor) &&
((condition != VER_EQUAL) || comparison);
((Condition != VER_EQUAL) || Comparison);
}
if ((TypeMask & VER_SERVICEPACKMINOR) && do_next_check)
{
comparison = RtlpVerCompare(ver.wServicePackMinor,
Comparison = RtlpVerCompare(ver.wServicePackMinor,
VersionInfo->wServicePackMinor,
condition);
Condition);
}
if (!comparison)
if (!Comparison)
return STATUS_REVISION_MISMATCH;
}
return STATUS_SUCCESS;
}
static BYTE
RtlpVerGetCondition(IN ULONGLONG dwlConditionMask,
IN DWORD dwTypeBitMask)
static UCHAR
RtlpVerGetCondition(IN ULONGLONG ConditionMask,
IN ULONG TypeMask)
{
BYTE bConditionMask = 0;
UCHAR Condition = 0;
if (dwTypeBitMask & VER_PRODUCT_TYPE)
bConditionMask |= dwlConditionMask >> (7 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_SUITENAME)
bConditionMask |= dwlConditionMask >> (6 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_PLATFORMID)
bConditionMask |= dwlConditionMask >> (3 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_BUILDNUMBER)
bConditionMask |= dwlConditionMask >> (2 * VER_NUM_BITS_PER_CONDITION_MASK);
if (TypeMask & VER_PRODUCT_TYPE)
Condition |= ConditionMask >> (7 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_SUITENAME)
Condition |= ConditionMask >> (6 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_PLATFORMID)
Condition |= ConditionMask >> (3 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_BUILDNUMBER)
Condition |= ConditionMask >> (2 * VER_NUM_BITS_PER_CONDITION_MASK);
/*
* We choose here the lexicographical order on the 4D space
* {(Major ; Minor ; SP Major ; SP Minor)} to select the
* appropriate comparison operator.
* Therefore the following 'else if' instructions must be in this order.
*/
else if (dwTypeBitMask & VER_MAJORVERSION)
bConditionMask |= dwlConditionMask >> (1 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_MINORVERSION)
bConditionMask |= dwlConditionMask >> (0 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
bConditionMask |= dwlConditionMask >> (5 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
bConditionMask |= dwlConditionMask >> (4 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_MAJORVERSION)
Condition |= ConditionMask >> (1 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_MINORVERSION)
Condition |= ConditionMask >> (0 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_SERVICEPACKMAJOR)
Condition |= ConditionMask >> (5 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_SERVICEPACKMINOR)
Condition |= ConditionMask >> (4 * VER_NUM_BITS_PER_CONDITION_MASK);
bConditionMask &= VER_CONDITION_MASK;
Condition &= VER_CONDITION_MASK;
return bConditionMask;
return Condition;
}
/*
@ -210,39 +210,39 @@ RtlpVerGetCondition(IN ULONGLONG dwlConditionMask,
*/
ULONGLONG
NTAPI
VerSetConditionMask(IN ULONGLONG dwlConditionMask,
IN DWORD dwTypeBitMask,
IN BYTE bConditionMask)
VerSetConditionMask(IN ULONGLONG ConditionMask,
IN ULONG TypeMask,
IN UCHAR Condition)
{
ULONGLONG ullCondMask;
if (dwTypeBitMask == 0)
return dwlConditionMask;
if (TypeMask == 0)
return ConditionMask;
bConditionMask &= VER_CONDITION_MASK;
Condition &= VER_CONDITION_MASK;
if (bConditionMask == 0)
return dwlConditionMask;
if (Condition == 0)
return ConditionMask;
ullCondMask = bConditionMask;
if (dwTypeBitMask & VER_PRODUCT_TYPE)
dwlConditionMask |= ullCondMask << (7 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_SUITENAME)
dwlConditionMask |= ullCondMask << (6 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_SERVICEPACKMAJOR)
dwlConditionMask |= ullCondMask << (5 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_SERVICEPACKMINOR)
dwlConditionMask |= ullCondMask << (4 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_PLATFORMID)
dwlConditionMask |= ullCondMask << (3 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_BUILDNUMBER)
dwlConditionMask |= ullCondMask << (2 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_MAJORVERSION)
dwlConditionMask |= ullCondMask << (1 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (dwTypeBitMask & VER_MINORVERSION)
dwlConditionMask |= ullCondMask << (0 * VER_NUM_BITS_PER_CONDITION_MASK);
ullCondMask = Condition;
if (TypeMask & VER_PRODUCT_TYPE)
ConditionMask |= ullCondMask << (7 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_SUITENAME)
ConditionMask |= ullCondMask << (6 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_SERVICEPACKMAJOR)
ConditionMask |= ullCondMask << (5 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_SERVICEPACKMINOR)
ConditionMask |= ullCondMask << (4 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_PLATFORMID)
ConditionMask |= ullCondMask << (3 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_BUILDNUMBER)
ConditionMask |= ullCondMask << (2 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_MAJORVERSION)
ConditionMask |= ullCondMask << (1 * VER_NUM_BITS_PER_CONDITION_MASK);
else if (TypeMask & VER_MINORVERSION)
ConditionMask |= ullCondMask << (0 * VER_NUM_BITS_PER_CONDITION_MASK);
return dwlConditionMask;
return ConditionMask;
}
/* EOF */

View file

@ -698,6 +698,14 @@ INIT_FUNCTION CM_SYSTEM_CONTROL_VECTOR CmControlVector[] =
NULL
},
{
L"Windows",
L"CSDReleaseType",
&CmNtCSDReleaseType,
NULL,
NULL
},
{
L"Nls\\Language",
L"Default",

View file

@ -2079,27 +2079,30 @@ VOID
NTAPI
CmpSetVersionData(VOID)
{
NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING KeyName;
UNICODE_STRING ValueName;
UNICODE_STRING ValueData;
ANSI_STRING TempString;
HANDLE SoftwareKeyHandle = NULL;
HANDLE MicrosoftKeyHandle = NULL;
HANDLE WindowsNtKeyHandle = NULL;
HANDLE CurrentVersionKeyHandle = NULL;
WCHAR Buffer[128];
NTSTATUS Status;
WCHAR Buffer[128]; // Buffer large enough to contain a full ULONG in decimal representation,
// and the full 'CurrentType' string.
/* Open the 'CurrentVersion' key */
RtlInitUnicodeString(&KeyName,
L"\\REGISTRY\\MACHINE\\SOFTWARE");
/*
* Open the 'HKLM\Software\Microsoft\Windows NT\CurrentVersion' key
* (create the intermediate subkeys if needed).
*/
RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\MACHINE\\SOFTWARE");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
NULL);
Status = NtCreateKey(&SoftwareKeyHandle,
KEY_CREATE_SUB_KEY,
&ObjectAttributes,
@ -2113,16 +2116,12 @@ CmpSetVersionData(VOID)
return;
}
/* Open the 'CurrentVersion' key */
RtlInitUnicodeString(&KeyName,
L"Microsoft");
RtlInitUnicodeString(&KeyName, L"Microsoft");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
SoftwareKeyHandle,
NULL);
Status = NtCreateKey(&MicrosoftKeyHandle,
KEY_CREATE_SUB_KEY,
&ObjectAttributes,
@ -2133,19 +2132,15 @@ CmpSetVersionData(VOID)
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to create key %wZ (Status: %08lx)\n", &KeyName, Status);
goto done;
goto Quit;
}
/* Open the 'CurrentVersion' key */
RtlInitUnicodeString(&KeyName,
L"Windows NT");
RtlInitUnicodeString(&KeyName, L"Windows NT");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
MicrosoftKeyHandle,
NULL);
Status = NtCreateKey(&WindowsNtKeyHandle,
KEY_CREATE_SUB_KEY,
&ObjectAttributes,
@ -2156,19 +2151,15 @@ CmpSetVersionData(VOID)
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to create key %wZ (Status: %08lx)\n", &KeyName, Status);
goto done;
goto Quit;
}
/* Open the 'CurrentVersion' key */
RtlInitUnicodeString(&KeyName,
L"CurrentVersion");
RtlInitUnicodeString(&KeyName, L"CurrentVersion");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
OBJ_CASE_INSENSITIVE,
WindowsNtKeyHandle,
NULL);
Status = NtCreateKey(&CurrentVersionKeyHandle,
KEY_CREATE_SUB_KEY | KEY_SET_VALUE,
&ObjectAttributes,
@ -2179,30 +2170,22 @@ CmpSetVersionData(VOID)
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to create key %wZ (Status: %08lx)\n", &KeyName, Status);
goto done;
goto Quit;
}
/* Set the 'CurrentType' value */
RtlInitUnicodeString(&ValueName,
L"CurrentType");
#ifdef CONFIG_SMP
wcscpy(Buffer, L"Multiprocessor");
#else
wcscpy(Buffer, L"Uniprocessor");
#endif
wcscat(Buffer, L" ");
#if (DBG == 1)
wcscat(Buffer, L"Checked");
#else
wcscat(Buffer, L"Free");
#endif
RtlInitUnicodeString(&ValueData,
Buffer);
/* Set the 'CurrentVersion' value */
RtlInitUnicodeString(&ValueName, L"CurrentVersion");
NtSetValueKey(CurrentVersionKeyHandle,
&ValueName,
0,
REG_SZ,
CmVersionString.Buffer,
CmVersionString.Length + sizeof(WCHAR));
/* Set the 'CurrentBuildNumber' value */
RtlInitUnicodeString(&ValueName, L"CurrentBuildNumber");
RtlInitEmptyUnicodeString(&ValueData, Buffer, sizeof(Buffer));
RtlIntegerToUnicodeString(NtBuildNumber & 0xFFFF, 10, &ValueData);
NtSetValueKey(CurrentVersionKeyHandle,
&ValueName,
0,
@ -2210,7 +2193,88 @@ CmpSetVersionData(VOID)
ValueData.Buffer,
ValueData.Length + sizeof(WCHAR));
done:;
/* Set the 'BuildLab' value */
RtlInitUnicodeString(&ValueName, L"BuildLab");
RtlInitAnsiString(&TempString, NtBuildLab);
Status = RtlAnsiStringToUnicodeString(&ValueData, &TempString, FALSE);
if (NT_SUCCESS(Status))
{
NtSetValueKey(CurrentVersionKeyHandle,
&ValueName,
0,
REG_SZ,
ValueData.Buffer,
ValueData.Length + sizeof(WCHAR));
}
/* Set the 'CurrentType' value */
RtlInitUnicodeString(&ValueName, L"CurrentType");
swprintf(Buffer, L"%s %s",
#ifdef CONFIG_SMP
L"Multiprocessor"
#else
L"Uniprocessor"
#endif
,
#if (DBG == 1)
L"Checked"
#else
L"Free"
#endif
);
RtlInitUnicodeString(&ValueData, Buffer);
NtSetValueKey(CurrentVersionKeyHandle,
&ValueName,
0,
REG_SZ,
ValueData.Buffer,
ValueData.Length + sizeof(WCHAR));
/* Set the 'CSDVersion' value */
RtlInitUnicodeString(&ValueName, L"CSDVersion");
if (CmCSDVersionString.Length != 0)
{
NtSetValueKey(CurrentVersionKeyHandle,
&ValueName,
0,
REG_SZ,
CmCSDVersionString.Buffer,
CmCSDVersionString.Length + sizeof(WCHAR));
}
else
{
NtDeleteValueKey(CurrentVersionKeyHandle, &ValueName);
}
/* Set the 'CSDBuildNumber' value */
RtlInitUnicodeString(&ValueName, L"CSDBuildNumber");
if (CmNtSpBuildNumber != 0)
{
RtlInitEmptyUnicodeString(&ValueData, Buffer, sizeof(Buffer));
RtlIntegerToUnicodeString(CmNtSpBuildNumber, 10, &ValueData);
NtSetValueKey(CurrentVersionKeyHandle,
&ValueName,
0,
REG_SZ,
ValueData.Buffer,
ValueData.Length + sizeof(WCHAR));
}
else
{
NtDeleteValueKey(CurrentVersionKeyHandle, &ValueName);
}
/* Set the 'SystemRoot' value */
RtlInitUnicodeString(&ValueName, L"SystemRoot");
NtSetValueKey(CurrentVersionKeyHandle,
&ValueName,
0,
REG_SZ,
NtSystemRoot.Buffer,
NtSystemRoot.Length + sizeof(WCHAR));
Quit:
/* Close the keys */
if (CurrentVersionKeyHandle != NULL)
NtClose(CurrentVersionKeyHandle);

View file

@ -41,9 +41,9 @@ typedef struct _INIT_BUFFER
/* NT Version Info */
ULONG NtMajorVersion = VER_PRODUCTMAJORVERSION;
ULONG NtMinorVersion = VER_PRODUCTMINORVERSION;
#if DBG
#if DBG /* Checked Build */
ULONG NtBuildNumber = VER_PRODUCTBUILD | 0xC0000000;
#else
#else /* Free Build */
ULONG NtBuildNumber = VER_PRODUCTBUILD;
#endif
@ -920,10 +920,10 @@ ExpInitializeExecutive(IN ULONG Cpu,
ULONG PerfMemUsed;
PLDR_DATA_TABLE_ENTRY NtosEntry;
PMESSAGE_RESOURCE_ENTRY MsgEntry;
ANSI_STRING CsdString;
ANSI_STRING CSDString;
size_t Remaining = 0;
PCHAR RcEnd = NULL;
CHAR VersionBuffer [65];
CHAR VersionBuffer[65];
/* Validate Loader */
if (!ExpIsLoaderValid(LoaderBlock))
@ -1076,17 +1076,11 @@ ExpInitializeExecutive(IN ULONG Cpu,
/* Setup initial system settings */
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 */
/* Set the Service Pack Number and add it to the CSD Version number if needed */
CmNtSpBuildNumber = VER_PRODUCTBUILD_QFE;
if (!(CmNtCSDVersion & 0xFFFF0000))
if (((CmNtCSDVersion & 0xFFFF0000) == 0) && (CmNtCSDReleaseType == 1))
{
/* Check the release type */
if (CmNtCSDReleaseType == 1) CmNtSpBuildNumber |= VER_PRODUCTBUILD_QFE << 16;
CmNtCSDVersion |= (VER_PRODUCTBUILD_QFE << 16);
}
/* Add loaded CmNtGlobalFlag value */
@ -1140,22 +1134,22 @@ ExpInitializeExecutive(IN ULONG Cpu,
if (NT_SUCCESS(Status))
{
/* Setup the string */
RtlInitAnsiString(&CsdString, (PCHAR)MsgEntry->Text);
RtlInitAnsiString(&CSDString, (PCHAR)MsgEntry->Text);
/* Remove trailing newline */
while ((CsdString.Length > 0) &&
((CsdString.Buffer[CsdString.Length - 1] == '\r') ||
(CsdString.Buffer[CsdString.Length - 1] == '\n')))
while ((CSDString.Length > 0) &&
((CSDString.Buffer[CSDString.Length - 1] == '\r') ||
(CSDString.Buffer[CSDString.Length - 1] == '\n')))
{
/* Skip the trailing character */
CsdString.Length--;
CSDString.Length--;
}
/* Fill the buffer with version information */
Status = RtlStringCbPrintfA(Buffer,
sizeof(Buffer),
"%Z %u%c",
&CsdString,
&CSDString,
(CmNtCSDVersion & 0xFF00) >> 8,
(CmNtCSDVersion & 0xFF) ?
'A' + (CmNtCSDVersion & 0xFF) - 1 :
@ -1197,7 +1191,7 @@ ExpInitializeExecutive(IN ULONG Cpu,
}
/* Check if we have an RC number */
if (CmNtCSDVersion & 0xFFFF0000)
if ((CmNtCSDVersion & 0xFFFF0000) && (CmNtCSDReleaseType == 1))
{
/* Check if we have no version data yet */
if (!(*Buffer))
@ -1223,10 +1217,12 @@ ExpInitializeExecutive(IN ULONG Cpu,
}
/* Add the version format string */
/* ReactOS specific: Append also the revision number */
Status = RtlStringCbPrintfA(RcEnd,
Remaining,
"r%u",
/*(CmNtCSDVersion & 0xFFFF0000) >> 16*/
"v.%u"
" r%u",
(CmNtCSDVersion & 0xFFFF0000) >> 16,
KERNEL_VERSION_BUILD_HEX);
if (!NT_SUCCESS(Status))
{
@ -1236,9 +1232,9 @@ ExpInitializeExecutive(IN ULONG Cpu,
}
/* Now setup the final string */
RtlInitAnsiString(&CsdString, Buffer);
RtlInitAnsiString(&CSDString, Buffer);
Status = RtlAnsiStringToUnicodeString(&CmCSDVersionString,
&CsdString,
&CSDString,
TRUE);
if (!NT_SUCCESS(Status))
{

View file

@ -9,9 +9,6 @@ extern ULONG ExpTickCountMultiplier;
extern ULONG ExpLastTimeZoneBias;
extern POBJECT_TYPE ExEventPairObjectType;
extern POBJECT_TYPE _ExEventObjectType, _ExSemaphoreObjectType;
extern ULONG NtBuildNumber;
extern ULONG NtMajorVersion;
extern ULONG NtMinorVersion;
extern FAST_MUTEX ExpEnvironmentLock;
extern ERESOURCE ExpFirmwareTableResource;
extern LIST_ENTRY ExpFirmwareTableProviderListHead;
@ -20,9 +17,8 @@ extern LIST_ENTRY ExpSystemResourcesList;
extern ULONG ExpAnsiCodePageDataOffset, ExpOemCodePageDataOffset;
extern ULONG ExpUnicodeCaseTableDataOffset;
extern PVOID ExpNlsSectionPointer;
extern CHAR NtBuildLab[];
extern ULONG CmNtCSDVersion;
extern ULONG NtGlobalFlag;
extern UNICODE_STRING NtSystemRoot;
extern ULONG ExpInitializationPhase;
extern ULONG ExpAltTimeZoneBias;
extern LIST_ENTRY ExSystemLookasideListHead;
@ -33,6 +29,19 @@ extern LIST_ENTRY ExpPagedLookasideListHead;
extern KSPIN_LOCK ExpNonPagedLookasideListLock;
extern KSPIN_LOCK ExpPagedLookasideListLock;
/*
* NT/Cm Version Info variables
*/
extern ULONG NtMajorVersion;
extern ULONG NtMinorVersion;
extern ULONG NtBuildNumber;
extern ULONG CmNtSpBuildNumber;
extern ULONG CmNtCSDVersion;
extern ULONG CmNtCSDReleaseType;
extern UNICODE_STRING CmVersionString;
extern UNICODE_STRING CmCSDVersionString;
extern CHAR NtBuildLab[];
#ifdef _WIN64
#define HANDLE_LOW_BITS (PAGE_SHIFT - 4)
#define HANDLE_HIGH_BITS (PAGE_SHIFT - 3)

View file

@ -30,7 +30,6 @@ IopTimerDispatch(
POBJECT_TYPE IoDeviceObjectType = NULL;
POBJECT_TYPE IoFileObjectType = NULL;
extern POBJECT_TYPE IoControllerObjectType;
extern UNICODE_STRING NtSystemRoot;
BOOLEAN IoCountOperations = TRUE;
ULONG IoReadOperationCount = 0;
LARGE_INTEGER IoReadTransferCount = {{0, 0}};

View file

@ -43,7 +43,7 @@ PVOID PspSystemDllSection;
PVOID PspSystemDllEntryPoint;
UNICODE_STRING PsNtDllPathName =
RTL_CONSTANT_STRING(L"\\SystemRoot\\system32\\ntdll.dll");
RTL_CONSTANT_STRING(L"\\SystemRoot\\System32\\ntdll.dll");
PHANDLE_TABLE PspCidTable;
@ -658,28 +658,23 @@ PsInitSystem(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
*/
BOOLEAN
NTAPI
PsGetVersion(IN PULONG MajorVersion OPTIONAL,
IN PULONG MinorVersion OPTIONAL,
IN PULONG BuildNumber OPTIONAL,
IN PUNICODE_STRING CSDVersion OPTIONAL)
PsGetVersion(OUT PULONG MajorVersion OPTIONAL,
OUT PULONG MinorVersion OPTIONAL,
OUT PULONG BuildNumber OPTIONAL,
OUT PUNICODE_STRING CSDVersion OPTIONAL)
{
if (MajorVersion) *MajorVersion = NtMajorVersion;
if (MinorVersion) *MinorVersion = NtMinorVersion;
if (BuildNumber) *BuildNumber = NtBuildNumber;
if (BuildNumber ) *BuildNumber = NtBuildNumber & 0x3FFF;
if (CSDVersion)
{
CSDVersion->Length = 0;
CSDVersion->MaximumLength = 0;
CSDVersion->Buffer = NULL;
#if 0
CSDVersion->Length = CmCSDVersionString.Length;
CSDVersion->MaximumLength = CmCSDVersionString.Maximum;
CSDVersion->MaximumLength = CmCSDVersionString.MaximumLength;
CSDVersion->Buffer = CmCSDVersionString.Buffer;
#endif
}
/* Check the High word */
/* Return TRUE if this is a Checked Build */
return (NtBuildNumber >> 28) == 0xC;
}