ntdll: Avoid truncating pointer to 32-bits in get_cpu_area().

Signed-off-by: Brendan Shanks <bshanks@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Brendan Shanks 2022-05-17 13:32:29 -07:00 committed by Alexandre Julliard
parent 57c04fd07c
commit fe52b067bf
2 changed files with 2 additions and 2 deletions

View file

@ -161,7 +161,7 @@ NTSTATUS WINAPI RtlWow64GetCpuAreaInfo( WOW64_CPURESERVED *cpu, ULONG reserved,
for (i = 0; i < ARRAY_SIZE(data); i++) for (i = 0; i < ARRAY_SIZE(data); i++)
{ {
#define ALIGN(ptr,align) ((void *)(((ULONG_PTR)(ptr) + (align) - 1) & ~((align) - 1))) #define ALIGN(ptr,align) ((void *)(((ULONG_PTR)(ptr) + (align) - 1) & ~((ULONG_PTR)(align) - 1)))
if (data[i].machine != cpu->Machine) continue; if (data[i].machine != cpu->Machine) continue;
info->Context = ALIGN( cpu + 1, data[i].align ); info->Context = ALIGN( cpu + 1, data[i].align );
info->ContextEx = ALIGN( (char *)info->Context + data[i].size, sizeof(void *) ); info->ContextEx = ALIGN( (char *)info->Context + data[i].size, sizeof(void *) );

View file

@ -1111,7 +1111,7 @@ void *get_cpu_area( USHORT machine )
case IMAGE_FILE_MACHINE_ARM64: align = TYPE_ALIGNMENT(ARM64_NT_CONTEXT); break; case IMAGE_FILE_MACHINE_ARM64: align = TYPE_ALIGNMENT(ARM64_NT_CONTEXT); break;
default: return NULL; default: return NULL;
} }
return (void *)(((ULONG_PTR)(cpu + 1) + align - 1) & ~(align - 1)); return (void *)(((ULONG_PTR)(cpu + 1) + align - 1) & ~((ULONG_PTR)align - 1));
} }