Commit ff88ed8b authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

kernel32: Implement LocateXStateFeature().

parent 2d544ff8
......@@ -3,6 +3,6 @@
@ stdcall RtlGetExtendedContextLength(long ptr) ntdll.RtlGetExtendedContextLength
@ stub RtlGetExtendedFeaturesMask
@ stdcall RtlInitializeExtendedContext(ptr long ptr) ntdll.RtlInitializeExtendedContext
@ stub RtlLocateExtendedFeature
@ stdcall RtlLocateExtendedFeature(ptr long ptr) ntdll.RtlLocateExtendedFeature
@ stub RtlLocateLegacyContext
@ stub RtlSetExtendedFeaturesMask
......@@ -2,5 +2,5 @@
@ stdcall -ret64 -arch=i386,x86_64 GetEnabledXStateFeatures() kernel32.GetEnabledXStateFeatures
@ stub GetXStateFeaturesMask
@ stdcall -arch=i386,x86_64 InitializeContext(ptr long ptr ptr) kernel32.InitializeContext
@ stub LocateXStateFeature
@ stdcall -arch=i386,x86_64 LocateXStateFeature(ptr long ptr) kernel32.LocateXStateFeature
@ stub SetXStateFeaturesMask
......@@ -1071,7 +1071,7 @@
@ stdcall LocalSize(long)
@ stdcall -import LocalUnlock(long)
@ stdcall -import LocaleNameToLCID(wstr long)
# @ stub LocateXStateFeature
@ stdcall -import -arch=i386,x86_64 LocateXStateFeature(ptr long ptr)
@ stdcall -import LockFile(long long long long long)
@ stdcall -import LockFileEx(long long long long long ptr)
@ stdcall -import LockResource(long)
......
......@@ -942,7 +942,7 @@
@ stdcall LocalReAlloc(long long long)
@ stdcall LocalUnlock(long)
@ stdcall LocaleNameToLCID(wstr long)
# @ stub LocateXStateFeature
@ stdcall -arch=i386,x86_64 LocateXStateFeature(ptr long ptr)
@ stdcall LockFile(long long long long long)
@ stdcall LockFileEx(long long long long long ptr)
@ stdcall LockResource(long)
......
......@@ -1237,6 +1237,57 @@ BOOL WINAPI InitializeContext( void *buffer, DWORD context_flags, CONTEXT **cont
/***********************************************************************
* LocateXStateFeature (kernelbase.@)
*/
#if defined(__x86_64__)
void * WINAPI LocateXStateFeature( CONTEXT *context, DWORD feature_id, DWORD *length )
{
if (!(context->ContextFlags & CONTEXT_AMD64))
return NULL;
if (feature_id >= 2)
return ((context->ContextFlags & CONTEXT_XSTATE) == CONTEXT_XSTATE)
? RtlLocateExtendedFeature( (CONTEXT_EX *)(context + 1), feature_id, length ) : NULL;
if (feature_id == 1)
{
if (length)
*length = sizeof(M128A) * 16;
return &context->u.FltSave.XmmRegisters;
}
if (length)
*length = offsetof(XSAVE_FORMAT, XmmRegisters);
return &context->u.FltSave;
}
#elif defined(__i386__)
void * WINAPI LocateXStateFeature( CONTEXT *context, DWORD feature_id, DWORD *length )
{
if (!(context->ContextFlags & CONTEXT_X86))
return NULL;
if (feature_id >= 2)
return ((context->ContextFlags & CONTEXT_XSTATE) == CONTEXT_XSTATE)
? RtlLocateExtendedFeature( (CONTEXT_EX *)(context + 1), feature_id, length ) : NULL;
if (feature_id == 1)
{
if (length)
*length = sizeof(M128A) * 8;
return (BYTE *)&context->ExtendedRegisters + offsetof(XSAVE_FORMAT, XmmRegisters);
}
if (length)
*length = offsetof(XSAVE_FORMAT, XmmRegisters);
return &context->ExtendedRegisters;
}
#endif
/***********************************************************************
* Firmware functions
***********************************************************************/
......
......@@ -806,3 +806,47 @@ NTSTATUS WINAPI RtlInitializeExtendedContext( void *context, ULONG context_flags
{
return RtlInitializeExtendedContext2( context, context_flags, context_ex, ~(ULONG64)0 );
}
/**********************************************************************
* RtlLocateExtendedFeature2 (NTDLL.@)
*/
void * WINAPI RtlLocateExtendedFeature2( CONTEXT_EX *context_ex, ULONG feature_id,
XSTATE_CONFIGURATION *xstate_config, ULONG *length )
{
TRACE( "context_ex %p, feature_id %u, xstate_config %p, length %p.\n",
context_ex, feature_id, xstate_config, length );
if (!xstate_config)
{
FIXME( "NULL xstate_config.\n" );
return NULL;
}
if (xstate_config != &user_shared_data->XState)
{
FIXME( "Custom xstate configuration is not supported.\n" );
return NULL;
}
if (feature_id != XSTATE_AVX)
return NULL;
if (length)
*length = sizeof(YMMCONTEXT);
if (context_ex->XState.Length < sizeof(XSTATE))
return NULL;
return (BYTE *)context_ex + context_ex->XState.Offset + offsetof(XSTATE, YmmContext);
}
/**********************************************************************
* RtlLocateExtendedFeature (NTDLL.@)
*/
void * WINAPI RtlLocateExtendedFeature( CONTEXT_EX *context_ex, ULONG feature_id,
ULONG *length )
{
return RtlLocateExtendedFeature2( context_ex, feature_id, &user_shared_data->XState, length );
}
......@@ -826,6 +826,8 @@
@ stdcall RtlLengthSid(ptr)
@ stdcall RtlLocalTimeToSystemTime(ptr ptr)
@ stdcall RtlLocaleNameToLcid(wstr ptr long)
@ stdcall RtlLocateExtendedFeature(ptr long ptr)
@ stdcall RtlLocateExtendedFeature2(ptr long ptr ptr)
# @ stub RtlLockBootStatusData
@ stdcall RtlLockHeap(long)
# @ stub RtlLockMemoryStreamRegion
......
......@@ -1174,6 +1174,8 @@
@ stdcall RtlLengthSecurityDescriptor(ptr)
@ stdcall RtlLengthSid(ptr)
@ stdcall RtlLocalTimeToSystemTime(ptr ptr)
@ stdcall RtlLocateExtendedFeature(ptr long ptr)
@ stdcall RtlLocateExtendedFeature2(ptr long ptr ptr)
@ stub RtlLockBootStatusData
@ stdcall RtlLookupAtomInAtomTable(ptr wstr ptr)
@ stub RtlLookupElementGenericTable
......
......@@ -1842,6 +1842,8 @@ NTSTATUS WINAPI RtlInitializeExtendedContext2(void*,ULONG,CONTEXT_EX**,ULONG64)
ULONG64 WINAPI RtlGetEnabledExtendedFeatures(ULONG64);
NTSTATUS WINAPI RtlGetExtendedContextLength(ULONG,ULONG*);
NTSTATUS WINAPI RtlGetExtendedContextLength2(ULONG,ULONG*,ULONG64);
void * WINAPI RtlLocateExtendedFeature(CONTEXT_EX*,ULONG,ULONG*);
void * WINAPI RtlLocateExtendedFeature2(CONTEXT_EX*,ULONG,XSTATE_CONFIGURATION*,ULONG*);
#endif
#ifdef __x86_64__
......
......@@ -2439,6 +2439,7 @@ WINBASEAPI HLOCAL WINAPI LocalReAlloc(HLOCAL,SIZE_T,UINT) __WINE_ALLOC_SIZE
WINBASEAPI SIZE_T WINAPI LocalShrink(HGLOBAL,UINT);
WINBASEAPI SIZE_T WINAPI LocalSize(HLOCAL);
WINBASEAPI BOOL WINAPI LocalUnlock(HLOCAL);
WINBASEAPI void * WINAPI LocateXStateFeature(CONTEXT *,DWORD,DWORD *);
WINBASEAPI LPVOID WINAPI LockResource(HGLOBAL);
#define LockSegment(handle) GlobalFix((HANDLE)(handle))
WINADVAPI BOOL WINAPI LookupAccountNameA(LPCSTR,LPCSTR,PSID,LPDWORD,LPSTR,LPDWORD,PSID_NAME_USE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment