kernel32: Move OS version functions to kernelbase.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2019-09-08 21:28:18 +02:00
parent d38a5ba4e6
commit 471c2f565c
4 changed files with 72 additions and 83 deletions

View File

@ -875,9 +875,9 @@
@ stdcall GetUserDefaultUILanguage()
@ stdcall GetUserGeoID(long)
@ stub GetVDMCurrentDirectories
@ stdcall GetVersion()
@ stdcall GetVersionExA(ptr)
@ stdcall GetVersionExW(ptr)
@ stdcall -import GetVersion()
@ stdcall -import GetVersionExA(ptr)
@ stdcall -import GetVersionExW(ptr)
@ stdcall GetVolumeInformationA(str ptr long ptr ptr ptr ptr long)
@ stdcall GetVolumeInformationByHandleW(ptr ptr long ptr ptr ptr ptr long)
@ stdcall GetVolumeInformationW(wstr ptr long ptr ptr ptr ptr long)

View File

@ -42,83 +42,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(ver);
/***********************************************************************
* GetVersion (KERNEL32.@)
*
* Win31 0x80000a03
* Win95 0xc0000004
* Win98 0xc0000a04
* WinME 0xc0005a04
* NT351 0x04213303
* NT4 0x05650004
* Win2000 0x08930005
* WinXP 0x0a280105
*/
DWORD WINAPI GetVersion(void)
{
DWORD result = MAKELONG( MAKEWORD( NtCurrentTeb()->Peb->OSMajorVersion,
NtCurrentTeb()->Peb->OSMinorVersion ),
(NtCurrentTeb()->Peb->OSPlatformId ^ 2) << 14 );
if (NtCurrentTeb()->Peb->OSPlatformId == VER_PLATFORM_WIN32_NT)
result |= LOWORD(NtCurrentTeb()->Peb->OSBuildNumber) << 16;
return result;
}
/***********************************************************************
* GetVersionExA (KERNEL32.@)
*/
BOOL WINAPI GetVersionExA(OSVERSIONINFOA *v)
{
RTL_OSVERSIONINFOEXW infoW;
if (v->dwOSVersionInfoSize != sizeof(OSVERSIONINFOA) &&
v->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXA))
{
WARN("wrong OSVERSIONINFO size from app (got: %d)\n",
v->dwOSVersionInfoSize );
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
infoW.dwOSVersionInfoSize = sizeof(infoW);
if (RtlGetVersion( &infoW ) != STATUS_SUCCESS) return FALSE;
v->dwMajorVersion = infoW.dwMajorVersion;
v->dwMinorVersion = infoW.dwMinorVersion;
v->dwBuildNumber = infoW.dwBuildNumber;
v->dwPlatformId = infoW.dwPlatformId;
WideCharToMultiByte( CP_ACP, 0, infoW.szCSDVersion, -1,
v->szCSDVersion, sizeof(v->szCSDVersion), NULL, NULL );
if(v->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA))
{
LPOSVERSIONINFOEXA vex = (LPOSVERSIONINFOEXA) v;
vex->wServicePackMajor = infoW.wServicePackMajor;
vex->wServicePackMinor = infoW.wServicePackMinor;
vex->wSuiteMask = infoW.wSuiteMask;
vex->wProductType = infoW.wProductType;
}
return TRUE;
}
/***********************************************************************
* GetVersionExW (KERNEL32.@)
*/
BOOL WINAPI GetVersionExW( OSVERSIONINFOW *info )
{
if (info->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW) &&
info->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW))
{
WARN("wrong OSVERSIONINFO size from app (got: %d)\n",
info->dwOSVersionInfoSize);
return FALSE;
}
return (RtlGetVersion( (RTL_OSVERSIONINFOEXW *)info ) == STATUS_SUCCESS);
}
/******************************************************************************
* VerifyVersionInfoA (KERNEL32.@)
*/

View File

@ -750,9 +750,9 @@
# @ stub GetUserOverrideString
# @ stub GetUserOverrideWord
@ stdcall GetUserPreferredUILanguages(long ptr ptr ptr) kernel32.GetUserPreferredUILanguages
@ stdcall GetVersion() kernel32.GetVersion
@ stdcall GetVersionExA(ptr) kernel32.GetVersionExA
@ stdcall GetVersionExW(ptr) kernel32.GetVersionExW
@ stdcall GetVersion()
@ stdcall GetVersionExA(ptr)
@ stdcall GetVersionExW(ptr)
@ stdcall GetVolumeInformationA(str ptr long ptr ptr ptr ptr long) kernel32.GetVolumeInformationA
@ stdcall GetVolumeInformationByHandleW(ptr ptr long ptr ptr ptr ptr long) kernel32.GetVolumeInformationByHandleW
@ stdcall GetVolumeInformationW(wstr ptr long ptr ptr ptr ptr long) kernel32.GetVolumeInformationW

View File

@ -1337,3 +1337,69 @@ DWORD WINAPI VerFindFileW( DWORD flags, LPCWSTR filename, LPCWSTR win_dir, LPCWS
debugstr_w(cur_dir), debugstr_w(dest));
return retval;
}
/***********************************************************************
* GetVersion (kernelbase.@)
*/
DWORD WINAPI GetVersion(void)
{
DWORD result = MAKELONG( MAKEWORD( NtCurrentTeb()->Peb->OSMajorVersion,
NtCurrentTeb()->Peb->OSMinorVersion ),
(NtCurrentTeb()->Peb->OSPlatformId ^ 2) << 14 );
if (NtCurrentTeb()->Peb->OSPlatformId == VER_PLATFORM_WIN32_NT)
result |= LOWORD(NtCurrentTeb()->Peb->OSBuildNumber) << 16;
return result;
}
/***********************************************************************
* GetVersionExA (kernelbase.@)
*/
BOOL WINAPI GetVersionExA( OSVERSIONINFOA *info )
{
RTL_OSVERSIONINFOEXW infoW;
if (info->dwOSVersionInfoSize != sizeof(OSVERSIONINFOA) &&
info->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXA))
{
WARN( "wrong OSVERSIONINFO size from app (got: %d)\n", info->dwOSVersionInfoSize );
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return FALSE;
}
infoW.dwOSVersionInfoSize = sizeof(infoW);
if (!set_ntstatus( RtlGetVersion( &infoW ))) return FALSE;
info->dwMajorVersion = infoW.dwMajorVersion;
info->dwMinorVersion = infoW.dwMinorVersion;
info->dwBuildNumber = infoW.dwBuildNumber;
info->dwPlatformId = infoW.dwPlatformId;
WideCharToMultiByte( CP_ACP, 0, infoW.szCSDVersion, -1,
info->szCSDVersion, sizeof(info->szCSDVersion), NULL, NULL );
if (info->dwOSVersionInfoSize == sizeof(OSVERSIONINFOEXA))
{
OSVERSIONINFOEXA *vex = (OSVERSIONINFOEXA *)info;
vex->wServicePackMajor = infoW.wServicePackMajor;
vex->wServicePackMinor = infoW.wServicePackMinor;
vex->wSuiteMask = infoW.wSuiteMask;
vex->wProductType = infoW.wProductType;
}
return TRUE;
}
/***********************************************************************
* GetVersionExW (kernelbase.@)
*/
BOOL WINAPI GetVersionExW( OSVERSIONINFOW *info )
{
if (info->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW) &&
info->dwOSVersionInfoSize != sizeof(OSVERSIONINFOEXW))
{
WARN( "wrong OSVERSIONINFO size from app (got: %d)\n", info->dwOSVersionInfoSize );
return FALSE;
}
return set_ntstatus( RtlGetVersion( (RTL_OSVERSIONINFOEXW *)info ));
}