mirror of
https://github.com/reactos/reactos.git
synced 2025-05-20 17:45:06 +00:00
[KERNEL32/NTDLL]
- Move the ReactOS-specific workaround described in http://jira.reactos.org/browse/CORE-6611 and http://jira.reactos.org/browse/CORE-4620 from kernel32 to ntdll for using it by RtlGetVersion, in order to : * still having it available in user-mode only, * and having VerifyVersionInfo (and its Rtl counter-part) working properly. [RTL/NTOSKRNL] - Code formatting. - Use a defined-constant instead of a hard-coded value. svn path=/trunk/; revision=57662
This commit is contained in:
parent
c7054c5c36
commit
8ba1ca638e
5 changed files with 141 additions and 139 deletions
|
@ -8,13 +8,64 @@
|
||||||
* Created 01/11/98
|
* Created 01/11/98
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ****************************************************************/
|
/* INCLUDES *******************************************************************/
|
||||||
|
|
||||||
#include <ntdll.h>
|
#include <ntdll.h>
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
|
/* HACK: ReactOS specific changes, see bug-reports CORE-6611 and CORE-4620 (aka. #5003) */
|
||||||
|
static VOID NTAPI
|
||||||
|
SetRosSpecificInfo(IN OUT PRTL_OSVERSIONINFOEXW VersionInformation)
|
||||||
|
{
|
||||||
|
CHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(ULONG)];
|
||||||
|
PKEY_VALUE_PARTIAL_INFORMATION kvpInfo = (PVOID)Buffer;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
ULONG ReportAsWorkstation = 0;
|
||||||
|
HANDLE hKey;
|
||||||
|
ULONG Length;
|
||||||
|
NTSTATUS Status;
|
||||||
|
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ReactOS\\Settings\\Version");
|
||||||
|
UNICODE_STRING ValName = RTL_CONSTANT_STRING(L"ReportAsWorkstation");
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&KeyName,
|
||||||
|
OBJ_OPENIF | OBJ_CASE_INSENSITIVE,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
/* Don't change anything if the key doesn't exist */
|
||||||
|
Status = NtOpenKey(&hKey, KEY_READ, &ObjectAttributes);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
/* Get the value from the registry and make sure it's a 32-bit value */
|
||||||
|
Status = NtQueryValueKey(hKey,
|
||||||
|
&ValName,
|
||||||
|
KeyValuePartialInformation,
|
||||||
|
kvpInfo,
|
||||||
|
sizeof(Buffer),
|
||||||
|
&Length);
|
||||||
|
if (NT_SUCCESS(Status) &&
|
||||||
|
(kvpInfo->Type == REG_DWORD) &&
|
||||||
|
(kvpInfo->DataLength == sizeof(ULONG)))
|
||||||
|
{
|
||||||
|
/* Is the value set? */
|
||||||
|
ReportAsWorkstation = *(PULONG)kvpInfo->Data;
|
||||||
|
if ((VersionInformation->wProductType == VER_NT_SERVER) &&
|
||||||
|
(ReportAsWorkstation != 0))
|
||||||
|
{
|
||||||
|
/* It is, modify the product type to report a workstation */
|
||||||
|
VersionInformation->wProductType = VER_NT_WORKSTATION;
|
||||||
|
DPRINT1("We modified the reported OS from NtProductServer to NtProductWinNt\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Close the handle */
|
||||||
|
NtClose(hKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME EXPORTED
|
* NAME EXPORTED
|
||||||
|
@ -40,12 +91,11 @@
|
||||||
*
|
*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BOOLEAN NTAPI
|
BOOLEAN NTAPI
|
||||||
RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
|
RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
|
||||||
{
|
{
|
||||||
*ProductType = SharedUserData->NtProductType;
|
*ProductType = SharedUserData->NtProductType;
|
||||||
return(TRUE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
@ -71,7 +121,6 @@ RtlGetNtProductType(PNT_PRODUCT_TYPE ProductType)
|
||||||
*
|
*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
|
||||||
VOID NTAPI
|
VOID NTAPI
|
||||||
RtlGetNtVersionNumbers(OUT LPDWORD pdwMajorVersion,
|
RtlGetNtVersionNumbers(OUT LPDWORD pdwMajorVersion,
|
||||||
OUT LPDWORD pdwMinorVersion,
|
OUT LPDWORD pdwMinorVersion,
|
||||||
|
@ -102,42 +151,49 @@ RtlGetNtVersionNumbers(OUT LPDWORD pdwMajorVersion,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
|
* @note User-mode version of RtlGetVersion in ntoskrnl/rtl/misc.c
|
||||||
*/
|
*/
|
||||||
NTSTATUS NTAPI
|
NTSTATUS NTAPI
|
||||||
RtlGetVersion(RTL_OSVERSIONINFOW *Info)
|
RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
|
||||||
{
|
{
|
||||||
LONG i, MaxLength;
|
LONG i, MaxLength;
|
||||||
|
|
||||||
if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
|
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
|
||||||
Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
|
lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
|
||||||
{
|
{
|
||||||
PPEB Peb = NtCurrentPeb();
|
PPEB Peb = NtCurrentPeb();
|
||||||
|
|
||||||
Info->dwMajorVersion = Peb->OSMajorVersion;
|
lpVersionInformation->dwMajorVersion = Peb->OSMajorVersion;
|
||||||
Info->dwMinorVersion = Peb->OSMinorVersion;
|
lpVersionInformation->dwMinorVersion = Peb->OSMinorVersion;
|
||||||
Info->dwBuildNumber = Peb->OSBuildNumber;
|
lpVersionInformation->dwBuildNumber = Peb->OSBuildNumber;
|
||||||
Info->dwPlatformId = Peb->OSPlatformId;
|
lpVersionInformation->dwPlatformId = Peb->OSPlatformId;
|
||||||
RtlZeroMemory(Info->szCSDVersion, sizeof(Info->szCSDVersion));
|
RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
|
||||||
|
|
||||||
if(((Peb->OSCSDVersion >> 8) & 0xFF) != 0)
|
if(((Peb->OSCSDVersion >> 8) & 0xFF) != 0)
|
||||||
{
|
{
|
||||||
MaxLength = (sizeof(Info->szCSDVersion) / sizeof(Info->szCSDVersion[0])) - 1;
|
MaxLength = (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0])) - 1;
|
||||||
i = _snwprintf(Info->szCSDVersion,
|
i = _snwprintf(lpVersionInformation->szCSDVersion,
|
||||||
MaxLength,
|
MaxLength,
|
||||||
L"Service Pack %d",
|
L"Service Pack %d",
|
||||||
((Peb->OSCSDVersion >> 8) & 0xFF));
|
((Peb->OSCSDVersion >> 8) & 0xFF));
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
{
|
{
|
||||||
/* null-terminate if it was overflowed */
|
/* Null-terminate if it was overflowed */
|
||||||
Info->szCSDVersion[MaxLength] = L'\0';
|
lpVersionInformation->szCSDVersion[MaxLength] = L'\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Info->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
|
|
||||||
|
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
|
||||||
{
|
{
|
||||||
RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)Info;
|
PRTL_OSVERSIONINFOEXW InfoEx = (PRTL_OSVERSIONINFOEXW)lpVersionInformation;
|
||||||
InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF;
|
InfoEx->wServicePackMajor = (Peb->OSCSDVersion >> 8) & 0xFF;
|
||||||
InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF;
|
InfoEx->wServicePackMinor = Peb->OSCSDVersion & 0xFF;
|
||||||
InfoEx->wSuiteMask = SharedUserData->SuiteMask & 0xFFFF;
|
InfoEx->wSuiteMask = SharedUserData->SuiteMask & 0xFFFF;
|
||||||
InfoEx->wProductType = SharedUserData->NtProductType;
|
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_SUCCESS;
|
||||||
|
|
|
@ -14,57 +14,6 @@
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
VOID
|
|
||||||
NTAPI
|
|
||||||
SetRosSpecificInfo(IN LPOSVERSIONINFOEXW VersionInformation)
|
|
||||||
{
|
|
||||||
CHAR Buffer[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + sizeof(DWORD)];
|
|
||||||
PKEY_VALUE_PARTIAL_INFORMATION kvpInfo = (PVOID)Buffer;
|
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
DWORD ReportAsWorkstation = 0;
|
|
||||||
HANDLE hKey;
|
|
||||||
DWORD dwSize;
|
|
||||||
NTSTATUS Status;
|
|
||||||
UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ReactOS\\Settings\\Version");
|
|
||||||
UNICODE_STRING ValName = RTL_CONSTANT_STRING(L"ReportAsWorkstation");
|
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&KeyName,
|
|
||||||
OBJ_OPENIF | OBJ_CASE_INSENSITIVE,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* Don't change anything if the key doesn't exist */
|
|
||||||
Status = NtOpenKey(&hKey, KEY_READ, &ObjectAttributes);
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
/* Get the value from the registry and make sure it's a 32-bit value */
|
|
||||||
Status = NtQueryValueKey(hKey,
|
|
||||||
&ValName,
|
|
||||||
KeyValuePartialInformation,
|
|
||||||
kvpInfo,
|
|
||||||
sizeof(Buffer),
|
|
||||||
&dwSize);
|
|
||||||
if ((NT_SUCCESS(Status)) &&
|
|
||||||
(kvpInfo->Type == REG_DWORD) &&
|
|
||||||
(kvpInfo->DataLength == sizeof(DWORD)))
|
|
||||||
{
|
|
||||||
/* Is the value set? */
|
|
||||||
ReportAsWorkstation = *(PULONG)kvpInfo->Data;
|
|
||||||
if ((VersionInformation->wProductType == VER_NT_SERVER) &&
|
|
||||||
(ReportAsWorkstation))
|
|
||||||
{
|
|
||||||
/* It is, modify the product type to report a workstation */
|
|
||||||
VersionInformation->wProductType = VER_NT_WORKSTATION;
|
|
||||||
DPRINT1("We modified the reported OS from NtProductServer to NtProductWinNt\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Close the handle */
|
|
||||||
NtClose(hKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -104,9 +53,6 @@ GetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation)
|
||||||
{
|
{
|
||||||
lpVersionInformationEx = (PVOID)lpVersionInformation;
|
lpVersionInformationEx = (PVOID)lpVersionInformation;
|
||||||
lpVersionInformationEx->wReserved = 0;
|
lpVersionInformationEx->wReserved = 0;
|
||||||
|
|
||||||
/* ReactOS specific changes */
|
|
||||||
SetRosSpecificInfo(lpVersionInformationEx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* PURPOSE: Runtime code
|
* PURPOSE: Runtime code
|
||||||
* FILE: lib/rtl/version.c
|
* FILE: lib/rtl/version.c
|
||||||
* PROGRAMERS: Filip Navara
|
* PROGRAMERS: Filip Navara
|
||||||
* Hermes BELUSCA - MAITO
|
* Hermes Belusca-Maito (hermes.belusca@sfr.fr)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
@ -18,9 +18,7 @@
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlGetVersion(
|
RtlGetVersion(OUT PRTL_OSVERSIONINFOW lpVersionInformation);
|
||||||
OUT PRTL_OSVERSIONINFOW lpVersionInformation
|
|
||||||
);
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
@ -54,11 +52,9 @@ RtlpVerCompare(ULONG left, ULONG right, UCHAR condition)
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlVerifyVersionInfo(
|
RtlVerifyVersionInfo(IN PRTL_OSVERSIONINFOEXW VersionInfo,
|
||||||
IN PRTL_OSVERSIONINFOEXW VersionInfo,
|
|
||||||
IN ULONG TypeMask,
|
IN ULONG TypeMask,
|
||||||
IN ULONGLONG ConditionMask
|
IN ULONGLONG ConditionMask)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
RTL_OSVERSIONINFOEXW ver;
|
RTL_OSVERSIONINFOEXW ver;
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
|
|
|
@ -678,7 +678,7 @@ MmCreatePeb(IN PEPROCESS Process,
|
||||||
Peb->OSMajorVersion = NtMajorVersion;
|
Peb->OSMajorVersion = NtMajorVersion;
|
||||||
Peb->OSMinorVersion = NtMinorVersion;
|
Peb->OSMinorVersion = NtMinorVersion;
|
||||||
Peb->OSBuildNumber = (USHORT)(NtBuildNumber & 0x3FFF);
|
Peb->OSBuildNumber = (USHORT)(NtBuildNumber & 0x3FFF);
|
||||||
Peb->OSPlatformId = 2; /* VER_PLATFORM_WIN32_NT */
|
Peb->OSPlatformId = VER_PLATFORM_WIN32_NT;
|
||||||
Peb->OSCSDVersion = (USHORT)CmNtCSDVersion;
|
Peb->OSCSDVersion = (USHORT)CmNtCSDVersion;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -29,10 +29,9 @@ ULONG
|
||||||
NTAPI
|
NTAPI
|
||||||
RtlGetNtGlobalFlags(VOID)
|
RtlGetNtGlobalFlags(VOID)
|
||||||
{
|
{
|
||||||
return(NtGlobalFlag);
|
return NtGlobalFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -41,6 +40,7 @@ RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
|
||||||
{
|
{
|
||||||
LONG i;
|
LONG i;
|
||||||
ULONG MaxLength;
|
ULONG MaxLength;
|
||||||
|
|
||||||
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
|
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOW) ||
|
||||||
lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
|
lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,7 @@ RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
|
||||||
lpVersionInformation->dwBuildNumber = NtBuildNumber;
|
lpVersionInformation->dwBuildNumber = NtBuildNumber;
|
||||||
lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
|
lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
|
||||||
RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
|
RtlZeroMemory(lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion));
|
||||||
|
|
||||||
if(((CmNtCSDVersion >> 8) & 0xFF) != 0)
|
if(((CmNtCSDVersion >> 8) & 0xFF) != 0)
|
||||||
{
|
{
|
||||||
MaxLength = (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0])) - 1;
|
MaxLength = (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0])) - 1;
|
||||||
|
@ -58,17 +59,19 @@ RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
|
||||||
((CmNtCSDVersion >> 8) & 0xFF));
|
((CmNtCSDVersion >> 8) & 0xFF));
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
{
|
{
|
||||||
/* null-terminate if it was overflowed */
|
/* Null-terminate if it was overflowed */
|
||||||
lpVersionInformation->szCSDVersion[MaxLength] = L'\0';
|
lpVersionInformation->szCSDVersion[MaxLength] = L'\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
|
|
||||||
|
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(RTL_OSVERSIONINFOEXW))
|
||||||
{
|
{
|
||||||
RTL_OSVERSIONINFOEXW *InfoEx = (RTL_OSVERSIONINFOEXW *)lpVersionInformation;
|
PRTL_OSVERSIONINFOEXW InfoEx = (PRTL_OSVERSIONINFOEXW)lpVersionInformation;
|
||||||
InfoEx->wServicePackMajor = (USHORT)(CmNtCSDVersion >> 8) & 0xFF;
|
InfoEx->wServicePackMajor = (USHORT)(CmNtCSDVersion >> 8) & 0xFF;
|
||||||
InfoEx->wServicePackMinor = (USHORT)(CmNtCSDVersion & 0xFF);
|
InfoEx->wServicePackMinor = (USHORT)(CmNtCSDVersion & 0xFF);
|
||||||
InfoEx->wSuiteMask = (USHORT)(SharedUserData->SuiteMask & 0xFFFF);
|
InfoEx->wSuiteMask = (USHORT)(SharedUserData->SuiteMask & 0xFFFF);
|
||||||
InfoEx->wProductType = SharedUserData->NtProductType;
|
InfoEx->wProductType = SharedUserData->NtProductType;
|
||||||
|
InfoEx->wReserved = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
@ -77,3 +80,4 @@ RtlGetVersion(IN OUT PRTL_OSVERSIONINFOW lpVersionInformation)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue