From 58176bba105c4e9af54f0ea9ef13fe06ce886819 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 8 Jan 2013 22:01:48 +0100 Subject: [PATCH] winedevice: Retrieve the page size from ntdll. --- programs/winedevice/device.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/programs/winedevice/device.c b/programs/winedevice/device.c index e48218e2016..72bc1242a92 100644 --- a/programs/winedevice/device.c +++ b/programs/winedevice/device.c @@ -66,7 +66,7 @@ static HMODULE load_driver_module( const WCHAR *name ) { IMAGE_NT_HEADERS *nt; const IMAGE_IMPORT_DESCRIPTOR *imports; - size_t page_size = getpagesize(); + SYSTEM_BASIC_INFORMATION info; int i; INT_PTR delta; ULONG size; @@ -80,7 +80,8 @@ static HMODULE load_driver_module( const WCHAR *name ) /* the loader does not apply relocations to non page-aligned binaries or executables, * we have to do it ourselves */ - if (nt->OptionalHeader.SectionAlignment < page_size || + NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL ); + if (nt->OptionalHeader.SectionAlignment < info.PageSize || !(nt->FileHeader.Characteristics & IMAGE_FILE_DLL)) { DWORD old; @@ -94,10 +95,10 @@ static HMODULE load_driver_module( const WCHAR *name ) while (rel < end && rel->SizeOfBlock) { void *page = (char *)module + rel->VirtualAddress; - VirtualProtect( page, page_size, PAGE_EXECUTE_READWRITE, &old ); + VirtualProtect( page, info.PageSize, PAGE_EXECUTE_READWRITE, &old ); rel = LdrProcessRelocationBlock( page, (rel->SizeOfBlock - sizeof(*rel)) / sizeof(USHORT), (USHORT *)(rel + 1), delta ); - if (old != PAGE_EXECUTE_READWRITE) VirtualProtect( page, page_size, old, NULL ); + if (old != PAGE_EXECUTE_READWRITE) VirtualProtect( page, info.PageSize, old, NULL ); if (!rel) goto error; } /* make sure we don't try again */