Module: wine Branch: master Commit: 3803997349efdd2860263d08bd9d71bc0702cd2c URL: https://source.winehq.org/git/wine.git/?a=commit;h=3803997349efdd2860263d08b...
Author: Paul Gofman pgofman@codeweavers.com Date: Mon Aug 31 12:31:59 2020 +0300
ntdll: Implement RtlLocateLegacyContext().
Signed-off-by: Paul Gofman pgofman@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
.../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 4d8d580387..b933eca226 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 cb9481322b..0e7e3b959e 100644 --- a/dlls/ntdll/exception.c +++ b/dlls/ntdll/exception.c @@ -850,3 +850,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 0829cc43a9..042ec1f99b 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 242ca9c61a..a1600a60c8 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); @@ -6307,6 +6308,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) { @@ -6738,6 +6751,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 6666031cc6..a900796359 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 893db4df20..2115627d3a 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); NTSTATUS WINAPI RtlGetExtendedContextLength(ULONG,ULONG*); NTSTATUS 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