From 6556d4f5db89370c5f7e2722bfbfcb6cdc596dff Mon Sep 17 00:00:00 2001 From: Zachary Cook Date: Wed, 9 Oct 2019 12:30:50 -0400 Subject: [PATCH] Support MAP_FIXED using MapViewOfFileEx --- mman.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mman.c b/mman.c index 9a2df41..e71666c 100644 --- a/mman.c +++ b/mman.c @@ -87,8 +87,6 @@ void* mmap(void *addr, size_t len, int prot, int flags, int fildes, OffsetType o errno = 0; if (len == 0 - /* Unsupported flag combinations */ - || (flags & MAP_FIXED) != 0 /* Usupported protection combinations */ || prot == PROT_EXEC) { @@ -113,7 +111,14 @@ void* mmap(void *addr, size_t len, int prot, int flags, int fildes, OffsetType o return MAP_FAILED; } - map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len); + if ((flags & MAP_FIXED) == 0) + { + map = MapViewOfFile(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len); + } + else + { + map = MapViewOfFileEx(fm, desiredAccess, dwFileOffsetHigh, dwFileOffsetLow, len, addr); + } CloseHandle(fm);