Skip to content

Commit

Permalink
Support MAP_FIXED using MapViewOfFileEx
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachCook authored Oct 9, 2019
1 parent 9f115ad commit 6556d4f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mman.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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);

Expand Down

0 comments on commit 6556d4f

Please sign in to comment.