kernel32: Implement GetEnabledXStateFeatures().

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2020-08-20 00:23:00 +03:00 committed by Alexandre Julliard
parent 97b5ad7597
commit a4af2b2b70
11 changed files with 61 additions and 19 deletions

View File

@ -1,5 +1,5 @@
@ stub RtlCopyExtendedContext
@ stub RtlGetEnabledExtendedFeatures
@ stdcall RtlGetEnabledExtendedFeatures(int64) ntdll.RtlGetEnabledExtendedFeatures
@ stub RtlGetExtendedContextLength
@ stub RtlGetExtendedFeaturesMask
@ stub RtlInitializeExtendedContext

View File

@ -659,7 +659,7 @@
# @ stub GetDurationFormatEx
@ stdcall -import GetDynamicTimeZoneInformation(ptr)
@ stdcall -import GetDynamicTimeZoneInformationEffectiveYears(ptr ptr ptr)
@ stdcall -ret64 -arch=i386,x86_64 GetEnabledXStateFeatures()
@ stdcall -import -ret64 -arch=i386,x86_64 GetEnabledXStateFeatures()
@ stdcall -import GetEnvironmentStrings()
@ stdcall -import GetEnvironmentStringsA()
@ stdcall -import GetEnvironmentStringsW()

View File

@ -741,15 +741,6 @@ DWORD WINAPI GetMaximumProcessorCount(WORD group)
return cpus;
}
/***********************************************************************
* GetEnabledXStateFeatures (KERNEL32.@)
*/
DWORD64 WINAPI GetEnabledXStateFeatures(void)
{
FIXME("\n");
return 0;
}
/***********************************************************************
* GetFirmwareEnvironmentVariableA (KERNEL32.@)
*/

View File

@ -493,7 +493,7 @@
# @ stub GetEffectivePackageStatusForUser
# @ stub GetEightBitStringToUnicodeSizeRoutine
# @ stub GetEightBitStringToUnicodeStringRoutine
@ stdcall -ret64 -arch=i386,x86_64 GetEnabledXStateFeatures() kernel32.GetEnabledXStateFeatures
@ stdcall -ret64 -arch=i386,x86_64 GetEnabledXStateFeatures()
@ stdcall GetEnvironmentStrings() GetEnvironmentStringsA
@ stdcall GetEnvironmentStringsA()
@ stdcall GetEnvironmentStringsW()

View File

@ -33,6 +33,7 @@
#include "winnls.h"
#include "winternl.h"
#include "winerror.h"
#include "ddk/wdm.h"
#include "kernelbase.h"
#include "wine/exception.h"
@ -1169,6 +1170,23 @@ LPVOID WINAPI DECLSPEC_HOTPATCH VirtualAllocExNuma( HANDLE process, void *addr,
}
/***********************************************************************
* CPU functions
***********************************************************************/
#if defined(__i386__) || defined(__x86_64__)
/***********************************************************************
* GetEnabledXStateFeatures (kernelbase.@)
*/
DWORD64 WINAPI GetEnabledXStateFeatures(void)
{
TRACE( "\n" );
return RtlGetEnabledExtendedFeatures( ~(ULONG64)0 );
}
#endif
/***********************************************************************
* Firmware functions
***********************************************************************/

View File

@ -30,6 +30,7 @@
#define WIN32_NO_STATUS
#include "windef.h"
#include "winternl.h"
#include "ddk/wdm.h"
#include "wine/exception.h"
#include "wine/server.h"
#include "wine/list.h"
@ -655,3 +656,12 @@ BOOL WINAPI IsBadStringPtrW( LPCWSTR str, UINT_PTR max )
__ENDTRY
return FALSE;
}
/**********************************************************************
* RtlGetEnabledExtendedFeatures (NTDLL.@)
*/
ULONG64 WINAPI RtlGetEnabledExtendedFeatures(ULONG64 feature_mask)
{
return user_shared_data->XState.EnabledFeatures & feature_mask;
}

View File

@ -693,6 +693,7 @@
@ stdcall RtlGetDaclSecurityDescriptor(ptr ptr ptr ptr)
@ stub RtlGetElementGenericTable
# @ stub RtlGetElementGenericTableAvl
@ stdcall RtlGetEnabledExtendedFeatures(int64)
@ stdcall RtlGetExePath(wstr ptr)
# @ stub RtlGetFirstRange
@ stdcall RtlGetFrame()

View File

@ -29,7 +29,9 @@
static unsigned int page_size;
static DWORD64 (WINAPI *pGetEnabledXStateFeatures)(void);
static NTSTATUS (WINAPI *pRtlCreateUserStack)(SIZE_T, SIZE_T, ULONG, SIZE_T, SIZE_T, INITIAL_TEB *);
static ULONG64 (WINAPI *pRtlGetEnabledExtendedFeatures)(ULONG64);
static NTSTATUS (WINAPI *pRtlFreeUserStack)(void *);
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
static const BOOL is_win64 = sizeof(void*) != sizeof(int);
@ -543,6 +545,7 @@ static void test_user_shared_data(void)
};
const KSHARED_USER_DATA *user_shared_data = (void *)0x7ffe0000;
XSTATE_CONFIGURATION xstate = user_shared_data->XState;
ULONG64 feature_mask;
unsigned int i;
ok(user_shared_data->NumberOfPhysicalPages == sbi.MmNumberOfPhysicalPages,
@ -560,17 +563,24 @@ static void test_user_shared_data(void)
|| broken(!user_shared_data->ActiveGroupCount) /* before Win7 */,
"Got unexpected ActiveGroupCount %u.\n", user_shared_data->ActiveGroupCount);
if (!pRtlGetEnabledExtendedFeatures)
{
skip("RtlGetEnabledExtendedFeatures is not available.\n");
return;
}
feature_mask = pRtlGetEnabledExtendedFeatures(~(ULONG64)0);
if (!feature_mask)
{
skip("XState features are not available.\n");
return;
}
if (!xstate.EnabledFeatures)
{
struct old_xstate_configuration *xs_old
= (struct old_xstate_configuration *)((char *)user_shared_data + 0x3e0);
if (!xs_old->EnabledFeatures)
{
skip("XState features are not supported.\n");
return;
}
memset(&xstate, 0, sizeof(xstate));
xstate.EnabledFeatures = xstate.EnabledVolatileFeatures = xs_old->EnabledFeatures;
memcpy(&xstate.Size, &xs_old->Size, sizeof(*xs_old) - offsetof(struct old_xstate_configuration, Size));
@ -580,6 +590,14 @@ static void test_user_shared_data(void)
}
trace("XState EnabledFeatures %s.\n", wine_dbgstr_longlong(xstate.EnabledFeatures));
feature_mask = pRtlGetEnabledExtendedFeatures(0);
ok(!feature_mask, "Got unexpected feature_mask %s.\n", wine_dbgstr_longlong(feature_mask));
feature_mask = pRtlGetEnabledExtendedFeatures(~(ULONG64)0);
ok(feature_mask == xstate.EnabledFeatures, "Got unexpected feature_mask %s.\n",
wine_dbgstr_longlong(feature_mask));
feature_mask = pGetEnabledXStateFeatures();
ok(feature_mask == xstate.EnabledFeatures, "Got unexpected feature_mask %s.\n",
wine_dbgstr_longlong(feature_mask));
ok((xstate.EnabledFeatures & SUPPORTED_XSTATE_FEATURES) == SUPPORTED_XSTATE_FEATURES,
"Got unexpected EnabledFeatures %s.\n", wine_dbgstr_longlong(xstate.EnabledFeatures));
ok((xstate.EnabledVolatileFeatures & SUPPORTED_XSTATE_FEATURES) == xstate.EnabledFeatures,
@ -623,10 +641,11 @@ START_TEST(virtual)
mod = GetModuleHandleA("kernel32.dll");
pIsWow64Process = (void *)GetProcAddress(mod, "IsWow64Process");
pGetEnabledXStateFeatures = (void *)GetProcAddress(mod, "GetEnabledXStateFeatures");
mod = GetModuleHandleA("ntdll.dll");
pRtlCreateUserStack = (void *)GetProcAddress(mod, "RtlCreateUserStack");
pRtlFreeUserStack = (void *)GetProcAddress(mod, "RtlFreeUserStack");
pRtlGetEnabledExtendedFeatures = (void *)GetProcAddress(mod, "RtlGetEnabledExtendedFeatures");
NtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), NULL);
trace("system page size %#x\n", sbi.PageSize);

View File

@ -1105,6 +1105,7 @@
@ stdcall RtlGetProductInfo(long long long long ptr)
@ stdcall RtlGetSaclSecurityDescriptor(ptr ptr ptr ptr)
@ stub RtlGetSetBootStatusData
@ stdcall RtlGetEnabledExtendedFeatures(int64)
@ stdcall RtlGetVersion(ptr)
@ stdcall RtlHashUnicodeString(ptr long long ptr)
@ stdcall RtlIdnToAscii(long wstr long ptr ptr)

View File

@ -1841,6 +1841,7 @@ void WINAPI RtlCopyMemoryNonTemporal(void*,const void*,SIZE_T);
#else
#define RtlCopyMemoryNonTemporal RtlCopyMemory
#endif
ULONG64 WINAPI RtlGetEnabledExtendedFeatures(ULONG64);
BOOLEAN WINAPI RtlIsNtDdiVersionAvailable(ULONG);
NTSTATUS WINAPI ZwAddBootEntry(PUNICODE_STRING,PUNICODE_STRING);

View File

@ -2136,6 +2136,7 @@ WINBASEAPI DWORD WINAPI GetDllDirectoryW(DWORD,LPWSTR);
WINBASEAPI UINT WINAPI GetDriveTypeA(LPCSTR);
WINBASEAPI UINT WINAPI GetDriveTypeW(LPCWSTR);
#define GetDriveType WINELIB_NAME_AW(GetDriveType)
WINBASEAPI DWORD64 WINAPI GetEnabledXStateFeatures(void);
WINBASEAPI LPSTR WINAPI GetEnvironmentStringsA(void);
WINBASEAPI LPWSTR WINAPI GetEnvironmentStringsW(void);
#define GetEnvironmentStrings WINELIB_NAME_AW(GetEnvironmentStrings)