Standardize code formating. No code change

svn path=/trunk/; revision=44480
This commit is contained in:
Ged Murphy 2009-12-09 13:15:47 +00:00
parent 757fd23400
commit 970b46f977

View file

@ -1,12 +1,9 @@
/* $Id$ /*
*
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
* FILE: lib/kernel32/misc/version.c * FILE: dll/win32/kernel32/misc/version.c
* PURPOSE: Version functions * PURPOSE: Version functions
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl) * PROGRAMMER: Ariadne (ariadne@xs4all.nl)
* UPDATE HISTORY:
* Created 01/11/98
*/ */
#include <k32.h> #include <k32.h>
@ -28,21 +25,21 @@ DWORD
WINAPI WINAPI
GetVersion(VOID) GetVersion(VOID)
{ {
PPEB pPeb = NtCurrentPeb(); PPEB pPeb = NtCurrentPeb();
DWORD nVersion; DWORD nVersion;
nVersion = MAKEWORD(pPeb->OSMajorVersion, pPeb->OSMinorVersion); nVersion = MAKEWORD(pPeb->OSMajorVersion, pPeb->OSMinorVersion);
/* behave consistently when posing as another operating system */ /* behave consistently when posing as another operating system */
/* build number */ /* build number */
if(pPeb->OSPlatformId != VER_PLATFORM_WIN32_WINDOWS) if(pPeb->OSPlatformId != VER_PLATFORM_WIN32_WINDOWS)
nVersion |= ((DWORD)(pPeb->OSBuildNumber)) << 16; nVersion |= ((DWORD)(pPeb->OSBuildNumber)) << 16;
/* non-NT platform flag */ /* non-NT platform flag */
if(pPeb->OSPlatformId != VER_PLATFORM_WIN32_NT) if(pPeb->OSPlatformId != VER_PLATFORM_WIN32_NT)
nVersion |= 0x80000000; nVersion |= 0x80000000;
return nVersion; return nVersion;
} }
/* /*
@ -50,126 +47,122 @@ GetVersion(VOID)
*/ */
BOOL BOOL
WINAPI WINAPI
GetVersionExW( GetVersionExW(LPOSVERSIONINFOW lpVersionInformation)
LPOSVERSIONINFOW lpVersionInformation
)
{ {
NTSTATUS Status; NTSTATUS Status;
if(lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW) &&
lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW))
{
/* for some reason win sets ERROR_INSUFFICIENT_BUFFER even if it is large
enough but doesn't match the exact sizes supported, ERROR_INVALID_PARAMETER
would've been much more appropriate... */
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
Status = RtlGetVersion((PRTL_OSVERSIONINFOW)lpVersionInformation);
if(NT_SUCCESS(Status))
{
int ln, maxlen;
/* append a reactos specific string to the szCSDVersion string */
/* FIXME - we shouldn't do this when there is a (ros-specific) compatibility
flag set so we don't screw applications that might depend on a
certain string */
ln = wcslen(lpVersionInformation->szCSDVersion) + 1;
maxlen = (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0]) - 1);
if(maxlen > ln)
{
PWCHAR szVer = lpVersionInformation->szCSDVersion + ln;
RtlZeroMemory(szVer, (maxlen - ln + 1) * sizeof(WCHAR));
wcsncpy(szVer,
L"ReactOS " UNICODIZE(KERNEL_VERSION_STR) L" (Build " UNICODIZE(KERNEL_VERSION_BUILD_STR) L")",
maxlen - ln);
}
return TRUE;
}
if(lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW) &&
lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW))
{
/* for some reason win sets ERROR_INSUFFICIENT_BUFFER even if it is large
enough but doesn't match the exact sizes supported, ERROR_INVALID_PARAMETER
would've been much more appropriate... */
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE; return FALSE;
} }
Status = RtlGetVersion((PRTL_OSVERSIONINFOW)lpVersionInformation);
if(NT_SUCCESS(Status))
{
int ln, maxlen;
/* append a reactos specific string to the szCSDVersion string */ /*
* @implemented
*/
BOOL
WINAPI
GetVersionExA(LPOSVERSIONINFOA lpVersionInformation)
{
OSVERSIONINFOEXW viw;
/* FIXME - we shouldn't do this when there is a (ros-specific) compatibility RtlZeroMemory(&viw, sizeof(viw));
flag set so we don't screw applications that might depend on a
certain string */
ln = wcslen(lpVersionInformation->szCSDVersion) + 1; switch(lpVersionInformation->dwOSVersionInfoSize)
maxlen = (sizeof(lpVersionInformation->szCSDVersion) / sizeof(lpVersionInformation->szCSDVersion[0]) - 1);
if(maxlen > ln)
{ {
PWCHAR szVer = lpVersionInformation->szCSDVersion + ln; case sizeof(OSVERSIONINFOA):
RtlZeroMemory(szVer, (maxlen - ln + 1) * sizeof(WCHAR)); viw.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
wcsncpy(szVer, break;
L"ReactOS " UNICODIZE(KERNEL_VERSION_STR) L" (Build " UNICODIZE(KERNEL_VERSION_BUILD_STR) L")",
maxlen - ln); case sizeof(OSVERSIONINFOEXA):
viw.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
break;
default:
/* for some reason win sets ERROR_INSUFFICIENT_BUFFER even if it is large
enough but doesn't match the exact sizes supported, ERROR_INVALID_PARAMETER
would've been much more appropriate... */
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
} }
return TRUE; if(GetVersionExW((LPOSVERSIONINFOW)&viw))
}
return FALSE;
}
/*
* @implemented
*/
BOOL
WINAPI
GetVersionExA(
LPOSVERSIONINFOA lpVersionInformation
)
{
OSVERSIONINFOEXW viw;
RtlZeroMemory(&viw, sizeof(viw));
switch(lpVersionInformation->dwOSVersionInfoSize)
{
case sizeof(OSVERSIONINFOA):
viw.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
break;
case sizeof(OSVERSIONINFOEXA):
viw.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
break;
default:
/* for some reason win sets ERROR_INSUFFICIENT_BUFFER even if it is large
enough but doesn't match the exact sizes supported, ERROR_INVALID_PARAMETER
would've been much more appropriate... */
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
if(GetVersionExW((LPOSVERSIONINFOW)&viw))
{
ANSI_STRING CSDVersionA;
UNICODE_STRING CSDVersionW;
/* copy back fields that match both supported structures */
lpVersionInformation->dwMajorVersion = viw.dwMajorVersion;
lpVersionInformation->dwMinorVersion = viw.dwMinorVersion;
lpVersionInformation->dwBuildNumber = viw.dwBuildNumber;
lpVersionInformation->dwPlatformId = viw.dwPlatformId;
/* convert the win version string */
RtlInitUnicodeString(&CSDVersionW, viw.szCSDVersion);
CSDVersionA.Length = 0;
CSDVersionA.MaximumLength = sizeof(lpVersionInformation->szCSDVersion);
CSDVersionA.Buffer = lpVersionInformation->szCSDVersion;
RtlUnicodeStringToAnsiString(&CSDVersionA, &CSDVersionW, FALSE);
/* convert the ReactOS version string */
CSDVersionW.Buffer = viw.szCSDVersion + CSDVersionW.Length / sizeof(WCHAR) + 1;
CSDVersionW.MaximumLength = sizeof(viw.szCSDVersion) - (CSDVersionW.Length + sizeof(WCHAR));
CSDVersionW.Length = wcslen(CSDVersionW.Buffer) * sizeof(WCHAR);
CSDVersionA.Buffer = lpVersionInformation->szCSDVersion + CSDVersionA.Length + 1;
CSDVersionA.MaximumLength = sizeof(lpVersionInformation->szCSDVersion) - (CSDVersionA.Length + 1);
CSDVersionA.Length = 0;
RtlUnicodeStringToAnsiString(&CSDVersionA, &CSDVersionW, FALSE);
/* copy back the extended fields */
if(viw.dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
{ {
((LPOSVERSIONINFOEXA)lpVersionInformation)->wServicePackMajor = viw.wServicePackMajor; ANSI_STRING CSDVersionA;
((LPOSVERSIONINFOEXA)lpVersionInformation)->wServicePackMinor = viw.wServicePackMinor; UNICODE_STRING CSDVersionW;
((LPOSVERSIONINFOEXA)lpVersionInformation)->wSuiteMask = viw.wSuiteMask;
((LPOSVERSIONINFOEXA)lpVersionInformation)->wProductType = viw.wProductType; /* copy back fields that match both supported structures */
((LPOSVERSIONINFOEXA)lpVersionInformation)->wReserved = viw.wReserved; lpVersionInformation->dwMajorVersion = viw.dwMajorVersion;
lpVersionInformation->dwMinorVersion = viw.dwMinorVersion;
lpVersionInformation->dwBuildNumber = viw.dwBuildNumber;
lpVersionInformation->dwPlatformId = viw.dwPlatformId;
/* convert the win version string */
RtlInitUnicodeString(&CSDVersionW, viw.szCSDVersion);
CSDVersionA.Length = 0;
CSDVersionA.MaximumLength = sizeof(lpVersionInformation->szCSDVersion);
CSDVersionA.Buffer = lpVersionInformation->szCSDVersion;
RtlUnicodeStringToAnsiString(&CSDVersionA, &CSDVersionW, FALSE);
/* convert the ReactOS version string */
CSDVersionW.Buffer = viw.szCSDVersion + CSDVersionW.Length / sizeof(WCHAR) + 1;
CSDVersionW.MaximumLength = sizeof(viw.szCSDVersion) - (CSDVersionW.Length + sizeof(WCHAR));
CSDVersionW.Length = wcslen(CSDVersionW.Buffer) * sizeof(WCHAR);
CSDVersionA.Buffer = lpVersionInformation->szCSDVersion + CSDVersionA.Length + 1;
CSDVersionA.MaximumLength = sizeof(lpVersionInformation->szCSDVersion) - (CSDVersionA.Length + 1);
CSDVersionA.Length = 0;
RtlUnicodeStringToAnsiString(&CSDVersionA, &CSDVersionW, FALSE);
/* copy back the extended fields */
if(viw.dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW))
{
((LPOSVERSIONINFOEXA)lpVersionInformation)->wServicePackMajor = viw.wServicePackMajor;
((LPOSVERSIONINFOEXA)lpVersionInformation)->wServicePackMinor = viw.wServicePackMinor;
((LPOSVERSIONINFOEXA)lpVersionInformation)->wSuiteMask = viw.wSuiteMask;
((LPOSVERSIONINFOEXA)lpVersionInformation)->wProductType = viw.wProductType;
((LPOSVERSIONINFOEXA)lpVersionInformation)->wReserved = viw.wReserved;
}
return TRUE;
} }
return TRUE; return FALSE;
}
return FALSE;
} }
@ -178,32 +171,30 @@ GetVersionExA(
*/ */
BOOL BOOL
WINAPI WINAPI
VerifyVersionInfoW( VerifyVersionInfoW(LPOSVERSIONINFOEXW lpVersionInformation,
LPOSVERSIONINFOEXW lpVersionInformation, DWORD dwTypeMask,
DWORD dwTypeMask, DWORDLONG dwlConditionMask)
DWORDLONG dwlConditionMask
)
{ {
NTSTATUS Status; NTSTATUS Status;
Status = RtlVerifyVersionInfo((PRTL_OSVERSIONINFOEXW)lpVersionInformation, Status = RtlVerifyVersionInfo((PRTL_OSVERSIONINFOEXW)lpVersionInformation,
dwTypeMask, dwTypeMask,
dwlConditionMask); dwlConditionMask);
switch(Status) switch(Status)
{ {
case STATUS_INVALID_PARAMETER: case STATUS_INVALID_PARAMETER:
SetLastError(ERROR_BAD_ARGUMENTS); SetLastError(ERROR_BAD_ARGUMENTS);
return FALSE; return FALSE;
case STATUS_REVISION_MISMATCH: case STATUS_REVISION_MISMATCH:
SetLastError(ERROR_OLD_WIN_VERSION); SetLastError(ERROR_OLD_WIN_VERSION);
return FALSE; return FALSE;
default: default:
/* RtlVerifyVersionInfo shouldn't report any other failure code! */ /* RtlVerifyVersionInfo shouldn't report any other failure code! */
ASSERT(NT_SUCCESS(Status)); ASSERT(NT_SUCCESS(Status));
return TRUE; return TRUE;
} }
} }
@ -212,27 +203,23 @@ VerifyVersionInfoW(
*/ */
BOOL BOOL
WINAPI WINAPI
VerifyVersionInfoA( VerifyVersionInfoA(LPOSVERSIONINFOEXA lpVersionInformation,
LPOSVERSIONINFOEXA lpVersionInformation, DWORD dwTypeMask,
DWORD dwTypeMask, DWORDLONG dwlConditionMask)
DWORDLONG dwlConditionMask
)
{ {
OSVERSIONINFOEXW viex; OSVERSIONINFOEXW viex;
viex.dwOSVersionInfoSize = sizeof(viex); viex.dwOSVersionInfoSize = sizeof(viex);
viex.dwMajorVersion = lpVersionInformation->dwMajorVersion; viex.dwMajorVersion = lpVersionInformation->dwMajorVersion;
viex.dwMinorVersion = lpVersionInformation->dwMinorVersion; viex.dwMinorVersion = lpVersionInformation->dwMinorVersion;
viex.dwBuildNumber = lpVersionInformation->dwBuildNumber; viex.dwBuildNumber = lpVersionInformation->dwBuildNumber;
viex.dwPlatformId = lpVersionInformation->dwPlatformId; viex.dwPlatformId = lpVersionInformation->dwPlatformId;
/* NOTE: szCSDVersion is ignored, we don't need to convert it to unicode */ /* NOTE: szCSDVersion is ignored, we don't need to convert it to unicode */
viex.wServicePackMajor = lpVersionInformation->wServicePackMajor; viex.wServicePackMajor = lpVersionInformation->wServicePackMajor;
viex.wServicePackMinor = lpVersionInformation->wServicePackMinor; viex.wServicePackMinor = lpVersionInformation->wServicePackMinor;
viex.wSuiteMask = lpVersionInformation->wSuiteMask; viex.wSuiteMask = lpVersionInformation->wSuiteMask;
viex.wProductType = lpVersionInformation->wProductType; viex.wProductType = lpVersionInformation->wProductType;
viex.wReserved = lpVersionInformation->wReserved; viex.wReserved = lpVersionInformation->wReserved;
return VerifyVersionInfoW(&viex, dwTypeMask, dwlConditionMask); return VerifyVersionInfoW(&viex, dwTypeMask, dwlConditionMask);
} }
/* EOF */