Signed-off-by: Paul Gofman pgofman@codeweavers.com --- .../api-ms-win-core-xstate-l1-1-0.spec | 2 +- dlls/ntdll/exception.c | 11 +++++++++++ dlls/ntdll/ntdll.spec | 1 + dlls/ntdll/tests/exception.c | 14 ++++++++++++++ dlls/ntoskrnl.exe/ntoskrnl.exe.spec | 1 + include/ddk/wdm.h | 1 + 6 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/dlls/api-ms-win-core-xstate-l1-1-0/api-ms-win-core-xstate-l1-1-0.spec b/dlls/api-ms-win-core-xstate-l1-1-0/api-ms-win-core-xstate-l1-1-0.spec index 4d8d5803871..b933eca226f 100644 --- a/dlls/api-ms-win-core-xstate-l1-1-0/api-ms-win-core-xstate-l1-1-0.spec +++ b/dlls/api-ms-win-core-xstate-l1-1-0/api-ms-win-core-xstate-l1-1-0.spec @@ -4,5 +4,5 @@ @ stub RtlGetExtendedFeaturesMask @ stdcall RtlInitializeExtendedContext(ptr long ptr) ntdll.RtlInitializeExtendedContext @ stdcall RtlLocateExtendedFeature(ptr long ptr) ntdll.RtlLocateExtendedFeature -@ stub RtlLocateLegacyContext +@ stdcall RtlLocateLegacyContext(ptr ptr) ntdll.RtlLocateLegacyContext @ stub RtlSetExtendedFeaturesMask diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c index 6b315a47be3..c6df36953e9 100644 --- a/dlls/ntdll/exception.c +++ b/dlls/ntdll/exception.c @@ -848,3 +848,14 @@ void * WINAPI RtlLocateExtendedFeature( CONTEXT_EX *context_ex, ULONG feature_id { return RtlLocateExtendedFeature2( context_ex, feature_id, &user_shared_data->XState, length ); } + +/********************************************************************** + * RtlLocateLegacyContext (NTDLL.@) + */ +void * WINAPI RtlLocateLegacyContext( CONTEXT_EX *context_ex, ULONG *length ) +{ + if (length) + *length = context_ex->Legacy.Length; + + return (BYTE *)context_ex + context_ex->Legacy.Offset; +} diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index c70bb44c47b..e3c0a9cf5f9 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -828,6 +828,7 @@ @ stdcall RtlLocaleNameToLcid(wstr ptr long) @ stdcall RtlLocateExtendedFeature(ptr long ptr) @ stdcall RtlLocateExtendedFeature2(ptr long ptr ptr) +@ stdcall RtlLocateLegacyContext(ptr ptr) # @ stub RtlLockBootStatusData @ stdcall RtlLockHeap(long) # @ stub RtlLockMemoryStreamRegion diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 6e8806c0ce2..95b2631eb81 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -52,6 +52,7 @@ static NTSTATUS (WINAPI *pRtlInitializeExtendedContext)(void *context, ULONG co static NTSTATUS (WINAPI *pRtlInitializeExtendedContext2)(void *context, ULONG context_flags, CONTEXT_EX **context_ex, ULONG64 compaction_mask); static void * (WINAPI *pRtlLocateExtendedFeature)(CONTEXT_EX *context_ex, ULONG feature_id, ULONG *length); +static void * (WINAPI *pRtlLocateLegacyContext)(CONTEXT_EX *context_ex, ULONG *length); static NTSTATUS (WINAPI *pNtReadVirtualMemory)(HANDLE, const void*, void*, SIZE_T, SIZE_T*); static NTSTATUS (WINAPI *pNtTerminateProcess)(HANDLE handle, LONG exit_code); static NTSTATUS (WINAPI *pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG); @@ -6301,6 +6302,18 @@ static void test_extended_context(void) ok(!context_ex->XState.Length, "Got unexpected Length %#x, flags %#x.\n", context_ex->XState.Length, flags);
+ if (0) + { + /* Crashes on Windows. */ + pRtlLocateLegacyContext(NULL, NULL); + } + p = pRtlLocateLegacyContext(context_ex, NULL); + ok(p == context, "Got unexpected p %p, flags %#x.\n", p, flags); + length2 = 0xdeadbeef; + p = pRtlLocateLegacyContext(context_ex, &length2); + ok(p == context && length2 == context_ex->Legacy.Length, + "Got unexpected p %p, length %#x, flags %#x.\n", p, length2, flags); + length2 = expected_length;
for (j = 0; j < context_arch[test].flags_offset; ++j) { @@ -6732,6 +6745,7 @@ START_TEST(exception) X(RtlInitializeExtendedContext); X(RtlInitializeExtendedContext2); X(RtlLocateExtendedFeature); + X(RtlLocateLegacyContext); #undef X
#define X(f) p##f = (void*)GetProcAddress(hkernel32, #f) diff --git a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec index 6666031cc6d..a900796359c 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.exe.spec +++ b/dlls/ntoskrnl.exe/ntoskrnl.exe.spec @@ -1176,6 +1176,7 @@ @ stdcall RtlLocalTimeToSystemTime(ptr ptr) @ stdcall RtlLocateExtendedFeature(ptr long ptr) @ stdcall RtlLocateExtendedFeature2(ptr long ptr ptr) +@ stdcall RtlLocateLegacyContext(ptr ptr) @ stub RtlLockBootStatusData @ stdcall RtlLookupAtomInAtomTable(ptr wstr ptr) @ stub RtlLookupElementGenericTable diff --git a/include/ddk/wdm.h b/include/ddk/wdm.h index d95a5acadaf..d6ced7044d8 100644 --- a/include/ddk/wdm.h +++ b/include/ddk/wdm.h @@ -1842,6 +1842,7 @@ NTSTATUS WINAPI RtlInitializeExtendedContext2(void*,ULONG,CONTEXT_EX**,ULONG64) ULONG64 WINAPI RtlGetEnabledExtendedFeatures(ULONG64); ULONG64 WINAPI RtlGetExtendedContextLength(ULONG,ULONG*); ULONG64 WINAPI RtlGetExtendedContextLength2(ULONG,ULONG*,ULONG64); +void * WINAPI RtlLocateLegacyContext(CONTEXT_EX*,ULONG*); void * WINAPI RtlLocateExtendedFeature(CONTEXT_EX*,ULONG,ULONG*); void * WINAPI RtlLocateExtendedFeature2(CONTEXT_EX*,ULONG,XSTATE_CONFIGURATION*,ULONG*); #endif