Module: wine Branch: master Commit: ff1dfb42b9675cd8d4920a5a37d3db7163fa8e79 URL: https://gitlab.winehq.org/wine/wine/-/commit/ff1dfb42b9675cd8d4920a5a37d3db7...
Author: Alexandre Julliard julliard@winehq.org Date: Fri Sep 1 17:01:20 2023 +0200
ntdll/tests: Work around a Windows pointer truncation bug in CPU info.
---
dlls/ntdll/tests/exception.c | 6 ++++++ dlls/ntdll/tests/wow64.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 19aa9992c2d..cdfa4b026b8 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -4350,6 +4350,12 @@ static void test_wow64_context(void) ok( cpu->Machine == IMAGE_FILE_MACHINE_I386, "wrong machine %04x\n", cpu->Machine ); ret = pRtlWow64GetCpuAreaInfo( cpu, 0, &cpu_info ); ok( !ret, "RtlWow64GetCpuAreaInfo failed %lx\n", ret ); + /* work around pointer truncation bug on win10 <= 1709 */ + if (!((ULONG_PTR)cpu_info.Context >> 32)) + { + cpu_info.Context = (char *)cpu + (ULONG)((char *)cpu_info.Context - (char *)cpu); + cpu_info.ContextEx = (char *)cpu + (ULONG)((char *)cpu_info.ContextEx - (char *)cpu); + } ctx_ptr = (WOW64_CONTEXT *)cpu_info.Context; ok(!*(void **)cpu_info.ContextEx, "got context_ex %p\n", *(void **)cpu_info.ContextEx); ok(ctx_ptr->ContextFlags == WOW64_CONTEXT_ALL, "got context flags %#lx\n", ctx_ptr->ContextFlags); diff --git a/dlls/ntdll/tests/wow64.c b/dlls/ntdll/tests/wow64.c index 485b9006b14..4e9107ded9d 100644 --- a/dlls/ntdll/tests/wow64.c +++ b/dlls/ntdll/tests/wow64.c @@ -1340,8 +1340,10 @@ static void test_cpu_area(void) status = pRtlWow64GetCpuAreaInfo( cpu, 0, &info ); ok( status == tests[i].expect, "%lu:%lu: failed %lx\n", i, j, status ); if (status) continue; - ok( info.Context == ALIGN( cpu + 1, tests[i].align ), "%lu:%lu: wrong offset %lu\n", - i, j, (ULONG)((char *)info.Context - (char *)cpu) ); + ok( info.Context == ALIGN( cpu + 1, tests[i].align ) || + broken( (ULONG_PTR)info.Context == (ULONG)(ULONG_PTR)ALIGN( cpu + 1, tests[i].align ) ), /* win10 <= 1709 */ + "%lu:%lu: wrong offset %Iu cpu %p context %p\n", + i, j, (ULONG_PTR)((char *)info.Context - (char *)cpu), cpu, info.Context ); ok( info.ContextEx == ALIGN( (char *)info.Context + tests[i].size, sizeof(void*) ), "%lu:%lu: wrong ex offset %lu\n", i, j, (ULONG)((char *)info.ContextEx - (char *)cpu) ); ok( info.ContextFlagsLocation == (char *)info.Context + tests[i].offset,