Signed-off-by: Paul Gofman pgofman@codeweavers.com --- dlls/kernel32/process.c | 6 ++++-- dlls/ntdll/exception.c | 10 +++++++++ dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/tests/virtual.c | 33 +++++++++++++++++++++++------ dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 1 + include/ddk/wdm.h | 2 ++ include/winbase.h | 1 + 7 files changed, 45 insertions(+), 9 deletions(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index b2bd5980fd9..4f27fc3298b 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -741,13 +741,15 @@ DWORD WINAPI GetMaximumProcessorCount(WORD group) return cpus; }
+ULONG64 WINAPI RtlGetEnabledExtendedFeatures(ULONG64 feature_mask); + /*********************************************************************** * GetEnabledXStateFeatures (KERNEL32.@) */ DWORD64 WINAPI GetEnabledXStateFeatures(void) { - FIXME("\n"); - return 0; + TRACE(".\n"); + return RtlGetEnabledExtendedFeatures(~(ULONG64)0); }
/*********************************************************************** diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c index f8aca6dfb7f..3f7443bb45b 100644 --- a/dlls/ntdll/exception.c +++ b/dlls/ntdll/exception.c @@ -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; +} diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index 2a95dddf202..9981c57bd7d 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -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() diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c index 4a0a4a6b8e5..47eb784cbbc 100644 --- a/dlls/ntdll/tests/virtual.c +++ b/dlls/ntdll/tests/virtual.c @@ -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); diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index 4d39f8eea2f..0e8082fad26 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -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) diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h index b8bb7bd971f..23bee1ba9ee 100644 --- a/include/ddk/wdm.h +++ b/include/ddk/wdm.h @@ -1843,6 +1843,8 @@ void WINAPI RtlCopyMemoryNonTemporal(void*,const void*,SIZE_T); #endif BOOLEAN WINAPI RtlIsNtDdiVersionAvailable(ULONG);
+ULONG64 WINAPI RtlGetEnabledExtendedFeatures(ULONG64 feature_mask); + NTSTATUS WINAPI ZwAddBootEntry(PUNICODE_STRING,PUNICODE_STRING); NTSTATUS WINAPI ZwAccessCheckAndAuditAlarm(PUNICODE_STRING,HANDLE,PUNICODE_STRING,PUNICODE_STRING,PSECURITY_DESCRIPTOR,ACCESS_MASK,PGENERIC_MAPPING,BOOLEAN,PACCESS_MASK,PBOOLEAN,PBOOLEAN); NTSTATUS WINAPI ZwAdjustPrivilegesToken(HANDLE,BOOLEAN,PTOKEN_PRIVILEGES,DWORD,PTOKEN_PRIVILEGES,PDWORD); diff --git a/include/winbase.h b/include/winbase.h index 319423b572f..f2177ada1e4 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -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)