Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries * FILE: dll/win32/kernel32/client/version.c * PURPOSE: Version functions * PROGRAMMER: Ariadne (ariadne@xs4all.nl) Ged Murphy (gedmurphy@reactos.org) */
#include <k32.h>
#define NDEBUG#include <debug.h>
/* FUNCTIONS ******************************************************************/
/* * @implemented */DWORDWINAPIGetVersion(VOID){ PPEB Peb = NtCurrentPeb();
return (DWORD)( ((Peb->OSPlatformId ^ 2) << 30) | (Peb->OSBuildNumber << 16) | (Peb->OSMinorVersion << 8 ) | Peb->OSMajorVersion );}
/* * @implemented */BOOLWINAPIGetVersionExW(IN LPOSVERSIONINFOW lpVersionInformation){ NTSTATUS Status; LPOSVERSIONINFOEXW lpVersionInformationEx;
if ((lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW)) && (lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW))) { SetLastError(ERROR_INSUFFICIENT_BUFFER); return FALSE; }
Status = RtlGetVersion((PRTL_OSVERSIONINFOW)lpVersionInformation); if (Status == STATUS_SUCCESS) { if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXW)) { lpVersionInformationEx = (PVOID)lpVersionInformation; lpVersionInformationEx->wReserved = 0; }
return TRUE; }
return FALSE;}
/* * @implemented */BOOLWINAPIGetVersionExA(IN LPOSVERSIONINFOA lpVersionInformation){ OSVERSIONINFOEXW VersionInformation; LPOSVERSIONINFOEXA lpVersionInformationEx; UNICODE_STRING CsdVersionW; NTSTATUS Status; ANSI_STRING CsdVersionA;
if ((lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOA)) && (lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXA))) { SetLastError(ERROR_INSUFFICIENT_BUFFER); return FALSE; }
VersionInformation.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
if (!GetVersionExW((LPOSVERSIONINFOW)&VersionInformation)) return FALSE;
/* Copy back fields that match both supported structures */ lpVersionInformation->dwMajorVersion = VersionInformation.dwMajorVersion; lpVersionInformation->dwMinorVersion = VersionInformation.dwMinorVersion; lpVersionInformation->dwBuildNumber = VersionInformation.dwBuildNumber; lpVersionInformation->dwPlatformId = VersionInformation.dwPlatformId;
if (lpVersionInformation->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA)) { lpVersionInformationEx = (PVOID)lpVersionInformation; lpVersionInformationEx->wServicePackMajor = VersionInformation.wServicePackMajor; lpVersionInformationEx->wServicePackMinor = VersionInformation.wServicePackMinor; lpVersionInformationEx->wSuiteMask = VersionInformation.wSuiteMask; lpVersionInformationEx->wProductType = VersionInformation.wProductType; lpVersionInformationEx->wReserved = VersionInformation.wReserved; }
/* Convert the CSD string */ RtlInitEmptyAnsiString(&CsdVersionA, lpVersionInformation->szCSDVersion, sizeof(lpVersionInformation->szCSDVersion)); RtlInitUnicodeString(&CsdVersionW, VersionInformation.szCSDVersion); Status = RtlUnicodeStringToAnsiString(&CsdVersionA, &CsdVersionW, FALSE); return (NT_SUCCESS(Status));}
/* * @implemented */BOOLWINAPIVerifyVersionInfoW(IN LPOSVERSIONINFOEXW lpVersionInformation, IN DWORD dwTypeMask, IN DWORDLONG dwlConditionMask){ NTSTATUS Status;
Status = RtlVerifyVersionInfo((PRTL_OSVERSIONINFOEXW)lpVersionInformation, dwTypeMask, dwlConditionMask); switch (Status) { case STATUS_INVALID_PARAMETER: SetLastError(ERROR_BAD_ARGUMENTS); return FALSE;
case STATUS_REVISION_MISMATCH: if (lpVersionInformation) { DPRINT1("VerifyVersionInfo -- Version mismatch(%d.%d.%d:%d)\n", (dwTypeMask & VER_MAJORVERSION) ? lpVersionInformation->dwMajorVersion : -1, (dwTypeMask & VER_MINORVERSION) ? lpVersionInformation->dwMinorVersion : -1, (dwTypeMask & VER_BUILDNUMBER) ? lpVersionInformation->dwBuildNumber : -1, (dwTypeMask & VER_PLATFORMID) ? lpVersionInformation->dwPlatformId : -1); } else { DPRINT1("VerifyVersionInfo -- Version mismatch(NULL)\n"); } SetLastError(ERROR_OLD_WIN_VERSION); return FALSE;
default: /* RtlVerifyVersionInfo shouldn't report any other failure code! */ ASSERT(NT_SUCCESS(Status)); return TRUE; }}